branch develop updated (37d7a96 -> 91a98ab)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository jaxx. See https://gitlab.nuiton.org/nuiton/jaxx.git from 37d7a96 [jgitflow-maven-plugin]Updating develop poms back to pre merge state new 483a599 Remove some deprecated api (See #4103) new 69c4470 Remove application API (Fixes #4107) new 5bd62db removing deprecated widgets (See #4103) new 91a98ab Introduce jaxx-widgets-file module (Fixes #4105) The 4 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 91a98aba3e5c5f8f42332a9907b56a43f5c9ccb3 Author: Tony CHEMIT <dev@tchemit.fr> Date: Sat Dec 31 13:31:38 2016 +0100 Introduce jaxx-widgets-file module (Fixes #4105) commit 5bd62db7890aada615519b35fbc81664600914e8 Author: Tony CHEMIT <dev@tchemit.fr> Date: Sat Dec 31 13:06:27 2016 +0100 removing deprecated widgets (See #4103) commit 69c4470b36dddf1edfce93b19cec427037feaab1 Author: Tony CHEMIT <dev@tchemit.fr> Date: Sat Dec 31 13:05:22 2016 +0100 Remove application API (Fixes #4107) commit 483a599dca6f42ae16d0d533d4bf87ffd5fd86c3 Author: Tony CHEMIT <dev@tchemit.fr> Date: Sat Dec 31 11:29:11 2016 +0100 Remove some deprecated api (See #4103) Summary of changes: jaxx-application-api/LICENSE.txt | 165 --- jaxx-application-api/README.md | 0 jaxx-application-api/pom.xml | 100 -- .../src/license/THIRD-PARTY.properties | 21 - .../application/ApplicationBusinessException.java | 49 - .../jaxx/application/ApplicationConfiguration.java | 81 -- .../jaxx/application/ApplicationContext.java | 39 - .../jaxx/application/ApplicationDataUtil.java | 86 -- .../nuiton/jaxx/application/ApplicationIOUtil.java | 262 ---- .../application/ApplicationTechnicalException.java | 48 - .../nuiton/jaxx/application/bean/BinderCache.java | 60 - .../jaxx/application/bean/JavaBeanObject.java | 137 -- .../JavaBeanObjectPropagateChangeListener.java | 71 -- .../jaxx/application/bean/JavaBeanObjectUtil.java | 109 -- .../bean/RemoveablePropertyChangeListener.java | 35 - .../listener/PropagatePropertyChangeListener.java | 81 -- .../type/ApplicationProgressionModel.java | 113 -- jaxx-application-api/src/site/site.xml | 44 - jaxx-application-swing/README.md | 0 jaxx-application-swing/pom.xml | 194 --- .../src/license/THIRD-PARTY.properties | 26 - .../swing/AbstractApplicationFormUIModel.java | 289 ----- .../swing/AbstractApplicationUIHandler.java | 1318 -------------------- .../jaxx/application/swing/ApplicationUI.java | 143 --- .../swing/ApplicationUIConfiguration.java | 43 - .../application/swing/ApplicationUIContext.java | 88 -- .../swing/action/AbstractApplicationAction.java | 438 ------- .../swing/action/ApplicationActionEngine.java | 126 -- .../swing/action/ApplicationActionException.java | 56 - .../swing/action/ApplicationActionFactory.java | 94 -- .../swing/action/ApplicationActionSwingWorker.java | 201 --- .../swing/action/ApplicationActionUI.jaxx | 72 -- .../swing/action/ApplicationActionUI.jcss | 66 - .../swing/action/ApplicationActionUIHandler.java | 274 ---- .../swing/action/ApplicationActionUIModel.java | 73 -- .../swing/action/ApplicationUIAction.java | 235 ---- .../swing/actionng/ApplicationAction.java | 65 - .../swing/actionng/ApplicationActionEngine.java | 101 -- .../swing/actionng/ApplicationActionEvent.java | 95 -- .../swing/actionng/ApplicationActionListener.java | 47 - .../jaxx/application/swing/tab/CustomTab.java | 220 ---- .../swing/tab/DelegateTabContainerHandler.java | 120 -- .../application/swing/tab/TabContainerHandler.java | 76 -- .../application/swing/tab/TabContentModel.java | 44 - .../jaxx/application/swing/tab/TabHandler.java | 58 - .../swing/table/AbstractApplicationTableModel.java | 371 ------ .../swing/table/AbstractSelectTableAction.java | 98 -- .../ApplicationTableModelValidatorDataLocator.java | 76 -- .../application/swing/table/ColumnIdentifier.java | 103 -- .../swing/table/MoveToNextEditableCellAction.java | 100 -- .../swing/table/MoveToNextEditableRowAction.java | 91 -- .../table/MoveToPreviousEditableCellAction.java | 80 -- .../table/MoveToPreviousEditableRowAction.java | 71 -- .../swing/util/ActionListCellRenderer.java | 60 - .../swing/util/ApplicationColorHighlighter.java | 64 - .../swing/util/ApplicationErrorHelper.java | 116 -- .../swing/util/ApplicationExceptionHandler.java | 89 -- .../application/swing/util/ApplicationUIUtil.java | 208 --- .../jaxx/application/swing/util/Cancelable.java | 34 - .../jaxx/application/swing/util/CloseableUI.java | 42 - .../i18n/jaxx-application-swing_en_GB.properties | 23 - .../i18n/jaxx-application-swing_es_ES.properties | 23 - .../i18n/jaxx-application-swing_fr_FR.properties | 23 - jaxx-application-swing/src/site/site.xml | 44 - jaxx-config/pom.xml | 6 + .../org/nuiton/jaxx/config/ConfigTableEditor.java | 2 +- jaxx-demo/pom.xml | 6 + .../demo/component/jaxx/editor/FileEditorDemo.jaxx | 2 +- .../component/jaxx/editor/NumberEditorDemo.jaxx | 113 -- .../jaxx/editor/NumberEditorDemoModel.java | 62 - .../jaxx/editor/SimpleTimeEditorDemo.jaxx | 81 -- .../jaxx/editor/SimpleTimeEditorDemo.jcss | 37 - .../jaxx/editor/SimpleTimeEditorDemoHandler.java | 47 - .../jaxx/editor/SimpleTimeEditorDemoModel.java | 54 - .../demo/component/jaxx/editor/TimeEditorDemo.jaxx | 84 -- .../demo/component/jaxx/editor/TimeEditorDemo.jcss | 47 - .../component/jaxx/editor/TimeEditorDemoModel.java | 53 - .../component/jaxx/editor/gis/CoordinateDemo.jaxx | 97 -- .../component/jaxx/editor/gis/CoordinateDemo.jcss | 146 --- .../jaxx/editor/gis/CoordinateDemoHandler.java | 154 --- .../jaxx/editor/gis/CoordinateDemoModel.java | 64 - .../feature/databinding/BindingExtremeDemo.jaxx | 8 +- .../nuiton/jaxx/demo/tree/DemoDataProvider.java | 10 +- .../org/nuiton/jaxx/runtime/FileChooserUtil.java | 358 ------ .../java/org/nuiton/jaxx/runtime/JAXXUtil.java | 66 - .../LICENSE.txt | 0 {jaxx-widgets => jaxx-widgets-file}/README.md | 0 {jaxx-widgets => jaxx-widgets-file}/changelog.txt | 0 {jaxx-widgets-number => jaxx-widgets-file}/pom.xml | 45 +- .../src/license/THIRD-PARTY.properties | 0 .../nuiton/jaxx/widgets/file}/FileCellEditor.java | 4 +- .../org/nuiton/jaxx/widgets/file}/FileEditor.jaxx | 0 .../jaxx/widgets/file}/FileEditorHandler.java | 3 +- .../nuiton/jaxx/widgets/file}/JaxxFileChooser.java | 2 +- .../i18n/jaxx-widgets-file_en_GB.properties | 0 .../i18n/jaxx-widgets-file_es_ES.properties | 0 .../i18n/jaxx-widgets-file_fr_FR.properties | 0 .../resources/icons/action-fileeditor-reset.png | Bin .../src/main/resources/icons/action-filter.png | Bin .../src/main/resources/icons/action-open.png | Bin .../src/site/site.xml | 0 jaxx-widgets/pom.xml | 10 - .../org/nuiton/jaxx/runtime/swing/AboutPanel.jaxx | 139 --- .../jaxx/runtime/swing/AboutPanelHandler.java | 177 --- .../nuiton/jaxx/runtime/swing/JAXXWidgetUtil.java | 14 +- .../jaxx/runtime/swing/editor/KeyStrokeEditor.java | 14 +- .../jaxx/runtime/swing/editor/NumberEditor.jaxx | 205 --- .../runtime/swing/editor/NumberEditorHandler.java | 591 --------- .../runtime/swing/editor/NumberEditorPopup.jcss | 47 - .../runtime/swing/editor/SimpleTimeEditor.jaxx | 61 - .../runtime/swing/editor/SimpleTimeEditor.jcss | 42 - .../swing/editor/SimpleTimeEditorHandler.java | 283 ----- .../swing/editor/SimpleTimeEditorModel.java | 109 -- .../jaxx/runtime/swing/editor/TimeEditor.jaxx | 87 -- .../jaxx/runtime/swing/editor/TimeEditor.jcss | 58 - .../runtime/swing/editor/TimeEditorHandler.java | 319 ----- .../swing/editor/cell/NumberCellEditor.java | 127 -- .../runtime/swing/editor/gis/DmdCoordinate.java | 336 ----- .../swing/editor/gis/DmdCoordinateConverter.java | 143 --- .../swing/editor/gis/DmdCoordinateEditor.jaxx | 58 - .../swing/editor/gis/DmdCoordinateEditor.jcss | 38 - .../editor/gis/DmdCoordinateEditorHandler.java | 303 ----- .../swing/editor/gis/DmdCoordinateEditorModel.java | 122 -- .../runtime/swing/editor/gis/DmsCoordinate.java | 364 ------ .../swing/editor/gis/DmsCoordinateConverter.java | 144 --- .../swing/editor/gis/DmsCoordinateEditor.jaxx | 59 - .../swing/editor/gis/DmsCoordinateEditor.jcss | 38 - .../editor/gis/DmsCoordinateEditorHandler.java | 314 ----- .../swing/editor/gis/DmsCoordinateEditorModel.java | 122 -- .../editor/gis/MaskFormatterFromConverter.java | 75 -- .../services/org.nuiton.converter.NuitonConverter | 2 - .../editor/gis/DmdCoordinateConverterTest.java | 102 -- .../swing/editor/gis/DmdCoordinateEditorTest.java | 204 --- .../swing/editor/gis/DmdCoordinateTest.java | 136 -- .../editor/gis/DmsCoordinateConverterTest.java | 105 -- .../swing/editor/gis/DmsCoordinateEditorTest.java | 206 --- .../swing/editor/gis/DmsCoordinateTest.java | 131 -- jaxx-widgets/src/test/resources/log4j.properties | 30 - pom.xml | 3 +- 139 files changed, 56 insertions(+), 14592 deletions(-) delete mode 100644 jaxx-application-api/LICENSE.txt delete mode 100644 jaxx-application-api/README.md delete mode 100644 jaxx-application-api/pom.xml delete mode 100644 jaxx-application-api/src/license/THIRD-PARTY.properties delete mode 100644 jaxx-application-api/src/main/java/org/nuiton/jaxx/application/ApplicationBusinessException.java delete mode 100644 jaxx-application-api/src/main/java/org/nuiton/jaxx/application/ApplicationConfiguration.java delete mode 100644 jaxx-application-api/src/main/java/org/nuiton/jaxx/application/ApplicationContext.java delete mode 100644 jaxx-application-api/src/main/java/org/nuiton/jaxx/application/ApplicationDataUtil.java delete mode 100644 jaxx-application-api/src/main/java/org/nuiton/jaxx/application/ApplicationIOUtil.java delete mode 100644 jaxx-application-api/src/main/java/org/nuiton/jaxx/application/ApplicationTechnicalException.java delete mode 100644 jaxx-application-api/src/main/java/org/nuiton/jaxx/application/bean/BinderCache.java delete mode 100644 jaxx-application-api/src/main/java/org/nuiton/jaxx/application/bean/JavaBeanObject.java delete mode 100644 jaxx-application-api/src/main/java/org/nuiton/jaxx/application/bean/JavaBeanObjectPropagateChangeListener.java delete mode 100644 jaxx-application-api/src/main/java/org/nuiton/jaxx/application/bean/JavaBeanObjectUtil.java delete mode 100644 jaxx-application-api/src/main/java/org/nuiton/jaxx/application/bean/RemoveablePropertyChangeListener.java delete mode 100644 jaxx-application-api/src/main/java/org/nuiton/jaxx/application/listener/PropagatePropertyChangeListener.java delete mode 100644 jaxx-application-api/src/main/java/org/nuiton/jaxx/application/type/ApplicationProgressionModel.java delete mode 100644 jaxx-application-api/src/site/site.xml delete mode 100644 jaxx-application-swing/README.md delete mode 100644 jaxx-application-swing/pom.xml delete mode 100644 jaxx-application-swing/src/license/THIRD-PARTY.properties delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/AbstractApplicationFormUIModel.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/AbstractApplicationUIHandler.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/ApplicationUI.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/ApplicationUIConfiguration.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/ApplicationUIContext.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/AbstractApplicationAction.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionEngine.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionException.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionFactory.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionSwingWorker.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionUI.jaxx delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionUI.jcss delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionUIHandler.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionUIModel.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationUIAction.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/actionng/ApplicationAction.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/actionng/ApplicationActionEngine.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/actionng/ApplicationActionEvent.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/actionng/ApplicationActionListener.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/tab/CustomTab.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/tab/DelegateTabContainerHandler.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/tab/TabContainerHandler.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/tab/TabContentModel.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/tab/TabHandler.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/AbstractApplicationTableModel.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/AbstractSelectTableAction.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/ApplicationTableModelValidatorDataLocator.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/ColumnIdentifier.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/MoveToNextEditableCellAction.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/MoveToNextEditableRowAction.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/MoveToPreviousEditableCellAction.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/MoveToPreviousEditableRowAction.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/ActionListCellRenderer.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/ApplicationColorHighlighter.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/ApplicationErrorHelper.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/ApplicationExceptionHandler.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/ApplicationUIUtil.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/Cancelable.java delete mode 100644 jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/CloseableUI.java delete mode 100644 jaxx-application-swing/src/main/resources/i18n/jaxx-application-swing_en_GB.properties delete mode 100644 jaxx-application-swing/src/main/resources/i18n/jaxx-application-swing_es_ES.properties delete mode 100644 jaxx-application-swing/src/main/resources/i18n/jaxx-application-swing_fr_FR.properties delete mode 100644 jaxx-application-swing/src/site/site.xml delete mode 100644 jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx delete mode 100644 jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/NumberEditorDemoModel.java delete mode 100644 jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/SimpleTimeEditorDemo.jaxx delete mode 100644 jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/SimpleTimeEditorDemo.jcss delete mode 100644 jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/SimpleTimeEditorDemoHandler.java delete mode 100644 jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/SimpleTimeEditorDemoModel.java delete mode 100644 jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/TimeEditorDemo.jaxx delete mode 100644 jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/TimeEditorDemo.jcss delete mode 100644 jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/TimeEditorDemoModel.java delete mode 100644 jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/gis/CoordinateDemo.jaxx delete mode 100644 jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/gis/CoordinateDemo.jcss delete mode 100644 jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/gis/CoordinateDemoHandler.java delete mode 100644 jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/gis/CoordinateDemoModel.java delete mode 100644 jaxx-runtime/src/main/java/org/nuiton/jaxx/runtime/FileChooserUtil.java rename {jaxx-application-swing => jaxx-widgets-file}/LICENSE.txt (100%) copy {jaxx-widgets => jaxx-widgets-file}/README.md (100%) copy {jaxx-widgets => jaxx-widgets-file}/changelog.txt (100%) copy {jaxx-widgets-number => jaxx-widgets-file}/pom.xml (84%) copy {jaxx-widgets => jaxx-widgets-file}/src/license/THIRD-PARTY.properties (100%) rename {jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/cell => jaxx-widgets-file/src/main/java/org/nuiton/jaxx/widgets/file}/FileCellEditor.java (94%) rename {jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor => jaxx-widgets-file/src/main/java/org/nuiton/jaxx/widgets/file}/FileEditor.jaxx (100%) rename {jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor => jaxx-widgets-file/src/main/java/org/nuiton/jaxx/widgets/file}/FileEditorHandler.java (98%) rename {jaxx-runtime/src/main/java/org/nuiton/jaxx/runtime => jaxx-widgets-file/src/main/java/org/nuiton/jaxx/widgets/file}/JaxxFileChooser.java (99%) copy jaxx-widgets/src/main/resources/i18n/jaxx-widgets_en_GB.properties => jaxx-widgets-file/src/main/resources/i18n/jaxx-widgets-file_en_GB.properties (100%) copy jaxx-widgets/src/main/resources/i18n/jaxx-widgets_es_ES.properties => jaxx-widgets-file/src/main/resources/i18n/jaxx-widgets-file_es_ES.properties (100%) copy jaxx-widgets/src/main/resources/i18n/jaxx-widgets_fr_FR.properties => jaxx-widgets-file/src/main/resources/i18n/jaxx-widgets-file_fr_FR.properties (100%) copy {jaxx-widgets => jaxx-widgets-file}/src/main/resources/icons/action-fileeditor-reset.png (100%) copy {jaxx-widgets => jaxx-widgets-file}/src/main/resources/icons/action-filter.png (100%) copy {jaxx-widgets => jaxx-widgets-file}/src/main/resources/icons/action-open.png (100%) copy {jaxx-widgets => jaxx-widgets-file}/src/site/site.xml (100%) delete mode 100644 jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/AboutPanel.jaxx delete mode 100644 jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/AboutPanelHandler.java delete mode 100644 jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/NumberEditor.jaxx delete mode 100644 jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/NumberEditorHandler.java delete mode 100644 jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/NumberEditorPopup.jcss delete mode 100644 jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/SimpleTimeEditor.jaxx delete mode 100644 jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/SimpleTimeEditor.jcss delete mode 100644 jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/SimpleTimeEditorHandler.java delete mode 100644 jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/SimpleTimeEditorModel.java delete mode 100644 jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/TimeEditor.jaxx delete mode 100644 jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/TimeEditor.jcss delete mode 100644 jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/TimeEditorHandler.java delete mode 100644 jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/cell/NumberCellEditor.java delete mode 100644 jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinate.java delete mode 100644 jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateConverter.java delete mode 100644 jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateEditor.jaxx delete mode 100644 jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateEditor.jcss delete mode 100644 jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateEditorHandler.java delete mode 100644 jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateEditorModel.java delete mode 100644 jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinate.java delete mode 100644 jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateConverter.java delete mode 100644 jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateEditor.jaxx delete mode 100644 jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateEditor.jcss delete mode 100644 jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateEditorHandler.java delete mode 100644 jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateEditorModel.java delete mode 100644 jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/MaskFormatterFromConverter.java delete mode 100644 jaxx-widgets/src/main/resources/META-INF/services/org.nuiton.converter.NuitonConverter delete mode 100644 jaxx-widgets/src/test/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateConverterTest.java delete mode 100644 jaxx-widgets/src/test/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateEditorTest.java delete mode 100644 jaxx-widgets/src/test/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateTest.java delete mode 100644 jaxx-widgets/src/test/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateConverterTest.java delete mode 100644 jaxx-widgets/src/test/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateEditorTest.java delete mode 100644 jaxx-widgets/src/test/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateTest.java delete mode 100644 jaxx-widgets/src/test/resources/log4j.properties -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository jaxx. See https://gitlab.nuiton.org/nuiton/jaxx.git commit 483a599dca6f42ae16d0d533d4bf87ffd5fd86c3 Author: Tony CHEMIT <dev@tchemit.fr> Date: Sat Dec 31 11:29:11 2016 +0100 Remove some deprecated api (See #4103) --- jaxx-application-swing/pom.xml | 5 + .../swing/AbstractApplicationUIHandler.java | 8 +- .../feature/databinding/BindingExtremeDemo.jaxx | 8 +- .../org/nuiton/jaxx/runtime/FileChooserUtil.java | 358 --------------------- .../java/org/nuiton/jaxx/runtime/JAXXUtil.java | 66 ---- .../org/nuiton/jaxx/runtime/swing/AboutPanel.jaxx | 139 -------- .../jaxx/runtime/swing/AboutPanelHandler.java | 177 ---------- .../nuiton/jaxx/runtime/swing/JAXXWidgetUtil.java | 9 +- .../swing/editor/cell/NumberCellEditor.java | 127 -------- 9 files changed, 15 insertions(+), 882 deletions(-) diff --git a/jaxx-application-swing/pom.xml b/jaxx-application-swing/pom.xml index 7cfb529..19d4f10 100644 --- a/jaxx-application-swing/pom.xml +++ b/jaxx-application-swing/pom.xml @@ -79,6 +79,11 @@ <artifactId>jaxx-widgets</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>jaxx-widgets-number</artifactId> + <version>${project.version}</version> + </dependency> <!-- Commons --> <dependency> diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/AbstractApplicationUIHandler.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/AbstractApplicationUIHandler.java index 3302a6e..bbf4083 100644 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/AbstractApplicationUIHandler.java +++ b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/AbstractApplicationUIHandler.java @@ -36,7 +36,7 @@ import org.nuiton.jaxx.runtime.swing.editor.bean.BeanComboBox; import org.nuiton.jaxx.runtime.swing.editor.bean.BeanDoubleList; import org.nuiton.jaxx.runtime.swing.editor.bean.BeanFilterableComboBox; import org.nuiton.jaxx.runtime.swing.editor.bean.BeanUIUtil; -import org.nuiton.jaxx.runtime.swing.editor.cell.NumberCellEditor; +import org.nuiton.jaxx.widgets.number.NumberCellEditor; import org.nuiton.jaxx.runtime.swing.editor.gis.DmdCoordinateEditor; import org.nuiton.jaxx.runtime.swing.editor.gis.DmsCoordinateEditor; import org.nuiton.jaxx.runtime.swing.renderer.DecoratorListCellRenderer; @@ -1128,8 +1128,7 @@ public abstract class AbstractApplicationUIHandler<M, UI extends ApplicationUI<M boolean sign, JTable table) { - NumberCellEditor<Float> editor = - JAXXWidgetUtil.newNumberTableCellEditor(Float.class, sign); + NumberCellEditor<Float> editor = new NumberCellEditor<>(Float.class, sign); editor.getNumberEditor().setSelectAllTextOnError(true); editor.getNumberEditor().getTextField().setBorder(new LineBorder(Color.GRAY, 2)); editor.getNumberEditor().setNumberPattern(numberPattern); @@ -1154,8 +1153,7 @@ public abstract class AbstractApplicationUIHandler<M, UI extends ApplicationUI<M boolean sign, JTable table) { - NumberCellEditor<Integer> editor = - JAXXWidgetUtil.newNumberTableCellEditor(Integer.class, sign); + NumberCellEditor<Integer> editor = new NumberCellEditor<>(Integer.class, sign); editor.getNumberEditor().setSelectAllTextOnError(true); editor.getNumberEditor().getTextField().setBorder(new LineBorder(Color.GRAY, 2)); editor.getNumberEditor().setNumberPattern(numberPattern); diff --git a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/feature/databinding/BindingExtremeDemo.jaxx b/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/feature/databinding/BindingExtremeDemo.jaxx index c74b404..05f3e29 100644 --- a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/feature/databinding/BindingExtremeDemo.jaxx +++ b/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/feature/databinding/BindingExtremeDemo.jaxx @@ -26,7 +26,7 @@ <import> org.nuiton.jaxx.runtime.JAXXBinding - org.nuiton.jaxx.runtime.FileChooserUtil + org.nuiton.jaxx.runtime.JaxxFileChooser java.awt.Color javax.swing.border.TitledBorder javax.swing.DefaultListModel @@ -146,7 +146,7 @@ protected String[] getSources() { </cell> <cell> <JButton text="file..." - onActionPerformed='setFile(FileChooserUtil.getFile(this, new String[0]))'/> + onActionPerformed='setFile(JaxxFileChooser.forLoadingFile().choose())'/> </cell> </row> @@ -205,7 +205,7 @@ protected String[] getSources() { </cell> <cell> <JButton text="model0.file..." - onActionPerformed='model0.setFile(FileChooserUtil.getFile(this,new String[0]))'/> + onActionPerformed='model0.setFile(JaxxFileChooser.forLoadingFile().choose())'/> </cell> </row> @@ -267,7 +267,7 @@ protected String[] getSources() { </cell> <cell> <JButton text="model1.file..." - onActionPerformed='model1.setFile(FileChooserUtil.getFile(this,new String[0]))'/> + onActionPerformed='model1.setFile(JaxxFileChooser.forLoadingFile().choose())'/> </cell> </row> diff --git a/jaxx-runtime/src/main/java/org/nuiton/jaxx/runtime/FileChooserUtil.java b/jaxx-runtime/src/main/java/org/nuiton/jaxx/runtime/FileChooserUtil.java deleted file mode 100644 index 1466f14..0000000 --- a/jaxx-runtime/src/main/java/org/nuiton/jaxx/runtime/FileChooserUtil.java +++ /dev/null @@ -1,358 +0,0 @@ -package org.nuiton.jaxx.runtime; - -/* - * #%L - * JAXX :: Runtime - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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.nuiton.util.FileUtil; - -import javax.swing.JFileChooser; -import java.awt.Component; -import java.io.File; - -/** - * To help choosing a file / directory. - * - * Was previously in {@code org.nuiton.util.FileUtil} from - * {@code nuiton-utils} project. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.5.16 - * @deprecated since 2.15, prefer use {@link JaxxFileChooser}. - */ -public class FileChooserUtil { - - /** Logger. */ - private static final Log log = LogFactory.getLog(FileChooserUtil.class); - - public static final File DEFAULT_CURRENT_DIRECTORY_FILE = new File("."); - - protected static File currentDirectory = DEFAULT_CURRENT_DIRECTORY_FILE; - - public static void setCurrentDirectory(File dir) { - JaxxFileChooser.setCurrentDirectory(currentDirectory ); - } - - public static File getCurrentDirectory() { - return JaxxFileChooser.getCurrentDirectory(); - } - - public static boolean isCurrentDirectoryDefault() { - return JaxxFileChooser.isCurrentDirectoryDefault(); - } - - protected FileChooserUtil() { - // no instance please - } - - - public static class PatternChooserFilter extends javax.swing.filechooser.FileFilter { - protected final String pattern; - - protected final String description; - - public PatternChooserFilter(String pattern, String description) { - this.pattern = pattern; - this.description = description; - } - - @Override - public boolean accept(File f) { - return f.isDirectory() || f.getAbsolutePath().matches(pattern); - } - - @Override - public String getDescription() { - return description; - } - - } - - - /** - * Retourne le nom du fichier entre dans la boite de dialogue. - * Si le bouton annuler est utilisé, ou qu'il y a une erreur retourne null. - * - * @param patternOrDescriptionFilters les filtres a utiliser, les chaines doivent etre données - * par deux, le pattern du filtre + la description du filtre - * @return le fichier accepté, ou null si rien n'est chois ou l'utilisateur a annulé - * @see #getFile(javax.swing.filechooser.FileFilter...) - */ - public static File getFile(String... patternOrDescriptionFilters) { - File result; - result = getFile(null, patternOrDescriptionFilters); - return result; - } - - /** - * Retourne le nom du fichier entre dans la boite de dialogue. - * Si le bouton annuler est utilisé, ou qu'il y a une erreur retourne null. - * - * @param filters les filtres a ajouter - * @return le fichier accepté, ou null si rien n'est chois ou l'utilisateur a annulé - */ - public static File getFile(javax.swing.filechooser.FileFilter... filters) { - return getFile(null, filters); - } - - /** - * Retourne le nom du fichier entre dans la boite de dialogue. - * Si le bouton annuler est utilisé, ou qu'il y a une erreur retourne null. - * - * @param parent le component parent du dialog - * @param patternOrDescriptionFilters les filtres a utiliser, les chaines doivent etre données - * par deux, le pattern du filtre + la description du filtre - * @return le fichier accepté, ou null si rien n'est chois ou l'utilisateur a annulé - * @see #getFile(javax.swing.filechooser.FileFilter...) - */ - public static File getFile(Component parent, - String... patternOrDescriptionFilters) { - File result; - result = getFile("Ok", "Ok", parent, patternOrDescriptionFilters); - return result; - } - - /** - * Retourne le nom du fichier entre dans la boite de dialogue. - * Si le bouton annuler est utilisé, ou qu'il y a une erreur retourne null. - * - * @param title le titre de la boite de dialogue - * @param approvalText le label du boutton d'acceptation - * @param parent le component parent du dialog - * @param patternOrDescriptionFilters les filtres a utiliser, les chaines doivent etre données - * par deux, le pattern du filtre + la description du filtre - * @return le fichier accepté, ou null si rien n'est chois ou l'utilisateur a annulé - * @see #getFile(javax.swing.filechooser.FileFilter...) - */ - public static File getFile(String title, - String approvalText, - Component parent, - String... patternOrDescriptionFilters) { - - if (patternOrDescriptionFilters.length % 2 != 0) { - throw new IllegalArgumentException( - "Arguments must be (pattern, description) couple"); - } - javax.swing.filechooser.FileFilter[] filters = - new javax.swing.filechooser.FileFilter[ - patternOrDescriptionFilters.length / 2]; - for (int i = 0; i < filters.length; i++) { - String pattern = patternOrDescriptionFilters[i * 2]; - String description = patternOrDescriptionFilters[i * 2 + 1]; - filters[i] = new PatternChooserFilter(pattern, description); - } - File result; - result = getFile(title, approvalText, parent, filters); - return result; - } - - - /** - * Retourne le nom du fichier entre dans la boite de dialogue. - * Si le bouton annuler est utilisé, ou qu'il y a une erreur retourne null. - * - * @param parent le component parent du dialog - * @param filters les filtres a ajouter - * @return le fichier accepté, ou null si rien n'est chois ou l'utilisateur a annulé - */ - public static File getFile(Component parent, - javax.swing.filechooser.FileFilter... filters) { - return getFile("Ok", "Ok", parent, filters); - } - - /** - * Retourne le nom du fichier entre dans la boite de dialogue. - * Si le bouton annuler est utilisé, ou qu'il y a une erreur retourne null. - * - * @param title le titre de la boite de dialogue - * @param approvalText le label du boutton d'acceptation - * @param parent le component parent du dialog - * @param filters les filtres a ajouter - * @return le fichier accepté, ou null si rien n'est choisi ou l'utilisateur a annulé - */ - public static File getFile(String title, - String approvalText, - Component parent, - javax.swing.filechooser.FileFilter... filters) { - try { - JFileChooser chooser = new JFileChooser(currentDirectory); - - chooser.setDialogType(JFileChooser.CUSTOM_DIALOG); - if (filters.length > 0) { - if (filters.length == 1) { - chooser.setFileFilter(filters[0]); - } else { - for (javax.swing.filechooser.FileFilter filter : filters) { - chooser.addChoosableFileFilter(filter); - } - } - } - chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - chooser.setDialogTitle(title); - int returnVal = chooser.showDialog(parent, approvalText); - if (returnVal == JFileChooser.APPROVE_OPTION) { - File theFile = chooser.getSelectedFile(); - if (theFile != null) { - currentDirectory = theFile; - return theFile.getAbsoluteFile(); - } - } - } catch (Exception eee) { - log.warn("Erreur:", eee); - } - return null; - } - - /** - * Retourne le nom du fichier entre dans la boite de dialogue. - * Si le bouton annuler est utilisé, ou qu'il y a une erreur retourne null. - * - * @param title le titre de la boite de dialogue - * @param approvalText le label du boutton d'acceptation - * @param parent le component parent du dialog - * @param patternOrDescriptionFilters les filtres a utiliser, les chaines doivent etre données - * par deux, le pattern du filtre + la description du filtre - * @return le fichier accepté, ou null si rien n'est chois ou l'utilisateur a annulé - */ - public static File saveFile(String filename, - String title, - String approvalText, - Component parent, - String... patternOrDescriptionFilters) { - - if (patternOrDescriptionFilters.length % 2 != 0) { - throw new IllegalArgumentException( - "Arguments must be (pattern, description) couple"); - } - javax.swing.filechooser.FileFilter[] filters = - new javax.swing.filechooser.FileFilter[ - patternOrDescriptionFilters.length / 2]; - for (int i = 0; i < filters.length; i++) { - String pattern = patternOrDescriptionFilters[i * 2]; - String description = patternOrDescriptionFilters[i * 2 + 1]; - filters[i] = new FileUtil.PatternChooserFilter(pattern, description); - } - File result; - result = saveFile(filename, title, approvalText, parent, filters); - return result; - } - - /** - * Retourne le nom du fichier entre dans la boite de dialogue. - * Si le bouton annuler est utilisé, ou qu'il y a une erreur retourne null. - * - * @param title le titre de la boite de dialogue - * @param approvalText le label du boutton d'acceptation - * @param parent le component parent du dialog - * @param filters les filtres a ajouter - * @return le fichier accepté, ou null si rien n'est chois ou l'utilisateur a annulé - */ - public static File saveFile(String filename, - String title, - String approvalText, - Component parent, - javax.swing.filechooser.FileFilter... filters) { - File selectedFile = new File(getCurrentDirectory(), filename); - JFileChooser chooser = new JFileChooser(selectedFile); - - chooser.setDialogType(JFileChooser.SAVE_DIALOG); - chooser.setSelectedFile(selectedFile); - if (filters.length > 0) { - if (filters.length == 1) { - chooser.setFileFilter(filters[0]); - } else { - for (javax.swing.filechooser.FileFilter filter : filters) { - chooser.addChoosableFileFilter(filter); - } - } - } - chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - chooser.setDialogTitle(title); - - File result = null; - - int returnVal = chooser.showDialog(parent, approvalText); - if (returnVal == JFileChooser.APPROVE_OPTION) { - result = chooser.getSelectedFile(); - if (result != null) { - setCurrentDirectory(result); - result = result.getAbsoluteFile(); - } - } - return result; - } - - /** - * @return le nom du repertoire entre dans la boite de dialogue. - * Si le bouton annuler est utilisé, ou qu'il y a une erreur retourne - * null. - */ - public static String getDirectory() { - return getDirectory(null, "Ok", "Ok"); - } - - /** - * @param title le nom de la boite de dialogue - * @param approvalText le texte de l'action d'acceptation du répertoire dans le file chooser - * @return le nom du repertoire entre dans la boite de dialogue. - * Si le bouton annuler est utilisé, ou qu'il y a une erreur retourne - * null. - */ - public static String getDirectory(String title, String approvalText) { - return getDirectory(null, title, approvalText); - } - - /** - * @param parent le component parent du dialog - * @param title le nom de la boite de dialogue - * @param approvalText le texte de l'action d'acceptation du répertoire dans le file chooser - * @return le nom du repertoire entre dans la boite de dialogue. - * Si le bouton annuler est utilisé, ou qu'il y a une erreur retourne - * null. - */ - public static String getDirectory(Component parent, - String title, - String approvalText) { - try { - JFileChooser chooser = new JFileChooser(currentDirectory); - chooser.setDialogType(JFileChooser.CUSTOM_DIALOG); - chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - chooser.setDialogTitle(title); - int returnVal = chooser.showDialog(parent, approvalText); - if (returnVal == JFileChooser.APPROVE_OPTION) { - File theFile = chooser.getSelectedFile(); - if (theFile != null) { - currentDirectory = theFile; - if (theFile.isDirectory()) { - return theFile.getAbsolutePath(); - } - } - } else { - return null; - } - } catch (Exception eee) { - log.warn("Erreur:", eee); - } - return null; - } -} diff --git a/jaxx-runtime/src/main/java/org/nuiton/jaxx/runtime/JAXXUtil.java b/jaxx-runtime/src/main/java/org/nuiton/jaxx/runtime/JAXXUtil.java index c38ce8b..d061a10 100644 --- a/jaxx-runtime/src/main/java/org/nuiton/jaxx/runtime/JAXXUtil.java +++ b/jaxx-runtime/src/main/java/org/nuiton/jaxx/runtime/JAXXUtil.java @@ -341,72 +341,6 @@ public class JAXXUtil { } } - /** @deprecated since 2.4.2, never use, will not be replaced */ - @Deprecated - public static boolean assignment(boolean value, - String name, - JAXXObject src) { - src.firePropertyChange(name.trim(), null, "dummy value"); - return value; - } - - /** @deprecated since 2.4.2, never use, will not be replaced */ - @Deprecated - - public static byte assignment(byte value, String name, JAXXObject src) { - src.firePropertyChange(name.trim(), null, "dummy value"); - return value; - } - - /** @deprecated since 2.4.2, never use, will not be replaced */ - @Deprecated - public static short assignment(short value, String name, JAXXObject src) { - src.firePropertyChange(name.trim(), null, "dummy value"); - return value; - } - - /** @deprecated since 2.4.2, never use, will not be replaced */ - @Deprecated - public static int assignment(int value, String name, JAXXObject src) { - src.firePropertyChange(name.trim(), null, "dummy value"); - return value; - } - - /** @deprecated since 2.4.2, never use, will not be replaced */ - @Deprecated - public static long assignment(long value, String name, JAXXObject src) { - src.firePropertyChange(name.trim(), null, "dummy value"); - return value; - } - - /** @deprecated since 2.4.2, never use, will not be replaced */ - @Deprecated - public static float assignment(float value, String name, JAXXObject src) { - src.firePropertyChange(name.trim(), null, "dummy value"); - return value; - } - - /** @deprecated since 2.4.2, never use, will not be replaced */ - @Deprecated - public static double assignment(double value, String name, JAXXObject src) { - src.firePropertyChange(name.trim(), null, "dummy value"); - return value; - } - - /** @deprecated since 2.4.2, never use, will not be replaced */ - @Deprecated - public static char assignment(char value, String name, JAXXObject src) { - src.firePropertyChange(name.trim(), null, "dummy value"); - return value; - } - - /** @deprecated since 2.4.2, never use, will not be replaced */ - @Deprecated - public static Object assignment(Object value, String name, JAXXObject src) { - src.firePropertyChange(name.trim(), null, "dummy value"); - return value; - } - /** * Compute the string representation of an object. * diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/AboutPanel.jaxx b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/AboutPanel.jaxx deleted file mode 100644 index 9dc8c63..0000000 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/AboutPanel.jaxx +++ /dev/null @@ -1,139 +0,0 @@ -<!-- - #%L - JAXX :: Widgets - %% - Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - %% - 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% - --> - -<Table insets='1' - background='{getBackgroundColor()}' - border='{BorderFactory.createLineBorder(Color.BLACK, 1)}'> - - <import> - java.awt.Color - java.awt.Frame - javax.swing.BorderFactory - javax.swing.SwingConstants - </import> - - <AboutPanelHandler id='handler' constructorParams='this'/> - - <String id='title' javaBean='null'/> - - <String id='iconPath' javaBean='null'/> - - <String id='aboutText' javaBean='null'/> - - <String id='bottomText' javaBean='null'/> - - <String id='licenseText' javaBean='null'/> - - <String id='thirdpartyText' javaBean='null'/> - - <Color id='backgroundColor' javaBean='null'/> - - <script><![CDATA[ -public void setLicenseFile(String filename) { - handler.setLicenseFile(filename); -} - -public void setThirdpartyFile(String filename) { - handler.setThirdpartyFile(filename); -} - -public void buildTopPanel() { - handler.buildTopPanel(); -} - -public void init() { - handler.init(); -} - -public void showInDialog(Frame ui, boolean undecorated) { - handler.showInDialog(ui, undecorated); -} - -void $afterCompleteSetup() { - handler.$afterCompleteSetup(); -} - -]]> - </script> - <row> - <cell weightx='1' fill='both'> - <JPanel background='{Color.WHITE}' layout='{new BorderLayout()}'> - <JLabel text='{SwingUtil.getStringValue(getTitle())}' - visible='{getTitle() != null}' - font-size='12' - constraints='BorderLayout.CENTER'/> - </JPanel> - </cell> - </row> - <row> - <cell weightx='1' fill='both'> - <JPanel id='topPanel'/> - </cell> - </row> - <row> - <cell weighty='1' fill='both'> - <JTabbedPane id='tabs'> - <tab title="aboutframe.about"> - <JScrollPane id='aboutContent' border='{null}'> - <JEditorPane contentType='text/html' - editable='false' - border='{null}' - text='{SwingUtil.getStringValue(getAboutText())}' - onHyperlinkUpdate='SwingUtil.openLink(event)'/> - </JScrollPane> - </tab> - <tab title="aboutframe.license"> - <JScrollPane id='licenseContent' border='{null}'> - <JTextArea id='licenseTextArea' - editable='false' - font-size='11' - border='{null}' - text='{SwingUtil.getStringValue(getLicenseText())}'/> - </JScrollPane> - </tab> - <tab title="aboutframe.thirdparty"> - <JScrollPane id='thirdpartyContent' border='{null}'> - <JTextArea id='thirdpartyTextArea' - editable='false' - font-size='11' - border='{null}' - text='{SwingUtil.getStringValue(getThirdpartyText())}'/> - </JScrollPane> - </tab> - </JTabbedPane> - </cell> - </row> - <row> - <cell fill='both'> - <JPanel layout='{new BorderLayout()}'> - <JLabel id='bottomLabel' - constraints='BorderLayout.CENTER' - horizontalAlignment='{SwingConstants.CENTER}' - text='{SwingUtil.getStringValue(getBottomText())}' - visible='{getBottomText() != null}'/> - <JButton id='close' action='{handler.closeAction}' - constraints='BorderLayout.EAST'/> - </JPanel> - </cell> - </row> - -</Table> diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/AboutPanelHandler.java b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/AboutPanelHandler.java deleted file mode 100644 index b514fe3..0000000 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/AboutPanelHandler.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * #%L - * JAXX :: Widgets - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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% - */ -package org.nuiton.jaxx.runtime.swing; - -import org.nuiton.jaxx.runtime.JAXXUtil; -import org.nuiton.jaxx.runtime.SwingUtil; -import org.apache.commons.io.IOUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.util.Resource; - -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.Icon; -import javax.swing.JComponent; -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JRootPane; -import javax.swing.KeyStroke; -import javax.swing.SwingUtilities; -import java.awt.Component; -import java.awt.Frame; -import java.awt.event.ActionEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.io.IOException; -import java.io.InputStream; - -import static org.nuiton.i18n.I18n.t; - -/** - * Handler of the ui {@link AboutPanel}. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.4 - * @deprecated please use now jaxx-widgets-about module instead. - */ -@Deprecated -public class AboutPanelHandler { - - private static final Log log = LogFactory.getLog(AboutPanelHandler.class); - - protected final AboutPanel ui; - - public AboutPanelHandler(AboutPanel ui) { - this.ui = ui; - } - - final protected Action closeAction = new AbstractAction("close") { - private static final long serialVersionUID = 1L; - - @Override - public void actionPerformed(ActionEvent e) { - JDialog container = ui.getParentContainer(JDialog.class); - if (container != null) { - container.dispose(); - } else { - ui.setVisible(false); - } - } - }; - - public void setLicenseFile(String filename) { - String load = load(filename); - ui.setLicenseText(load); - } - - public void setThirdpartyFile(String filename) { - String load = load(filename); - ui.setThirdpartyText(load); - } - - public void buildTopPanel() { - // image - JLabel labelIcon; - if (ui.iconPath != null) { - Icon logoIcon = Resource.getIcon(ui.iconPath); - labelIcon = new JLabel(logoIcon); - } else { - labelIcon = new JLabel(); - } - ui.topPanel.add(labelIcon); - } - - public void init() { - if (ui.getAboutText() == null) { - ui.tabs.remove(ui.aboutContent); - } - if (ui.getLicenseText() == null) { - ui.tabs.remove(ui.licenseContent); - } else { - SwingUtilities.invokeLater(() -> ui.licenseTextArea.setCaretPosition(0)); - - } - if (ui.getThirdpartyText() == null) { - ui.tabs.remove(ui.thirdpartyContent); - } else { - SwingUtilities.invokeLater(() -> ui.thirdpartyTextArea.setCaretPosition(0)); - } - } - - public void showInDialog(Frame ui, boolean undecorated) { - JDialog f = new JDialog(ui, true); - f.add(this.ui); - if (this.ui.iconPath != null) { - f.setIconImage(SwingUtil.createIcon(this.ui.iconPath).getImage()); - } - f.setResizable(false); - f.setSize(550, 450); - f.setUndecorated(undecorated); - JRootPane rootPane = f.getRootPane(); - rootPane.setDefaultButton(this.ui.close); - rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close"); - rootPane.getActionMap().put("close", closeAction); - f.addWindowListener(new WindowAdapter() { - @Override - public void windowClosed(WindowEvent e) { - Component ui = (Component) e.getSource(); - if (log.isInfoEnabled()) { - log.info("destroy ui " + ui); - } - JAXXUtil.destroy(ui); - JAXXUtil.destroy(AboutPanelHandler.this.ui); - } - }); - SwingUtil.center(ui, f); - f.setVisible(true); - } - - protected String load(String filename) { - InputStream licenseStream = getClass().getResourceAsStream("/" + filename); - String result = null; - try { - if (licenseStream != null) { - result = IOUtils.toString(licenseStream); - } - } catch (IOException ex) { - // ignore it - } finally { - if (licenseStream != null) { - try { - licenseStream.close(); - } catch (IOException ex) { - log.error("could not close file " + filename); - } - } - } - if (result == null) { - result = "resource " + filename + " not found"; - } - return result; - } - - void $afterCompleteSetup() { - buildTopPanel(); - ui.close.setText(t("aboutframe.ok")); - } -} diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/JAXXWidgetUtil.java b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/JAXXWidgetUtil.java index 1d08f7b..cff617d 100644 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/JAXXWidgetUtil.java +++ b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/JAXXWidgetUtil.java @@ -21,15 +21,15 @@ */ package org.nuiton.jaxx.runtime.swing; -import javax.swing.table.TableCellEditor; -import javax.swing.table.TableCellRenderer; import org.nuiton.jaxx.runtime.SwingUtil; import org.nuiton.jaxx.runtime.swing.editor.cell.DateCellEditor; import org.nuiton.jaxx.runtime.swing.editor.cell.FileCellEditor; import org.nuiton.jaxx.runtime.swing.editor.cell.KeyStrokeCellEditor; -import org.nuiton.jaxx.runtime.swing.editor.cell.NumberCellEditor; import org.nuiton.jaxx.runtime.swing.renderer.DateCellRenderer; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; + /** * @author Sylvain Lletellier */ @@ -55,7 +55,4 @@ public class JAXXWidgetUtil extends SwingUtil { return new KeyStrokeCellEditor(); } - public static <E extends Number> NumberCellEditor<E> newNumberTableCellEditor(Class<E> type, boolean useSign) { - return new NumberCellEditor<>(type, useSign); - } } diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/cell/NumberCellEditor.java b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/cell/NumberCellEditor.java deleted file mode 100644 index 138e00a..0000000 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/cell/NumberCellEditor.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * #%L - * JAXX :: Widgets - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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% - */ -package org.nuiton.jaxx.runtime.swing.editor.cell; - -import java.awt.Component; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import javax.swing.AbstractCellEditor; -import javax.swing.JTable; -import javax.swing.SwingConstants; -import javax.swing.SwingUtilities; -import javax.swing.event.AncestorEvent; -import javax.swing.event.AncestorListener; -import javax.swing.table.TableCellEditor; -import org.nuiton.jaxx.runtime.JAXXUtil; -import org.nuiton.jaxx.runtime.swing.editor.NumberEditor; - -/** - * @author Sylvain Lletellier - * @deprecated since 2.17, prefer use {@code org.nuiton.jaxx.widgets.editor.cell.NumberCellEditor}. - */ -@Deprecated -public class NumberCellEditor<E extends Number> extends AbstractCellEditor - implements TableCellEditor, FocusListener, AncestorListener { - - private static final long serialVersionUID = 1L; - - protected final NumberEditor numberEditor; - - /** constructor */ - public NumberCellEditor(Class<E> type, boolean useSign) { - numberEditor = new NumberEditor(); - numberEditor.getTextField().setHorizontalAlignment(SwingConstants.RIGHT); - numberEditor.getTextField().setBorder(null); - numberEditor.getTextField().addFocusListener(this); - numberEditor.getTextField().addAncestorListener(this); - - numberEditor.setModelType(type); - - numberEditor.setUseSign(useSign); - numberEditor.init(); - } - - @Override - public Component getTableCellEditorComponent(JTable table, Object value, - boolean isSelected, int row, int column) { - - E number = (E) value; - numberEditor.setModel(number); - numberEditor.setModelText(JAXXUtil.getStringValue(number)); - return numberEditor; - } - - public NumberEditor getNumberEditor() { - return numberEditor; - } - - @Override - public E getCellEditorValue() { - return (E)numberEditor.getModel(); - } - - @Override - public void focusGained(FocusEvent e) { - SwingUtilities.invokeLater(() -> { - numberEditor.getTextField().requestFocus(); - numberEditor.getTextField().selectAll(); - }); - } - - @Override - public void focusLost(FocusEvent e) { - // commenting the next line fixes http://www.nuiton.org/issues/3517 and http://www.nuiton.org/issues/3518 -// cancelCellEditing(); - } - - @Override - public void ancestorAdded(AncestorEvent event) { - SwingUtilities.invokeLater(() -> { - numberEditor.getTextField().requestFocus(); - numberEditor.getTextField().selectAll(); - }); - } - - @Override - public void ancestorRemoved(AncestorEvent event) { - } - - @Override - public void ancestorMoved(AncestorEvent event) { - } - - @Override - public boolean stopCellEditing() { - boolean result = super.stopCellEditing(); - // Reset previous data to avoid keeping it on other cell edition - if (result) { - numberEditor.setModel(null); - // Use empty string, otherwise there is a NPE in NumberEditorHandler - numberEditor.setModelText(""); - // force binding, I do not know why the textfield text is not emptied - // if we do not force it - numberEditor.applyDataBinding(NumberEditor.BINDING_TEXT_FIELD_TEXT); - } - return result; - } - -} -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository jaxx. See https://gitlab.nuiton.org/nuiton/jaxx.git commit 69c4470b36dddf1edfce93b19cec427037feaab1 Author: Tony CHEMIT <dev@tchemit.fr> Date: Sat Dec 31 13:05:22 2016 +0100 Remove application API (Fixes #4107) --- jaxx-application-api/LICENSE.txt | 165 --- jaxx-application-api/README.md | 0 jaxx-application-api/pom.xml | 100 -- .../src/license/THIRD-PARTY.properties | 21 - .../application/ApplicationBusinessException.java | 49 - .../jaxx/application/ApplicationConfiguration.java | 81 -- .../jaxx/application/ApplicationContext.java | 39 - .../jaxx/application/ApplicationDataUtil.java | 86 -- .../nuiton/jaxx/application/ApplicationIOUtil.java | 262 ---- .../application/ApplicationTechnicalException.java | 48 - .../nuiton/jaxx/application/bean/BinderCache.java | 60 - .../jaxx/application/bean/JavaBeanObject.java | 137 -- .../JavaBeanObjectPropagateChangeListener.java | 71 -- .../jaxx/application/bean/JavaBeanObjectUtil.java | 109 -- .../bean/RemoveablePropertyChangeListener.java | 35 - .../listener/PropagatePropertyChangeListener.java | 81 -- .../type/ApplicationProgressionModel.java | 113 -- jaxx-application-api/src/site/site.xml | 44 - jaxx-application-swing/LICENSE.txt | 165 --- jaxx-application-swing/README.md | 0 jaxx-application-swing/pom.xml | 199 --- .../src/license/THIRD-PARTY.properties | 26 - .../swing/AbstractApplicationFormUIModel.java | 289 ----- .../swing/AbstractApplicationUIHandler.java | 1316 -------------------- .../jaxx/application/swing/ApplicationUI.java | 143 --- .../swing/ApplicationUIConfiguration.java | 43 - .../application/swing/ApplicationUIContext.java | 88 -- .../swing/action/AbstractApplicationAction.java | 438 ------- .../swing/action/ApplicationActionEngine.java | 126 -- .../swing/action/ApplicationActionException.java | 56 - .../swing/action/ApplicationActionFactory.java | 94 -- .../swing/action/ApplicationActionSwingWorker.java | 201 --- .../swing/action/ApplicationActionUI.jaxx | 72 -- .../swing/action/ApplicationActionUI.jcss | 66 - .../swing/action/ApplicationActionUIHandler.java | 274 ---- .../swing/action/ApplicationActionUIModel.java | 73 -- .../swing/action/ApplicationUIAction.java | 235 ---- .../swing/actionng/ApplicationAction.java | 65 - .../swing/actionng/ApplicationActionEngine.java | 101 -- .../swing/actionng/ApplicationActionEvent.java | 95 -- .../swing/actionng/ApplicationActionListener.java | 47 - .../jaxx/application/swing/tab/CustomTab.java | 220 ---- .../swing/tab/DelegateTabContainerHandler.java | 120 -- .../application/swing/tab/TabContainerHandler.java | 76 -- .../application/swing/tab/TabContentModel.java | 44 - .../jaxx/application/swing/tab/TabHandler.java | 58 - .../swing/table/AbstractApplicationTableModel.java | 371 ------ .../swing/table/AbstractSelectTableAction.java | 98 -- .../ApplicationTableModelValidatorDataLocator.java | 76 -- .../application/swing/table/ColumnIdentifier.java | 103 -- .../swing/table/MoveToNextEditableCellAction.java | 100 -- .../swing/table/MoveToNextEditableRowAction.java | 91 -- .../table/MoveToPreviousEditableCellAction.java | 80 -- .../table/MoveToPreviousEditableRowAction.java | 71 -- .../swing/util/ActionListCellRenderer.java | 60 - .../swing/util/ApplicationColorHighlighter.java | 64 - .../swing/util/ApplicationErrorHelper.java | 116 -- .../swing/util/ApplicationExceptionHandler.java | 89 -- .../application/swing/util/ApplicationUIUtil.java | 208 ---- .../jaxx/application/swing/util/Cancelable.java | 34 - .../jaxx/application/swing/util/CloseableUI.java | 42 - .../i18n/jaxx-application-swing_en_GB.properties | 23 - .../i18n/jaxx-application-swing_es_ES.properties | 23 - .../i18n/jaxx-application-swing_fr_FR.properties | 23 - jaxx-application-swing/src/site/site.xml | 44 - pom.xml | 2 - 66 files changed, 7949 deletions(-) diff --git a/jaxx-application-api/LICENSE.txt b/jaxx-application-api/LICENSE.txt deleted file mode 100644 index cca7fc2..0000000 --- a/jaxx-application-api/LICENSE.txt +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/jaxx-application-api/README.md b/jaxx-application-api/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/jaxx-application-api/pom.xml b/jaxx-application-api/pom.xml deleted file mode 100644 index 9cc40ef..0000000 --- a/jaxx-application-api/pom.xml +++ /dev/null @@ -1,100 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - #%L - Ifremer shared :: Application - %% - Copyright (C) 2013 Ifremer, CodeLutin, Tony CHEMIT - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU 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 Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program. If not, see - <http://www.gnu.org/licenses/gpl-3.0.html>. - #L% - --> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.nuiton</groupId> - <artifactId>jaxx</artifactId> - <version>3.0-SNAPSHOT</version> - </parent> - - <groupId>org.nuiton.jaxx</groupId> - <artifactId>jaxx-application-api</artifactId> - <name>JAXX :: Application API</name> - - <dependencies> - - <!-- Commons --> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-lang3</artifactId> - </dependency> - <dependency> - <groupId>commons-beanutils</groupId> - <artifactId>commons-beanutils</artifactId> - </dependency> - <dependency> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </dependency> - <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-vfs2</artifactId> - </dependency> - - <!-- Guava --> - <dependency> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - </dependency> - - <!-- Nuiton --> - <dependency> - <groupId>org.nuiton</groupId> - <artifactId>nuiton-version</artifactId> - </dependency> - <dependency> - <groupId>org.nuiton</groupId> - <artifactId>nuiton-utils</artifactId> - </dependency> - <dependency> - <groupId>org.nuiton</groupId> - <artifactId>nuiton-config</artifactId> - </dependency> - <dependency> - <groupId>org.nuiton.i18n</groupId> - <artifactId>nuiton-i18n</artifactId> - </dependency> - - <!-- SwingX --> - <dependency> - <groupId>org.swinglabs.swingx</groupId> - <artifactId>swingx-common</artifactId> - </dependency> - - - <!-- Test --> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - </dependency> - - </dependencies> - -</project> diff --git a/jaxx-application-api/src/license/THIRD-PARTY.properties b/jaxx-application-api/src/license/THIRD-PARTY.properties deleted file mode 100644 index cc60d11..0000000 --- a/jaxx-application-api/src/license/THIRD-PARTY.properties +++ /dev/null @@ -1,21 +0,0 @@ -# Generated by org.codehaus.mojo.license.AddThirdPartyMojo -#------------------------------------------------------------------------------- -# Already used licenses in project : -# - BSD License -# - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 -# - Common Public License Version 1.0 -# - GNU Library or Lesser General Public License -# - Indiana University Extreme! Lab Software License, vesion 1.1.1 -# - Lesser General Public License (LGPL) -# - Lesser General Public License (LGPL) v 3.0 -# - Lesser General Public License (LPGL) -# - Lesser General Public License (LPGL) v 2.1 -# - MIT License -# - New BSD License -# - The Apache Software License, Version 2.0 -#------------------------------------------------------------------------------- -# Please fill the missing licenses for dependencies : -# -# -#Sun Nov 24 23:48:15 CET 2013 -commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0 diff --git a/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/ApplicationBusinessException.java b/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/ApplicationBusinessException.java deleted file mode 100644 index 6a5b4e7..0000000 --- a/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/ApplicationBusinessException.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.nuiton.jaxx.application; - -/* - * #%L - * JAXX :: Application API - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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% - */ - -/** - * Application business exception, a such exeception should be shown to - * user in application. - * - * Created on 11/23/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public class ApplicationBusinessException extends RuntimeException { - - private static final long serialVersionUID = 1L; - - public ApplicationBusinessException(String message) { - super(message); - } - - public ApplicationBusinessException(String message, Throwable cause) { - super(message, cause); - } - - public ApplicationBusinessException(Throwable cause) { - super(cause); - } -} diff --git a/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/ApplicationConfiguration.java b/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/ApplicationConfiguration.java deleted file mode 100644 index 7e7ec37..0000000 --- a/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/ApplicationConfiguration.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.nuiton.jaxx.application; - -/* - * #%L - * JAXX :: Application API - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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.nuiton.config.ApplicationConfig; -import org.nuiton.config.ApplicationConfigHelper; -import org.nuiton.config.ApplicationConfigProvider; -import org.nuiton.version.Version; - -import javax.swing.KeyStroke; -import java.util.Set; - -/** - * Created on 11/24/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public abstract class ApplicationConfiguration { - - /** - * Delegate application config. - */ - protected final ApplicationConfig applicationConfig; - - public abstract String getApplicationName(); - - public abstract Version getVersion(); - - /** - * @deprecated since 2.13, use now {@code org.nuiton.jaxx.application.swing.ApplicationUIConfiguration#getShortcutClosePopup()} - */ - @Deprecated - public abstract KeyStroke getShortcutClosePopup(); - - public ApplicationConfiguration(ApplicationConfig applicationConfig) { - this.applicationConfig = applicationConfig; - } - - public ApplicationConfig getApplicationConfig() { - return applicationConfig; - } - - public static Set<ApplicationConfigProvider> loadApplicationConfig(ApplicationConfig applicationConfig) { - - // get all config providers - Set<ApplicationConfigProvider> providers = - ApplicationConfigHelper.getProviders(null, - null, - null, - true); - - // load all default options - ApplicationConfigHelper.loadAllDefaultOption(applicationConfig, providers); - - // load actions - ApplicationConfigHelper.loadAllActions(applicationConfig, providers); - - return providers; - } -} diff --git a/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/ApplicationContext.java b/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/ApplicationContext.java deleted file mode 100644 index 04a8b81..0000000 --- a/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/ApplicationContext.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.nuiton.jaxx.application; - -/* - * #%L - * JAXX :: Application API - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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% - */ - -/** - * Context of application, may contains config, data sources, ... - * - * Created on 11/23/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public interface ApplicationContext { - - /** - * @return the application configuration - */ - ApplicationConfiguration getConfiguration(); -} diff --git a/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/ApplicationDataUtil.java b/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/ApplicationDataUtil.java deleted file mode 100644 index 0d3f39f..0000000 --- a/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/ApplicationDataUtil.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.nuiton.jaxx.application; - -/* - * #%L - * JAXX :: Application API - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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 org.apache.commons.beanutils.PropertyUtils; -import org.apache.commons.lang3.time.DurationFormatUtils; -import org.nuiton.jaxx.application.bean.JavaBeanObjectUtil; - -import java.util.Date; - -/** - * Useful methods on data. - * - * TODO Needs some javadoc. - * - * Created on 11/24/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - * @deprecated since 2.12, will not be replaced. - */ -@Deprecated -public class ApplicationDataUtil { - - /** - * @deprecated since 2.12, prefer use {@link JavaBeanObjectUtil#setProperty(Object, String, Object)} - */ - @Deprecated - public static void setProperty(Object bean, String property, Object value) { - Preconditions.checkNotNull(bean); - Preconditions.checkNotNull(property); - try { - PropertyUtils.setSimpleProperty(bean, property, value); - } catch (Exception e) { - throw new ApplicationTechnicalException(String.format("Property %1s not found on object of type %2s", property, bean.getClass().getName()), e); - } - } - - /** - * @deprecated since 2.12, prefer use {@link JavaBeanObjectUtil#getProperty(Object, String)}) - */ - @Deprecated - public static Object getProperty(Object bean, String property) { - Preconditions.checkNotNull(bean); - Preconditions.checkNotNull(property); - try { - return PropertyUtils.getSimpleProperty(bean, property); - } catch (Exception e) { - throw new ApplicationTechnicalException(String.format("Property %1s not found on object of type %2s", property, bean.getClass().getName()), e); - } - } - - public static String getDuration(Date startDate, - Date endDate, - String format) { - String duration = ""; - if (startDate != null && endDate != null && !startDate.after(endDate)) { - duration = DurationFormatUtils.formatPeriod( - startDate.getTime(), - endDate.getTime(), - format); - } - return duration; - } -} diff --git a/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/ApplicationIOUtil.java b/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/ApplicationIOUtil.java deleted file mode 100644 index 335b847..0000000 --- a/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/ApplicationIOUtil.java +++ /dev/null @@ -1,262 +0,0 @@ -package org.nuiton.jaxx.application; - -/* - * #%L - * JAXX :: Application API - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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.Charsets; -import com.google.common.io.Files; -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.FilenameUtils; -import org.apache.commons.vfs2.FileObject; -import org.apache.commons.vfs2.FileSelector; -import org.apache.commons.vfs2.FileSystemManager; -import org.apache.commons.vfs2.FileType; -import org.apache.commons.vfs2.VFS; -import org.nuiton.util.FileUtil; -import org.nuiton.util.ZipUtil; - -import java.io.Closeable; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.Reader; -import java.io.Writer; -import java.util.Collection; -import java.util.UUID; - -import static org.nuiton.i18n.I18n.t; - -/** - * Useful methods around IO, all method errors are boxes a - * {@link ApplicationTechnicalException}. - * - * Created on 11/24/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public class ApplicationIOUtil { - - protected ApplicationIOUtil() { - // no instance - } - - public static void close(Closeable toClose, String errorMessage) { - - try { - toClose.close(); - } catch (IOException e) { - throw new ApplicationTechnicalException(errorMessage, e); - } - } - - public static void zip(File source, File archiveFile, String errorMessage) { - try { - ZipUtil.compress(archiveFile, source); - } catch (IOException e) { - throw new ApplicationTechnicalException(errorMessage, e); - } - } - - public static void zip(File source, File archiveFile, Collection<File> files, String errorMessage) { - try { - ZipUtil.compressFiles(archiveFile, source, files); - } catch (IOException e) { - throw new ApplicationTechnicalException(t(errorMessage, archiveFile), e); - } - } - - public static FileObject resolveFile(String file, String errorMessage) { - try { - FileSystemManager manager = VFS.getManager(); - return manager.resolveFile(file); - } catch (IOException e) { - throw new ApplicationTechnicalException(errorMessage, e); - } - } - - public static FileObject[] getChildren(FileObject objectFile, String errorMessage) { - try { - return objectFile.getChildren(); - } catch (IOException e) { - throw new ApplicationTechnicalException(errorMessage, e); - } - } - - public static FileObject getChild(FileObject objectFile, String name, String errorMessage) { - try { - return objectFile.getChild(name); - } catch (IOException e) { - throw new ApplicationTechnicalException(errorMessage, e); - } - } - - - public static FileType getType(FileObject objectFile, String errorMessage) { - try { - return objectFile.getType(); - } catch (IOException e) { - throw new ApplicationTechnicalException(errorMessage, e); - } - } - - public static void explode(FileObject archiveFile, - File target, - FileSelector fileSelector, String errorMessage) { - try { - FileSystemManager manager = VFS.getManager(); - FileObject targetObject = manager.toFileObject(target); - targetObject.copyFrom(archiveFile, fileSelector); - } catch (IOException e) { - throw new ApplicationTechnicalException(errorMessage, e); - } - } - - public static void forceMkdir(File dir, String errorMessage) { - try { - FileUtils.forceMkdir(dir); - } catch (IOException e) { - throw new ApplicationTechnicalException(errorMessage, e); - } - } - - public static void cleanDirectory(File dir, String errorMessage) { - try { - FileUtils.cleanDirectory(dir); - } catch (IOException e) { - throw new ApplicationTechnicalException(errorMessage, e); - } - } - - public static void deleteDirectory(File dir, String errorMessage) { - try { - FileUtils.deleteDirectory(dir); - } catch (IOException e) { - throw new ApplicationTechnicalException(errorMessage, e); - } - } - - public static void forceDeleteOnExit(File dir, String errorMessage) { - try { - FileUtils.forceDeleteOnExit(dir); - } catch (IOException e) { - throw new ApplicationTechnicalException(errorMessage, e); - } - } - - public static void copyDirectory(File source, File target, String errorMessage) { - try { - FileUtils.copyDirectory(source, target); - } catch (IOException e) { - throw new ApplicationTechnicalException(errorMessage, e); - } - } - - public static void copyFileToDirectory(File source, File target, String errorMessage) { - try { - FileUtils.copyFileToDirectory(source, target); - } catch (IOException e) { - throw new ApplicationTechnicalException(errorMessage, e); - } - } - - public static void copyFile(File source, File target, String errorMessage) { - try { - FileUtils.copyFile(source, target); - } catch (IOException e) { - throw new ApplicationTechnicalException(errorMessage, e); - } - } - - public static void deleteFile(File file, String errorMessage) { - try { - FileUtils.forceDelete(file); - } catch (IOException e) { - throw new ApplicationTechnicalException(errorMessage, e); - } - } - - public static String getBaseName(String file) { - return FilenameUtils.getBaseName(file); - } - - public static String getExtension(String file) { - return FilenameUtils.getExtension(file); - } - - public static Reader newReader(File file, String errorMessage) { - try { - return Files.newReader(file, Charsets.UTF_8); - - } catch (FileNotFoundException e) { - throw new ApplicationTechnicalException(t(errorMessage, file), e); - } - } - - public static Writer newWriter(File file, String errorMessage - ) { - try { - return Files.newWriter(file, Charsets.UTF_8); - - } catch (FileNotFoundException e) { - throw new ApplicationTechnicalException(t(errorMessage, file), e); - } - } - - public static File explodeZip(File rootDirectory, - File file, - String errorMessage) { - File tempDir = new File(rootDirectory, UUID.randomUUID().toString()); - try { - ZipUtil.uncompress(file, tempDir); - } catch (IOException e) { - throw new ApplicationTechnicalException(t(errorMessage, file), e); - } - return tempDir; - } - - public static String readContent(File file, String errorMessage) { - - try { - return FileUtils.readFileToString(file, Charsets.UTF_8); - - } catch (IOException e) { - throw new ApplicationTechnicalException(errorMessage, e); - } - } - - public static void writeContent(File file, String content, String errorMessage) { - try { - FileUtils.write(file, content, Charsets.UTF_8); - } catch (IOException e) { - throw new ApplicationTechnicalException(errorMessage, e); - } - } - - public static File createTemporaryDirectory(String prefix) { - try { - return FileUtil.createTempDirectory(prefix, null); - } catch (IOException e) { - throw new ApplicationTechnicalException("Could not create temporary directory", e); - } - } -} diff --git a/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/ApplicationTechnicalException.java b/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/ApplicationTechnicalException.java deleted file mode 100644 index 129964b..0000000 --- a/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/ApplicationTechnicalException.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.nuiton.jaxx.application; - -/* - * #%L - * JAXX :: Application API - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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% - */ - -/** - * Application Technical exception. - * - * Created on 11/23/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public class ApplicationTechnicalException extends RuntimeException { - - private static final long serialVersionUID = 1L; - - public ApplicationTechnicalException(String message) { - super(message); - } - - public ApplicationTechnicalException(String message, Throwable cause) { - super(message, cause); - } - - public ApplicationTechnicalException(Throwable cause) { - super(cause); - } -} diff --git a/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/bean/BinderCache.java b/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/bean/BinderCache.java deleted file mode 100644 index 9dcf693..0000000 --- a/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/bean/BinderCache.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.nuiton.jaxx.application.bean; - -/* - * #%L - * JAXX :: Application API - * %% - * Copyright (C) 2008 - 2014 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.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import org.apache.commons.lang3.tuple.Pair; -import org.nuiton.jaxx.application.ApplicationTechnicalException; -import org.nuiton.util.beans.Binder; -import org.nuiton.util.beans.BinderFactory; - -import java.util.concurrent.ExecutionException; - -/** - * To cache binders. - * - * Created on 8/12/14. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.10 - */ -public class BinderCache { - - public static final LoadingCache<Pair<Class<?>, Class<?>>, Binder> cache = CacheBuilder.newBuilder().build(new CacheLoader<Pair<Class<?>, Class<?>>, Binder>() { - @Override - public Binder load(Pair<Class<?>, Class<?>> key) throws Exception { - return BinderFactory.newBinder(key.getLeft(), key.getRight()); - } - }); - - public static <S, T> Binder<S, T> getBinder(Class<S> sourceType, Class<T> targetType) { - Pair of = Pair.of(sourceType, targetType); - try { - return cache.get(of); - } catch (ExecutionException e) { - throw new ApplicationTechnicalException("Could not get binder from cache", e); - } - } -} diff --git a/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/bean/JavaBeanObject.java b/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/bean/JavaBeanObject.java deleted file mode 100644 index 99d1e3d..0000000 --- a/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/bean/JavaBeanObject.java +++ /dev/null @@ -1,137 +0,0 @@ -package org.nuiton.jaxx.application.bean; - -/* - * #%L - * JAXX :: Application API - * %% - * Copyright (C) 2008 - 2014 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.beans.PropertyChangeListener; - -/** - * Created on 8/12/14. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.10 - */ -public interface JavaBeanObject { - - /** - * Add a PropertyChangeListener to the listener list. - * The listener is registered for all properties. - * The same listener object may be added more than once, and will be called - * as many times as it is added. - * If <code>listener</code> is null, no exception is thrown and no action - * is taken. - * - * @param listener The PropertyChangeListener to be added - */ - void addPropertyChangeListener(PropertyChangeListener listener); - - /** - * Remove a PropertyChangeListener from the listener list. - * This removes a PropertyChangeListener that was registered - * for all properties. - * If <code>listener</code> was added more than once to the same event - * source, it will be notified one less time after being removed. - * If <code>listener</code> is null, or was never added, no exception is - * thrown and no action is taken. - * - * @param listener The PropertyChangeListener to be removed - */ - void removePropertyChangeListener(PropertyChangeListener listener); - - /** - * Returns an array of all the listeners that were added to the - * PropertyChangeSupport object with addPropertyChangeListener(). - * <p> - * If some listeners have been added with a named property, then - * the returned array will be a mixture of PropertyChangeListeners - * and <code>PropertyChangeListenerProxy</code>s. If the calling - * method is interested in distinguishing the listeners then it must - * test each element to see if it's a - * <code>PropertyChangeListenerProxy</code>, perform the cast, and examine - * the parameter. - * - * <pre> - * PropertyChangeListener[] listeners = bean.getPropertyChangeListeners(); - * for (int i = 0; i < listeners.length; i++) { - * if (listeners[i] instanceof PropertyChangeListenerProxy) { - * PropertyChangeListenerProxy proxy = - * (PropertyChangeListenerProxy)listeners[i]; - * if (proxy.getPropertyName().equals("foo")) { - * // proxy is a PropertyChangeListener which was associated - * // with the property named "foo" - * } - * } - * } - * </pre> - * - * @return all of the <code>PropertyChangeListeners</code> added or an - * empty array if no listeners have been added - * @see java.beans.PropertyChangeListenerProxy - */ - PropertyChangeListener[] getPropertyChangeListeners(); - - /** - * Add a PropertyChangeListener for a specific property. The listener - * will be invoked only when a call on firePropertyChange names that - * specific property. - * The same listener object may be added more than once. For each - * property, the listener will be invoked the number of times it was added - * for that property. - * If <code>propertyName</code> or <code>listener</code> is null, no - * exception is thrown and no action is taken. - * - * @param propertyName The name of the property to listen on. - * @param listener The PropertyChangeListener to be added - */ - void addPropertyChangeListener(String propertyName, PropertyChangeListener listener); - - /** - * Remove a PropertyChangeListener for a specific property. - * If <code>listener</code> was added more than once to the same event - * source for the specified property, it will be notified one less time - * after being removed. - * If <code>propertyName</code> is null, no exception is thrown and no - * action is taken. - * If <code>listener</code> is null, or was never added for the specified - * property, no exception is thrown and no action is taken. - * - * @param propertyName The name of the property that was listened on. - * @param listener The PropertyChangeListener to be removed - */ - void removePropertyChangeListener(String propertyName, PropertyChangeListener listener); - - /** - * Returns an array of all the listeners which have been associated - * with the named property. - * - * @param propertyName The name of the property being listened to - * @return all of the <code>PropertyChangeListeners</code> associated with - * the named property. If no such listeners have been added, - * or if <code>propertyName</code> is null, an empty array is - * returned. - */ - PropertyChangeListener[] getPropertyChangeListeners(String propertyName); - - void firePropertyChanged(String propertyName, - Object oldValue, - Object newValue); -} diff --git a/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/bean/JavaBeanObjectPropagateChangeListener.java b/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/bean/JavaBeanObjectPropagateChangeListener.java deleted file mode 100644 index 9764808..0000000 --- a/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/bean/JavaBeanObjectPropagateChangeListener.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.nuiton.jaxx.application.bean; - -/* - * #%L - * JAXX :: Application API - * %% - * Copyright (C) 2008 - 2014 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.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - -/** - * Created on 8/12/14. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.10 - */ -public class JavaBeanObjectPropagateChangeListener implements PropertyChangeListener { - - public static void listenAndPropagate(JavaBeanObject producer, - JavaBeanObject consumer, - String propertyNameToListen, - String propertyNameToForward) { - JavaBeanObjectPropagateChangeListener listener = - new JavaBeanObjectPropagateChangeListener(propertyNameToForward, - consumer); - producer.addPropertyChangeListener(propertyNameToListen, listener); - } - - public static void listenAndPropagateAll(JavaBeanObject producer, - JavaBeanObject consumer) { - JavaBeanObjectPropagateChangeListener listener = - new JavaBeanObjectPropagateChangeListener(null, consumer); - producer.addPropertyChangeListener(listener); - } - - private final String propertyName; - - private final JavaBeanObject editor; - - public JavaBeanObjectPropagateChangeListener(String propertyName, - JavaBeanObject editor) { - this.propertyName = propertyName; - this.editor = editor; - } - - @Override - public void propertyChange(PropertyChangeEvent evt) { - String name = propertyName == null ? evt.getPropertyName() : propertyName; - editor.firePropertyChanged(name, - evt.getOldValue(), - evt.getNewValue()); - } - -} diff --git a/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/bean/JavaBeanObjectUtil.java b/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/bean/JavaBeanObjectUtil.java deleted file mode 100644 index 707742d..0000000 --- a/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/bean/JavaBeanObjectUtil.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.nuiton.jaxx.application.bean; - -/* - * #%L - * JAXX :: Application API - * %% - * Copyright (C) 2008 - 2014 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 com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import org.apache.commons.beanutils.PropertyUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.jaxx.application.ApplicationTechnicalException; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeListenerProxy; - -/** - * Created on 8/14/14. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.10 - */ -public class JavaBeanObjectUtil { - - /** Logger. */ - private static final Log log = LogFactory.getLog(JavaBeanObjectUtil.class); - - public static void removeAllPropertyChangeListeners(Iterable<? extends JavaBeanObject> beans) { - for (JavaBeanObject bean : beans) { - removeAllPropertyChangeListeners(bean); - } - } - - public static void removeAllPropertyChangeListeners(JavaBeanObject bean) { - - removePropertyChangeListeners(bean, Predicates.alwaysTrue()); - - } - - public static void removeAllRemovablePropertyChangeListeners(JavaBeanObject bean) { - - removePropertyChangeListeners(bean, input -> input instanceof RemoveablePropertyChangeListener); - - } - - public static void removePropertyChangeListeners(JavaBeanObject bean, Predicate<PropertyChangeListener> predicate) { - - PropertyChangeListener[] propertyChangeListeners = bean.getPropertyChangeListeners(); - for (PropertyChangeListener listener : propertyChangeListeners) { - - if (listener instanceof PropertyChangeListenerProxy) { - - PropertyChangeListenerProxy listenerProxy = (PropertyChangeListenerProxy) listener; - listener = listenerProxy.getListener(); - - } - - if (predicate.apply(listener)) { - - if (log.isDebugEnabled()) { - log.debug("Remove listener: " + listener); - } - bean.removePropertyChangeListener(listener); - - } - - } - - } - - public static void setProperty(Object bean, String property, Object value) { - Preconditions.checkNotNull(bean); - Preconditions.checkNotNull(property); - try { - PropertyUtils.setSimpleProperty(bean, property, value); - } catch (Exception e) { - throw new ApplicationTechnicalException(String.format("Could not set property %1s not found on object of type %2s", property, bean.getClass().getName()), e); - } - } - - public static Object getProperty(Object bean, String property) { - Preconditions.checkNotNull(bean); - Preconditions.checkNotNull(property); - try { - return PropertyUtils.getSimpleProperty(bean, property); - } catch (Exception e) { - throw new ApplicationTechnicalException(String.format("Could not get property %1s on object of type %2s", property, bean.getClass().getName()), e); - } - } -} diff --git a/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/bean/RemoveablePropertyChangeListener.java b/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/bean/RemoveablePropertyChangeListener.java deleted file mode 100644 index 106dbc7..0000000 --- a/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/bean/RemoveablePropertyChangeListener.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.nuiton.jaxx.application.bean; - -/* - * #%L - * JAXX :: Application API - * %% - * Copyright (C) 2008 - 2014 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.beans.PropertyChangeListener; - -/** - * This contract is just used to mark some {@link PropertyChangeListener} we - * want when we reload some ui to remove. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.10 - */ -public abstract class RemoveablePropertyChangeListener implements PropertyChangeListener { -} diff --git a/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/listener/PropagatePropertyChangeListener.java b/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/listener/PropagatePropertyChangeListener.java deleted file mode 100644 index bec28f6..0000000 --- a/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/listener/PropagatePropertyChangeListener.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.nuiton.jaxx.application.listener; - -/* - * #%L - * JAXX :: Application API - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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.AbstractBean; -import org.nuiton.jaxx.application.bean.JavaBeanObjectPropagateChangeListener; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - -/** - * To listen a bean and propagate some of properties. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - * @deprecated since 2.10, prefer use {@link JavaBeanObjectPropagateChangeListener} - */ -@Deprecated -public class PropagatePropertyChangeListener implements PropertyChangeListener { - - public interface PropagatePropertyChange { - void firePropertyChanged(String propertyName, - Object oldValue, - Object newValue); - } - - public static void listenAndPropagate(AbstractBean producer, - PropagatePropertyChange consumer, - String propertyNameToListen, - String propertyNameToForward) { - PropagatePropertyChangeListener listener = - new PropagatePropertyChangeListener(propertyNameToForward, - consumer); - producer.addPropertyChangeListener(propertyNameToListen, listener); - } - - public static void listenAndPropagateAll(AbstractBean producer, - PropagatePropertyChange consumer) { - PropagatePropertyChangeListener listener = - new PropagatePropertyChangeListener(null, consumer); - producer.addPropertyChangeListener(listener); - } - - private final String propertyName; - - private final PropagatePropertyChange editor; - - public PropagatePropertyChangeListener(String propertyName, - PropagatePropertyChange editor) { - this.propertyName = propertyName; - this.editor = editor; - } - - @Override - public void propertyChange(PropertyChangeEvent evt) { - String name = propertyName == null ? evt.getPropertyName() : propertyName; - editor.firePropertyChanged(name, - evt.getOldValue(), - evt.getNewValue()); - } -} diff --git a/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/type/ApplicationProgressionModel.java b/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/type/ApplicationProgressionModel.java deleted file mode 100644 index a963869..0000000 --- a/jaxx-application-api/src/main/java/org/nuiton/jaxx/application/type/ApplicationProgressionModel.java +++ /dev/null @@ -1,113 +0,0 @@ -package org.nuiton.jaxx.application.type; - -/* - * #%L - * JAXX :: Application API - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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; - -/** - * Simple model for a progression long task. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public class ApplicationProgressionModel extends AbstractSerializableBean { - - private static final long serialVersionUID = 1L; - - public static final String PROPERTY_TOTAL = "total"; - - public static final String PROPERTY_CURRENT = "current"; - - public static final String PROPERTY_RATE = "rate"; - - public static final String PROPERTY_MESSAGE = "message"; - - protected int total; - - protected int current; - - protected float rate; - - protected String message; - - public int getTotal() { - return total; - } - - public void setTotal(int total) { - Object oldValue = getTotal(); - this.total = total; - firePropertyChange(PROPERTY_TOTAL, oldValue, total); - setCurrent(0); - } - - public void adaptTotal(int total) { - int current = getCurrent(); - setTotal(total); - increments(current); - Object oldValue = getTotal(); - this.total = total; - firePropertyChange(PROPERTY_TOTAL, oldValue, total); - setCurrent(current); - } - - public int getCurrent() { - return current; - } - - public void setCurrent(int current) { - Object oldValue = getCurrent(); - this.current = current; - firePropertyChange(PROPERTY_CURRENT, oldValue, current); - } - - public void increments(int nb) { - setCurrent(current + nb); - setRate(getCurrent() / getTotal()); - } - - public float getRate() { - return rate; - } - - public void setRate(float rate) { - Object oldValue = getRate(); - this.rate = rate; - firePropertyChange(PROPERTY_RATE, oldValue, rate); - } - - public String getMessage() { - return message; - } - - public void increments(String message) { - increments(1); - setMessage(message); - } - - public void setMessage(String message) { - Object oldValue = getMessage(); - this.message = message; - firePropertyChange(PROPERTY_MESSAGE, oldValue, message); - } -} diff --git a/jaxx-application-api/src/site/site.xml b/jaxx-application-api/src/site/site.xml deleted file mode 100644 index 1a18b30..0000000 --- a/jaxx-application-api/src/site/site.xml +++ /dev/null @@ -1,44 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - #%L - JAXX :: Application API - %% - Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - %% - 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% - --> - -<project name="${project.name}" - xmlns="http://maven.apache.org/DECORATION/1.4.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/DECORATION/1.4.0 http://maven.apache.org/xsd/decoration-1.4.0.xsd"> - - <bannerLeft> - <name>${project.name}</name> - <src>${siteCommonResourcesUrl}/images/logos/jaxx-logo.png</src> - <href>index.html</href> - </bannerLeft> - - <body> - - <breadcrumbs> - <item name="${project.name}" href="index.html"/> - </breadcrumbs> - - <menu ref="parent"/> - - <menu ref="reports"/> - - </body> -</project> diff --git a/jaxx-application-swing/LICENSE.txt b/jaxx-application-swing/LICENSE.txt deleted file mode 100644 index cca7fc2..0000000 --- a/jaxx-application-swing/LICENSE.txt +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/jaxx-application-swing/README.md b/jaxx-application-swing/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/jaxx-application-swing/pom.xml b/jaxx-application-swing/pom.xml deleted file mode 100644 index 19d4f10..0000000 --- a/jaxx-application-swing/pom.xml +++ /dev/null @@ -1,199 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - #%L - Ifremer shared :: Application Swing - %% - Copyright (C) 2013 Ifremer, CodeLutin, Tony CHEMIT - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU 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 Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program. If not, see - <http://www.gnu.org/licenses/gpl-3.0.html>. - #L% - --> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.nuiton</groupId> - <artifactId>jaxx</artifactId> - <version>3.0-SNAPSHOT</version> - </parent> - - <groupId>org.nuiton.jaxx</groupId> - <artifactId>jaxx-application-swing</artifactId> - <name>JAXX :: Application Swing</name> - - <properties> - - <!-- jaxx configuration --> - <jaxx.addProjectClassPath>true</jaxx.addProjectClassPath> - <jaxx.addSourcesToClassPath>true</jaxx.addSourcesToClassPath> - <jaxx.defaultErrorUIFQN> - org.nuiton.jaxx.validator.swing.ui.ImageValidationUI - </jaxx.defaultErrorUIFQN> - <!--<jaxx.useUIManagerForIcon>true</jaxx.useUIManagerForIcon>--> - <jaxx.generateHelp>true</jaxx.generateHelp> - <jaxx.generateSearch>false</jaxx.generateSearch> - <jaxx.autoImportCss>true</jaxx.autoImportCss> - <jaxx.autoRecurseInCss>false</jaxx.autoRecurseInCss> - <jaxx.addAutoHandlerUI>true</jaxx.addAutoHandlerUI> - <jaxx.cssExtension>jcss</jaxx.cssExtension> - - <!-- FIXME ! --> - <i18n.failsIfWarning>false</i18n.failsIfWarning> - - </properties> - - <dependencies> - - <!-- Sibling --> - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>jaxx-application-api</artifactId> - <version>${project.version}</version> - </dependency> - - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>jaxx-runtime</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>jaxx-validator</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>jaxx-widgets</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>jaxx-widgets-number</artifactId> - <version>${project.version}</version> - </dependency> - - <!-- Commons --> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-lang3</artifactId> - </dependency> - <dependency> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </dependency> - <dependency> - <groupId>commons-httpclient</groupId> - <artifactId>commons-httpclient</artifactId> - <scope>runtime</scope> - </dependency> - - <!-- Guava --> - <dependency> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - </dependency> - - <!-- Nuiton --> - <dependency> - <groupId>org.nuiton</groupId> - <artifactId>nuiton-utils</artifactId> - </dependency> - <dependency> - <groupId>org.nuiton</groupId> - <artifactId>nuiton-decorator</artifactId> - </dependency> - <dependency> - <groupId>org.nuiton.i18n</groupId> - <artifactId>nuiton-i18n</artifactId> - </dependency> - <dependency> - <groupId>org.nuiton</groupId> - <artifactId>nuiton-csv</artifactId> - </dependency> - <dependency> - <groupId>org.nuiton</groupId> - <artifactId>nuiton-validator</artifactId> - </dependency> - - <!-- SwingX --> - <dependency> - <groupId>org.swinglabs.swingx</groupId> - <artifactId>swingx-core</artifactId> - </dependency> - <dependency> - <groupId>org.swinglabs.swingx</groupId> - <artifactId>swingx-common</artifactId> - </dependency> - <dependency> - <groupId>org.swinglabs.swingx</groupId> - <artifactId>swingx-autocomplete</artifactId> - </dependency> - - <!-- Logging --> - <!--dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-jcl</artifactId> - <scope>runtime</scope> - </dependency> - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - <scope>runtime</scope> - </dependency--> - - <!-- Test --> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - </dependency> - - </dependencies> - - <build> - - <plugins> - - <plugin> - <groupId>org.nuiton.jaxx</groupId> - <artifactId>jaxx-maven-plugin</artifactId> - <version>${project.version}</version> - <executions> - <execution> - <goals> - <goal>generate</goal> - </goals> - </execution> - </executions> - </plugin> - - <plugin> - <groupId>org.nuiton.i18n</groupId> - <artifactId>i18n-maven-plugin</artifactId> - <executions> - <execution> - <id>scan-sources</id> - <goals> - <goal>parserJava</goal> - <goal>gen</goal> - </goals> - </execution> - </executions> - </plugin> - - </plugins> - </build> - -</project> diff --git a/jaxx-application-swing/src/license/THIRD-PARTY.properties b/jaxx-application-swing/src/license/THIRD-PARTY.properties deleted file mode 100644 index de1b7e2..0000000 --- a/jaxx-application-swing/src/license/THIRD-PARTY.properties +++ /dev/null @@ -1,26 +0,0 @@ -# Generated by org.codehaus.mojo.license.AddThirdPartyMojo -#------------------------------------------------------------------------------- -# Already used licenses in project : -# - Apache License -# - Apache License 2.0 -# - BSD License -# - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 -# - Common Public License Version 1.0 -# - GNU General Public License - Version 2 with the class path exception -# - GNU Library or Lesser General Public License -# - Indiana University Extreme! Lab Software License, vesion 1.1.1 -# - Lesser General Public License (LGPL) -# - Lesser General Public License (LGPL) v 3.0 -# - Lesser General Public License (LPGL) -# - Lesser General Public License (LPGL) v 2.1 -# - MIT License -# - MPL 1.1 -# - New BSD License -# - The Apache Software License, Version 2.0 -#------------------------------------------------------------------------------- -# Please fill the missing licenses for dependencies : -# -# -#Sun Aug 03 12:16:24 CEST 2014 -commons-codec--commons-codec--1.2=The Apache Software License, Version 2.0 -commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0 diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/AbstractApplicationFormUIModel.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/AbstractApplicationFormUIModel.java deleted file mode 100644 index 146d6d7..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/AbstractApplicationFormUIModel.java +++ /dev/null @@ -1,289 +0,0 @@ -package org.nuiton.jaxx.application.swing; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 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.Function; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jdesktop.beans.AbstractSerializableBean; -import org.nuiton.jaxx.application.ApplicationTechnicalException; -import org.nuiton.jaxx.application.bean.BinderCache; -import org.nuiton.jaxx.application.bean.JavaBeanObject; -import org.nuiton.util.beans.Binder; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.Set; - -/** - * A ui form model. - * - * Created on 8/15/14. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.10 - */ -public abstract class AbstractApplicationFormUIModel<E, B extends AbstractApplicationFormUIModel<E, B>> extends AbstractSerializableBean implements JavaBeanObject { - - private static final long serialVersionUID = 1L; - - /** Logger. */ - private static final Log log = LogFactory.getLog(AbstractApplicationFormUIModel.class); - - public static final String PROPERTY_MODIFY = "modify"; - - public static final String PROPERTY_VALID = "valid"; - - public static final String PROPERTY_CREATE = "create"; - - public static final ImmutableSet<String> MODIFY_IGNORE_PROPERTIES = - ImmutableSet.copyOf(Sets.newHashSet( - PROPERTY_MODIFY, - PROPERTY_VALID, - PROPERTY_CREATE)); - - /** - * Modify state of the form. - */ - private boolean modify; - - /** - * Valid state of the form. - */ - private boolean valid; - - /** - * Create state of the form (at true when editing a new object). - */ - private boolean create; - - /** - * To bind for incoming object inside the form. - */ - private final Binder<E, B> fromBeanBinder; - - /** - * To bind fro the from to outside world. - */ - private final Binder<B, E> toBeanBinder; - - /** - * Used to copy the form to outside world. - * - * @return a new instance of outisde world object. - */ - protected abstract E newEntity(); - - protected AbstractApplicationFormUIModel() { - fromBeanBinder = null; - toBeanBinder = null; - } - - protected AbstractApplicationFormUIModel(Class<E> entityType, - Class<B> uiModelType) { - this(BinderCache.getBinder(entityType, uiModelType), - BinderCache.getBinder(uiModelType, entityType)); - } - - protected AbstractApplicationFormUIModel(Binder<E, B> fromBeanBinder, - Binder<B, E> toBeanBinder) { - this.fromBeanBinder = fromBeanBinder; - this.toBeanBinder = toBeanBinder; - } - - /** - * Method to override the copy of incoming entity into the form. - * - * By default, invoke the simple binder copy (method {@link #fromBean(Object)}. - * - * @param entity incoming entity to copy inside the form - */ - public void fromEntity(E entity) { - fromBean(entity); - } - - /** - * Method to override the copy of the form to outside world ({@code entity}). - * - * By default, invoke the simple binder copy (method {@link #toBean(Object)}. - * - * @param entity the outside world object to fill - */ - public void toEntity(E entity) { - toBean(entity); - } - - /** - * <strong>Note:</strong> the method is {@code final}, if you need to customize something, do it in the - * {@link #toEntity(Object)} method. - * - * @return a new instance of object to persist from this form - */ - public final E toEntity() { - E result = newEntity(); - toEntity(result); - return result; - } - - /** - * @param bean object to copy into form using the {@link #fromBeanBinder} binder - */ - public final void fromBean(E bean) { - fromBeanBinder.copy(bean, (B) this); - } - - /** - * @return the new instance of bean binded from form to outside world - */ - public final E toBean() { - E result = newEntity(); - toBean(result); - return result; - } - - /** - * @param bean the bean to bind - * @return the binded form to the given {@code result} - */ - public final E toBean(E bean) { - toBeanBinder.copy((B) this, bean); - return bean; - } - - public boolean isModify() { - return modify; - } - - public void setModify(boolean modify) { - Object oldValue = isModify(); - this.modify = modify; - firePropertyChange(PROPERTY_MODIFY, oldValue, modify); - } - - public boolean isValid() { - return valid; - } - - public void setValid(boolean valid) { - Object oldValue = isValid(); - this.valid = valid; - firePropertyChange(PROPERTY_VALID, oldValue, valid); - } - - public boolean isCreate() { - return create; - } - - public void setCreate(boolean create) { - Object oldValue = isCreate(); - this.create = create; - firePropertyChange(PROPERTY_CREATE, oldValue, create); - } - - - /** - * @return set of property names that will not change the modify state. - */ - protected Set<String> getModifyIgnorePropertyNames() { - return MODIFY_IGNORE_PROPERTIES; - } - - //------------------------------------------------------------------------// - //-- PropagatePropertyChangeListener methods --// - //------------------------------------------------------------------------// - - @Override - public void firePropertyChanged(String propertyName, - Object oldValue, - Object newValue) { - firePropertyChange(propertyName, oldValue, newValue); - } - - //------------------------------------------------------------------------// - //-- To listen bean changes and reflect it to the modifiy state --// - //------------------------------------------------------------------------// - - public final <B extends JavaBeanObject> void listenModelIsModify(B... javaBeanObjects) { - - ModifyPropertyChangeListener listener = new ModifyPropertyChangeListener(this, getModifyIgnorePropertyNames()); - for (B javaBeanObject : javaBeanObjects) { - javaBeanObject.addPropertyChangeListener(listener); - } - - } - - protected <B extends JavaBeanObject> void listenAndModifyModel(Iterable<B> javaBeanObjects) { - - ModifyPropertyChangeListener listener = new ModifyPropertyChangeListener(this, getModifyIgnorePropertyNames()); - for (B javaBeanObject : javaBeanObjects) { - javaBeanObject.addPropertyChangeListener(listener); - } - - } - - //------------------------------------------------------------------------// - //-- Transform methods --// - //------------------------------------------------------------------------// - - protected static <E, B extends AbstractApplicationFormUIModel<E, B>> Function<B, E> modelToEntity() { - return AbstractApplicationFormUIModel::toEntity; - } - - protected static <E, B extends AbstractApplicationFormUIModel<E, B>> Function<E, B> entityToModel(final Class<B> modelType) { - return entity -> { - try { - B model = modelType.newInstance(); - model.fromEntity(entity); - return model; - } catch (Exception e) { - throw new ApplicationTechnicalException("Can't create new model " + modelType.getName(), e); - } - - }; - } - - protected static class ModifyPropertyChangeListener implements PropertyChangeListener { - - private final AbstractApplicationFormUIModel consumer; - - private final Set<String> propertiesToIgnore; - - public ModifyPropertyChangeListener(AbstractApplicationFormUIModel consumer, Set<String> propertiesToIgnore) { - this.consumer = consumer; - this.propertiesToIgnore = propertiesToIgnore; - } - - @Override - public void propertyChange(PropertyChangeEvent evt) { - String propertyName = evt.getPropertyName(); - if (!propertiesToIgnore.contains(propertyName)) { - if (log.isInfoEnabled()) { - log.info("A property changed: " + evt); - } - consumer.setModify(true); - } - } - } -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/AbstractApplicationUIHandler.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/AbstractApplicationUIHandler.java deleted file mode 100644 index bbf4083..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/AbstractApplicationUIHandler.java +++ /dev/null @@ -1,1316 +0,0 @@ -package org.nuiton.jaxx.application.swing; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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 com.google.common.collect.Lists; -import com.google.common.collect.Sets; -import org.nuiton.jaxx.runtime.JAXXUtil; -import org.nuiton.jaxx.runtime.SwingUtil; -import org.nuiton.jaxx.runtime.spi.UIHandler; -import org.nuiton.jaxx.runtime.swing.JAXXWidgetUtil; -import org.nuiton.jaxx.runtime.swing.editor.FileEditor; -import org.nuiton.jaxx.runtime.swing.editor.NumberEditor; -import org.nuiton.jaxx.runtime.swing.editor.SimpleTimeEditor; -import org.nuiton.jaxx.runtime.swing.editor.bean.BeanComboBox; -import org.nuiton.jaxx.runtime.swing.editor.bean.BeanDoubleList; -import org.nuiton.jaxx.runtime.swing.editor.bean.BeanFilterableComboBox; -import org.nuiton.jaxx.runtime.swing.editor.bean.BeanUIUtil; -import org.nuiton.jaxx.widgets.number.NumberCellEditor; -import org.nuiton.jaxx.runtime.swing.editor.gis.DmdCoordinateEditor; -import org.nuiton.jaxx.runtime.swing.editor.gis.DmsCoordinateEditor; -import org.nuiton.jaxx.runtime.swing.renderer.DecoratorListCellRenderer; -import org.nuiton.jaxx.runtime.swing.renderer.DecoratorTableCellRenderer; -import org.nuiton.jaxx.validator.swing.SwingValidator; -import org.apache.commons.lang3.ArrayUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jdesktop.swingx.JXDatePicker; -import org.jdesktop.swingx.JXTable; -import org.jdesktop.swingx.autocomplete.ComboBoxCellEditor; -import org.jdesktop.swingx.autocomplete.ObjectToStringConverter; -import org.jdesktop.swingx.table.TableColumnExt; -import org.nuiton.decorator.Decorator; -import org.nuiton.decorator.JXPathDecorator; -import org.nuiton.jaxx.application.ApplicationConfiguration; -import org.nuiton.jaxx.application.bean.JavaBeanObjectUtil; -import org.nuiton.jaxx.application.swing.action.AbstractApplicationAction; -import org.nuiton.jaxx.application.swing.action.ApplicationActionUI; -import org.nuiton.jaxx.application.swing.action.ApplicationUIAction; -import org.nuiton.jaxx.application.swing.table.ColumnIdentifier; -import org.nuiton.jaxx.application.swing.util.ApplicationUIUtil; -import org.nuiton.jaxx.application.swing.util.Cancelable; -import org.nuiton.jaxx.application.type.ApplicationProgressionModel; -import org.nuiton.validator.bean.AbstractValidator; -import org.nuiton.validator.bean.list.BeanListValidator; -import org.nuiton.validator.bean.simple.SimpleBeanValidator; - -import javax.swing.AbstractAction; -import javax.swing.AbstractButton; -import javax.swing.Action; -import javax.swing.DefaultComboBoxModel; -import javax.swing.JComboBox; -import javax.swing.JComponent; -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.JOptionPane; -import javax.swing.JPopupMenu; -import javax.swing.JRootPane; -import javax.swing.JScrollPane; -import javax.swing.JSpinner; -import javax.swing.JTable; -import javax.swing.JTextField; -import javax.swing.JViewport; -import javax.swing.KeyStroke; -import javax.swing.ListCellRenderer; -import javax.swing.ListSelectionModel; -import javax.swing.ScrollPaneConstants; -import javax.swing.SwingConstants; -import javax.swing.SwingUtilities; -import javax.swing.UIManager; -import javax.swing.border.LineBorder; -import javax.swing.event.ListSelectionEvent; -import javax.swing.table.TableCellEditor; -import javax.swing.table.TableCellRenderer; -import javax.swing.table.TableColumnModel; -import javax.swing.text.JTextComponent; -import java.awt.Color; -import java.awt.Component; -import java.awt.Container; -import java.awt.Dialog; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.event.ActionEvent; -import java.awt.event.FocusAdapter; -import java.awt.event.FocusEvent; -import java.awt.event.HierarchyEvent; -import java.awt.event.ItemEvent; -import java.awt.event.KeyEvent; -import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.io.File; -import java.io.Serializable; -import java.text.ParseException; -import java.util.Collections; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static org.nuiton.i18n.I18n.t; - -/** - * Handler of any ui. - * - * Created on 11/23/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public abstract class AbstractApplicationUIHandler<M, UI extends ApplicationUI<M, ?>> implements UIHandler<UI> { - - /** Logger. */ - private static final Log log = - LogFactory.getLog(AbstractApplicationUIHandler.class); - - public abstract void onCloseUI(); - - /** - * @return a single validator :( - * @deprecated since 2.10, prefer use now the {@link #getSimpleValidators()} and {@link #getListValidators()} initialized in {@link #initUI(ApplicationUI)} method. - */ - @Deprecated - public abstract SwingValidator<M> getValidator(); - - public abstract Component getTopestUI(); - - public abstract <E> Decorator<E> getDecorator(Class<E> beanType, String decoratorContext); - - /** - * Hook to prepare popup just before showing it. - * - * The right place to update actions accessibility; a quite better design - * than trying to update each time something change in the table... - * - * @param modelRowIndex selected row index (or lowest selected one) - * @param modelColumnIndex selected column index - * @since 2.6 - */ - protected void beforeOpenPopup(int modelRowIndex, int modelColumnIndex) { - // by default do nothing - } - - /** - * Global application context. - */ - private ApplicationUIContext context; - - /** - * UI handled. - */ - protected UI ui; - - /** - * Simple validators detected in {@link #initUI(ApplicationUI)} method. - * - * @since 2.10 - */ - private Set<SimpleBeanValidator> simpleValidators; - - /** - * List validators detected in {@link #initUI(ApplicationUI)} method. - * - * @since 2.10 - */ - private Set<BeanListValidator> listValidators; - - //------------------------------------------------------------------------// - //-- Public methods --// - //------------------------------------------------------------------------// - - /** - * @deprecated since 2.10, should move this to {@link SwingUtil#newComboModel(Object...)} - */ - @Deprecated - public DefaultComboBoxModel newComboModel(Object... items) { - return SwingUtil.newComboModel(items); - } - - public final M getModel() { - return ui.getModel(); - } - - public final UI getUI() { - return ui; - } - - public Set<SimpleBeanValidator> getSimpleValidators() { - return simpleValidators; - } - - public Set<BeanListValidator> getListValidators() { - return listValidators; - } - - @Override - public void beforeInit(UI ui) { - this.ui = ui; - } - - public ApplicationUIContext getContext() { - if (context == null) { - context = ApplicationUIUtil.getApplicationContext(ui); - } - return context; - } - - public void setText(KeyEvent event, String property) { - JTextComponent field = (JTextComponent) event.getSource(); - String value = field.getText(); - JavaBeanObjectUtil.setProperty(getModel(), property, value); - } - - public void setFile(ActionEvent event, String property) { - FileEditor field = (FileEditor) event.getSource(); - File value = field.getSelectedFile(); - JavaBeanObjectUtil.setProperty(getModel(), property, value); - } - - public void setBoolean(ItemEvent event, String property) { - boolean value = event.getStateChange() == ItemEvent.SELECTED; - JavaBeanObjectUtil.setProperty(getModel(), property, value); - } - - public void setDate(ActionEvent event, String property) { - JXDatePicker field = (JXDatePicker) event.getSource(); - Date value = field.getDate(); - JavaBeanObjectUtil.setProperty(getModel(), property, value); - } - - public void selectListData(ListSelectionEvent event, String property) { - if (!event.getValueIsAdjusting()) { - JList list = (JList) event.getSource(); - ListSelectionModel selectionModel = list.getSelectionModel(); - - selectionModel.setValueIsAdjusting(true); - try { - List<Object> selectedList = Lists.newLinkedList(); - - for (int index : list.getSelectedIndices()) { - Object o = list.getModel().getElementAt(index); - selectedList.add(o); - } - JavaBeanObjectUtil.setProperty(getModel(), property, selectedList); - } finally { - selectionModel.setValueIsAdjusting(false); - } - } - } - - public void openDialog(ApplicationUI dialogContent, - String title, Dimension dim) { - Component topestUI = getTopestUI(); - - JDialog result; - if (topestUI instanceof Frame) { - result = new JDialog((Frame) topestUI, title, true); - } else { - result = new JDialog((Dialog) topestUI, title, true); - } - - result.add((Component) dialogContent); - result.setResizable(true); - - result.setSize(dim); - - final AbstractApplicationUIHandler handler = dialogContent.getHandler(); - - if (handler instanceof Cancelable) { - - // add a auto-close action - JRootPane rootPane = result.getRootPane(); - - KeyStroke shortcutClosePopup = getContext().getConfiguration().getShortcutClosePopup(); - - rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( - shortcutClosePopup, "close"); - rootPane.getActionMap().put("close", new AbstractAction() { - private static final long serialVersionUID = 1L; - - @Override - public void actionPerformed(ActionEvent e) { - ((Cancelable) handler).cancel(); - } - }); - } - - result.addWindowListener(new WindowAdapter() { - - @Override - public void windowClosed(WindowEvent e) { - Component ui = (Component) e.getSource(); - if (log.isDebugEnabled()) { - log.debug("Destroy ui " + ui); - } - JAXXUtil.destroy(ui); - } - }); - SwingUtil.center(getContext().getMainUI(), result); - result.setVisible(true); - } - - public void closeDialog() { - getParentContainer(JDialog.class).setVisible(false); - } - - public <U extends Container> U getParentContainer(Class<U> uiType) { - return SwingUtil.getParentContainer(ui, uiType); - } - - public static final String CONFIRMATION_FORMAT = "<html>%s<hr/><br/>%s</html>"; - - public int askSaveBeforeLeaving(String message) { - String htmlMessage = String.format( - CONFIRMATION_FORMAT, - message, - t("jaxx.application.common.askSaveBeforeLeaving.help")); - return JOptionPane.showConfirmDialog( - getTopestUI(), - htmlMessage, - t("jaxx.application.common.askSaveBeforeLeaving.title"), - JOptionPane.YES_NO_CANCEL_OPTION, - JOptionPane.QUESTION_MESSAGE); - } - - public boolean askCancelEditBeforeLeaving(String message) { - String htmlMessage = String.format( - CONFIRMATION_FORMAT, - message, - t("jaxx.application.common.askCancelEditBeforeLeaving.help")); - int i = JOptionPane.showConfirmDialog( - getTopestUI(), - htmlMessage, - t("jaxx.application.common.askCancelEditBeforeLeaving.title"), - JOptionPane.OK_CANCEL_OPTION, - JOptionPane.QUESTION_MESSAGE); - - return i == JOptionPane.OK_OPTION; - } - - public void showSuccessMessage(String title, String message) { - - Component topestUI = getTopestUI(); - boolean alwaysOnTop = false; - - if (topestUI instanceof JDialog) { - alwaysOnTop = ((JDialog) topestUI).isAlwaysOnTop(); - } - - if (alwaysOnTop) { - ((JDialog) topestUI).setAlwaysOnTop(false); - } - try { - - JOptionPane.showMessageDialog( - topestUI, - message, - title, - JOptionPane.INFORMATION_MESSAGE, - UIManager.getIcon("info") - ); - } finally { - if (alwaysOnTop) { - ((JDialog) topestUI).setAlwaysOnTop(true); - } - } - } - - protected void addHighlighters(final JXTable table) { - - } - - public void autoSelectRowInTable(MouseEvent e, JPopupMenu popup) { - - boolean rightClick = SwingUtilities.isRightMouseButton(e); - - if (rightClick || SwingUtilities.isLeftMouseButton(e)) { - - // get the coordinates of the mouse click - Point p = e.getPoint(); - - JXTable source = (JXTable) e.getSource(); - - int[] selectedRows = source.getSelectedRows(); - int[] selectedColumns = source.getSelectedColumns(); - - // get the row index at this point - int rowIndex = source.rowAtPoint(p); - - // get the column index at this point - int columnIndex = source.columnAtPoint(p); - - if (log.isDebugEnabled()) { - log.debug("At point [" + p + "] found Row " + rowIndex + ", Column " + columnIndex); - } - - boolean canContinue = true; - - if (source.isEditing()) { - - // stop editing - boolean stopEdit = source.getCellEditor().stopCellEditing(); - if (!stopEdit) { - if (log.isWarnEnabled()) { - log.warn("Could not stop edit cell..."); - } - canContinue = false; - } - } - - if (canContinue) { - - // select row (could empty selection) - if (rowIndex == -1) { - source.clearSelection(); - } else if (!ArrayUtils.contains(selectedRows, rowIndex)) { - if (ListSelectionModel.MULTIPLE_INTERVAL_SELECTION == source.getSelectionMode()) { - // add to selection - source.addRowSelectionInterval(rowIndex, rowIndex); - } else { - // set selection - source.setRowSelectionInterval(rowIndex, rowIndex); - } - } - - // select column (could empty selection) - if (columnIndex == -1) { - source.clearSelection(); - } else if (!ArrayUtils.contains(selectedColumns, columnIndex)) { - source.setColumnSelectionInterval(columnIndex, columnIndex); - } - - if (rightClick) { - - // use now model coordinate - int modelRowIndex = rowIndex == -1 ? -1 : source.convertRowIndexToModel(rowIndex); - int modelColumnIndex = columnIndex == -1 ? -1 : source.convertColumnIndexToModel(columnIndex); - - beforeOpenPopup(modelRowIndex, modelColumnIndex); - - // on right click show popup - popup.show(source, e.getX(), e.getY()); - } - } - } - } - - public void openRowMenu(KeyEvent e, JPopupMenu popup) { - - if (e.getKeyCode() == KeyEvent.VK_CONTEXT_MENU) { - - JXTable source = (JXTable) e.getSource(); - - // get the lowest selected row - int[] selectedRows = source.getSelectedRows(); - int lowestRow = -1; - for (int row : selectedRows) { - lowestRow = Math.max(lowestRow, row); - } - // get the selected column - int selectedColumn = source.getSelectedColumn(); - Rectangle r = source.getCellRect(lowestRow, selectedColumn, true); - - // get the point in the middle lower of the cell - Point p = new Point(r.x + r.width / 2, r.y + r.height); - - if (log.isDebugEnabled()) { - log.debug("Row " + lowestRow + " found t point [" + p + "]"); - } - - boolean canContinue = true; - - if (source.isEditing()) { - - // stop editing - boolean stopEdit = source.getCellEditor().stopCellEditing(); - if (!stopEdit) { - if (log.isWarnEnabled()) { - log.warn("Could not stop edit cell..."); - } - canContinue = false; - } - } - - if (canContinue) { - - // use now model coordinate - int rowIndex = source.convertRowIndexToModel(lowestRow); - int columnIndex = source.convertColumnIndexToModel(selectedColumn); - beforeOpenPopup(rowIndex, columnIndex); - - popup.show(source, p.x, p.y); - } - } - } - - //------------------------------------------------------------------------// - //-- Init methods --// - //------------------------------------------------------------------------// - - protected void initUIComponent(Object component) { - if (component instanceof NumberEditor) { - - initNumberEditor((NumberEditor) component); - } else if (component instanceof JXDatePicker) { - - initDatePicker((JXDatePicker) component); - } else if (component instanceof SimpleTimeEditor) { - - initTimeEditor((SimpleTimeEditor) component); - } else if (component instanceof JLabel) { - - initLabel((JLabel) component); - } else if (component instanceof JTextField) { - - initTextField((JTextField) component); - } else if (component instanceof AbstractButton) { - - initButton((AbstractButton) component); - } else if (component instanceof JScrollPane) { - - initScrollPane((JScrollPane) component); - } else if (component instanceof DmsCoordinateEditor) { - - initCoordinateDMSEditor((DmsCoordinateEditor) component); - } else if (component instanceof DmdCoordinateEditor) { - - initCoordinateDMDEditor((DmdCoordinateEditor) component); - } else if (component instanceof SimpleBeanValidator) { - - simpleValidators.add((SimpleBeanValidator) component); - } else if (component instanceof BeanListValidator) { - - listValidators.add((BeanListValidator) component); - } - } - - protected void initUI(UI ui) { - - simpleValidators = Sets.newHashSet(); - listValidators = Sets.newHashSet(); - - for (Map.Entry<String, Object> entry : ui.get$objectMap().entrySet()) { - Object component = entry.getValue(); - initUIComponent(component); - } - - simpleValidators = Collections.unmodifiableSet(simpleValidators); - listValidators = Collections.unmodifiableSet(listValidators); - - initValidators(simpleValidators, listValidators); - - //FIXME This does not work if there is more than one ui - initComponentToFocus((Component) ui); - } - - protected void initComponentToFocus(Component ui) { - ui.addHierarchyListener(e -> { - JComponent component = getComponentToFocus(); - if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) > 0 - && e.getChanged().isShowing() - && component != null) { - component.requestFocus(); - } - }); - } - - protected abstract JComponent getComponentToFocus(); - - protected void initTextField(JTextField jTextField) { - - if (isAutoSelectOnFocus(jTextField)) { - addAutoSelectOnFocus(jTextField); - } - } - - protected void initLabel(JLabel jLabel) { - - // by default do nothing more - } - - protected void initButton(AbstractButton abstractButton) { - - Class actionName = (Class) abstractButton.getClientProperty("applicationAction"); - if (actionName != null) { - Action action = getContext().getActionFactory().createUIAction(this, abstractButton, actionName); - abstractButton.setAction(action); - } - - if (abstractButton.getAction() != null) { - // get the _applicationActionKey property - String key = (String) abstractButton.getClientProperty("applicationActionKey"); - if (key != null) { - affectKeyStroke(abstractButton, key); - } - } - } - - protected void affectKeyStroke(AbstractButton abstractButton, String key) { - - if (abstractButton.getAction() == null) { - log.warn("the buton '" + abstractButton.getName() + "' has no action. can't affect key stroke."); - return; - } - - KeyStroke keyStroke = KeyStroke.getKeyStroke(key); - - if (keyStroke == null) { - - if (log.isWarnEnabled()) { - log.warn("Could not transform keyStroke: " + key); - } - - } else { - - // affect this key stroke to the button's action - abstractButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(keyStroke, key); - abstractButton.getActionMap().put(key, abstractButton.getAction()); - - boolean modifyText = true; - boolean modifyTip = false; - ApplicationConfiguration configuration = context.getConfiguration(); - if (configuration instanceof ApplicationUIConfiguration) { - ApplicationUIConfiguration applicationUIConfiguration = (ApplicationUIConfiguration) configuration; - - modifyText = applicationUIConfiguration.isShowKeyStrokeOnText(); - modifyTip = applicationUIConfiguration.isShowKeyStrokeOnTip(); - - } - - // modify text - String text = abstractButton.getText(); - if (modifyText && !StringUtils.isBlank(text)) { - text += " (" + key.toUpperCase() + ")"; - abstractButton.setText(text); - } - - // modify tip - String tip = abstractButton.getToolTipText(); - if (modifyTip && !StringUtils.isBlank(tip)) { - tip += " (" + key.toUpperCase() + ")"; - abstractButton.setToolTipText(tip); - } - - } - - - } - - /** - * Prépare un component de choix d'entités pour un type d'entité donné et - * pour un service de persistance donné. - * - * @param comboBox le component graphique à initialiser - */ - protected <E> void initBeanFilterableComboBox( - BeanFilterableComboBox<E> comboBox, - List<E> data, - E selectedData) { - - initBeanFilterableComboBox(comboBox, data, selectedData, null); - } - - protected <E> void initBeanFilterableComboBox( - BeanFilterableComboBox<E> comboBox, - List<E> data, - E selectedData, - String decoratorContext) { - - Preconditions.checkNotNull(comboBox, "No comboBox!"); - - Class<E> beanType = comboBox.getBeanType(); - - Preconditions.checkNotNull(beanType, "No beanType on the combobox!"); - - Decorator<E> decorator = getDecorator(beanType, decoratorContext); - - if (data == null) { - data = Lists.newArrayList(); - } - - if (log.isDebugEnabled()) { - log.debug("entity comboBox list [" + beanType.getName() + "] : " + data.size()); - } - - comboBox.setI18nPrefix(getContext().getI18nPrefix()); - - // add data list to combo box - comboBox.init((JXPathDecorator<E>) decorator, data); - - comboBox.setSelectedItem(selectedData); - - if (log.isDebugEnabled()) { - log.debug("combo [" + beanType.getName() + "] : " + - comboBox.getData().size()); - } - } - - protected <E> void initBeanComboBox(BeanComboBox<E> comboBox, - List<E> data, - E selectedData) { - - initBeanComboBox(comboBox, data, selectedData, null); - } - - protected <E> void initBeanComboBox(BeanComboBox<E> comboBox, - List<E> data, - E selectedData, - String decoratorContext) { - - Preconditions.checkNotNull(comboBox, "No comboBox!"); - - Class<E> beanType = comboBox.getBeanType(); - - Preconditions.checkNotNull(beanType, "No beanType on the combobox!"); - - Decorator<E> decorator = getDecorator(beanType, decoratorContext); - - if (data == null) { - data = Lists.newArrayList(); - } - - if (log.isDebugEnabled()) { - log.debug("entity comboBox list [" + beanType.getName() + "] : " + data.size()); - } - - comboBox.setI18nPrefix(getContext().getI18nPrefix()); - - // add data list to combo box - comboBox.init((JXPathDecorator<E>) decorator, data); - - comboBox.setSelectedItem(selectedData); - - if (log.isDebugEnabled()) { - log.debug("combo [" + beanType.getName() + "] : " + - comboBox.getData().size()); - } - } - - /** - * Prépare un component de choix d'entités pour un type d'entité donné et - * pour un service de persistance donné. - * - * @param list le component graphique à initialiser - * @param data la liste des données à mettre dans la liste de gauche - * @param selectedData la liste des données à mettre dans la liste de droite - */ - protected <E> void initBeanList(BeanDoubleList<E> list, - List<E> data, - List<E> selectedData, - Decorator<E> selectedDecorator) { - - Preconditions.checkNotNull(list, "No list!"); - - Class<E> beanType = list.getBeanType(); - Preconditions.checkNotNull(beanType, "No beanType on the double list!"); - - Decorator<E> decorator = getDecorator(beanType, null); - - if (log.isDebugEnabled()) { - log.debug("entity list [" + beanType.getName() + "] : " + - (data == null ? 0 : data.size())); - } - - list.setI18nPrefix(getContext().getI18nPrefix()); - - // add data list to combo box - list.init((JXPathDecorator<E>) decorator, - (JXPathDecorator<E>) selectedDecorator, - data, - selectedData); - - if (log.isDebugEnabled()) { - log.debug("Jlist [" + beanType.getName() + "] : " + - list.getUniverseList().getModel().getSize()); - } - } - - /** - * Prépare un component de choix d'entités pour un type d'entité donné et - * pour un service de persistance donné. - * - * @param list le component graphique à initialiser - * @param data la liste des données à mettre dans la liste de gauche - * @param selectedData la liste des données à mettre dans la liste de droite - */ - protected <E> void initBeanList(BeanDoubleList<E> list, - List<E> data, - List<E> selectedData) { - - initBeanList(list, data, selectedData, null); - } - - protected void initNumberEditor(NumberEditor editor) { - if (log.isDebugEnabled()) { - log.debug("init number editor " + editor.getName()); - } - editor.init(); - - // Force binding if value is already in model - Number model = editor.getModel(); - if (model != null) { - editor.setModel(null); - editor.setModel(model); - } - - if (isAutoSelectOnFocus(editor)) { - - addAutoSelectOnFocus(editor.getTextField()); - } - } - - protected void initTimeEditor(SimpleTimeEditor editor) { - if (log.isDebugEnabled()) { - log.debug("init time editor " + editor.getName() + - " for property " + editor.getModel().getProperty()); - } - editor.init(); - - if (isAutoSelectOnFocus(editor)) { - addAutoSelectOnFocus(((JSpinner.DefaultEditor) editor.getHour().getEditor()).getTextField()); - addAutoSelectOnFocus(((JSpinner.DefaultEditor) editor.getMinute().getEditor()).getTextField()); - } - } - - protected void initCoordinateDMSEditor(DmsCoordinateEditor editor) { - Object property = editor.getClientProperty("longitudeEditor"); - boolean longitudeEditor = property != null && Boolean.valueOf(property.toString()); - editor.init(longitudeEditor); - } - - protected void initCoordinateDMDEditor(DmdCoordinateEditor editor) { - Object property = editor.getClientProperty("longitudeEditor"); - boolean longitudeEditor = property != null && Boolean.valueOf(property.toString()); - editor.init(longitudeEditor); - } - - protected void initDatePicker(final JXDatePicker picker) { - - if (log.isDebugEnabled()) { - log.debug("disable JXDatePicker editor" + picker.getName()); - } - String dateFormat = getContext().getDateFormat(); - picker.setFormats(dateFormat); - picker.setToolTipText(t("jaxx.application.common.datefield.tip", dateFormat)); - picker.getEditor().addFocusListener(new FocusAdapter() { - - @Override - public void focusLost(FocusEvent e) { - try { - picker.commitEdit(); - - } catch (ParseException ex) { - if (log.isDebugEnabled()) { - log.debug("format error", ex); - } - picker.requestFocus(); - } - } - }); - - if (isAutoSelectOnFocus(picker)) { - addAutoSelectOnFocus(picker.getEditor()); - } - } - - protected void initScrollPane(JScrollPane scrollPane) { - Boolean onlyVerticalScrollable = (Boolean) scrollPane.getClientProperty("onlyVerticalScrollable"); - if (onlyVerticalScrollable != null && onlyVerticalScrollable) { - scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); - - final JViewport viewport = scrollPane.getViewport(); - viewport.addChangeListener(e -> { - Dimension newDimension = new Dimension(viewport.getExtentSize().width, - viewport.getViewSize().height); - viewport.setViewSize(newDimension); - }); - } - } - - protected void initValidators(Set<SimpleBeanValidator> simpleValidators, Set<BeanListValidator> listValidators) { - - M model = getModel(); - if (useSimpleValidators() || useListValidators()) { - - Set<AbstractValidator> validators = Sets.newHashSet(); - validators.addAll(simpleValidators); - validators.addAll(listValidators); - - ValidatorsValidPropertyChangeListener listener = new ValidatorsValidPropertyChangeListener((AbstractApplicationFormUIModel) model, validators); - for (AbstractValidator validator : validators) { - - if (log.isInfoEnabled()) { - log.info("Listen valid state of validator: " + validator); - } - validator.addPropertyChangeListener(SimpleBeanValidator.VALID_PROPERTY, listener); - - } - - } - - } - - protected boolean useListValidators() { - return getModel() instanceof AbstractApplicationFormUIModel && !listValidators.isEmpty(); - } - - protected boolean useSimpleValidators() { - return getModel() instanceof AbstractApplicationFormUIModel && !simpleValidators.isEmpty(); - } - - protected boolean isAutoSelectOnFocus(JComponent comp) { - Object selectOnFocus = comp.getClientProperty("selectOnFocus"); - return selectOnFocus != null && Boolean.valueOf(selectOnFocus.toString()); - } - - protected void addAutoSelectOnFocus(JTextField jTextField) { - jTextField.addFocusListener(new FocusAdapter() { - @Override - public void focusGained(final FocusEvent e) { - SwingUtilities.invokeLater(() -> { - JTextField source = (JTextField) e.getSource(); - source.selectAll(); - }); - - } - }); - } - - /** - * @deprecated since 2.11, use now {@link #quitScreen(boolean, boolean, String, String, Action, boolean)} - */ - @Deprecated - protected boolean quitScreen(boolean modelIsValid, - boolean modelIsModify, - String askGiveUpMessage, - String askSaveMessage, - Action saveAction) { - - return quitScreen(modelIsValid, - modelIsModify, - askGiveUpMessage, - askSaveMessage, - saveAction, - false); - - } - - /** - * @deprecated since 2.11, use now {@link #quitScreen(boolean, boolean, String, String, Action, boolean)} - */ - @Deprecated - protected boolean quitInternalScreen(boolean modelIsValid, - boolean modelIsModify, - String askGiveUpMessage, - String askSaveMessage, - Action saveAction) { - - return quitScreen(modelIsValid, - modelIsModify, - askGiveUpMessage, - askSaveMessage, - saveAction, - true); - - } - - protected boolean quitScreen(boolean modelIsValid, - boolean modelIsModify, - String askGiveUpMessage, - String askSaveMessage, - Action saveAction, - boolean runInternal) { - boolean result; - - if (!modelIsValid) { - - // model is not valid - // ask user to qui or not - result = askCancelEditBeforeLeaving(askGiveUpMessage); - - } else if (modelIsModify) { - - // something is modify ask user what to do - int answer = askSaveBeforeLeaving(askSaveMessage); - switch (answer) { - case JOptionPane.YES_OPTION: - - // ok save - if (runInternal) { - - ApplicationUIAction uiAction = (ApplicationUIAction) saveAction; - getContext().getActionEngine().runFullInternalAction(uiAction.getLogicAction()); - - } else { - - saveAction.actionPerformed(null); - - } - result = true; - break; - case JOptionPane.NO_OPTION: - - // do not save but can still quit the screen (so nothing to do) - result = true; - break; - default: - // do not save and stay here (so nothing to do) - result = false; - - } - } else { - - // model is valid and not modify, can safely quit screen - result = true; - } - return result; - } - - //------------------------------------------------------------------------// - //-- Decorator API --// - //------------------------------------------------------------------------// - - protected String decorate(Serializable object) { - return decorate(object, null); - } - - protected String decorate(Serializable object, String context) { - String result = ""; - if (object != null) { - result = getDecorator(object.getClass(), context).toString(object); - } - return result; - } - - //------------------------------------------------------------------------// - //-- List API --// - //------------------------------------------------------------------------// - - protected <O> ListCellRenderer newListCellRender(Class<O> type) { - - return newListCellRender(type, null); - } - - protected <O> ListCellRenderer newListCellRender(Class<O> type, String name) { - - Decorator<O> decorator = getDecorator(type, name); - return newListCellRender(decorator); - } - - protected <O> ListCellRenderer newListCellRender(Decorator<O> decorator) { - - Preconditions.checkNotNull(decorator); - - return new DecoratorListCellRenderer(decorator); - } - - //FIXME Move this in JAXX - protected <B> void changeValidatorContext(String newContext, - SwingValidator<B> validator) { - B bean = validator.getBean(); - validator.setContext(newContext); - validator.setBean(bean); - } - - //------------------------------------------------------------------------// - //-- Table API --// - //------------------------------------------------------------------------// - - protected <R> TableColumnExt addColumnToModel(TableColumnModel model, - TableCellEditor editor, - TableCellRenderer renderer, - ColumnIdentifier<R> identifier) { - - TableColumnExt col = new TableColumnExt(model.getColumnCount()); - col.setCellEditor(editor); - col.setCellRenderer(renderer); - String label = t(identifier.getHeaderI18nKey()); - - col.setHeaderValue(label); - String tip = t(identifier.getHeaderTipI18nKey()); - - col.setToolTipText(tip); - - col.setIdentifier(identifier); - model.addColumn(col); - // by default no column is sortable, must specify it - col.setSortable(false); - return col; - } - - protected <R> TableColumnExt addColumnToModel(TableColumnModel model, - ColumnIdentifier<R> identifier) { - - return addColumnToModel(model, null, null, identifier); - } - - protected <R> TableColumnExt addFloatColumnToModel(TableColumnModel model, - ColumnIdentifier<R> identifier, - String numberPattern, - boolean sign, - JTable table) { - - NumberCellEditor<Float> editor = new NumberCellEditor<>(Float.class, sign); - editor.getNumberEditor().setSelectAllTextOnError(true); - editor.getNumberEditor().getTextField().setBorder(new LineBorder(Color.GRAY, 2)); - editor.getNumberEditor().setNumberPattern(numberPattern); - - TableCellRenderer renderer = - newNumberCellRenderer(table.getDefaultRenderer(Number.class)); - - return addColumnToModel(model, editor, renderer, identifier); - } - - protected <R> TableColumnExt addFloatColumnToModel(TableColumnModel model, - ColumnIdentifier<R> identifier, - String numberPattern, - JTable table) { - - return addFloatColumnToModel(model, identifier, numberPattern, false, table); - } - - protected <R> TableColumnExt addIntegerColumnToModel(TableColumnModel model, - ColumnIdentifier<R> identifier, - String numberPattern, - boolean sign, - JTable table) { - - NumberCellEditor<Integer> editor = new NumberCellEditor<>(Integer.class, sign); - editor.getNumberEditor().setSelectAllTextOnError(true); - editor.getNumberEditor().getTextField().setBorder(new LineBorder(Color.GRAY, 2)); - editor.getNumberEditor().setNumberPattern(numberPattern); - - TableCellRenderer renderer = newNumberCellRenderer(table.getDefaultRenderer(Number.class)); - return addColumnToModel(model, editor, renderer, identifier); - } - - protected <R> TableColumnExt addIntegerColumnToModel(TableColumnModel model, - ColumnIdentifier<R> identifier, - String numberPattern, - JTable table) { - - return addIntegerColumnToModel(model, identifier, numberPattern, false, table); - } - - protected TableCellRenderer newNumberCellRenderer(final TableCellRenderer defaultRenderer) { - return (table, value, isSelected, hasFocus, row, column) -> { - Component result1 = defaultRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - if (result1 instanceof JLabel) { - JLabel jLabel = (JLabel) result1; - jLabel.setHorizontalTextPosition(SwingConstants.RIGHT); - - } - return result1; - }; - } - - - protected <R> TableColumnExt addBooleanColumnToModel(TableColumnModel model, - ColumnIdentifier<R> identifier, - JTable table) { - - return addColumnToModel(model, - table.getDefaultEditor(Boolean.class), - table.getDefaultRenderer(Boolean.class), - identifier); - } - - protected <R, B> TableColumnExt addComboDataColumnToModel(TableColumnModel model, - ColumnIdentifier<R> identifier, - Decorator<B> decorator, - List<B> data) { - JComboBox comboBox = new JComboBox(); - comboBox.setRenderer(newListCellRender(decorator)); - - List<B> dataToList = Lists.newArrayList(data); - - // add a null value at first position - if (!dataToList.isEmpty() && dataToList.get(0) != null) { - dataToList.add(0, null); - } - SwingUtil.fillComboBox(comboBox, dataToList, null); - - ObjectToStringConverter converter = BeanUIUtil.newDecoratedObjectToStringConverter(decorator); - BeanUIUtil.decorate(comboBox, converter); - ComboBoxCellEditor editor = new ComboBoxCellEditor(comboBox); - - return addColumnToModel(model, - editor, - newTableCellRender(decorator), - identifier); - } - - protected <O> TableCellRenderer newTableCellRender(Class<O> type) { - - return newTableCellRender(type, null); - } - - protected <O> TableCellRenderer newTableCellRender(Class<O> type, String name) { - - Decorator<O> decorator = getDecorator(type, name); - - return newTableCellRender(decorator); - } - - protected <O> TableCellRenderer newTableCellRender(Decorator<O> decorator) { - - Preconditions.checkNotNull(decorator); - - return new DecoratorTableCellRenderer(decorator, true); - } - - protected void incrementsMessage(String message) { - - ApplicationActionUI actionUI = getContext().getActionUI(); - if (actionUI != null) { - ApplicationProgressionModel progressionModel = actionUI.getModel().getProgressionModel(); - if (progressionModel != null) - - progressionModel.increments(message); - } - } - - /** - * - */ - private static class ValidatorsValidPropertyChangeListener implements PropertyChangeListener { - - private final AbstractApplicationFormUIModel model; - - private final Set<AbstractValidator> validators; - - public ValidatorsValidPropertyChangeListener(AbstractApplicationFormUIModel model, - Set<AbstractValidator> validators) { - this.model = model; - this.validators = validators; - } - - @Override - public void propertyChange(PropertyChangeEvent evt) { - - boolean valid = true; - for (AbstractValidator validator : validators) { - if (!validator.isValid()) { - valid = false; - break; - } - } - - model.setValid(valid); - - } - } - - protected static class RunFullInternalActionListener implements PropertyChangeListener { - - private final ApplicationUIContext context; - - private final AbstractApplicationAction uiAction; - - public RunFullInternalActionListener(ApplicationUIContext context, AbstractApplicationUIHandler handler, Class actionName) { - this.context = context; - this.uiAction = context.getActionFactory().createLogicAction(handler, actionName); - } - - protected boolean doPropertyChange(PropertyChangeEvent evt) { - return true; - } - - @Override - public void propertyChange(PropertyChangeEvent evt) { - - boolean doPropertyChange = doPropertyChange(evt); - - if (doPropertyChange) { - if (log.isInfoEnabled()) { - log.info("Execute action start: " + uiAction); - } - - context.getActionEngine().runFullInternalAction(uiAction); - - if (log.isInfoEnabled()) { - log.info("Execute action end: " + uiAction); - } - } - - } - } -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/ApplicationUI.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/ApplicationUI.java deleted file mode 100644 index c82f1b6..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/ApplicationUI.java +++ /dev/null @@ -1,143 +0,0 @@ -package org.nuiton.jaxx.application.swing; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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.nuiton.jaxx.runtime.JAXXObject; - -/** - * Contract to place on each ui. - * - * Created on 11/23/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public interface ApplicationUI<M, H extends AbstractApplicationUIHandler<M, ?>> extends JAXXObject { - - M getModel(); - - H getHandler(); - - /** - * Pattern to use for short numeric values in editors with max 1 digits. - * - * @since 0.2 - */ - String INT_1_DIGITS_PATTERN = "\\d{0,1}"; - - /** - * Pattern to use for short numeric values in editors with max 2 digits. - * - * @since 0.1 - */ - String INT_2_DIGITS_PATTERN = "\\d{0,2}"; - - /** - * Pattern to use for signed numeric values in editors with max 2 digits. - * - * @since 2.8 - */ - String SIGNED_INT_2_DIGITS_PATTERN = "-?\\d{0,2}"; - - /** - * Pattern to use for short numeric values in editors with max 3 digits. - * - * @since 0.1 - */ - String INT_3_DIGITS_PATTERN = "\\d{0,3}"; - - /** - * Pattern to use for singed numeric values in editors with max 3 digits. - * - * @since 2.8 - */ - String SIGNED_INT_3_DIGITS_PATTERN = "-?\\d{0,3}"; - - /** - * Pattern to use for short numeric values in editors with max 4 digits. - * - * @since 0.2 - */ - String INT_4_DIGITS_PATTERN = "\\d{0,4}"; - - /** - * Pattern to use for integer numeric values in editors with max 6 digits. - * - * @since 0.1 - */ - String INT_6_DIGITS_PATTERN = "\\d{0,6}"; - - /** - * Pattern to use for integer numeric values in editors with max 7 digits. - * - * @since 0.1 - */ - String INT_7_DIGITS_PATTERN = "\\d{0,7}"; - - /** - * Pattern to use for integer numeric values in editors with max 10 digits. - * - * @since 2.10 - */ - String INT_10_DIGITS_PATTERN = "\\d{0,10}"; - - /** - * Pattern to use for decimal numeric values with 1 decimal digits in - * editors. - * - * @since 0.1 - */ - String DECIMAL1_PATTERN = "\\d{0,6}(\\.\\d{0,1})?"; - - /** - * Pattern to use for decimal numeric values with 2 decimal digits in - * editors. - * - * @since 0.1 - */ - String DECIMAL2_PATTERN = "\\d{0,6}(\\.\\d{0,2})?"; - - /** - * Pattern to use for decimal numeric values with 3 decimal digits in - * editors. - * - * @since 0.1 - */ - String DECIMAL3_PATTERN = "\\d{0,6}(\\.\\d{0,3})?"; - - /** - * Pattern to use for decimal numeric values with 4 decimal digits in - * editors. - * - * @since 2.6 - */ - String DECIMAL4_PATTERN = "\\d{0,6}(\\.\\d{0,4})?"; - - /** - * Pattern to use for decimal numeric values with 2 digits + 3 decimal digits in - * editors. - * - * @since 2.8 - */ - String DECIMAL2_DIGITS_PATTERN = "\\d{0,2}(\\.\\d*)?"; -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/ApplicationUIConfiguration.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/ApplicationUIConfiguration.java deleted file mode 100644 index 9061842..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/ApplicationUIConfiguration.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.nuiton.jaxx.application.swing; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 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 javax.swing.KeyStroke; - -/** - * Contract to place on ui configuration. - * - * Created on 9/19/14. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.13 - */ -public interface ApplicationUIConfiguration { - - KeyStroke getShortcutClosePopup(); - - boolean isShowKeyStrokeOnText(); - - boolean isShowKeyStrokeOnTip(); - -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/ApplicationUIContext.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/ApplicationUIContext.java deleted file mode 100644 index 4828278..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/ApplicationUIContext.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.nuiton.jaxx.application.swing; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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.nuiton.jaxx.application.ApplicationContext; -import org.nuiton.jaxx.application.swing.action.ApplicationActionEngine; -import org.nuiton.jaxx.application.swing.action.ApplicationActionFactory; -import org.nuiton.jaxx.application.swing.action.ApplicationActionUI; -import org.nuiton.jaxx.application.swing.action.ApplicationUIAction; -import org.nuiton.jaxx.application.swing.util.ApplicationErrorHelper; - -import java.awt.Color; -import java.awt.Component; - -/** - * Created on 11/24/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public interface ApplicationUIContext extends ApplicationContext { - - /** - * @return the main ui of the application. - */ - Component getMainUI(); - - /** - * @return the ui used to display long action. - */ - ApplicationActionUI getActionUI(); - - /** - * Wait until the action ui is not null and then returns it. - * - * @return the ui used to display long action. - */ - ApplicationActionUI getExistingActionUI(); - - Component getBodyUI(); - - Component getStatusUI(); - - boolean isBusy(); - - void setBusy(boolean busy); - - boolean isHideBody(); - - void setHideBody(boolean b); - - Color getColorBlockingLayer(); - - ApplicationActionFactory getActionFactory(); - - ApplicationActionEngine getActionEngine(); - - ApplicationErrorHelper getErrorHelper(); - - String getI18nPrefix(); - - String getDateFormat(); - - /** Is the action already running? If yes, it will not run again (cf https://forge.nuiton.org/issues/3499) */ - boolean isActionInProgress(ApplicationUIAction action); - - void setActionInProgress(ApplicationUIAction action, boolean actionInProgress); -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/AbstractApplicationAction.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/AbstractApplicationAction.java deleted file mode 100644 index 1da7ab4..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/AbstractApplicationAction.java +++ /dev/null @@ -1,438 +0,0 @@ -package org.nuiton.jaxx.application.swing.action; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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 org.apache.commons.lang3.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jdesktop.beans.AbstractBean; -import org.nuiton.decorator.Decorator; -import org.nuiton.jaxx.application.ApplicationConfiguration; -import org.nuiton.jaxx.application.swing.AbstractApplicationUIHandler; -import org.nuiton.jaxx.application.swing.ApplicationUI; -import org.nuiton.jaxx.application.swing.ApplicationUIContext; -import org.nuiton.jaxx.application.type.ApplicationProgressionModel; -import org.nuiton.jaxx.runtime.JaxxFileChooser; - -import javax.swing.JOptionPane; -import java.awt.Component; -import java.io.File; -import java.util.Arrays; - -import static org.nuiton.i18n.I18n.t; - -/** - * Tutti base action. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public abstract class AbstractApplicationAction<M extends AbstractBean, UI extends ApplicationUI<M, ?>, H extends AbstractApplicationUIHandler<M, UI>> - extends AbstractBean { - - /** Logger. */ - private static final Log log = LogFactory.getLog(AbstractApplicationAction.class); - - public static final String PROPERTY_DONE = "done"; - - public static final String MESAGE_FORMAT = "<html>%s</html>"; - - protected final H handler; - - protected String actionDescription; - - protected final boolean hideBody; - - protected final Object lock = new Object(); - - public abstract void doAction(); - - protected AbstractApplicationAction(H handler, boolean hideBody) { - this.handler = handler; - this.hideBody = hideBody; - } - - public boolean prepareAction() { - // by default nothing to prepare - return true; - } - - protected void releaseAction() { - // by default nothing to clean - firePropertyChange(PROPERTY_DONE, null, true); - } - - public void postSuccessAction() { - // by default nothing to do after action - } - - public void postFailedAction(Throwable error) { - // by default nothing to do after action - } - - public H getHandler() { - return handler; - } - - public M getModel() { - return handler.getModel(); - } - - public final UI getUI() { - return handler.getUI(); - } - - public ApplicationUIContext getContext() { - return handler.getContext(); - } - - public String getActionDescription() { - return actionDescription; - } - - public void setActionDescription(String actionDescription) { - this.actionDescription = actionDescription; - } - - public void setProgressionModel(ApplicationProgressionModel progressionModel) { - getContext().getActionUI().getModel().setProgressionModel(progressionModel); - } - - protected ApplicationProgressionModel getProgressionModel() { - return getContext().getActionUI().getModel().getProgressionModel(); - } - - public boolean isHideBody() { - return hideBody; - } - - protected ApplicationConfiguration getConfig() { - return getContext().getConfiguration(); - } - - protected abstract void sendMessage(String message); - - protected <O> Decorator<O> getDecorator(Class<O> type, String name) { - Decorator<O> decorator = handler.getDecorator(type, name); - Preconditions.checkNotNull(decorator); - return decorator; - } - - protected String decorate(Object object) { - return getDecorator(object.getClass(), null).toString(object); - } - - protected String decorate(Object object, String context) { - return getDecorator(object.getClass(), context).toString(object); - } - - /** - * Choisir un fichier via un sélecteur graphique de fichiers. - * - * @param title le titre du dialogue de sélection - * @param buttonLabel le label du boutton d'acceptation - * @param filters les filtres + descriptions sur le sélecteur de - * fichiers - * @return le fichier choisi ou le fichier incoming si l'opération a été - * annulée - */ - protected File chooseFile(String title, - String buttonLabel, - String... filters) { - - File file = JaxxFileChooser.forLoadingFile() - .setTitle(title) - .setParent((Component) getUI()) - .setApprovalText(buttonLabel) - .setPatternOrDescriptionFilters(Arrays.asList(filters)) - .choose(); - -// File file = FileChooserUtil.getFile(title, -// buttonLabel, -// getContext().getMainUI(), -// filters); - if (log.isDebugEnabled()) { - log.debug(title + " : " + file); - } - if (file != null) { - File newDir = file.isDirectory() ? file : file.getParentFile(); - JaxxFileChooser.setCurrentDirectory(newDir); - } - return file; - } - - /** - * Sauver un fichier via un sélecteur graphique de fichiers. - * - * @param title le titre du dialogue de sélection - * @param buttonLabel le label du boutton d'acceptation - * @param filters les filtres + descriptions sur le sélecteur de - * fichiers - * @return le fichier choisi ou {@code null} si pas de fichier choisi ou - * pas voulu écrasé un fichier existant. - */ - protected File saveFile(File defaultFile, - String filename, - String extension, - String title, - String buttonLabel, - String... filters) { - - if (defaultFile != null && JaxxFileChooser.isCurrentDirectoryDefault()) { - - // set default directory to this one - JaxxFileChooser.setCurrentDirectory(defaultFile); - } - return saveFile(filename, extension, title, buttonLabel, filters); - } - - /** - * Sauver un fichier via un sélecteur graphique de fichiers. - * - * @param title le titre du dialogue de sélection - * @param buttonLabel le label du boutton d'acceptation - * @param filters les filtres + descriptions sur le sélecteur de - * fichiers - * @return le fichier choisi ou {@code null} si pas de fichier choisi ou - * pas voulu écrasé un fichier existant. - */ - protected File saveFile(String filename, - String extension, - String title, - String buttonLabel, - String... filters) { - - boolean withExtension = StringUtils.isNotBlank(extension); - String filenameSuffix = withExtension ? "." + extension : ""; - - File file = JaxxFileChooser.forSaving() - .setTitle(title) - .setParent((Component) getUI()) - .setApprovalText(buttonLabel) - .setPatternOrDescriptionFilters(Arrays.asList(filters)) - .setFilename(filename + filenameSuffix) - .choose(); - - //File file = FileChooserUtil.saveFile(filename + filenameSuffix, title, buttonLabel, getContext().getMainUI(), filters); - if (log.isDebugEnabled()) { - log.debug(title + " : " + file); - } - if (file != null) { - Preconditions.checkState(!file.isDirectory()); - - // add extension if missing - if (withExtension && !file.getName().endsWith(filenameSuffix)) { - file = new File(file.getParentFile(), file.getName() + filenameSuffix); - } - - // ask user to confirm overwrite. - boolean confirm = askOverwriteFile(file); - - if (confirm) { - - // on conserve le répertoire (pour une prochaine utilisation) - JaxxFileChooser.setCurrentDirectory(file.getParentFile()); - } else { - - // l'utilisateur n'a pas confirmé l'écrasement - // donc pas de fichier en retour - file = null; - } - } - - return file; - } - - /** - * Sauver un fichier via un sélecteur graphique de fichiers, en précisant - * le répertoire où sauvegarder le fichier. - * - * @param startDirectory le répertoire à utiliser pour choisir le fichier - * @param keepCurrentDirectory un drapeau pour dire si on veut ou pas conserver le répertoire choisit comme nouveau répertoire par défaut - * @param title le titre du dialogue de sélection - * @param buttonLabel le label du boutton d'acceptation - * @param filters les filtres + descriptions sur le sélecteur de - * fichiers - * @return le fichier choisi ou {@code null} si pas de fichier choisi ou - * pas voulu écrasé un fichier existant. - * @since 2.17 - */ - protected File saveFileWithStartDirectory(File startDirectory, - boolean keepCurrentDirectory, - String filename, - String extension, - String title, - String buttonLabel, - String... filters) { - - boolean withExtension = StringUtils.isNotBlank(extension); - String filenameSuffix = withExtension ? "." + extension : ""; - - File file = JaxxFileChooser.forSaving() - .setStartDirectory(startDirectory) - .setKeepCurrentDirectory(keepCurrentDirectory) - .setTitle(title) - .setParent((Component) getUI()) - .setApprovalText(buttonLabel) - .setPatternOrDescriptionFilters(Arrays.asList(filters)) - .setFilename(filename + filenameSuffix) - .choose(); - - //File file = FileChooserUtil.saveFile(filename + filenameSuffix, title, buttonLabel, getContext().getMainUI(), filters); - if (log.isDebugEnabled()) { - log.debug(title + " : " + file); - } - if (file != null) { - Preconditions.checkState(!file.isDirectory()); - - // add extension if missing - if (withExtension && !file.getName().endsWith(filenameSuffix)) { - file = new File(file.getParentFile(), file.getName() + filenameSuffix); - } - - // ask user to confirm overwrite. - boolean confirm = askOverwriteFile(file); - - if (confirm) { - - if (keepCurrentDirectory) { - - // on conserve le répertoire (pour une prochaine utilisation) - JaxxFileChooser.setCurrentDirectory(file.getParentFile()); - - } - - } else { - - // l'utilisateur n'a pas confirmé l'écrasement - // donc pas de fichier en retour - file = null; - } - } - - return file; - } - - protected boolean askOverwriteFile(File file) { - boolean result; - if (file.exists()) { - - // file exists ask user to overwrite - String htmlMessage = String.format( - AbstractApplicationUIHandler.CONFIRMATION_FORMAT, - t("jaxx.application.common.askOverwriteFile.message", file), - t("jaxx.application.common.askOverwriteFile.help")); - - Component ui = getDialogParentComponent(); - - result = JOptionPane.showConfirmDialog( - ui, - htmlMessage, - t("jaxx.application.common.askOverwriteFile.title"), - JOptionPane.OK_CANCEL_OPTION, - JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION; - } else { - - // file does not exist - result = true; - } - return result; - } - - protected boolean askBeforeDelete(String title, String message) { - String htmlMessage = String.format( - AbstractApplicationUIHandler.CONFIRMATION_FORMAT, - message, - t("jaxx.application.common.askBeforeDelete.help")); - Component ui = getDialogParentComponent(); - int i = JOptionPane.showConfirmDialog( - ui, - htmlMessage, - title, - JOptionPane.OK_CANCEL_OPTION, - JOptionPane.QUESTION_MESSAGE); - - return i == JOptionPane.OK_OPTION; - } - - protected void displayInfoMessage(String title, String message) { - String htmlMessage = String.format(MESAGE_FORMAT, message); - Component ui = getDialogParentComponent(); - JOptionPane.showMessageDialog( - ui, - htmlMessage, - title, - JOptionPane.INFORMATION_MESSAGE); - } - - protected void displayWarningMessage(String title, String message) { - String htmlMessage = String.format(MESAGE_FORMAT, message); - - Component ui = getDialogParentComponent(); - JOptionPane.showMessageDialog( - ui, - htmlMessage, - title, - JOptionPane.WARNING_MESSAGE); - } - - protected void displayErrorMessage(String title, String message) { - String htmlMessage = String.format(MESAGE_FORMAT, message); - Component ui = getDialogParentComponent(); - JOptionPane.showMessageDialog( - ui, - htmlMessage, - title, - JOptionPane.ERROR_MESSAGE); - } - - protected Component getDialogParentComponent() { - Component ui = getContext().getMainUI(); - if (ui==null) { - ui = getHandler().getTopestUI(); - } - return ui; - } - - protected void createProgressionModelIfRequired(int total) { - ApplicationProgressionModel progressionModel = getProgressionModel(); - if (progressionModel == null) { - progressionModel = new ApplicationProgressionModel(); - progressionModel.setTotal(total); - progressionModel.setMessage(""); - progressionModel.setCurrent(0); - setProgressionModel(progressionModel); - } else { - progressionModel.adaptTotal(total); - } - } - - public ApplicationActionFactory getActionFactory() { - return getContext().getActionFactory(); - } - - public ApplicationActionEngine getActionEngine() { - return getContext().getActionEngine(); - } -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionEngine.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionEngine.java deleted file mode 100644 index 4ee4e82..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionEngine.java +++ /dev/null @@ -1,126 +0,0 @@ -package org.nuiton.jaxx.application.swing.action; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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.nuiton.jaxx.application.swing.AbstractApplicationUIHandler; - -import javax.swing.AbstractButton; - -/** - * To create and consume {@link AbstractApplicationAction}. - * Created on 11/24/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public class ApplicationActionEngine { - - /** Logger. */ - private static final Log log = - LogFactory.getLog(ApplicationActionEngine.class); - - private final ApplicationActionFactory actionFactory; - - public ApplicationActionEngine(ApplicationActionFactory actionFactory) { - this.actionFactory = actionFactory; - } - - public <A extends AbstractApplicationAction> void runInternalAction(A action) { - Throwable error = null; - - try { - action.doAction(); - action.postSuccessAction(); - } catch (Throwable e) { - error = e; - if (log.isErrorEnabled()) { - log.error("Error in action:", e); - } - throw ApplicationActionException.propagateError(action, e); - } finally { - try { - if (error != null) { - action.postFailedAction(error); - } - } finally { - - action.releaseAction(); - } - } - } - - public <A extends AbstractApplicationAction> void runFullInternalAction(A action) { - Throwable error = null; - - try { - boolean doAction = action.prepareAction(); - if (doAction) { - action.doAction(); - action.postSuccessAction(); - } - } catch (Throwable e) { - error = e; - if (log.isErrorEnabled()) { - log.error("Error in action:", e); - } - throw ApplicationActionException.propagateError(action, e); - } finally { - try { - if (error != null) { - action.postFailedAction(error); - } - } finally { - - action.releaseAction(); - } - } - } - - public <A extends AbstractApplicationAction> void runInternalAction(AbstractApplicationUIHandler handler, - Class<A> actionName) { - A action = actionFactory.createLogicAction(handler, actionName); - runInternalAction(action); - } - - public <A extends AbstractApplicationAction> void runAction(A action) { - ApplicationUIAction<A> uiAction = actionFactory.createUIAction(null, action); - uiAction.actionPerformed(null); - } - - public void runAction(AbstractButton button) { - button.getAction().actionPerformed(null); - } - - public <A extends AbstractApplicationAction> void runActionAndWait(A action) { - ApplicationUIAction<A> uiAction = actionFactory.createUIAction(null, action); - uiAction.launchActionAndWait(); - } - - public <A extends AbstractApplicationAction> void runActionAndWait(AbstractApplicationUIHandler handler, - Class<A> actionName) { - A logicAction = actionFactory.createLogicAction(handler, actionName); - runActionAndWait(logicAction); - } -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionException.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionException.java deleted file mode 100644 index 2cc33a3..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionException.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.nuiton.jaxx.application.swing.action; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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% - */ - -/** - * To box any error of a {@link AbstractApplicationAction}. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public class ApplicationActionException extends RuntimeException { - - private static final long serialVersionUID = 1L; - - private final AbstractApplicationAction action; - - public ApplicationActionException(AbstractApplicationAction action, Throwable cause) { - super(cause); - this.action = action; - } - - public static ApplicationActionException propagateError(AbstractApplicationAction action, - Throwable cause) { - ApplicationActionException result; - if (cause instanceof ApplicationActionException) { - result = ((ApplicationActionException) cause); - } else { - result = new ApplicationActionException(action, cause); - } - return result; - } - - public AbstractApplicationAction getAction() { - return action; - } -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionFactory.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionFactory.java deleted file mode 100644 index 7a53221..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionFactory.java +++ /dev/null @@ -1,94 +0,0 @@ -package org.nuiton.jaxx.application.swing.action; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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 org.apache.commons.lang3.reflect.ConstructorUtils; -import org.nuiton.jaxx.application.ApplicationTechnicalException; -import org.nuiton.jaxx.application.swing.AbstractApplicationUIHandler; - -import javax.swing.AbstractButton; -import javax.swing.Action; - -import static org.nuiton.i18n.I18n.t; - -/** - * Factory of actions. - * - * Created on 11/24/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public class ApplicationActionFactory { - - public <A extends AbstractApplicationAction> ApplicationUIAction<A> createUIAction(AbstractApplicationUIHandler handler, - Class<A> actionName) { - return createUIAction(handler, null, actionName); - } - - - public <A extends AbstractApplicationAction> ApplicationUIAction<A> createUIAction(AbstractApplicationUIHandler handler, - AbstractButton abstractButton, - Class<A> actionName) { - try { - - // create logic action - A logicAction = createLogicAction(handler, actionName); - - // create ui action - return createUIAction(abstractButton, logicAction); - } catch (Exception e) { - throw new ApplicationTechnicalException(t("jaxx.application.action.create.error", actionName), e); - } - - } - - public <A extends AbstractApplicationAction> ApplicationUIAction<A> createUIAction(AbstractButton abstractButton, - A logicAction) { - - // create ui action - return new ApplicationUIAction<>(abstractButton, - logicAction); - - - } - - public <A extends AbstractApplicationAction> A createLogicAction(AbstractApplicationUIHandler handler, - Class<A> actionName) { - try { - - // create action - return ConstructorUtils.invokeConstructor(actionName, handler); - } catch (Exception e) { - throw new ApplicationTechnicalException(t("jaxx.application.action.create.error", actionName), e); - } - } - - public <A extends AbstractApplicationAction> A getLogicAction(AbstractButton b) { - Action action = b.getAction(); - Preconditions.checkNotNull(action); - Preconditions.checkState(action instanceof ApplicationUIAction); - return ((ApplicationUIAction<A>) action).getLogicAction(); - } -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionSwingWorker.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionSwingWorker.java deleted file mode 100644 index 2f556b2..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionSwingWorker.java +++ /dev/null @@ -1,201 +0,0 @@ -package org.nuiton.jaxx.application.swing.action; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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 javax.swing.SwingUtilities; -import javax.swing.SwingWorker; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.Timer; -import java.util.TimerTask; - -/** - * Worker to execute logic action. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public class ApplicationActionSwingWorker<A extends AbstractApplicationAction> extends SwingWorker<Void, String> { - - /** Logger. */ - private static final Log log = - LogFactory.getLog(ApplicationActionSwingWorker.class); - - /** - * Timer used to launch timerTask (to open load dialog). - * - * @since 2.8.2 - */ - private static final Timer t = new Timer(); - - protected final ApplicationActionUI actionUI; - - protected final A action; - - protected Throwable error; - - protected TimerTask timer; - - protected ApplicationActionSwingWorker(A action) { - - this.action = action; - this.actionUI = action.getContext().getActionUI(); - } - - public Throwable getError() { - return error; - } - - public boolean isFailed() { - return error != null; - } - - @Override - protected Void doInBackground() throws Exception { - - if (!isCancelled()) { - - timer = new TuttiActionTimerTask(); - - t.schedule(timer, 1000); - - try { - - action.doAction(); - - } catch (Throwable e) { - if (log.isErrorEnabled()) { - log.error("Task [" + this + "] Error while doAction: ", e); - } - error = e; - } finally { - if (log.isDebugEnabled()) { - log.debug("Task [" + this + "] done"); - } - } - } - return null; - } - - @Override - protected void done() { - super.done(); - - if (log.isDebugEnabled()) { - log.debug("Task [" + this + "] execute done method after all"); - } - - if (error == null) { - - // success hook - action.postSuccessAction(); - } else { - - // fail hook - action.postFailedAction(error); - } - - action.releaseAction(); - - if (timer != null) { - - timer.cancel(); - } - - actionUI.close(); - - updateBusyState(false); - } - - protected void updateBusyState(boolean busy) { - - boolean hideBody = action.isHideBody(); - - action.getContext().setBusy(busy); - - if (hideBody) { - action.getContext().setHideBody(!busy); - } - - } - - protected class TuttiActionTimerTask extends TimerTask { - - public TuttiActionTimerTask() { - action.addPropertyChangeListener(AbstractApplicationAction.PROPERTY_DONE, new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - - // prevent memory leak, TuttiActionTimerTask is created each time see https://forge.nuiton.org/issues/3990 - action.removePropertyChangeListener(AbstractApplicationAction.PROPERTY_DONE, this); - - // we do NOT want the timer to wake up then the actionUI dialog - cancel(); - - //if (actionUI.isVisible()) { -//} - SwingUtilities.invokeLater(actionUI::close); - } - }); - } - - @Override - public void run() { - if (isCancelled() || isDone()) { - - if (log.isDebugEnabled()) { - log.debug("Task [" + action + "] was already canceled or done, do nothing"); - } - } else { - - if (log.isDebugEnabled()) { - log.debug("Task [" + action + "] is started, show waiting dialog"); - } - - SwingUtilities.invokeLater(() -> { - - synchronized (actionUI) { - - try { - actionUI.open(action); - } catch (Exception e) { - - // swallow any exception due to ui bad initialisation - // this should not happen, but it does :( - // See https://forge.codelutin.com/issues/7489 - // See http://stackoverflow.com/questions/15545055/nimbus-java-lang-classcastexcept... - // See http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6785663 - if (log.isErrorEnabled()) { - log.error("Something was wrong while opening the action ui, but we do not care", e); - } - } - } - }); - } - } - } -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionUI.jaxx b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionUI.jaxx deleted file mode 100644 index cf7eee1..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionUI.jaxx +++ /dev/null @@ -1,72 +0,0 @@ -<!-- - #%L - JAXX :: Application Swing - %% - Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - %% - 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% - --> -<JDialog width='300' height='200' modal='true' - undecorated='true' - implements='org.nuiton.jaxx.application.swing.ApplicationUI<ApplicationActionUIModel, ApplicationActionUIHandler>'> - <import> - - org.nuiton.jaxx.application.swing.ApplicationUI - org.nuiton.jaxx.application.swing.ApplicationUIContext - org.nuiton.jaxx.application.swing.util.ApplicationUIUtil - - org.nuiton.jaxx.runtime.swing.BlockingLayerUI - - javax.swing.border.EmptyBorder - </import> - - <script><![CDATA[ - - public ApplicationActionUI(JFrame frame, ApplicationUIContext context) { - super(frame, true); - ApplicationUIUtil.setApplicationContext(this, context); - } - - public void open(AbstractApplicationAction action) { - getModel().setAction(action); - } - - public void close() { - getModel().clear(); - } - ]]></script> - - - <BlockingLayerUI id='busyBlockLayerUI'/> - - <ApplicationActionUIModel id='model' - initializer='getContextValue(ApplicationActionUIModel.class)'/> - - <JPanel id='rootPanel' layout='{new BorderLayout()}' - constraints='BorderLayout.CENTER' decorator='boxed'> - <JPanel id='globalPanel' constraints='BorderLayout.NORTH' - layout='{new BorderLayout()}'> - <JLabel id='globalActionLabel' constraints='BorderLayout.CENTER'/> - <JProgressBar id='globalProgressBar' constraints='BorderLayout.SOUTH'/> - </JPanel> - <JPanel id='taskPanel' constraints='BorderLayout.CENTER' - layout='{new BorderLayout()}'> - <JLabel id='taskActionLabel' constraints='BorderLayout.CENTER'/> - <JProgressBar id='taskProgressBar' constraints='BorderLayout.SOUTH'/> - </JPanel> - </JPanel> - -</JDialog> diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionUI.jcss b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionUI.jcss deleted file mode 100644 index 9601cda..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionUI.jcss +++ /dev/null @@ -1,66 +0,0 @@ -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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% - */ - -#busyBlockLayerUI { - useIcon:false; - blockingColor: {handler.getContext().getColorBlockingLayer()}; - block:{true}; -} - -#globalPanel { - border: {new TitledBorder((String) null)}; -} - -#globalActionLabel { - border: {new EmptyBorder(5, 5, 5, 5)}; -} - -#globalProgressBar { - indeterminate: true; -} - -#taskPanel { - visible: false; - border: {new TitledBorder((String) null)}; -} - -#taskProgressBar { - indeterminate: false; -} - -#taskActionLabel { - border: {new EmptyBorder(5, 5, 5, 5)}; -} - -#informationPanel { - visible: false; - border: {new TitledBorder((String) null)}; -} - -#informationLabel { - border: {new EmptyBorder(5, 5, 5, 5)}; -} - -#okAction { - actionIcon: information; - text: "tutti.action.ok"; -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionUIHandler.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionUIHandler.java deleted file mode 100644 index 3f92f4d..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionUIHandler.java +++ /dev/null @@ -1,274 +0,0 @@ -package org.nuiton.jaxx.application.swing.action; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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.nuiton.jaxx.runtime.SwingUtil; -import org.nuiton.jaxx.validator.swing.SwingValidator; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.decorator.Decorator; -import org.nuiton.jaxx.application.swing.AbstractApplicationUIHandler; -import org.nuiton.jaxx.application.type.ApplicationProgressionModel; - -import javax.swing.JComponent; -import java.awt.Component; -import java.awt.Cursor; -import java.awt.event.ComponentAdapter; -import java.awt.event.ComponentEvent; -import java.awt.event.ComponentListener; -import java.beans.PropertyChangeListener; - -import static org.nuiton.i18n.I18n.t; - -/** - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public class ApplicationActionUIHandler extends AbstractApplicationUIHandler<ApplicationActionUIModel, ApplicationActionUI> { - - /** Logger. */ - private static final Log log = - LogFactory.getLog(ApplicationActionUIHandler.class); - - protected final PropertyChangeListener progressionListener; - - protected final ComponentListener listener; - - public ApplicationActionUIHandler() { - progressionListener = evt -> { - - String propertyName = evt.getPropertyName(); - if (ApplicationProgressionModel.PROPERTY_MESSAGE.equals(propertyName)) { - - // change message - String newMessage = (String) evt.getNewValue(); - ui.getTaskActionLabel().setText("<html><body>" + newMessage + "</body></html>"); - ui.pack(); - } else if (ApplicationProgressionModel.PROPERTY_TOTAL.equals(propertyName)) { - - // change total progressbar max - ui.getTaskProgressBar().setMaximum((Integer) evt.getNewValue()); - - } else if (ApplicationProgressionModel.PROPERTY_CURRENT.equals(propertyName)) { - - // change value of progress bar - ui.getTaskProgressBar().setValue((Integer) evt.getNewValue()); - } - }; - listener = new ComponentAdapter() { - boolean moving; - - boolean resizing; - - @Override - public void componentMoved(ComponentEvent e) { - - Component mainUI = (Component) e.getSource(); - - if (!moving && mainUI.isShowing()) { - - moving = true; - try { - setLocation(mainUI); - } finally { - moving = false; - } - } - } - - @Override - public void componentResized(ComponentEvent e) { - - Component mainUI = (Component) e.getSource(); - - if (!resizing && mainUI.isShowing()) { - - resizing = true; - try { - setSize(mainUI); - } finally { - resizing = false; - } - } - } - }; - } - - //------------------------------------------------------------------------// - //-- AbstractTuttiUIHandler methods --// - //------------------------------------------------------------------------// - - @Override - public void beforeInit(ApplicationActionUI ui) { - this.ui = ui; - ApplicationActionUIModel model = new ApplicationActionUIModel(); - ui.setContextValue(model); - - model.addPropertyChangeListener(ApplicationActionUIModel.PROPERTY_ACTION, evt -> { - - // udpate global label - AbstractApplicationAction action = (AbstractApplicationAction) evt.getNewValue(); - - if (log.isDebugEnabled()) { - log.debug("Action to use: " + action); - } - if (action == null) { - - // stoping action - hideAction(); - } else { - - // starting action - showAction(action); - } - }); - - model.addPropertyChangeListener(ApplicationActionUIModel.PROPERTY_PROGRESSION_MODEL, evt -> { - - // change progression model - - ApplicationProgressionModel oldValue = (ApplicationProgressionModel) evt.getOldValue(); - ApplicationProgressionModel newValue = (ApplicationProgressionModel) evt.getNewValue(); - - if (log.isDebugEnabled()) { - log.debug("progression model: " + newValue); - } - if (oldValue != null) { - oldValue.removePropertyChangeListener(progressionListener); - } - - if (newValue == null) { - - // remove progression model - ApplicationActionUIHandler.this.ui.getTaskPanel().setVisible(false); - } else { - - // use progression model - ApplicationActionUIHandler.this.ui.getTaskPanel().setVisible(true); - - newValue.addPropertyChangeListener(progressionListener); - } - }); - } - - @Override - public void afterInit(ApplicationActionUI ui) { - - initUI(this.ui); - - // installation layer de blocage en mode busy - SwingUtil.setLayerUI(this.ui.getRootPanel(), this.ui.getBusyBlockLayerUI()); - - this.ui.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - } - - @Override - protected JComponent getComponentToFocus() { - return null; - } - - @Override - public void onCloseUI() { - - } - - @Override - public SwingValidator<ApplicationActionUIModel> getValidator() { - return null; - } - - @Override - public Component getTopestUI() { - return null; - } - - @Override - public <E> Decorator<E> getDecorator(Class<E> beanType, String decoratorContext) { - return null; - } - - //------------------------------------------------------------------------// - //-- Internal methods --// - //------------------------------------------------------------------------// - - protected void hideAction() { - ui.setVisible(false); - } - - protected void showAction(AbstractApplicationAction action) { - ui.setTitle(t("jaxx.application.title.actionUI", - getContext().getConfiguration().getApplicationName(), - getContext().getConfiguration().getVersion(), - action.getActionDescription())); - ui.getGlobalActionLabel().setText( - t("jaxx.application.message.action.running", - action.getActionDescription())); - ui.pack(); - - Component mainUI = getContext().getMainUI(); - if (mainUI != null) { - mainUI.addComponentListener(listener); - - setLocation(mainUI); - setSize(mainUI); - } - try { - ui.setVisible(true); - } finally { - if (mainUI != null) { - mainUI.removeComponentListener(listener); - } - } - } - - protected void setLocation(Component mainUI) { - Component component = getContext().getBodyUI(); - Component status = getContext().getStatusUI(); - int width = component == null ? 0 : component.getWidth(); - int height = component == null ? 0 : component.getHeight() + status.getHeight(); - - int x; - int y; - if (height == 0) { - x = mainUI.getX() + 5; - y = mainUI.getY() + 15; - } else { - x = mainUI.getX() + (mainUI.getWidth() - width); - y = mainUI.getY() + (mainUI.getHeight() - height); - } - ui.setLocation(x, y); - } - - protected void setSize(Component mainUI) { - // Better to let his own size to the action progress bar - // see http://forge.codelutin.com/issues/3263 -// Container component = mainUI.getBody(); -// int width = component == null ? 0 : component.getWidth(); - - ui.pack(); - -// if (width != 0 && ui.getWidth() < width) { -// ui.setSize(width, ui.getHeight()); -// } - } -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionUIModel.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionUIModel.java deleted file mode 100644 index 833e37e..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationActionUIModel.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.nuiton.jaxx.application.swing.action; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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 org.jdesktop.beans.AbstractSerializableBean; -import org.nuiton.jaxx.application.type.ApplicationProgressionModel; - -/** - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public class ApplicationActionUIModel extends AbstractSerializableBean { - - private static final long serialVersionUID = 1L; - - public static final String PROPERTY_ACTION = "action"; - - public static final String PROPERTY_PROGRESSION_MODEL = "progressionModel"; - - protected AbstractApplicationAction action; - - protected ApplicationProgressionModel progressionModel; - - public ApplicationProgressionModel getProgressionModel() { - return progressionModel; - } - - public void setProgressionModel(ApplicationProgressionModel progressionModel) { - Object oldValue = getProgressionModel(); - this.progressionModel = progressionModel; - firePropertyChange(PROPERTY_PROGRESSION_MODEL, oldValue, progressionModel); - } - - public AbstractApplicationAction getAction() { - return action; - } - - public void setAction(AbstractApplicationAction action) { - Preconditions.checkNotNull(action, "action can not be null"); - Object oldValue = getAction(); - this.action = action; - firePropertyChange(PROPERTY_ACTION, oldValue, action); - } - - public void clear() { - setProgressionModel(null); - - Object oldValue = getAction(); - action = null; - firePropertyChange(PROPERTY_ACTION, oldValue, null); - } -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationUIAction.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationUIAction.java deleted file mode 100644 index 50fd56c..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/action/ApplicationUIAction.java +++ /dev/null @@ -1,235 +0,0 @@ -package org.nuiton.jaxx.application.swing.action; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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.nuiton.jaxx.application.swing.ApplicationUIContext; -import org.nuiton.util.TimeLog; - -import javax.swing.AbstractAction; -import javax.swing.AbstractButton; -import javax.swing.Icon; -import javax.swing.SwingUtilities; -import java.awt.event.ActionEvent; -import java.util.concurrent.CancellationException; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -/** - * Abstract tutti ui action which launch a {@link AbstractApplicationAction}. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8.2 - */ -public class ApplicationUIAction<A extends AbstractApplicationAction> extends AbstractAction { - - private static final long serialVersionUID = 1L; - - /** Logger. */ - private static final Log log = LogFactory.getLog(ApplicationUIAction.class); - - private static final TimeLog TIME_LOG = new TimeLog(ApplicationUIAction.class); - - public static final ExecutorService waitingThread = - Executors.newSingleThreadExecutor(); - - private static final String LOGIC_ACTION = "logicAction"; - - private final Object lock = new Object(); - - private boolean wait; - - private long t0; - - public ApplicationUIAction(final AbstractButton button, A action) { - - putValue(LOGIC_ACTION, action); - - // fill the ui action from the button - setActionKey(action.getClass().getName()); - if (button != null) { - - setActionIcon(button.getIcon()); - setActionName(button.getText()); - setActionDescription(button.getToolTipText()); - setActionMnemonic(button.getMnemonic()); - setEnabled(button.isEnabled()); - - // see https://forge.nuiton.org/issues/3525 - button.addPropertyChangeListener(evt -> setEnabled(button.isEnabled())); - - } - } - - public void launchActionAndWait() { - wait = true; - actionPerformed(null); - lock(); - } - - - @Override - public final void actionPerformed(final ActionEvent event) { - - t0 = TimeLog.getTime(); - - if (log.isInfoEnabled()) { - log.info("Task [" + getLogicAction().getClass().getSimpleName() + "] starting"); - } - - // prepare action - boolean doAction; - - A action = getLogicAction(); - - ApplicationUIContext actionContext = action.getContext(); - if (actionContext.isActionInProgress(this)) { - if (log.isInfoEnabled()) { - log.info("Task [" + getLogicAction().getClass().getSimpleName() + "] stopped: action already in progress"); - } - return; - } - - actionContext.setActionInProgress(this, true); - - // reset status message - action.sendMessage(""); - - try { - doAction = action.prepareAction(); - } catch (Exception e) { - action.releaseAction(); - actionContext.setActionInProgress(this, false); - throw ApplicationActionException.propagateError(action, e); - } - - if (doAction) { - - final ApplicationActionSwingWorker<A> worker = - new ApplicationActionSwingWorker<>(action); - - SwingUtilities.invokeLater(() -> { - - // make ui busy - worker.updateBusyState(true); - - }); - - if (log.isDebugEnabled()) { - log.debug("Before execute of action " + action); - } - - // perform and release action - worker.execute(); - - // wait until action is done - waitingThread.execute( - () -> { - - A action1 = getLogicAction(); - try { - try { - worker.get(); - } catch (ExecutionException | InterruptedException | CancellationException e) { - // don't care . - } - if (log.isDebugEnabled()) { - log.debug("After execute of action " + action1 + " (worker done? " + worker.isDone() + ")"); - } - - if (worker.isFailed()) { - - throw ApplicationActionException.propagateError(action1, worker.getError()); - } - } finally { - unlock(); - } - } - ); - - } else { - - try { - // release action - action.releaseAction(); - - } finally { - unlock(); - } - } - } - - public void setActionIcon(Icon actionIcon) { - putValue(SMALL_ICON, actionIcon); - putValue(LARGE_ICON_KEY, actionIcon); - } - - public void setActionKey(String actionKey) { - putValue(ACTION_COMMAND_KEY, actionKey); - } - - public void setActionName(String actionName) { - putValue(NAME, actionName); - } - - public void setActionDescription(String actionDescription) { - putValue(SHORT_DESCRIPTION, actionDescription); - getLogicAction().setActionDescription(actionDescription); - } - - public void setActionMnemonic(int key) { - putValue(MNEMONIC_KEY, key); - } - - public A getLogicAction() { - return (A) getValue(LOGIC_ACTION); - } - - protected void lock() { - if (wait) { - synchronized (lock) { - try { - - lock.wait(); - - } catch (InterruptedException e) { - throw ApplicationActionException.propagateError(getLogicAction(), e); - } finally { - wait = false; - } - } - } - } - - protected void unlock() { - TIME_LOG.log(t0, "Task [" + getLogicAction().getClass().getSimpleName() + "] End"); - if (wait) { - synchronized (lock) { - lock.notifyAll(); - } - } - getLogicAction().getContext().setActionInProgress(this, false); - } -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/actionng/ApplicationAction.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/actionng/ApplicationAction.java deleted file mode 100644 index 5f17aab..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/actionng/ApplicationAction.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.nuiton.jaxx.application.swing.actionng; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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% - */ - -/** - * Contract of an application action. - * - * Created on 11/23/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public interface ApplicationAction { - - /** - * Before executing the action. - * - * <strong>This code is executed in the Swing thread</strong> - * - * @return {@code true} if action can be execute, {@code false} otherwise. - */ - boolean prepare(); - - /** - * Real action code. - * - * <strong>This code is not executed, you can't then touch to any models or components of UI.</strong> - */ - void action(); - - /** - * Executed when action ended with success. - * - * <strong>This code is executed in the Swing thread, you can here update</strong> - * - */ - void done(); - - /** - * Executed when action failed. - * - * @param error failure exception - */ - void fail(Exception error); -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/actionng/ApplicationActionEngine.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/actionng/ApplicationActionEngine.java deleted file mode 100644 index 7e73cf0..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/actionng/ApplicationActionEngine.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.nuiton.jaxx.application.swing.actionng; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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 javax.swing.event.EventListenerList; - -/** - * Engine what consumes incoming actions. - * - * Created on 11/23/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public class ApplicationActionEngine { - - private final EventListenerList eventList; - - public ApplicationActionEngine() { - eventList = new EventListenerList(); - } - - public void addAction(ApplicationAction action) { - - } - - //------------------------------------------------------------------------// - //--- ApplicationActionListener API ---// - //------------------------------------------------------------------------// - - public void addApplicationEventListener(ApplicationActionListener listener) { - eventList.add(ApplicationActionListener.class, listener); - } - - public void removeApplicationEventListener(ApplicationActionListener listener) { - eventList.remove(ApplicationActionListener.class, listener); - } - - protected void fireInit(ApplicationAction action) { - ApplicationActionEvent event = new ApplicationActionEvent(action, ApplicationActionEvent.EventType.INIT); - - ApplicationActionListener[] listeners = eventList.getListeners(ApplicationActionListener.class); - for (ApplicationActionListener listener : listeners) { - listener.actionStarted(event); - } - } - - protected void fireStart(ApplicationAction action) { - ApplicationActionEvent event = new ApplicationActionEvent(action, ApplicationActionEvent.EventType.START); - - ApplicationActionListener[] listeners = eventList.getListeners(ApplicationActionListener.class); - for (ApplicationActionListener listener : listeners) { - listener.actionStarted(event); - } - } - - protected void fireDone(ApplicationAction action) { - ApplicationActionEvent event = new ApplicationActionEvent(action, ApplicationActionEvent.EventType.DONE); - ApplicationActionListener[] listeners = eventList.getListeners(ApplicationActionListener.class); - for (ApplicationActionListener listener : listeners) { - listener.actionDone(event); - } - } - - protected void fireFail(ApplicationAction action, Exception error) { - ApplicationActionEvent event = new ApplicationActionEvent(action, ApplicationActionEvent.EventType.FAIL); - event.setError(error); - ApplicationActionListener[] listeners = eventList.getListeners(ApplicationActionListener.class); - for (ApplicationActionListener listener : listeners) { - listener.actionFailed(event); - } - } - - protected void fireProgressionChange(ApplicationAction action) { - ApplicationActionEvent event = new ApplicationActionEvent(action, ApplicationActionEvent.EventType.PROGRESSION_CHANGE); - ApplicationActionListener[] listeners = eventList.getListeners(ApplicationActionListener.class); - for (ApplicationActionListener listener : listeners) { - listener.actionProgressionChanged(event); - } - } -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/actionng/ApplicationActionEvent.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/actionng/ApplicationActionEvent.java deleted file mode 100644 index d481d75..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/actionng/ApplicationActionEvent.java +++ /dev/null @@ -1,95 +0,0 @@ -package org.nuiton.jaxx.application.swing.actionng; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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.util.EventObject; - -/** - * Events... - * - * Created on 11/23/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public class ApplicationActionEvent extends EventObject { - - private static final long serialVersionUID = 1L; - - public enum EventType { - /** - * Before starting action. - */ - INIT, - /** - * When action is started. - */ - START, - /** - * When action end with succes. - */ - DONE, - /** - * When action failed. - */ - FAIL, - /** - * When progression changed. - */ - PROGRESSION_CHANGE - } - - private Exception error; - - private final EventType eventType; - - /** - * Constructs a prototypical Event. - * - * @param source The object on which the Event initially occurred. - * @param eventType The type of event - * @throws IllegalArgumentException if source is null. - */ - public ApplicationActionEvent(ApplicationAction source, - EventType eventType) { - super(source); - this.eventType = eventType; - } - - @Override - public ApplicationAction getSource() { - return (ApplicationAction) super.getSource(); - } - - public Exception getError() { - return error; - } - - public void setError(Exception error) { - this.error = error; - } - - public EventType getEventType() { - return eventType; - } -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/actionng/ApplicationActionListener.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/actionng/ApplicationActionListener.java deleted file mode 100644 index f461d29..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/actionng/ApplicationActionListener.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.nuiton.jaxx.application.swing.actionng; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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.util.EventListener; - -/** - * To listen {@link ApplicationActionEngine} events. - * - * Created on 11/23/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public interface ApplicationActionListener extends EventListener { - - void actionInit(ApplicationActionEvent event); - - void actionStarted(ApplicationActionEvent event); - - void actionProgressionChanged(ApplicationActionEvent event); - - void actionDone(ApplicationActionEvent event); - - void actionFailed(ApplicationActionEvent event); - -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/tab/CustomTab.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/tab/CustomTab.java deleted file mode 100644 index ccb27c7..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/tab/CustomTab.java +++ /dev/null @@ -1,220 +0,0 @@ -package org.nuiton.jaxx.application.swing.tab; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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.nuiton.jaxx.runtime.SwingUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.util.beans.BeanUtil; - -import javax.swing.AbstractButton; -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JTabbedPane; -import javax.swing.UIManager; -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Font; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; - -import static org.nuiton.i18n.I18n.t; - -/** - * Custom tab component which adds a * in the end of the title - * when the content is modified. - * - * @author Kevin Morin - morin@codelutin.com - * @since 2.8 - */ -public class CustomTab extends JPanel { - - private static final long serialVersionUID = 1L; - - private static final Log log = LogFactory.getLog(CustomTab.class); - - protected final TabContentModel model; - - protected final TabContainerHandler handler; - - protected final JLabel title = new JLabel(); - - public TabContentModel getModel() { - return model; - } - - public CustomTab(TabContentModel model, TabContainerHandler handler) { - super(new FlowLayout(FlowLayout.LEFT, 0, 0)); - - this.model = model; - this.handler = handler; - - try { - BeanUtil.addPropertyChangeListener( - evt -> updateTitle(), this.model); - - } catch (Exception ex) { - log.error("Error while adding the listener to the model modifications", ex); - } - - setBackground(null); - - updateTitle(); - String actionIcon = model.getIcon(); - if (actionIcon != null) { - title.setIcon(SwingUtil.createActionIcon(actionIcon)); - } - title.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); - add(title); - - if (model.isCloseable()) { - JButton button = new TabButton(); - add(button); - } - - setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); - } - - @Override - public void setBackground(Color bg) { - if (bg == null) { - bg = new Color(0, 0, 0, 0); - } - super.setBackground(bg); - revalidate(); - } - - @Override - public void setForeground(Color fg) { - super.setForeground(fg); - if (title != null) { - title.setForeground(fg); - } - } - - protected void updateTitle() { - Font f = UIManager.getDefaults().getFont("Label.font"); - String titleValue = t(model.getTitle()); - - int style; - if (model.isModify()) { - style = Font.BOLD; - titleValue += "*"; - - } else if (model.isEmpty()) { - style = Font.ITALIC; - - } else { - style = Font.PLAIN; - } - - title.setText(titleValue); - title.setFont(f.deriveFont(style)); - } - - protected class TabButton extends JButton implements ActionListener { - - public TabButton() { - int size = 17; - setPreferredSize(new Dimension(size, size)); - setToolTipText(t("jaxx.application.tab.customtab.close.label")); - //Make it transparent - setContentAreaFilled(false); - //No need to be focusable - setFocusable(false); - setBorder(BorderFactory.createEtchedBorder()); - setBorderPainted(false); - //Making nice rollover effect - //we use the same listener for all buttons - addMouseListener(buttonMouseListener); - setRolloverEnabled(true); - //Close the proper tab by clicking the button - addActionListener(this); - } - - @Override - public void actionPerformed(ActionEvent e) { -// if (tabbedPane != null) { -// if (i != -1) { -// tabbedPane.remove(i); -// } -// } - if (handler != null) { - JTabbedPane tabPanel = handler.getTabPanel(); - int i = tabPanel.indexOfTabComponent(CustomTab.this); - handler.removeTab(i); - } - } - - //paint the cross - @Override - protected void paintComponent(Graphics g) { - super.paintComponent(g); - - Graphics2D g2 = (Graphics2D) g.create(); - //shift the image for pressed buttons - if (getModel().isPressed()) { - g2.translate(1, 1); - } - g2.setStroke(new BasicStroke(2)); - if (getModel().isRollover()) { -// g2.setBackground(Color.MAGENTA); - g2.setColor(Color.MAGENTA); - } else { - g2.setColor(Color.BLACK); - } - int delta = 5; - g2.drawLine(delta, delta, getWidth() - delta - 1, getHeight() - delta - 1); - g2.drawLine(getWidth() - delta - 1, delta, delta, getHeight() - delta - 1); - g2.dispose(); - } - } - - private final MouseListener buttonMouseListener = new MouseAdapter() { - public void mouseEntered(MouseEvent e) { - Component component = e.getComponent(); - if (component instanceof AbstractButton) { - AbstractButton button = (AbstractButton) component; - button.setBorderPainted(true); - } - } - - public void mouseExited(MouseEvent e) { - Component component = e.getComponent(); - if (component instanceof AbstractButton) { - AbstractButton button = (AbstractButton) component; - button.setBorderPainted(false); - } - } - }; -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/tab/DelegateTabContainerHandler.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/tab/DelegateTabContainerHandler.java deleted file mode 100644 index 72e6ac5..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/tab/DelegateTabContainerHandler.java +++ /dev/null @@ -1,120 +0,0 @@ -package org.nuiton.jaxx.application.swing.tab; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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.nuiton.jaxx.application.swing.AbstractApplicationUIHandler; -import org.nuiton.jaxx.application.swing.ApplicationUI; - -import javax.swing.DefaultSingleSelectionModel; -import javax.swing.JTabbedPane; -import java.awt.Component; - -/** - * Created on 11/25/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public class DelegateTabContainerHandler implements TabContainerHandler { - - final JTabbedPane tabbedPane; - - public DelegateTabContainerHandler(JTabbedPane tabbedPane) { - this.tabbedPane = tabbedPane; - } - - @Override - public JTabbedPane getTabPanel() { - return tabbedPane; - } - - @Override - public void init() { - - getTabPanel().setModel(new DefaultSingleSelectionModel() { - - private static final long serialVersionUID = 1L; - - @Override - public void setSelectedIndex(int index) { - int currentIndex = getTabPanel().getSelectedIndex(); - boolean mustChangeTab = onTabChanged(currentIndex, index); - - if (mustChangeTab) { - super.setSelectedIndex(index); - } - } - - }); - } - - @Override - public boolean onTabChanged(int currentIndex, int newIndex) { - boolean result = true; - if (currentIndex != newIndex) { - TabHandler handler = getTabHandler(currentIndex); - if (handler != null) { - result = handler.onHideTab(currentIndex, newIndex); - } - - handler = getTabHandler(newIndex); - if (handler != null) { - handler.onShowTab(currentIndex, newIndex); - } - } - return result; - } - - @Override - public TabHandler getTabHandler(int index) { - TabHandler tabHandler = null; - JTabbedPane tabPanel = getTabPanel(); - if (index >= 0 && index < tabPanel.getTabCount()) { - Component tab = tabPanel.getComponentAt(index); - if (ApplicationUI.class.isInstance(tab)) { - ApplicationUI tuttiTab = (ApplicationUI) tabPanel.getComponentAt(index); - AbstractApplicationUIHandler handler = tuttiTab.getHandler(); - if (TabHandler.class.isInstance(handler)) { - tabHandler = (TabHandler) handler; - } - } - } - return tabHandler; - } - - @Override - public void setCustomTab(int index, TabContentModel model) { - JTabbedPane tabPanel = getTabPanel(); - tabPanel.setTabComponentAt(index, new CustomTab(model, this)); - } - - @Override - public boolean removeTab(int i) { - TabHandler tabHandler = getTabHandler(i); - boolean remove = tabHandler.onRemoveTab(); - if (remove) { - getTabPanel().removeTabAt(i); - } - return remove; - } -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/tab/TabContainerHandler.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/tab/TabContainerHandler.java deleted file mode 100644 index 9e817a0..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/tab/TabContainerHandler.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.nuiton.jaxx.application.swing.tab; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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 javax.swing.JTabbedPane; - -/** - * Created on 11/25/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public interface TabContainerHandler { - - JTabbedPane getTabPanel(); - - void init(); - - /** - * Method called when the user selects a tab. - * - * @param currentIndex - * @param newIndex - * @return <code>false</code> if you want to prevent the tab change, - * <code>true</code> otherwise - */ - boolean onTabChanged(int currentIndex, int newIndex); - - /** - * Returns the tab handler of the tab i. - * - * @param index the index of the tab - * @return the tab handler of the index i if the handler implements - * the {@link TabHandler} interface, - * <code>null</code> otherwise - */ - TabHandler getTabHandler(int index); - - /** - * Sets a {@link CustomTab} as tab component. - * - * @param index - * @param model - */ - void setCustomTab(int index, TabContentModel model); - - /** - * Removes the tab i - * - * @param i the index of the tab to remove - * @return <code>false</code> if you want to prevent the tab close, - * <code>true</code> otherwise - */ - boolean removeTab(int i); - -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/tab/TabContentModel.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/tab/TabContentModel.java deleted file mode 100644 index 7a06746..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/tab/TabContentModel.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.nuiton.jaxx.application.swing.tab; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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% - */ - -/** - * Interface defining the models of the tab content UIs. - * - * @author Kevin Morin - morin@codelutin.com - * @since 2.8 - */ -public interface TabContentModel { - - boolean isEmpty(); - - boolean isValid(); - - boolean isModify(); - - String getTitle(); - - String getIcon(); - - boolean isCloseable(); -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/tab/TabHandler.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/tab/TabHandler.java deleted file mode 100644 index df35072..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/tab/TabHandler.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.nuiton.jaxx.application.swing.tab; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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% - */ - -/** - * Interface describing UI contained in a tab. - * - * @author Kevin Morin - morin@codelutin.com - * @since 2.8 - */ -public interface TabHandler { - - /** - * Method called when the tab is hidden - * - * @param currentIndex - * @param newIndex - * @return <code>false</code> to prevent the tab to be hidden, - * <code>true</code> otherwise. - */ - boolean onHideTab(int currentIndex, int newIndex); - - /** - * Method called when the tab is shown - * - * @param currentIndex - * @param newIndex - */ - void onShowTab(int currentIndex, int newIndex); - - /** - * Method called when the tab is removed - * - * @return <code>false</code> to prevent the tab to be closed, - * <code>true</code> otherwise. - */ - boolean onRemoveTab(); -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/AbstractApplicationTableModel.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/AbstractApplicationTableModel.java deleted file mode 100644 index 0f9449f..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/AbstractApplicationTableModel.java +++ /dev/null @@ -1,371 +0,0 @@ -package org.nuiton.jaxx.application.swing.table; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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 com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; -import org.nuiton.jaxx.runtime.SwingUtil; -import org.apache.commons.lang3.ObjectUtils; -import org.apache.commons.lang3.tuple.Pair; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jdesktop.swingx.table.TableColumnModelExt; - -import javax.swing.table.AbstractTableModel; -import javax.swing.table.TableColumn; -import java.io.Serializable; -import java.util.List; -import java.util.Set; - -/** - * Abstract model of a table. - * - * @param <R> type of a row. - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public abstract class AbstractApplicationTableModel<R extends Serializable> extends AbstractTableModel { - - private static final long serialVersionUID = 1L; - - /** Logger. */ - private static final Log log = - LogFactory.getLog(AbstractApplicationTableModel.class); - - /** - * Data in the model. - * - * @since 0.2 - */ - protected List<R> rows; - - /** - * Set of non editable columns. - * - * @since 0.2 - */ - protected Set<ColumnIdentifier<?>> noneEditableCols; - - /** - * Creates a new row when moving to next editable cell / row ? - * - * @since 0.3 - */ - protected final boolean createNewRow; - - /** - * Creates a first empty row when setting a null or empty list of rows ? - * - * @since 0.3 - */ - protected final boolean createEmptyRowIsEmpty; - - /** - * Identifiers of columns (in initial order). - * - * @since 1.1 - */ - protected final List<ColumnIdentifier<R>> identifiers; - - public abstract R createNewRow(); - - protected AbstractApplicationTableModel(TableColumnModelExt columnModel, - boolean createNewRow, - boolean createEmptyRowIsEmpty) { - this.identifiers = Lists.newArrayListWithCapacity(columnModel.getColumnCount()); - for (TableColumn tc : columnModel.getColumns(true)) { - this.identifiers.add((ColumnIdentifier<R>) tc.getIdentifier()); - } - this.createNewRow = createNewRow; - this.createEmptyRowIsEmpty = createEmptyRowIsEmpty; - } - - public final List<R> getRows() { - return rows; - } - - public final void setRows(List<R> data) { - - // can't accept a empty data list - Preconditions.checkNotNull(data, "Data list can not be null."); - - onBeforeRowsChanged(rows); - - this.rows = null; - if (createEmptyRowIsEmpty && data.isEmpty()) { - - if (log.isDebugEnabled()) { - log.debug("Creates a first empty row on tableModel " + this); - } - // add a first edit line - data.add(createNewRow()); - } - if (log.isDebugEnabled()) { - log.debug("Set " + data.size() + " row(s) in table model " + this); - } - this.rows = data; - onRowsChanged(data); - fireTableDataChanged(); - } - - public boolean isCreateNewRow() { - return createNewRow; - } - - public boolean isCreateEmptyRowIsEmpty() { - return createEmptyRowIsEmpty; - } - - public final void addNewRow() { - R newValue = createNewRow(); - addNewRow(newValue); - } - - public final void addNewRow(R newValue) { - - addNewRow(getRowCount(), newValue); - } - - public final void addNewRow(int rowIndex, R newValue) { - - Preconditions.checkNotNull(newValue, "Row can not be null."); - - List<R> data = getRows(); - Preconditions.checkNotNull(data, "Data list can not be null."); - - data.add(rowIndex, newValue); - - onRowAdded(rowIndex, newValue); - fireTableRowsInserted(rowIndex, rowIndex); - } - - public final void fireTableRowsInserted(R newValue) { - - Preconditions.checkNotNull(newValue, "Row can not be null."); - - int rowIndex = getRowIndex(newValue); - fireTableRowsInserted(rowIndex, rowIndex); - } - - public final int updateRow(R row) { - Preconditions.checkNotNull(row, "Row can not be null."); - - List<R> data = getRows(); - Preconditions.checkNotNull(data, "Data list can not be null."); - - int rowIndex = data.indexOf(row); - - onRowUpdated(rowIndex, row); - fireTableRowsUpdated(rowIndex, rowIndex); - return rowIndex; - } - - public final R removeRow(int rowIndex) { - SwingUtil.ensureRowIndex(this, rowIndex); - - List<R> data = getRows(); - - R row = data.remove(rowIndex); - - onRowRemoved(rowIndex, row); - fireTableRowsDeleted(rowIndex, rowIndex); - return row; - } - - protected void onRowsChanged(List<R> newRows) { - // by default do nothing - } - - protected void onBeforeRowsChanged(List<R> oldRows) { - // by default do nothing - } - - protected void onRowAdded(int rowIndex, R row) { - // by default do nothing - } - - protected void onRowUpdated(int rowIndex, R row) { - // by default do nothing - } - - protected void onRowRemoved(int rowIndex, R row) { - // by default do nothing - } - - public final int getRowIndex(R row) { - return rows == null ? -1 : rows.indexOf(row); - } - - public final R getEntry(int rowIndex) { - SwingUtil.ensureRowIndex(this, rowIndex); - List<R> data = getRows(); - return data == null ? null : data.get(rowIndex); - } - - public final void setNoneEditableCols(ColumnIdentifier<?>... noneEditableCols) { - this.noneEditableCols = Sets.newHashSet(noneEditableCols); - } - - @Override - public final int getRowCount() { - return rows == null ? 0 : rows.size(); - } - - @Override - public final int getColumnCount() { - return identifiers.size(); - } - - @Override - public final Object getValueAt(int rowIndex, int columnIndex) { - R entry = getEntry(rowIndex); - ColumnIdentifier<R> identifier = getIdentifier(columnIndex); - if (log.isDebugEnabled()) { - log.debug("columnIndex: " + columnIndex + " :: " + identifier.getPropertyName()); - } - return identifier.getValue(entry); - } - - @Override - public final void setValueAt(Object aValue, int rowIndex, int columnIndex) { - if (log.isDebugEnabled()) { - log.debug("setValueAt " + aValue); - } - R entry = getEntry(rowIndex); - ColumnIdentifier<R> identifier = getIdentifier(columnIndex); - setValueAt(aValue, rowIndex, columnIndex, identifier, entry); - } - - @Override - public final boolean isCellEditable(int rowIndex, int columnIndex) { - ColumnIdentifier<R> identifier = getIdentifier(columnIndex); - return isCellEditable(rowIndex, columnIndex, identifier); - } - - protected void setValueAt(Object aValue, - int rowIndex, - int columnIndex, - ColumnIdentifier<R> propertyName, - R entry) { - if (log.isDebugEnabled()) { - log.debug("setValueAt " + aValue); - } - propertyName.setValue(entry, aValue); - } - - protected boolean isCellEditable(int rowIndex, - int columnIndex, - ColumnIdentifier<R> propertyName) { - return !noneEditableCols.contains(propertyName); - } - - public final void fireTableCellUpdated(int rowIndex, - ColumnIdentifier<R>... identifiers) { - for (ColumnIdentifier<R> identifier : identifiers) { - int columnIndex = this.identifiers.indexOf(identifier); - fireTableCellUpdated(rowIndex, columnIndex); - } - } - - public final void fireTableRowUpdatedShell(Set<R> shell) { - - int minRowIndex1 = getColumnCount(); - int maxRowIndex1 = 0; - - for (R r : shell) { - int rowIndex1 = getRowIndex(r); - minRowIndex1 = Math.min(minRowIndex1, rowIndex1); - maxRowIndex1 = Math.max(maxRowIndex1, rowIndex1); - } - fireTableRowsUpdated(minRowIndex1, maxRowIndex1); - } - - protected void collectShell(R row, Set<R> collectedRows) { - - // by default just add the incoming row - collectedRows.add(row); - } - - @Override - public String getColumnName(int columnIndex) { - return getIdentifier(columnIndex).getPropertyName(); - } - - protected ColumnIdentifier<R> getIdentifier(int columnIndex) { - return identifiers.get(columnIndex); - } - - public int getColumnIndex(final String propertyName) { - return Iterables.indexOf(identifiers, input -> ObjectUtils.equals(propertyName, input.getPropertyName())); - } - - public Pair<Integer, Integer> getCell(R row, final String propertyName) { - - int rowIndex = getRowIndex(row); - int columnIndex = getColumnIndex(propertyName); - - return Pair.of(rowIndex, columnIndex); - } - - public void moveUp(R row) { - - int rowIndex = getRowIndex(row); - - if (log.isInfoEnabled()) { - log.info("Will move up row of index: " + rowIndex); - } - rows.remove(rowIndex); - rows.add(rowIndex - 1, row); - fireTableRowsUpdated(rowIndex - 1, rowIndex); - - } - - public void moveDown(R row) { - - int rowIndex = getRowIndex(row); - - if (log.isInfoEnabled()) { - log.info("Will move down row of index: " + rowIndex); - } - rows.remove(rowIndex); - rows.add(rowIndex + 1, row); - fireTableRowsUpdated(rowIndex, rowIndex + 1); - - } - - public boolean isFirstRow(R row) { - - int rowIndex = getRowIndex(row); - return rowIndex == 0; - - } - - public boolean isLastRow(R row) { - - int rowIndex = getRowIndex(row); - return rowIndex == getRowCount() - 1; - - } -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/AbstractSelectTableAction.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/AbstractSelectTableAction.java deleted file mode 100644 index c5ef9e7..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/AbstractSelectTableAction.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.nuiton.jaxx.application.swing.table; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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.nuiton.jaxx.application.swing.util.ApplicationUIUtil; - -import javax.swing.AbstractAction; -import javax.swing.JTable; - -/** - * Abstract action to select a cell in a table. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public abstract class AbstractSelectTableAction<M extends AbstractApplicationTableModel> extends AbstractAction { - - private static final long serialVersionUID = 1L; - - /** Logger. */ - private static final Log log = - LogFactory.getLog(AbstractSelectTableAction.class); - - private final M model; - - private final JTable table; - - public AbstractSelectTableAction(M model, JTable table) { - this.model = model; - this.table = table; - } - - protected void doSelectCell(int rowIndex, int columnIndex) { - - if (log.isDebugEnabled()) { - log.debug("Will select cell at " + - getCellCoordinate(rowIndex, columnIndex)); - } - ApplicationUIUtil.doSelectCell(table, rowIndex, columnIndex); - } - - protected int getSelectedRow() { - return table.getSelectedRow(); - } - - protected int getSelectedColumn() { - return table.getSelectedColumn(); - } - - protected int getRowCount() { - return table.getRowCount(); - } - - protected int getColumnCount() { - return table.getColumnCount(); - } - - protected boolean isCellEditable(int rowIndex, int columnIndex) { - boolean result; - result = rowIndex > -1 && columnIndex > -1 && - table.isCellEditable(rowIndex, columnIndex); - return result; - } - - protected boolean isCreateNewRow() { - return model.isCreateNewRow(); - } - - protected String getCellCoordinate(int rowIndex, int columnIndex) { - return " [" + rowIndex + ", " + columnIndex + "]"; - } - - protected void addNewRow() { - model.addNewRow(); - } -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/ApplicationTableModelValidatorDataLocator.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/ApplicationTableModelValidatorDataLocator.java deleted file mode 100644 index 9a4ba5f..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/ApplicationTableModelValidatorDataLocator.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.nuiton.jaxx.application.swing.table; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 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.nuiton.jaxx.validator.swing.SwingListValidatorDataLocator; -import org.apache.commons.lang3.tuple.Pair; - -import javax.swing.table.TableModel; -import java.io.Serializable; - -/** - * To locate data in a {@link AbstractApplicationTableModel}. - * - * Created on 8/14/14. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.10 - */ -public class ApplicationTableModelValidatorDataLocator<R extends Serializable, T extends AbstractApplicationTableModel<R>> implements SwingListValidatorDataLocator<R> { - - public static <R extends Serializable, T extends AbstractApplicationTableModel<R>> ApplicationTableModelValidatorDataLocator<R, T> newLocator(Class<R> rowType) { - return new ApplicationTableModelValidatorDataLocator<>(rowType); - } - - private final Class<R> rowType; - - public ApplicationTableModelValidatorDataLocator(Class<R> rowType) { - this.rowType = rowType; - } - - @Override - public boolean acceptType(Class<?> beanType) { - return rowType.isAssignableFrom(beanType); - } - - @Override - public Pair<Integer, Integer> locateDataCell(TableModel tableModel, - R bean, - String fieldName) { - T model = (T) tableModel; - - return model.getCell(bean, fieldName); - } - - @Override - public int locateBeanRowIndex(TableModel tableModel, R bean) { - T model = (T) tableModel; - return model.getRowIndex(bean); - } - - @Override - public R locateBean(TableModel tableModel, int rowIndex) { - T model = (T) tableModel; - return model.getEntry(rowIndex); - } -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/ColumnIdentifier.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/ColumnIdentifier.java deleted file mode 100644 index 2205ea9..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/ColumnIdentifier.java +++ /dev/null @@ -1,103 +0,0 @@ -package org.nuiton.jaxx.application.swing.table; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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.nuiton.jaxx.application.bean.JavaBeanObjectUtil; - -import java.io.Serializable; - -/** - * To represent a column of a table. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public class ColumnIdentifier<R> implements Serializable { - - private static final long serialVersionUID = 1L; - - private final String propertyName; - - private final String headerI18nKey; - - private final String headerTipI18nKey; - - public static <R> ColumnIdentifier<R> newId(String propertyName, - String headerI18nKey, - String headerTipI18nKey) { - return new ColumnIdentifier<>(propertyName, - headerI18nKey, - headerTipI18nKey); - } - - public static <R> ColumnIdentifier<R> newReadOnlyId(String propertyName, - String headerI18nKey, - String headerTipI18nKey) { - return new ColumnIdentifier<R>(propertyName, - headerI18nKey, - headerTipI18nKey) { - - private static final long serialVersionUID = 1L; - - @Override - public void setValue(R entry, Object value) { - // no set - } - }; - } - - protected ColumnIdentifier(String propertyName, - String headerI18nKey, - String headerTipI18nKey) { - this.propertyName = propertyName; - this.headerI18nKey = headerI18nKey; - this.headerTipI18nKey = headerTipI18nKey; - } - - public String getPropertyName() { - return propertyName; - } - - public String getHeaderI18nKey() { - return headerI18nKey; - } - - public String getHeaderTipI18nKey() { - return headerTipI18nKey; - } - - public Object getValue(R entry) { - Object result = null; - if (propertyName != null && entry != null) { - result = JavaBeanObjectUtil.getProperty(entry, propertyName); - } - return result; - } - - public void setValue(R entry, Object value) { - if (propertyName != null) { - JavaBeanObjectUtil.setProperty(entry, propertyName, value); - } - } - -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/MoveToNextEditableCellAction.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/MoveToNextEditableCellAction.java deleted file mode 100644 index 674ca97..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/MoveToNextEditableCellAction.java +++ /dev/null @@ -1,100 +0,0 @@ -package org.nuiton.jaxx.application.swing.table; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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 javax.swing.JTable; -import java.awt.event.ActionEvent; - -/** - * Action to select next editable cell in a table. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public class MoveToNextEditableCellAction<M extends AbstractApplicationTableModel> extends AbstractSelectTableAction<M> { - - private static final long serialVersionUID = 1L; - - /** Logger. */ - private static final Log log = - LogFactory.getLog(MoveToNextEditableCellAction.class); - - public static <M extends AbstractApplicationTableModel> MoveToNextEditableCellAction<M> newAction(M model, JTable table) { - return new MoveToNextEditableCellAction<>(model, table); - } - - protected MoveToNextEditableCellAction(M model, JTable table) { - super(model, table); - } - - @Override - public void actionPerformed(ActionEvent e) { - - int currentRow = getSelectedRow(); - int currentColumn = getSelectedColumn(); - - if (log.isDebugEnabled()) { - log.debug("Move to previous editable cell " + - getCellCoordinate(currentRow, currentColumn)); - } - - int columnCount = getColumnCount(); - - int rowCount = getRowCount(); - - if (currentRow <= rowCount || currentColumn <= columnCount) { - - // go to next cell - currentColumn++; - boolean canSelect = true; - - // select next cell - if (currentColumn >= columnCount) { - - // no more cell, so will move to next editable column on next row - currentColumn = 0; - currentRow++; - - if (currentRow == rowCount) { - - if (isCreateNewRow()) { - - // create a new row in model - addNewRow(); - } else { - - // can not create new row, so do nothing - canSelect = false; - } - } - } - - if (canSelect) { - doSelectCell(currentRow, currentColumn); - } - } - } -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/MoveToNextEditableRowAction.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/MoveToNextEditableRowAction.java deleted file mode 100644 index a86fe65..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/MoveToNextEditableRowAction.java +++ /dev/null @@ -1,91 +0,0 @@ -package org.nuiton.jaxx.application.swing.table; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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 javax.swing.JTable; -import java.awt.event.ActionEvent; - -/** - * Action to select next editable row in a table. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public class MoveToNextEditableRowAction<M extends AbstractApplicationTableModel> extends AbstractSelectTableAction<M> { - - private static final long serialVersionUID = 1L; - - /** Logger. */ - private static final Log log = - LogFactory.getLog(MoveToNextEditableRowAction.class); - - public static <M extends AbstractApplicationTableModel> MoveToNextEditableRowAction<M> newAction(M model, JTable table) { - return new MoveToNextEditableRowAction<>(model, table); - } - - protected MoveToNextEditableRowAction(M model, JTable table) { - super(model, table); - } - - @Override - public void actionPerformed(ActionEvent e) { - int currentRow = getSelectedRow(); - int currentColumn = getSelectedColumn(); - - if (log.isDebugEnabled()) { - log.debug("Move to next row editable cell " + - getCellCoordinate(currentRow, currentColumn)); - } - - int rowCount = getRowCount(); - - if (currentRow < rowCount) { - // go to next cell - currentRow++; - boolean canSelect = true; - - // select next cell - if (currentRow >= rowCount) { - - if (log.isDebugEnabled()) { - log.debug("No next row"); - } - if (isCreateNewRow()) { - - // create a new row in model - addNewRow(); - - } else { - canSelect = false; - } - } - - if (canSelect) { - doSelectCell(currentRow, currentColumn); - } - } - } -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/MoveToPreviousEditableCellAction.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/MoveToPreviousEditableCellAction.java deleted file mode 100644 index b951522..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/MoveToPreviousEditableCellAction.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.nuiton.jaxx.application.swing.table; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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 javax.swing.JTable; -import java.awt.event.ActionEvent; - -/** - * Action to select previous editable cell in a table. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public class MoveToPreviousEditableCellAction<M extends AbstractApplicationTableModel> extends AbstractSelectTableAction<M> { - - private static final long serialVersionUID = 1L; - - /** Logger. */ - private static final Log log = - LogFactory.getLog(MoveToPreviousEditableCellAction.class); - - public static <M extends AbstractApplicationTableModel> MoveToPreviousEditableCellAction<M> newAction(M model, JTable table) { - return new MoveToPreviousEditableCellAction<>(model, table); - } - - protected MoveToPreviousEditableCellAction(M model, JTable table) { - super(model, table); - } - - @Override - public void actionPerformed(ActionEvent e) { - int currentRow = getSelectedRow(); - int currentColumn = getSelectedColumn(); - - if (log.isDebugEnabled()) { - log.debug("Move to previous editable cell, " + - getCellCoordinate(currentRow, currentColumn)); - } - - int columnCount = getColumnCount(); - - if (currentRow > 0 || currentColumn > 0) { - - // go to next cell - currentColumn--; - - // select next cell - if (currentColumn < 0) { - - currentColumn = columnCount - 1; - currentRow--; - } - - doSelectCell(currentRow, currentColumn); - } - } -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/MoveToPreviousEditableRowAction.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/MoveToPreviousEditableRowAction.java deleted file mode 100644 index 05117c9..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/table/MoveToPreviousEditableRowAction.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.nuiton.jaxx.application.swing.table; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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 javax.swing.JTable; -import java.awt.event.ActionEvent; - -/** - * Action to select previous editable row in a table. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public class MoveToPreviousEditableRowAction<M extends AbstractApplicationTableModel> extends AbstractSelectTableAction<M> { - - private static final long serialVersionUID = 1L; - - /** Logger. */ - private static final Log log = - LogFactory.getLog(MoveToPreviousEditableRowAction.class); - - public static <M extends AbstractApplicationTableModel> MoveToPreviousEditableRowAction<M> newAction(M model, JTable table) { - return new MoveToPreviousEditableRowAction<>(model, table); - } - - protected MoveToPreviousEditableRowAction(M model, JTable table) { - super(model, table); - } - - @Override - public void actionPerformed(ActionEvent e) { - - int currentRow = getSelectedRow(); - int currentColumn = getSelectedColumn(); - - if (log.isDebugEnabled()) { - log.debug("Move to previous row editable cell " + - getCellCoordinate(currentRow, currentColumn)); - } - - if (currentRow > 0) { - - // go to next cell - currentRow--; - doSelectCell(currentRow, currentColumn); - } - } -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/ActionListCellRenderer.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/ActionListCellRenderer.java deleted file mode 100644 index 6099d16..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/ActionListCellRenderer.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.nuiton.jaxx.application.swing.util; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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 javax.swing.Action; -import javax.swing.DefaultListCellRenderer; -import javax.swing.Icon; -import javax.swing.JButton; -import javax.swing.JList; -import javax.swing.border.EmptyBorder; -import java.awt.Component; - -/** - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public class ActionListCellRenderer extends DefaultListCellRenderer { - - private static final long serialVersionUID = 1L; - - protected final EmptyBorder border = new EmptyBorder(4, 8, 4, 8); - - @Override - public Component getListCellRendererComponent(JList list, - Object value, - int index, - boolean isSelected, - boolean cellHasFocus) { - - Component result = super.getListCellRendererComponent( - list, value, index, isSelected, cellHasFocus); - Action action = ((JButton) value).getAction(); - setIcon((Icon) action.getValue(Action.LARGE_ICON_KEY)); - setText((String) action.getValue(Action.NAME)); - setToolTipText((String) action.getValue(Action.SHORT_DESCRIPTION)); - setEnabled(action.isEnabled()); - setBorder(border); - return result; - } -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/ApplicationColorHighlighter.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/ApplicationColorHighlighter.java deleted file mode 100644 index a68c3e2..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/ApplicationColorHighlighter.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.nuiton.jaxx.application.swing.util; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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.swingx.decorator.AbstractHighlighter; -import org.jdesktop.swingx.decorator.ComponentAdapter; -import org.jdesktop.swingx.decorator.HighlightPredicate; -import org.jdesktop.swingx.util.PaintUtils; - -import java.awt.Color; -import java.awt.Component; - -/** - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public class ApplicationColorHighlighter extends AbstractHighlighter { - - protected final Color color; - - protected final boolean foreground; - - public ApplicationColorHighlighter(HighlightPredicate predicate, Color color, boolean foreground) { - super(predicate); - this.color = color; - this.foreground = foreground; - } - - @Override - protected Component doHighlight(Component component, ComponentAdapter adapter) { - - if (foreground) { - component.setForeground(color); - - } else { - component.setBackground(color); - if (adapter.isSelected()) { - component.setForeground(PaintUtils.computeForeground(color)); - } - } - - return component; - } -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/ApplicationErrorHelper.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/ApplicationErrorHelper.java deleted file mode 100644 index 85fe4c9..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/ApplicationErrorHelper.java +++ /dev/null @@ -1,116 +0,0 @@ -package org.nuiton.jaxx.application.swing.util; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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.swingx.JXErrorPane; -import org.jdesktop.swingx.error.ErrorInfo; -import org.jdesktop.swingx.error.ErrorReporter; -import org.nuiton.csv.ImportRuntimeException; -import org.nuiton.jaxx.application.ApplicationBusinessException; -import org.nuiton.jaxx.application.swing.ApplicationUIContext; -import org.nuiton.jaxx.application.swing.action.ApplicationActionUI; - -import javax.swing.JOptionPane; - -import static org.nuiton.i18n.I18n.t; - -/** - * Helper to display errors. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public class ApplicationErrorHelper implements ErrorReporter { - - protected final ApplicationUIContext context; - - public ApplicationErrorHelper(ApplicationUIContext context) { - this.context = context; - } - - /** - * Display a user friendly error frame. - * - * @param message message for user - * @param cause exception cause - */ - public void showErrorDialog(String message, Throwable cause) { - - if (cause == null) { - JOptionPane.showMessageDialog(context.getMainUI(), "<html><body>" + message + "</body></html>", - t("jaxx.application.error.ui.business.error"), - JOptionPane.ERROR_MESSAGE); - } else if (cause instanceof ApplicationBusinessException) { - JOptionPane.showMessageDialog(context.getMainUI(), "<html><body>" + cause.getMessage() + "</body></html>", - t("jaxx.application.error.ui.business.error"), - JOptionPane.ERROR_MESSAGE); - } else if (cause instanceof ImportRuntimeException) { - JOptionPane.showMessageDialog(context.getMainUI(), cause.getMessage(), - t("jaxx.application.error.ui.business.error"), - JOptionPane.ERROR_MESSAGE); - } else { - - JXErrorPane pane = new JXErrorPane(); - ErrorInfo info = new ErrorInfo(t("jaxx.application.error.ui.other.error"), - t("jaxx.application.error.errorpane.htmlmessage", message), null, null, - cause, null, null); - pane.setErrorInfo(info); - pane.setErrorReporter(this); - ApplicationActionUI actionUI = context.getActionUI(); - if (actionUI != null) { - actionUI.close(); - } - JXErrorPane.showDialog(context.getMainUI(), pane); - } - - } - - /** - * Display a user friendly error frame. - * - * @param message message for user - */ - public void showErrorDialog(String message) { - showErrorDialog(message, null); - } - - @Override - public void reportError(ErrorInfo errorInfo) throws NullPointerException { - - showErrorDialog(errorInfo.getBasicErrorMessage(), errorInfo.getErrorException()); - } - - /** - * Display a user friendly warning frame. - * - * @param message message for user - */ - public void showWarningDialog(String message) { - - JOptionPane.showMessageDialog(context.getMainUI(), "<html><body>" + message + "</body></html>", - t("jaxx.application.error.ui.business.warning"), - JOptionPane.WARNING_MESSAGE); - - } - -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/ApplicationExceptionHandler.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/ApplicationExceptionHandler.java deleted file mode 100644 index c848962..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/ApplicationExceptionHandler.java +++ /dev/null @@ -1,89 +0,0 @@ -package org.nuiton.jaxx.application.swing.util; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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.nuiton.jaxx.runtime.swing.JAXXRuntimeException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.jaxx.application.ApplicationTechnicalException; - -/** - * Global exception handler. - * - * Catch all application uncaught and display it in a custom JoptionPane - * or JXErrorPane. - * - * See http://stackoverflow.com/a/4448569/1165234 for details. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public class ApplicationExceptionHandler implements Thread.UncaughtExceptionHandler { - - private static final Log log = - LogFactory.getLog(ApplicationExceptionHandler.class); - - final ApplicationErrorHelper errorHelper; - - public ApplicationExceptionHandler(ApplicationErrorHelper errorHelper) { - this.errorHelper = errorHelper; - } - - @Override - public void uncaughtException(Thread t, Throwable ex) { - handleException(t.getName(), ex); - } - - public void handle(Throwable thrown) { - // for EDT exceptions - handleException(Thread.currentThread().getName(), thrown); - } - - protected void handleException(String tname, Throwable ex) { - if (log.isErrorEnabled()) { - log.error("Global application exception [" + tname + "]", ex); - } - - Throwable cause = getCause(ex); - - showErrorDialog(cause.getMessage(), cause); - } - - protected Throwable getCause(Throwable ex) { - - Throwable cause = ex; - - if (cause instanceof ApplicationTechnicalException) { - cause = cause.getCause(); - } - - if (cause instanceof JAXXRuntimeException) { - cause = cause.getCause(); - } - return cause; - } - - public void showErrorDialog(String message, Throwable cause) { - errorHelper.showErrorDialog(message, cause); - } -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/ApplicationUIUtil.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/ApplicationUIUtil.java deleted file mode 100644 index 57cdac1..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/ApplicationUIUtil.java +++ /dev/null @@ -1,208 +0,0 @@ -package org.nuiton.jaxx.application.swing.util; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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.nuiton.jaxx.runtime.JAXXObject; -import org.nuiton.jaxx.runtime.swing.JTables; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jdesktop.swingx.JXTable; -import org.jdesktop.swingx.decorator.HighlightPredicate; -import org.jdesktop.swingx.decorator.Highlighter; -import org.nuiton.jaxx.application.ApplicationTechnicalException; -import org.nuiton.jaxx.application.swing.ApplicationUIContext; - -import javax.swing.JTable; -import java.awt.Color; -import java.awt.Desktop; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; - -import static org.nuiton.i18n.I18n.t; - -/** - * Useful ui methods. - * - * Created on 11/23/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public class ApplicationUIUtil { - - /** Logger. */ - private static final Log log = LogFactory.getLog(ApplicationUIUtil.class); - - protected ApplicationUIUtil() { - // avoid instanciate util class - } - - public static void setApplicationContext(JAXXObject ui, ApplicationUIContext context) { - ui.setContextValue(context, "applicationContext"); - } - - public static ApplicationUIContext getApplicationContext(JAXXObject ui) { - return ui.getContextValue(ApplicationUIContext.class, "applicationContext"); - } - - public static Highlighter newBackgroundColorHighlighter(HighlightPredicate predicate, Color color) { - return new ApplicationColorHighlighter(predicate, color, false); - } - - public static Highlighter newForegroundColorHighlighter(HighlightPredicate predicate, Color color) { - return new ApplicationColorHighlighter(predicate, color, true); - } - - public static void openLink(URL url) { - try { - openLink(url.toURI()); - } catch (URISyntaxException e) { - throw new ApplicationTechnicalException(t("jaxx.application.error.cannot.open.link", url), e); - } - } - - public static Desktop getDesktopForBrowse() { - - if (!Desktop.isDesktopSupported()) { - throw new ApplicationTechnicalException( - t("jaxx.application.error.desktop.not.supported")); - } - - Desktop desktop = Desktop.getDesktop(); - - if (!desktop.isSupported(Desktop.Action.BROWSE)) { - - throw new ApplicationTechnicalException( - t("jaxx.application.error.desktop.browse.not.supported")); - } - - return desktop; - } - - public static Desktop getDesktopForOpen() { - - if (!Desktop.isDesktopSupported()) { - throw new ApplicationTechnicalException( - t("jaxx.application.error.desktop.not.supported")); - } - - Desktop desktop = Desktop.getDesktop(); - - if (!desktop.isSupported(Desktop.Action.OPEN)) { - - throw new ApplicationTechnicalException( - t("jaxx.application.error.desktop.open.not.supported")); - } - - return desktop; - } - - public static void openLink(URI uri) { - - Desktop desktop = getDesktopForBrowse(); - - try { - - desktop.browse(uri); - } catch (Exception e) { - - throw new ApplicationTechnicalException( - t("jaxx.application.error.cannot.open.link", uri), e); - } - } - - public static Desktop getDesktopForMail() { - - if (!Desktop.isDesktopSupported()) { - throw new ApplicationTechnicalException( - t("jaxx.application.error.desktop.not.supported")); - } - - Desktop desktop = Desktop.getDesktop(); - - if (!desktop.isSupported(Desktop.Action.MAIL)) { - - throw new ApplicationTechnicalException( - t("jaxx.application.error.desktop.mail.not.supported")); - } - - return desktop; - } - - public static void mail(String subject, String body) { - - Desktop desktop = getDesktopForMail(); - - try { - URI mailtoURI = new URI("mailto", null, null, "subject=" + subject + "&body=" + body, null); - desktop.mail(mailtoURI); - - } catch (Exception e) { - - throw new ApplicationTechnicalException( - t("jaxx.application.error.cannot.mail"), e); - } - } - - /** - * @deprecated since 2.18, use instead {@link JTables#selectFirstCellOnFirstRowAndStopEditing(JTable)} - */ - @Deprecated - public static void selectFirstCellOnFirstRowAndStopEditing(JXTable table) { - - JTables.selectFirstCellOnFirstRowAndStopEditing(table); - - } - - /** - * @deprecated since 2.18, use instead {@link JTables#selectFirstCellOnLastRow(JTable)} - */ - @Deprecated - public static void selectFirstCellOnLastRow(JXTable table) { - - JTables.selectFirstCellOnLastRow(table); - - } - - /** - * @deprecated since 2.18, use instead {@link JTables#selectFirstCellOnRow(JTable, int, boolean)} - */ - @Deprecated - public static void selectFirstCellOnRow(JXTable table, int row, boolean stopEdit) { - - JTables.selectFirstCellOnRow(table, row, stopEdit); - - } - - /** - * @deprecated since 2.18, use instead {@link JTables#doSelectCell(JTable, int, int)} - */ - @Deprecated - public static void doSelectCell(JTable table, int rowIndex, int columnIndex) { - - JTables.doSelectCell(table, rowIndex, columnIndex); - - } - -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/Cancelable.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/Cancelable.java deleted file mode 100644 index 78719b8..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/Cancelable.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.nuiton.jaxx.application.swing.util; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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% - */ - -/** - * To cancel contract. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public interface Cancelable { - - void cancel(); -} diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/CloseableUI.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/CloseableUI.java deleted file mode 100644 index fec6ee7..0000000 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/CloseableUI.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.nuiton.jaxx.application.swing.util; - -/* - * #%L - * JAXX :: Application Swing - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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% - */ - -/** - * Place this contract on any handler of ui that need some check before closing. - * - * Contract to close an ui. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.8 - */ -public interface CloseableUI { - - /** - * Try to quit UI. - * - * @return {@code true} if ui is safe to quit, {@code false} otherwise - * (means must stay on it). - */ - boolean quitUI(); -} diff --git a/jaxx-application-swing/src/main/resources/i18n/jaxx-application-swing_en_GB.properties b/jaxx-application-swing/src/main/resources/i18n/jaxx-application-swing_en_GB.properties deleted file mode 100644 index 9643ccf..0000000 --- a/jaxx-application-swing/src/main/resources/i18n/jaxx-application-swing_en_GB.properties +++ /dev/null @@ -1,23 +0,0 @@ -jaxx.application.action.create.error= -jaxx.application.common.askBeforeDelete.help= -jaxx.application.common.askCancelEditBeforeLeaving.help= -jaxx.application.common.askCancelEditBeforeLeaving.title= -jaxx.application.common.askOverwriteFile.help= -jaxx.application.common.askOverwriteFile.message= -jaxx.application.common.askOverwriteFile.title= -jaxx.application.common.askSaveBeforeLeaving.help= -jaxx.application.common.askSaveBeforeLeaving.title= -jaxx.application.common.datefield.tip= -jaxx.application.error.cannot.mail= -jaxx.application.error.cannot.open.link= -jaxx.application.error.desktop.browse.not.supported= -jaxx.application.error.desktop.mail.not.supported= -jaxx.application.error.desktop.not.supported= -jaxx.application.error.desktop.open.not.supported= -jaxx.application.error.errorpane.htmlmessage= -jaxx.application.error.ui.business.error= -jaxx.application.error.ui.business.warning= -jaxx.application.error.ui.other.error= -jaxx.application.message.action.running= -jaxx.application.tab.customtab.close.label= -jaxx.application.title.actionUI= diff --git a/jaxx-application-swing/src/main/resources/i18n/jaxx-application-swing_es_ES.properties b/jaxx-application-swing/src/main/resources/i18n/jaxx-application-swing_es_ES.properties deleted file mode 100644 index 9643ccf..0000000 --- a/jaxx-application-swing/src/main/resources/i18n/jaxx-application-swing_es_ES.properties +++ /dev/null @@ -1,23 +0,0 @@ -jaxx.application.action.create.error= -jaxx.application.common.askBeforeDelete.help= -jaxx.application.common.askCancelEditBeforeLeaving.help= -jaxx.application.common.askCancelEditBeforeLeaving.title= -jaxx.application.common.askOverwriteFile.help= -jaxx.application.common.askOverwriteFile.message= -jaxx.application.common.askOverwriteFile.title= -jaxx.application.common.askSaveBeforeLeaving.help= -jaxx.application.common.askSaveBeforeLeaving.title= -jaxx.application.common.datefield.tip= -jaxx.application.error.cannot.mail= -jaxx.application.error.cannot.open.link= -jaxx.application.error.desktop.browse.not.supported= -jaxx.application.error.desktop.mail.not.supported= -jaxx.application.error.desktop.not.supported= -jaxx.application.error.desktop.open.not.supported= -jaxx.application.error.errorpane.htmlmessage= -jaxx.application.error.ui.business.error= -jaxx.application.error.ui.business.warning= -jaxx.application.error.ui.other.error= -jaxx.application.message.action.running= -jaxx.application.tab.customtab.close.label= -jaxx.application.title.actionUI= diff --git a/jaxx-application-swing/src/main/resources/i18n/jaxx-application-swing_fr_FR.properties b/jaxx-application-swing/src/main/resources/i18n/jaxx-application-swing_fr_FR.properties deleted file mode 100644 index 5af83ef..0000000 --- a/jaxx-application-swing/src/main/resources/i18n/jaxx-application-swing_fr_FR.properties +++ /dev/null @@ -1,23 +0,0 @@ -jaxx.application.action.create.error=Erreur à l'instanciation de l'action %s -jaxx.application.common.askBeforeDelete.help=Que voulez-vous faire ?<ul><li><strong>Annuler</strong> pour ne pas supprimer</li><li><strong>OK</strong> pour supprimer l'objet en question</li></ul> -jaxx.application.common.askCancelEditBeforeLeaving.help=Que voulez-vous faire ?<ul><li><strong>Annuler</strong> pour rester sur cet écran</li><li><strong>OK</strong> pour quitter l'écran en abandonnant les modifications</li></ul> -jaxx.application.common.askCancelEditBeforeLeaving.title=Modifications non enregistrées mais invalides -jaxx.application.common.askOverwriteFile.help=Que voulez-vous faire ?<ul><li><strong>Annuler</strong> pour ne pas écraser le fichier et annuler l'opération</li><li><strong>Oui</strong> pour écraser le fichier et continuer l'opération</li></ul> -jaxx.application.common.askOverwriteFile.message=Le fichier %s existe déjà, confirmer pour l'écraser -jaxx.application.common.askOverwriteFile.title=Confirmer l'écrasement d'un fichier... -jaxx.application.common.askSaveBeforeLeaving.help=Que voulez-vous faire?<ul><li><strong>Annuler</strong> pour rester sur cet écran</li><li><strong>Non</strong> pour quitter l'écran en abandonnant les modifications en cours</li><li><strong>Oui</strong> pour quitter l'écran après enregistrement des modifications</li></ul> -jaxx.application.common.askSaveBeforeLeaving.title=Modifications non enregistrées -jaxx.application.common.datefield.tip=Format attendu \: %s -jaxx.application.error.cannot.mail=Erreur lors de l'ouverture du client mail -jaxx.application.error.cannot.open.link=Impossible d'ouvrir le fichier %s -jaxx.application.error.desktop.browse.not.supported=Le navigateur n'a pas pu être ouvert. Vérifiez que vous avez défini un navigateur par défaut dans votre système -jaxx.application.error.desktop.mail.not.supported=Le client mail n'a pas pu être ouvert. Vérifiez que vous avez défini un client mail par défaut dans votre système -jaxx.application.error.desktop.not.supported=Votre système ne permet pas d'ouvrir des liens ou fichiers en dehors de l'application -jaxx.application.error.desktop.open.not.supported=Le fichier n'a pas pu être ouvert. Vérifiez que vous avez défini un logiciel par défaut dans votre système pour ce type de fichier -jaxx.application.error.errorpane.htmlmessage=<html><body><b>Une erreur s'est produite</b>\:<br/>%s</body></html> -jaxx.application.error.ui.business.error=Erreur -jaxx.application.error.ui.business.warning=Avertissement -jaxx.application.error.ui.other.error=Erreur -jaxx.application.message.action.running=<html>Action <strong>%s</strong> en cours d'exécution...</html> -jaxx.application.tab.customtab.close.label=Fermer l'onglet -jaxx.application.title.actionUI=%s - v %s [%s] diff --git a/jaxx-application-swing/src/site/site.xml b/jaxx-application-swing/src/site/site.xml deleted file mode 100644 index 2975066..0000000 --- a/jaxx-application-swing/src/site/site.xml +++ /dev/null @@ -1,44 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - #%L - JAXX :: Application Swing - %% - Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - %% - 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% - --> - -<project name="${project.name}" - xmlns="http://maven.apache.org/DECORATION/1.4.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/DECORATION/1.4.0 http://maven.apache.org/xsd/decoration-1.4.0.xsd"> - - <bannerLeft> - <name>${project.name}</name> - <src>${siteCommonResourcesUrl}/images/logos/jaxx-logo.png</src> - <href>index.html</href> - </bannerLeft> - - <body> - - <breadcrumbs> - <item name="${project.name}" href="index.html"/> - </breadcrumbs> - - <menu ref="parent"/> - - <menu ref="reports"/> - - </body> -</project> diff --git a/pom.xml b/pom.xml index e13d74d..bdd0ef9 100644 --- a/pom.xml +++ b/pom.xml @@ -47,8 +47,6 @@ <module>jaxx-widgets-datetime</module> <module>jaxx-widgets-gis</module> <module>jaxx-config</module> - <module>jaxx-application-api</module> - <module>jaxx-application-swing</module> </modules> <developers> -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository jaxx. See https://gitlab.nuiton.org/nuiton/jaxx.git commit 5bd62db7890aada615519b35fbc81664600914e8 Author: Tony CHEMIT <dev@tchemit.fr> Date: Sat Dec 31 13:06:27 2016 +0100 removing deprecated widgets (See #4103) --- .../component/jaxx/editor/NumberEditorDemo.jaxx | 113 ---- .../jaxx/editor/NumberEditorDemoModel.java | 62 --- .../jaxx/editor/SimpleTimeEditorDemo.jaxx | 81 --- .../jaxx/editor/SimpleTimeEditorDemo.jcss | 37 -- .../jaxx/editor/SimpleTimeEditorDemoHandler.java | 47 -- .../jaxx/editor/SimpleTimeEditorDemoModel.java | 54 -- .../demo/component/jaxx/editor/TimeEditorDemo.jaxx | 84 --- .../demo/component/jaxx/editor/TimeEditorDemo.jcss | 47 -- .../component/jaxx/editor/TimeEditorDemoModel.java | 53 -- .../component/jaxx/editor/gis/CoordinateDemo.jaxx | 97 ---- .../component/jaxx/editor/gis/CoordinateDemo.jcss | 146 ----- .../jaxx/editor/gis/CoordinateDemoHandler.java | 154 ------ .../jaxx/editor/gis/CoordinateDemoModel.java | 64 --- .../nuiton/jaxx/demo/tree/DemoDataProvider.java | 10 +- .../jaxx/runtime/swing/editor/KeyStrokeEditor.java | 14 +- .../jaxx/runtime/swing/editor/NumberEditor.jaxx | 205 ------- .../runtime/swing/editor/NumberEditorHandler.java | 591 --------------------- .../runtime/swing/editor/NumberEditorPopup.jcss | 47 -- .../runtime/swing/editor/SimpleTimeEditor.jaxx | 61 --- .../runtime/swing/editor/SimpleTimeEditor.jcss | 42 -- .../swing/editor/SimpleTimeEditorHandler.java | 283 ---------- .../swing/editor/SimpleTimeEditorModel.java | 109 ---- .../jaxx/runtime/swing/editor/TimeEditor.jaxx | 87 --- .../jaxx/runtime/swing/editor/TimeEditor.jcss | 58 -- .../runtime/swing/editor/TimeEditorHandler.java | 319 ----------- .../runtime/swing/editor/gis/DmdCoordinate.java | 336 ------------ .../swing/editor/gis/DmdCoordinateConverter.java | 143 ----- .../swing/editor/gis/DmdCoordinateEditor.jaxx | 58 -- .../swing/editor/gis/DmdCoordinateEditor.jcss | 38 -- .../editor/gis/DmdCoordinateEditorHandler.java | 303 ----------- .../swing/editor/gis/DmdCoordinateEditorModel.java | 122 ----- .../runtime/swing/editor/gis/DmsCoordinate.java | 364 ------------- .../swing/editor/gis/DmsCoordinateConverter.java | 144 ----- .../swing/editor/gis/DmsCoordinateEditor.jaxx | 59 -- .../swing/editor/gis/DmsCoordinateEditor.jcss | 38 -- .../editor/gis/DmsCoordinateEditorHandler.java | 314 ----------- .../swing/editor/gis/DmsCoordinateEditorModel.java | 122 ----- .../editor/gis/MaskFormatterFromConverter.java | 75 --- .../services/org.nuiton.converter.NuitonConverter | 2 - .../editor/gis/DmdCoordinateConverterTest.java | 102 ---- .../swing/editor/gis/DmdCoordinateEditorTest.java | 204 ------- .../swing/editor/gis/DmdCoordinateTest.java | 136 ----- .../editor/gis/DmsCoordinateConverterTest.java | 105 ---- .../swing/editor/gis/DmsCoordinateEditorTest.java | 206 ------- .../swing/editor/gis/DmsCoordinateTest.java | 131 ----- jaxx-widgets/src/test/resources/log4j.properties | 30 -- 46 files changed, 7 insertions(+), 5890 deletions(-) diff --git a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx b/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx deleted file mode 100644 index 4063fef..0000000 --- a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx +++ /dev/null @@ -1,113 +0,0 @@ -<!-- - #%L - JAXX :: Demo - %% - Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - %% - 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% - --> - -<org.nuiton.jaxx.demo.DemoPanel layout='{new BorderLayout()}'> - - <import> - org.nuiton.jaxx.runtime.swing.editor.NumberEditor - static org.nuiton.i18n.I18n.t - </import> - - <!-- model --> - <NumberEditorDemoModel id='demoModel'/> - - <script><![CDATA[ - -public void changeNumberPattern() { - editor.setNumberPattern(numberPattern.getText()); -} - -void $afterCompleteSetup() { - editor.init(); - changeNumberPattern(); -} - -]]> - </script> - - <Table insets='0' fill='both' weightx='1' constraints='BorderLayout.NORTH'> - <row> - <cell> - <JPanel - border='{new TitledBorder(t("jaxxdemo.numbereditor.configuration"))}' - layout='{new GridLayout(0,1)}'> - - <JCheckBox id='useFloat' - text='jaxxdemo.numbereditor.useFloat' - selected='true'/> - - <JCheckBox id='useSign' - text='jaxxdemo.numbereditor.useSign' - selected='true'/> - - <JCheckBox id='showPopupButton' - text='jaxxdemo.numbereditor.showPopupButton' - selected='true'/> - - <JCheckBox id='showResetButton' - text='jaxxdemo.numbereditor.showReset' - selected='true'/> - - <JCheckBox id='autoPopup' - text='jaxxdemo.numbereditor.autoPopup' - selected='false'/> - <JPanel - border='{new TitledBorder(t("jaxxdemo.numbereditor.numberPattern.configuration"))}' - layout='{new GridLayout(1,0)}'> - <JTextField id='numberPattern' text='{"\\d{0,3}"}'/> - <JButton id='applyNumberPattern' - text='jaxxdemo.numbereditor.applyNumberPattern' - onActionPerformed='changeNumberPattern();'/> - </JPanel> - </JPanel> - </cell> - </row> - <row> - <cell> - <org.nuiton.jaxx.runtime.swing.editor.NumberEditor id='editor' - constructorParams='this' - bean='{demoModel}' - property='{useFloat.isSelected() ? "floatProperty" : "integerProperty"}' - useFloat='{useFloat.isSelected()}' - useSign='{useSign.isSelected()}' - autoPopup='{autoPopup.isSelected()}' - showPopupButton='{showPopupButton.isSelected()}' - showReset='{showResetButton.isSelected()}'/> - </cell> - </row> - <row> - <cell> - <JPanel border='{new TitledBorder(t("jaxxdemo.numbereditor.model"))}' - layout='{new GridLayout(0,1)}'> - <JLabel - text='{t("jaxxdemo.numbereditor.model.numberPattern", editor.getNumberPattern())}'/> - <JLabel - text='{t("jaxxdemo.numbereditor.model.int", demoModel.getIntegerProperty())}'/> - <JLabel - text='{t("jaxxdemo.numbereditor.model.float", demoModel.getFloatProperty())}'/> - - </JPanel> - </cell> - </row> - </Table> -</org.nuiton.jaxx.demo.DemoPanel> - diff --git a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/NumberEditorDemoModel.java b/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/NumberEditorDemoModel.java deleted file mode 100644 index 86f729e..0000000 --- a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/NumberEditorDemoModel.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * #%L - * JAXX :: Demo - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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% - */ - -package org.nuiton.jaxx.demo.component.jaxx.editor; - -import org.jdesktop.beans.AbstractSerializableBean; - -/** - * @author Tony Chemit - dev@tchemit.fr - * @since 1.5 - */ -public class NumberEditorDemoModel extends AbstractSerializableBean { - - public static final String INTEGER_PROPERTY = "integerProperty"; - - public static final String FLOAT_PROPERTY = "floatProperty"; - - private static final long serialVersionUID = 1L; - - protected int integerProperty; - - protected float floatProperty; - - public float getFloatProperty() { - return floatProperty; - } - - public int getIntegerProperty() { - return integerProperty; - } - - public void setFloatProperty(float floatProperty) { - float old = this.floatProperty; - this.floatProperty = floatProperty; - firePropertyChange(FLOAT_PROPERTY, old, floatProperty); - } - - public void setIntegerProperty(int integerProperty) { - int old = this.integerProperty; - this.integerProperty = integerProperty; - firePropertyChange(INTEGER_PROPERTY, old, integerProperty); - } -} diff --git a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/SimpleTimeEditorDemo.jaxx b/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/SimpleTimeEditorDemo.jaxx deleted file mode 100644 index d4dbd14..0000000 --- a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/SimpleTimeEditorDemo.jaxx +++ /dev/null @@ -1,81 +0,0 @@ -<!-- - #%L - JAXX :: Demo - %% - Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - %% - 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% - --> -<org.nuiton.jaxx.demo.DemoPanel layout='{new BorderLayout()}'> - - <import> - org.nuiton.jaxx.runtime.swing.editor.SimpleTimeEditor - - static org.nuiton.i18n.I18n.t - </import> - - <!-- model --> - <SimpleTimeEditorDemoModel id='demoModel'/> - - <Table insets='0' fill='both' weightx='1' constraints='BorderLayout.NORTH'> - <row> - <cell> - <JPanel id="configPanel"> - - <!--JCheckBox id='useFloat' - text='jaxxdemo.numbereditor.useFloat' - selected='true'/> - - <JCheckBox id='useSign' - text='jaxxdemo.numbereditor.useSign' - selected='true'/> - - <JCheckBox id='showPopupButton' - text='jaxxdemo.numbereditor.showPopupButton' - selected='true'/> - - <JCheckBox id='showResetButton' - text='jaxxdemo.numbereditor.showReset' - selected='true'/> - - <JCheckBox id='autoPopup' - text='jaxxdemo.numbereditor.autoPopup' - selected='false'/--> - - </JPanel> - </cell> - </row> - <row> - <cell> - <SimpleTimeEditor id='editor' constructorParams='this' - border='{new TitledBorder(t("jaxxdemo.timeeditor.editor"))}'/> - </cell> - </row> - <row> - <cell> - - <JPanel id='resultPane'> - - <JLabel constraints='BorderLayout.CENTER' - text='{t("jaxxdemo.timeeditor.value", demoModel.getTime())}'/> - </JPanel> - - </cell> - </row> - </Table> - - -</org.nuiton.jaxx.demo.DemoPanel> diff --git a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/SimpleTimeEditorDemo.jcss b/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/SimpleTimeEditorDemo.jcss deleted file mode 100644 index b58e6a4..0000000 --- a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/SimpleTimeEditorDemo.jcss +++ /dev/null @@ -1,37 +0,0 @@ -/* - * #%L - * JAXX :: Demo - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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% - */ -#configPanel { - border:{new TitledBorder(t("jaxxdemo.numbereditor.configuration"))}; - layout:{new GridLayout(0,1)}; -} - -#editor { - property:"time"; - border:{new TitledBorder(t("jaxxdemo.timeeditor.editor"))}; - bean:{demoModel}; - date:{demoModel.getTime()}; -} - -#resultPane { - border:{new TitledBorder(t("jaxxdemo.timeeditor.model"))}; - layout:{new BorderLayout()}; -} diff --git a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/SimpleTimeEditorDemoHandler.java b/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/SimpleTimeEditorDemoHandler.java deleted file mode 100644 index 6839ce3..0000000 --- a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/SimpleTimeEditorDemoHandler.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.nuiton.jaxx.demo.component.jaxx.editor; - -/* - * #%L - * JAXX :: Demo - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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.nuiton.jaxx.runtime.spi.UIHandler; - -/** - * Created on 11/22/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.6 - */ -public class SimpleTimeEditorDemoHandler implements UIHandler<SimpleTimeEditorDemo> { - @Override - public void beforeInit(SimpleTimeEditorDemo ui) { - - } - - @Override - public void afterInit(SimpleTimeEditorDemo ui) { - // init time editor - ui.editor.init(); - - // set current time in model - ui.demoModel.setTime(new java.util.Date()); - } -} diff --git a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/SimpleTimeEditorDemoModel.java b/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/SimpleTimeEditorDemoModel.java deleted file mode 100644 index 9ed6381..0000000 --- a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/SimpleTimeEditorDemoModel.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * #%L - * JAXX :: Demo - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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% - */ -package org.nuiton.jaxx.demo.component.jaxx.editor; - -import org.nuiton.jaxx.runtime.swing.editor.SimpleTimeEditor; -import org.jdesktop.beans.AbstractSerializableBean; - -import java.util.Date; - -/** - * Model of a bean using the {@link SimpleTimeEditor}. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.6 - */ -public class SimpleTimeEditorDemoModel extends AbstractSerializableBean { - - public static final String TIME_PROPERTY = "time"; - - private static final long serialVersionUID = 1L; - - protected Date time; - - public Date getTime() { - return time; - } - - public void setTime(Date time) { - Date old = this.time; - this.time = time; - firePropertyChange(TIME_PROPERTY, old, time); - } - - -} diff --git a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/TimeEditorDemo.jaxx b/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/TimeEditorDemo.jaxx deleted file mode 100644 index 268ff2a..0000000 --- a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/TimeEditorDemo.jaxx +++ /dev/null @@ -1,84 +0,0 @@ -<!-- - #%L - JAXX :: Demo - %% - Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - %% - 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% - --> -<org.nuiton.jaxx.demo.DemoPanel layout='{new BorderLayout()}'> - - <import> - org.nuiton.jaxx.runtime.swing.editor.TimeEditor - static org.nuiton.i18n.I18n.t - </import> - - <!-- model --> - <org.nuiton.jaxx.demo.component.jaxx.editor.TimeEditorDemoModel id='demoModel'/> - - <script><![CDATA[ - -void $afterCompleteSetup() { - - // init time editor - editor.init(); - - // set current time in model - demoModel.setTime(new java.util.Date()); -} -]]> - </script> - - - <Table insets='0' fill='both' weightx='1' constraints='BorderLayout.NORTH'> - <row> - <cell> - <JPanel id="configPanel"> - - <JPanel layout='{new BorderLayout()}'> - - <JLabel id='labelConfigLabel' constraints='BorderLayout.WEST'/> - - <JTextField id='labelConfig' constraints='BorderLayout.CENTER'/> - </JPanel> - - </JPanel> - </cell> - </row> - <row> - <cell> - <org.nuiton.jaxx.runtime.swing.editor.TimeEditor id='editor' constructorParams='this' property='time' - border='{new TitledBorder(t("jaxxdemo.timeeditor.editor"))}' - bean='{demoModel}' - date="{demoModel.getTime()}" - label="{labelConfig.getText()}"/> - </cell> - </row> - <row> - <cell> - - <JPanel id='resultPane'> - - <JLabel constraints='BorderLayout.CENTER' - text='{t("jaxxdemo.timeeditor.value", demoModel.getTime())}'/> - </JPanel> - - </cell> - </row> - </Table> - - -</org.nuiton.jaxx.demo.DemoPanel> diff --git a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/TimeEditorDemo.jcss b/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/TimeEditorDemo.jcss deleted file mode 100644 index 5483202..0000000 --- a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/TimeEditorDemo.jcss +++ /dev/null @@ -1,47 +0,0 @@ -/* - * #%L - * JAXX :: Demo - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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% - */ -#configPanel { - border:{new TitledBorder(t("jaxxdemo.numbereditor.configuration"))}; - layout:{new GridLayout(0,1)}; -} - -#labelConfigLabel { - text:"jaxxdemo.timeeditor.label"; -} - -#labelConfig { - text:{t("jaxxdemo.timeeditor.editor")}; -} - -/*FIXME tchemit 2010-09-02 make this works -#editor { - property:"time"; - border:{new TitledBorder(t("jaxxdemo.timeeditor.editor"))}; - bean:{demoModel}; - date:{demoModel.getTime()}; - label:{labelConfig.getText()}; -}*/ - -#resultPane { - border:{new TitledBorder(t("jaxxdemo.timeeditor.model"))}; - layout:{new BorderLayout()}; -} diff --git a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/TimeEditorDemoModel.java b/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/TimeEditorDemoModel.java deleted file mode 100644 index 95a5549..0000000 --- a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/TimeEditorDemoModel.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * #%L - * JAXX :: Demo - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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% - */ -package org.nuiton.jaxx.demo.component.jaxx.editor; - -import org.nuiton.jaxx.runtime.swing.editor.TimeEditor; -import org.jdesktop.beans.AbstractSerializableBean; - -import java.util.Date; - -/** - * Model of a bean using the {@link TimeEditor}. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.2 - */ -public class TimeEditorDemoModel extends AbstractSerializableBean { - - public static final String TIME_PROPERTY = "time"; - - private static final long serialVersionUID = 1L; - - protected Date time; - - public Date getTime() { - return time; - } - - public void setTime(Date time) { - Date old = this.time; - this.time = time; - firePropertyChange(TIME_PROPERTY, old, time); - } - -} diff --git a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/gis/CoordinateDemo.jaxx b/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/gis/CoordinateDemo.jaxx deleted file mode 100644 index 99ba05d..0000000 --- a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/gis/CoordinateDemo.jaxx +++ /dev/null @@ -1,97 +0,0 @@ -<!-- - #%L - JAXX :: Demo - %% - Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - %% - 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% - --> -<org.nuiton.jaxx.demo.DemoPanel layout='{new BorderLayout()}'> - - <import> - org.nuiton.jaxx.runtime.swing.editor.NumberEditor - org.nuiton.jaxx.runtime.swing.editor.gis.DmsCoordinate - org.nuiton.jaxx.runtime.swing.editor.gis.DmsCoordinateEditor - org.nuiton.jaxx.runtime.swing.editor.gis.DmdCoordinate - org.nuiton.jaxx.runtime.swing.editor.gis.DmdCoordinateEditor - </import> - - <!-- model --> - <CoordinateDemoModel id='model'/> - - <!-- internal editor models --> - <DmsCoordinate id='latitudeDms'/> - <DmdCoordinate id='latitudeDmd'/> - <Float id='latitudeDd' javaBean='null'/> - <DmsCoordinate id='longitudeDms'/> - <DmdCoordinate id='longitudeDmd'/> - <Float id='longitudeDd' javaBean='null'/> - - <Table insets='0' fill='both' weightx='1' constraints='BorderLayout.NORTH'> - <row> - <cell> - <JPanel id='config' layout='{new GridLayout(1,0)}'> - - <JPanel id='configLatitude' layout='{new GridLayout(0,1)}'> - <JCheckBox id='latitudeShowReset'/> - <JRadioButton id='latitudeUseDms' - onActionPerformed='handler.useLatitudeDmsEditor()'/> - <JRadioButton id='latitudeUseDmd' - onActionPerformed='handler.useLatitudeDmdEditor()'/> - <JRadioButton id='latitudeUseDd' - onActionPerformed='handler.useLatitudeDdEditor()'/> - </JPanel> - <JPanel id='configLongitude' layout='{new GridLayout(0,1)}'> - <JCheckBox id='longitudeShowReset'/> - <JRadioButton id='longitudeUseDms' - onActionPerformed='handler.useLongitudeDmsEditor()'/> - <JRadioButton id='longitudeUseDmd' - onActionPerformed='handler.useLongitudeDmdEditor()'/> - <JRadioButton id='longitudeUseDd' - onActionPerformed='handler.useLongitudeDdEditor()'/> - </JPanel> - </JPanel> - </cell> - </row> - <row> - <cell> - <JPanel layout='{new GridLayout(1,0)}'> - <JPanel id='latitudePane' layout='{new GridLayout(0,1)}'> - <DmsCoordinateEditor id='latitudeDmsEditor' constructorParams='this'/> - <DmdCoordinateEditor id='latitudeDmdEditor' constructorParams='this'/> - <NumberEditor id='latitudeDdEditor' constructorParams='this'/> - </JPanel> - <JPanel id='longitudePane' layout='{new GridLayout(0,1)}'> - <DmsCoordinateEditor id='longitudeDmsEditor' - constructorParams='this'/> - <DmdCoordinateEditor id='longitudeDmdEditor' - constructorParams='this'/> - <NumberEditor id='longitudeDdEditor' constructorParams='this'/> - </JPanel> - </JPanel> - </cell> - </row> - <row> - <cell> - <JPanel id='result' layout='{new GridLayout(0,1)}'> - <JLabel id='resultLatitude'/> - <JLabel id='resultLongitude'/> - - </JPanel> - </cell> - </row> - </Table> -</org.nuiton.jaxx.demo.DemoPanel> diff --git a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/gis/CoordinateDemo.jcss b/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/gis/CoordinateDemo.jcss deleted file mode 100644 index b7f5505..0000000 --- a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/gis/CoordinateDemo.jcss +++ /dev/null @@ -1,146 +0,0 @@ -/* - * #%L - * JAXX :: Demo - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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% - */ - -#config { - border: {new TitledBorder(t("jaxxdemo.numbereditor.configuration"))}; -} - -#latitudeShowReset { - text: "jaxxdemo.coordinate.showReset"; - selected: true; -} - -#latitudeUseDms { - text: "jaxxdemo.coordinate.latitudeDms"; - value: DMS; - buttonGroup: latitudeEditor; - selected: true; -} - -#latitudeUseDmd { - text: "jaxxdemo.coordinate.latitudeDmd"; - value: DMD; - buttonGroup: latitudeEditor; -} - -#latitudeUseDd { - text: "jaxxdemo.coordinate.latitudeDd"; - value: "DD"; - buttonGroup: latitudeEditor; - selected: true; -} - -#longitudeShowReset { - text: "jaxxdemo.numbereditor.showReset"; - selected: true; -} - -#longitudeUseDms { - text: "jaxxdemo.coordinate.longitudeDms"; - value: DMS; - buttonGroup: longitudeEditor; - selected: true; -} - -#longitudeUseDmd { - text: "jaxxdemo.coordinate.longitudeDmd"; - value: DMD; - buttonGroup: longitudeEditor; -} - -#longitudeUseDd { - text: "jaxxdemo.coordinate.longitudeDd"; - value: "DD"; - buttonGroup: longitudeEditor; -} - -#latitudePane { - border: {new TitledBorder(t("jaxxdemo.coordinate.latitude"))}; -} - -#latitudeDmsEditor { - bean: {latitudeDms}; - propertySign: sign; - propertyDegree: degree; - propertyMinute: minute; - propertySecond: second; - showReset: {latitudeShowReset.isSelected()}; -} - -#latitudeDmdEditor { - bean: {latitudeDmd}; - propertySign: sign; - propertyDegree: degree; - propertyMinute: minute; - propertyDecimal: decimal; - showReset: {latitudeShowReset.isSelected()}; -} - -#latitudeDdEditor { - bean: {this}; - property: latitudeDd; - showReset: {latitudeShowReset.isSelected()}; - useFloat: true; - useSign: true; -} - -#longitudePane { - border: {new TitledBorder(t("jaxxdemo.coordinate.longitude"))}; -} - -#longitudeDmsEditor { - bean: {longitudeDms}; - propertySign: sign; - propertyDegree: degree; - propertyMinute: minute; - propertySecond: second; - showReset: {longitudeShowReset.isSelected()}; -} - -#longitudeDmdEditor { - bean: {longitudeDmd}; - propertySign: sign; - propertyDegree: degree; - propertyMinute: minute; - propertyDecimal: decimal; - showReset: {longitudeShowReset.isSelected()}; -} - -#longitudeDdEditor { - bean: {this}; - property: longitudeDd; - showReset: {longitudeShowReset.isSelected()}; - useFloat: true; - useSign: true; -} - -#result { - border: {new TitledBorder(t("jaxxdemo.coordinate.result"))}; -} - -#resultLatitude { - text: {handler.getLatitudeText(model.getLatitude())}; -} - -#resultLongitude { - text: {handler.getLongitudeText(model.getLongitude())}; -} diff --git a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/gis/CoordinateDemoHandler.java b/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/gis/CoordinateDemoHandler.java deleted file mode 100644 index bc0d149..0000000 --- a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/gis/CoordinateDemoHandler.java +++ /dev/null @@ -1,154 +0,0 @@ -package org.nuiton.jaxx.demo.component.jaxx.editor.gis; - -/* - * #%L - * JAXX :: Demo - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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.nuiton.jaxx.runtime.spi.UIHandler; -import org.nuiton.jaxx.runtime.swing.editor.gis.DmdCoordinate; -import org.nuiton.jaxx.runtime.swing.editor.gis.DmsCoordinate; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import static org.nuiton.i18n.I18n.t; - -/** - * Created on 11/26/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.6 - */ -public class CoordinateDemoHandler implements UIHandler<CoordinateDemo> { - - /** Logger. */ - private static final Log log = - LogFactory.getLog(CoordinateDemoHandler.class); - - private CoordinateDemo ui; - - @Override - public void beforeInit(CoordinateDemo ui) { - if (log.isInfoEnabled()) { - log.info("BeforeInit " + ui.getName()); - } - this.ui = ui; - } - - @Override - public void afterInit(CoordinateDemo ui) { - - if (log.isInfoEnabled()) { - log.info("AfterInit " + ui.getName()); - } - - ui.getLatitudeDmsEditor().init(false); - ui.getLatitudeDmdEditor().init(false); - ui.getLatitudeDdEditor().init(); - ui.getLongitudeDmsEditor().init(true); - ui.getLongitudeDmdEditor().init(true); - ui.getLongitudeDdEditor().init(); - - ui.getLatitudeDms().addPropertyChangeListener(evt -> { - DmsCoordinate source = (DmsCoordinate) evt.getSource(); - getModel().setLatitude(source.toDecimal()); - }); - ui.getLatitudeDmd().addPropertyChangeListener(evt -> { - DmdCoordinate source = (DmdCoordinate) evt.getSource(); - getModel().setLatitude(source.toDecimal()); - }); - - ui.addPropertyChangeListener("latitudeDd", evt -> { - Float source = (Float) evt.getNewValue(); - getModel().setLatitude(source); - }); - - ui.getLongitudeDms().addPropertyChangeListener(evt -> { - DmsCoordinate source = (DmsCoordinate) evt.getSource(); - getModel().setLongitude(source.toDecimal()); - }); - ui.getLongitudeDmd().addPropertyChangeListener(evt -> { - DmdCoordinate source = (DmdCoordinate) evt.getSource(); - getModel().setLongitude(source.toDecimal()); - }); - - ui.addPropertyChangeListener("longitudeDd", evt -> { - Float source = (Float) evt.getNewValue(); - getModel().setLongitude(source); - }); - - useLatitudeDmsEditor(); - useLongitudeDmsEditor(); - } - - public void useLatitudeDmsEditor() { - ui.getLatitudeDmsEditor().setValue(DmsCoordinate.valueOf(getModel().getLatitude())); - ui.getLatitudeDmsEditor().setEnabled(true); - ui.getLatitudeDmdEditor().setEnabled(false); - ui.getLatitudeDdEditor().setEnabled(false); - } - - public void useLatitudeDmdEditor() { - ui.getLatitudeDmdEditor().setValue(DmdCoordinate.valueOf(getModel().getLatitude())); - ui.getLatitudeDmsEditor().setEnabled(false); - ui.getLatitudeDmdEditor().setEnabled(true); - ui.getLatitudeDdEditor().setEnabled(false); - } - - public void useLatitudeDdEditor() { - ui.getLatitudeDdEditor().setModel(getModel().getLatitude()); - ui.getLatitudeDmsEditor().setEnabled(false); - ui.getLatitudeDmdEditor().setEnabled(false); - ui.getLatitudeDdEditor().setEnabled(true); - } - - public void useLongitudeDmsEditor() { - ui.getLongitudeDmsEditor().setValue(DmsCoordinate.valueOf(getModel().getLongitude())); - ui.getLongitudeDmsEditor().setEnabled(true); - ui.getLongitudeDmdEditor().setEnabled(false); - ui.getLongitudeDdEditor().setEnabled(false); - } - - public void useLongitudeDmdEditor() { - ui.getLongitudeDmdEditor().setValue(DmdCoordinate.valueOf(getModel().getLongitude())); - ui.getLongitudeDmsEditor().setEnabled(false); - ui.getLongitudeDmdEditor().setEnabled(true); - ui.getLongitudeDdEditor().setEnabled(false); - } - - public void useLongitudeDdEditor() { - ui.getLongitudeDdEditor().setModel(getModel().getLongitude()); - ui.getLongitudeDmsEditor().setEnabled(false); - ui.getLongitudeDmdEditor().setEnabled(false); - ui.getLongitudeDdEditor().setEnabled(true); - } - - public String getLatitudeText(Float latitude) { - return t("jaxxdemo.coordinate.result.latitude", latitude); - } - - public String getLongitudeText(Float longitude) { - return t("jaxxdemo.coordinate.result.longitude", longitude); - } - - protected CoordinateDemoModel getModel() { - return ui.getModel(); - } -} diff --git a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/gis/CoordinateDemoModel.java b/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/gis/CoordinateDemoModel.java deleted file mode 100644 index 4a240df..0000000 --- a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/gis/CoordinateDemoModel.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.nuiton.jaxx.demo.component.jaxx.editor.gis; - -/* - * #%L - * JAXX :: Demo - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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; - -/** - * Created on 11/26/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.6 - */ -public class CoordinateDemoModel extends AbstractSerializableBean { - - public static final String PROPERTY_LONGITUDE = "longitude"; - - public static final String PROPERTY_LATITUDE = "latitude"; - - private static final long serialVersionUID = 1L; - - protected Float latitude; - - protected Float longitude; - - public Float getLongitude() { - return longitude; - } - - public void setLongitude(Float longitude) { - Object oldValue = getLongitude(); - this.longitude = longitude; - firePropertyChange(PROPERTY_LONGITUDE, oldValue, longitude); - } - - public Float getLatitude() { - return latitude; - } - - public void setLatitude(Float latitude) { - Object oldValue = getLatitude(); - this.latitude = latitude; - firePropertyChange(PROPERTY_LATITUDE, oldValue, latitude); - } -} diff --git a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/tree/DemoDataProvider.java b/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/tree/DemoDataProvider.java index 4d83a5d..890460e 100644 --- a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/tree/DemoDataProvider.java +++ b/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/tree/DemoDataProvider.java @@ -22,7 +22,6 @@ package org.nuiton.jaxx.demo.tree; -import org.nuiton.jaxx.runtime.swing.nav.NavDataProvider; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.jaxx.demo.component.jaxx.BoxedDecoratorDemo; @@ -35,8 +34,6 @@ import org.nuiton.jaxx.demo.component.jaxx.editor.DatePickerDemo; import org.nuiton.jaxx.demo.component.jaxx.editor.FileEditorDemo; import org.nuiton.jaxx.demo.component.jaxx.editor.I18nEditorDemo; import org.nuiton.jaxx.demo.component.jaxx.editor.ListSelectorDemo; -import org.nuiton.jaxx.demo.component.jaxx.editor.SimpleTimeEditorDemo; -import org.nuiton.jaxx.demo.component.jaxx.editor.gis.CoordinateDemo; import org.nuiton.jaxx.demo.component.jaxx.widgets.datetime.DateTimeEditorDemo; import org.nuiton.jaxx.demo.component.jaxx.widgets.datetime.TimeEditorDemo; import org.nuiton.jaxx.demo.component.jaxx.widgets.gis.CoordinatesEditorDemo; @@ -69,6 +66,7 @@ import org.nuiton.jaxx.demo.feature.validation.simple.SimpleBeanValidationByTabl import org.nuiton.jaxx.demo.fun.CalculatorDemo; import org.nuiton.jaxx.demo.fun.CounterDemo; import org.nuiton.jaxx.demo.fun.LabelStyleDemo; +import org.nuiton.jaxx.runtime.swing.nav.NavDataProvider; import java.util.Arrays; import java.util.HashMap; @@ -183,9 +181,6 @@ public class DemoDataProvider implements NavDataProvider { ); addMapping(n("jaxxdemo.component.jaxx.editor"), - org.nuiton.jaxx.demo.component.jaxx.editor.TimeEditorDemo.class, - SimpleTimeEditorDemo.class, - org.nuiton.jaxx.demo.component.jaxx.editor.NumberEditorDemo.class, ComboEditorDemo.class, I18nEditorDemo.class, DatePickerDemo.class, @@ -193,8 +188,7 @@ public class DemoDataProvider implements NavDataProvider { ListSelectorDemo.class, BeanComboBoxDemo.class, BeanFilterableComboBoxDemo.class, - BeanDoubleListDemo.class, - CoordinateDemo.class + BeanDoubleListDemo.class ); addMapping(n("jaxxdemo.feature"), diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/KeyStrokeEditor.java b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/KeyStrokeEditor.java index 874c1b5..b314481 100644 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/KeyStrokeEditor.java +++ b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/KeyStrokeEditor.java @@ -21,12 +21,10 @@ */ package org.nuiton.jaxx.runtime.swing.editor; -import java.awt.event.KeyEvent; import javax.swing.JTextField; import javax.swing.KeyStroke; import javax.swing.SwingUtilities; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import java.awt.event.KeyEvent; /** * Custom text field to disable default key events @@ -35,8 +33,6 @@ import org.apache.commons.logging.LogFactory; */ public class KeyStrokeEditor extends JTextField { - private static final Log log = LogFactory.getLog(KeyStrokeEditor.class); - protected KeyStroke keyStroke; public KeyStrokeEditor() { @@ -49,10 +45,10 @@ public class KeyStrokeEditor extends JTextField { if (e.getID() == KeyEvent.KEY_PRESSED) { int keyCode = e.getKeyCode(); if (keyCode == KeyEvent.VK_SHIFT || - keyCode == KeyEvent.VK_ALT || - keyCode == KeyEvent.VK_CONTROL || - keyCode == KeyEvent.VK_ALT_GRAPH || - keyCode == KeyEvent.VK_META) { + keyCode == KeyEvent.VK_ALT || + keyCode == KeyEvent.VK_CONTROL || + keyCode == KeyEvent.VK_ALT_GRAPH || + keyCode == KeyEvent.VK_META) { return; } diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/NumberEditor.jaxx b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/NumberEditor.jaxx deleted file mode 100644 index 2036113..0000000 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/NumberEditor.jaxx +++ /dev/null @@ -1,205 +0,0 @@ -<!-- - #%L - JAXX :: Widgets - %% - Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - %% - 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 layout='{new BorderLayout()}' - onFocusGained='textField.requestFocus()' - onFocusLost='setPopupVisible(false);popup.setVisible(false);' - onMouseExited='setPopupVisible(false);popup.setVisible(false);'> - - <import> - java.awt.Color - java.awt.BorderLayout - java.awt.GridLayout - java.awt.Dimension - - javax.swing.BorderFactory - - </import> - <!-- onFocusGained='if (autoPopup) setPopupVisible(true); textField.requestFocus();'--> - - <!-- bean property associated with the editing value --> - <String id='property' javaBean='""'/> - - <!-- bean property --> - <Object id='bean' javaBean='null'/> - - <!-- editor model --> - <Number id="model" javaBean='null'/> - - <!-- editor model type (specify it when you want to use a special type other than Integer or Float)--> - <Class id="modelType" genericType='?' javaBean='null'/> - - <!-- useFloat property --> - <Boolean id='useFloat' javaBean='false'/> - - <!-- useSign property --> - <Boolean id='useSign' javaBean='false'/> - - <!-- autoPopup property --> - <Boolean id='autoPopup' javaBean='false'/> - - <!-- showPopupButton property --> - <Boolean id='showPopupButton' javaBean='false'/> - - <!-- show reset property --> - <Boolean id='showReset' javaBean='false'/> - - <!-- show reset property --> - <String id="numberPattern" javaBean='null'/> - - <!-- internal editor model as text --> - <String id="modelText" javaBean='""'/> - - <!-- internal state --> - <Boolean id='popupVisible' javaBean='false'/> - - <!-- When a error occurs, previous valid value is repush in textField, with this flag setted to true then also reselect this content. --> - <Boolean id='selectAllTextOnError' javaBean='false'/> - - <!-- ui handler --> - <NumberEditorHandler id='handler' constructorParams='this'/> - - <!-- popup digital number editor --> - <JPopupMenu id='popup' - onPopupMenuWillBecomeVisible='showPopUpButton.setSelected(true)' - onPopupMenuWillBecomeInvisible='showPopUpButton.setSelected(false)' - onPopupMenuCanceled='showPopUpButton.setSelected(false)'> - <style source='NumberEditorPopup.jcss'/> - <JPanel layout='{new GridLayout(4,4)}' - border='{BorderFactory.createEmptyBorder(4, 4, 4, 4)}' - background='{Color.WHITE}'> - <JButton text='numbereditor.7' onActionPerformed='addChar(event)' - styleClass='digit'/> - <JButton text='numbereditor.8' onActionPerformed='addChar(event)' - styleClass='digit'/> - <JButton text='numbereditor.9' onActionPerformed='addChar(event)' - styleClass='digit'/> - <JButton text='numbereditor.clearAll' onActionPerformed='setModel(null)' - styleClass='clear' enabled='{!getModelText().isEmpty()}'/> - - - <JButton text='numbereditor.4' onActionPerformed='addChar(event)' - styleClass='digit'/> - <JButton text='numbereditor.5' onActionPerformed='addChar(event)' - styleClass='digit'/> - <JButton text='numbereditor.6' onActionPerformed='addChar(event)' - styleClass='digit'/> - <JButton text='numbereditor.clearOne' - onActionPerformed='getHandler().removeChar()' styleClass='clear' - enabled='{!(getModelText().isEmpty() || textField.getCaretPosition() ==0 )}'/> - - <JButton text='numbereditor.1' onActionPerformed='addChar(event)' - styleClass='digit'/> - <JButton text='numbereditor.2' onActionPerformed='addChar(event)' - styleClass='digit'/> - <JButton text='numbereditor.3' onActionPerformed='addChar(event)' - styleClass='digit'/> - - <JButton enabled="false"/> - - <JButton text='numbereditor.0' onActionPerformed='addChar(event)' - styleClass='digit' - enabled='{!getEditor().getModelText().equals("0")}'/> - - <JButton id='toggleSign' text='numbereditor.toggleSign' - styleClass='operator' - onActionPerformed='getHandler().toggleSign()' - enabled='{isUseSign() && !getEditor().getModelText().isEmpty()}'/> - - <JButton id='dot' text='numbereditor..' styleClass='operator' - onActionPerformed='addChar(event)' - enabled='{isUseFloat() && getEditor().getModelText().indexOf(".") == -1 }'/> - - <JButton actionIcon='numbereditor-validate' - onActionPerformed="getHandler().validate()"/> - </JPanel> - </JPopupMenu> - <script><![CDATA[ -public void init() { - handler.init(); -} - -public NumberEditor getEditor() { - return this; -} - -public void addChar(ActionEvent event) { - getHandler().addChar(((JButton)event.getSource()).getText()); -} - -void showPopup() { - if ( popupVisible || autoPopup ) { - if (!popupVisible) { - setPopupVisible(true); - } else if (!getPopup().isVisible()) { - getHandler().setPopupVisible(true); - } - } -} - -@Override -public void setToolTipText(String toolTipText) { - super.setToolTipText(toolTipText); - textField.setToolTipText(toolTipText); -} - -]]> - </script> - - <JToolBar id='toolbar' - floatable='false' - borderPainted='false' - visible='{isShowReset()}' - constraints='BorderLayout.WEST'> - <JButton id='resetButton' - actionIcon='numbereditor-reset' - toolTipText='numbereditor.action.reset.tip' - focusable='false' - focusPainted='false' - enabled='{isEnabled()}' - onActionPerformed='setModel(null)'/> - </JToolBar> - - <JTextField id='textField' - constraints='BorderLayout.CENTER' - text='{getModelText()}' - enabled='{isEnabled()}' - onKeyReleased='getHandler().setModel(textField.getText())' - onFocusGained='showPopup()'/> - - <JToolBar constraints='BorderLayout.EAST' - floatable='false' - opaque='false' - borderPainted='false' - visible='{isShowPopupButton()}' - maximumSize='{new Dimension(24,24)}'> - <JToggleButton id='showPopUpButton' - focusable='false' - focusPainted='false' - actionIcon='numbereditor-calculator' - toolTipText='numbereditor.action.show.tip' - enabled='{isEnabled()}' - onActionPerformed='getHandler().setPopupVisible(!popup.isVisible())'/> - </JToolBar> - -</JPanel> diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/NumberEditorHandler.java b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/NumberEditorHandler.java deleted file mode 100644 index c6c4bc2..0000000 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/NumberEditorHandler.java +++ /dev/null @@ -1,591 +0,0 @@ -/* - * #%L - * JAXX :: Widgets - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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% - */ - -package org.nuiton.jaxx.runtime.swing.editor; - -import org.apache.commons.beanutils.PropertyUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.math.NumberUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.util.beans.BeanUtil; - -import javax.swing.JComponent; -import javax.swing.JTextField; -import javax.swing.SwingUtilities; -import javax.swing.text.BadLocationException; -import java.awt.Dimension; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.beans.PropertyDescriptor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import static org.nuiton.jaxx.runtime.swing.editor.NumberEditor.PROPERTY_MODEL; -import static org.nuiton.jaxx.runtime.swing.editor.NumberEditor.PROPERTY_POPUP_VISIBLE; - -/** - * Le handler de l'éditeur graphique de nombres. - * - * Note: Ce handler n'est pas staless, et chaque ui possède le sien. - * - * @author Tony Chemit - dev@tchemit.fr - * @see NumberEditor - */ -public class NumberEditorHandler { - /** Logger */ - public static final Log log = LogFactory.getLog(NumberEditorHandler.class); - - public static final String VALIDATE_PROPERTY = "validate"; - - /** editor ui */ - protected final NumberEditor editor; - - /** the mutator method on the property of boxed bean in the editor */ - protected Method mutator; - - /** the getter method on the property */ - protected Method getter; - - /** a flag to known if mutator accept null value */ - protected Boolean acceptNull; - - protected Class<?> modelType; - - protected Pattern numberPattern; - - public NumberEditorHandler(NumberEditor ui) { - editor = ui; - } - - /** initialise l'ui et les listeners d'évènements. */ - public void init() { - try { -// if (editor.getBean() == null) { -// throw new NullPointerException("can not have a null bean in ui " + editor); -// } - - editor.addPropertyChangeListener(NumberEditor.PROPERTY_NUMBER_PATTERN, evt -> { - String newPattern = (String) evt.getNewValue(); - if (log.isInfoEnabled()) { - log.info("set new numberPattern" + newPattern); - } - if (StringUtils.isEmpty(newPattern)) { - numberPattern = null; - } else { - numberPattern = Pattern.compile(newPattern); - } - }); - - editor.addPropertyChangeListener(NumberEditor.PROPERTY_SHOW_POPUP_BUTTON, evt -> { - if (log.isDebugEnabled()) { - log.debug("set showPopupButton" + evt.getNewValue() + " for " + editor.getProperty()); - } - if (editor.getPopup().isVisible()) { - setPopupVisible(false); - } - }); - - editor.addPropertyChangeListener(NumberEditor.PROPERTY_AUTO_POPUP, evt -> { - if (log.isDebugEnabled()) { - log.debug("set auto popup " + evt.getNewValue() + " for " + editor.getProperty()); - } - if (editor.getPopup().isVisible()) { - setPopupVisible(false); - } - }); - - editor.addPropertyChangeListener(PROPERTY_MODEL, evt -> { - if (log.isDebugEnabled()) { - log.debug("set new model " + evt.getNewValue() + " for " + editor.getProperty()); - } - setModel((Number) evt.getOldValue(), (Number) evt.getNewValue()); - }); - editor.addPropertyChangeListener(PROPERTY_POPUP_VISIBLE, evt -> setPopupVisible((Boolean) evt.getNewValue())); - editor.getTextField().addMouseListener(new PopupListener()); - - // Initialise le number pattern - if (StringUtils.isNotEmpty(editor.getNumberPattern())) { - numberPattern = Pattern.compile(editor.getNumberPattern()); - } - - // Determine si c'est un float - Class<?> type = editor.getModelType(); - if (editor.getModelType() == null) { - if (editor.getBean() != null) { - type = getGetter().getReturnType(); - } - } - modelType = type; - if (log.isDebugEnabled()) { - log.debug("model type to use = " + modelType); - } - //FIXME le test n'est pas assez fort (on peut avoir un long, short,...) - editor.setUseFloat(!type.equals(Integer.class) && !type.equals(int.class)); - - // Initialise le model - if (editor.getModel() == null) { - if (editor.getBean() != null) { - Number num = (Number) getGetter().invoke(editor.getBean()); - editor.setModel(num); - } - } - - /*if (editor.getResetButton().getIcon() == null) { - editor.getResetButton().setIcon(SwingUtil.createActionIcon("numbereditor-reset")); - } - if (editor.getButton().getIcon() == null) { - editor.getButton().setIcon(SwingUtil.createActionIcon("numbereditor-calculator")); - }*/ - } catch (IllegalAccessException | InvocationTargetException | IllegalArgumentException ex) { - log.error(ex); - } - } - - /** - * Affiche ou cache la popup. - * - * @param newValue la nouvelle valeur de visibilité de la popup. - */ - public void setPopupVisible(Boolean newValue) { - - if (log.isTraceEnabled()) { - log.trace(newValue); - } - - if (newValue == null || !newValue) { - editor.getPopup().setVisible(false); - return; - } - SwingUtilities.invokeLater(() -> { - JComponent invoker = - editor.isShowPopupButton() ? - editor.getShowPopUpButton() : - editor; - Dimension dim = editor.getPopup().getPreferredSize(); - int x = (int) (invoker.getPreferredSize().getWidth() - dim.getWidth()); - editor.getPopup().show(invoker, - x, invoker.getHeight()); - editor.getTextField().requestFocus(); - }); - } - - protected String lastValidText; - - /** - * Modifie le modèle de la donnée à éditer à partir d'un evenement clavier - * - * TODO utiliser une filtre sur les donnes en entrees pour ne pas a avoir - * faire les tests ici. - * - * @param s la nouvelle valeur du modèle - */ - public void setModel(String s) { - - String text = editor.getModelText(); - if (text.equals(s)) { - // le modeèle n'a pas changé, rien a faire sur le modèle - if (log.isDebugEnabled()) { - log.debug("modelText is the same, skip !"); - } - return; - } - - if (StringUtils.isNotEmpty(s) && numberPattern != null) { - - // use given number pattern - Matcher matcher = numberPattern.matcher(s); - if (!matcher.matches()) { - - // the current text is not accepted... - if (log.isInfoEnabled()) { - log.info("Does not accept the new number " + s + - ", will reapply lastValidText : " + lastValidText); - } - - String oldText; - if (lastValidText != null) { - - // push back last valid text - oldText = lastValidText; - } else { - oldText = ""; - } - editor.getTextField().setText(oldText); - return; - } - } - - boolean canApply = false; - - boolean endWithDot = false; - - boolean isLess = false; - - Number newValue = null; - - // allow using ',' char - s = s.replaceAll(",", "."); - - if (s.trim().isEmpty()) { - // le champ est vide donc c'est la valeur null a reaffecter - s = null; - canApply = true; - } else if (s.endsWith(".")) { - s += "0"; - endWithDot = true; - } else if (editor.isUseSign() && s.length() == 1 && s.startsWith("-")) { - s = "0"; - isLess = true; - } - - //FIXME tchemit-2014-03-25 Need to bring that bug to commons-lang team - if (s != null && (s.startsWith("0.") && NumberUtils.isNumber(s.substring(1)) || NumberUtils.isNumber(s))) { - - // on a un nombre valide - - try { - Double f = Double.parseDouble(s); - if (!editor.isUseSign() && s.startsWith("-")) { - if (log.isDebugEnabled()) { - log.debug("will skip since can not allow sign on this editor but was " + f); - } - } else { - - if (!editor.isUseFloat() && s.contains(".")) { - if (log.isDebugEnabled()) { - log.debug("will skip since can not allow float on this editor but was " + f); - } - } else { - // ok on peut utilise ce modele - newValue = getRealValue(f); -// if (editor.isUseFloat()) { -// if (getMutator().getParameterTypes()[0] == BigDecimal.class) { -// newValue = BigDecimal.valueOf(f); -// } else { -// newValue = f; -// } -// } else { -// newValue = f.intValue(); -// } - canApply = true; - } - } - - } catch (NumberFormatException e) { - // rien a faire - log.debug(e); - } - } - JTextField field = editor.getTextField(); - - int oldPosition = field.getCaretPosition(); - - if (canApply) { - - if (log.isDebugEnabled()) { - log.debug("can apply new model value : " + newValue); - } - if (isLess) { - editor.setModelText("-"); - return; - } - // on peut mettre a jour le model - editor.setModel(newValue); - if (endWithDot) { - editor.setModelText(s.substring(0, s.length() - 1)); - field.setCaretPosition(oldPosition); - } - - lastValidText = editor.getModelText(); - return; - } - - // on ne peut pas appliquer, on repositionne l'ancien texte - // dans l'éditeur - - if (log.isDebugEnabled()) { - log.debug("invalid text " + s + " reput old text " + text); - } - - field.setText(text); - - lastValidText = text; - if (editor.isSelectAllTextOnError()) { - field.selectAll(); - } else { - if (oldPosition > 0) { - oldPosition--; - } - try { - field.setCaretPosition(oldPosition); - } catch (IllegalArgumentException ex) { - log.debug("CaretPosition is invalid for position : " + oldPosition, ex); - } - } - } - - private Number getRealValue(Double f) { - if (modelType == Integer.class) { - return f.intValue(); - } - if (modelType == Double.class) { - return f; - } - if (modelType == Long.class) { - return f.longValue(); - } - if (modelType == BigInteger.class) { - return new BigInteger(f.longValue() + ""); - } - if (modelType == BigDecimal.class) { - return new BigDecimal(f + ""); - } - if (modelType == Float.class || editor.isUseFloat()) { - return f.floatValue(); - } - return f.intValue(); - } - - /** - * Ajoute le caractère donné à l'endroit où est le curseur dans la zone de - * saisie et met à jour le modèle. - * - * @param s le caractère à ajouter. - */ - public void addChar(String s) { - char c = s.charAt(0); - try { - editor.getTextField().getDocument().insertString(editor.getTextField().getCaretPosition(), c + "", null); - setModel(editor.getTextField().getText()); - //setModel(editor.getModelText() + c); - - } catch (BadLocationException e) { - log.warn(e); - } - } - - /** - * Supprime le caractère juste avant le curseur du modèle (textuel) et - * met à jour la zone de saisie. - */ - public void removeChar() { - String s = editor.getModelText(); - int position = editor.getTextField().getCaretPosition(); - if (position < 1 || s.isEmpty()) { - if (log.isDebugEnabled()) { - log.debug("cannot remove when caret on first position or text empty"); - } - // on est au debut du doc, donc rien a faire - return; - } - try { - editor.getTextField().getDocument().remove(position - 1, 1); - } catch (BadLocationException ex) { - // ne devrait jamais arrive vu qu'on a fait le controle... - log.debug(ex); - return; - } - String newText = editor.getTextField().getText(); - if (log.isDebugEnabled()) { - log.debug("text updated : " + newText); - } - position--; - editor.getTextField().setCaretPosition(position); - setModel(newText); - } - - /** - * Permute le signe dans la zone de saisie et - * dans le modèle. - */ - public void toggleSign() { - String newValue = editor.getModelText(); - - if (newValue.startsWith("-")) { - setModel(newValue.substring(1)); - } else { - setModel("-" + newValue); - } - } - - /** @return l'éditeur au quel est rattaché le handler. */ - public NumberEditor getEditor() { - return editor; - } - - protected void setModel(Number oldValue, Number newValue) { - - if (log.isDebugEnabled()) { - log.debug(editor.getProperty() + " on " + editor.getBean().getClass() + " :: " + oldValue + " to " + newValue); - } - - String strValue; - if (newValue == null) { - strValue = ""; - } else { - strValue = newValue + ""; - if (editor.isUseFloat()) { - Float n = Float.parseFloat(strValue); - if ((float) n.intValue() == n) { - strValue = n.intValue() + ""; - } - } - } - - lastValidText = strValue; - editor.setModelText(strValue); - - if (editor.getBean() == null) { - return; - } - - try { - Method mutator = getMutator(); - if (newValue == null && !getAcceptNull()) { - // valeur nulle sur une propriete primitive - // on ne peut pas utiliser la valeur null, mais 0 à la place - newValue = getRealValue(0.0d); -// if (editor.isUseFloat()) { -// if (log.isInfoEnabled()) { -// log.info("use float, check mutator default type = " + mutator.getParameterTypes()[0]); -// } -// if (mutator.getParameterTypes()[0] == BigDecimal.class) { -// newValue = BigDecimal.valueOf(0); -// } else { -// newValue = 0.0f; -//// mutator.invoke(editor.getBean(), 0.0f); -// } -// } else { -// newValue = 0; -//// mutator.invoke(editor.getBean(), 0); -// } - - } //else { -// mutator.invoke(editor.getBean(), newValue); -// } - mutator.invoke(editor.getBean(), newValue); - - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - protected void validate() { - - setPopupVisible(false); - // fire validate property (to be able to notify listeners) - editor.firePropertyChange(VALIDATE_PROPERTY, null, true); - } - - protected class PopupListener extends MouseAdapter { - - @Override - public void mousePressed(MouseEvent e) { - maybeShowPopup(e); - } - - @Override - public void mouseReleased(MouseEvent e) { - maybeShowPopup(e); - } - - protected void maybeShowPopup(MouseEvent e) { - if (!e.isPopupTrigger()) { - return; - } - if (editor.isAutoPopup()) { - if (editor.isPopupVisible()) { - if (!editor.getPopup().isVisible()) { - setPopupVisible(true); - } - // popup already visible - - } else { - // set popup auto - editor.setPopupVisible(true); - - } - } else { - if (editor.isPopupVisible()) { - setPopupVisible(true); - } - } - } - } - - protected Method getMutator() { - if (mutator == null) { - mutator = BeanUtil.getMutator(editor.getBean(), editor.getProperty()); - } - return mutator; - } - - protected Method getGetter() { - if (getter == null) { - Object bean = editor.getBean(); - if (bean == null) { - throw new NullPointerException("could not find bean in " + editor); - } - String property = editor.getProperty(); - if (property == null) { - throw new NullPointerException("could not find property in " + editor); - } - if (log.isDebugEnabled()) { - log.debug("searching accessor for property " + property + " on bean of type " + bean.getClass()); - } - if (log.isTraceEnabled()) { - PropertyDescriptor[] descriptors = PropertyUtils.getPropertyDescriptors(bean); - for (PropertyDescriptor p : descriptors) { - log.trace("property discover " + p.getName() + " reader = " + p.getWriteMethod()); - } - } - try { - PropertyDescriptor descriptor = PropertyUtils.getPropertyDescriptor(bean, property); - getter = descriptor.getReadMethod(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - return getter; - } - - public Boolean getAcceptNull() { - if (acceptNull == null) { - Method m = getMutator(); - if (m == null) { - // should never happens - throw new IllegalStateException("could not find the mutator"); - } - Class<?> returnType = m.getParameterTypes()[0]; - acceptNull = !returnType.isPrimitive(); - if (log.isDebugEnabled()) { - log.debug(acceptNull + " for mutator " + m.getName() + " type : " + returnType); - } - } - return acceptNull; - } -} diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/NumberEditorPopup.jcss b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/NumberEditorPopup.jcss deleted file mode 100644 index c1e25c7..0000000 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/NumberEditorPopup.jcss +++ /dev/null @@ -1,47 +0,0 @@ -/* - * #%L - * JAXX :: Widgets - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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% - */ - -JButton { - font-size: 14; - focusPainted: false; - focusable: false; -} - -JButton.digit { - foreground: blue; -} - -JButton.operator { - foreground: #009900; -} - -JButton.clear { - foreground: red; -} - -JButton:mouseover { - font-weight: bold; -} - -JButton.operator:mouseover { - font-weight: normal; -} diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/SimpleTimeEditor.jaxx b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/SimpleTimeEditor.jaxx deleted file mode 100644 index 5ff996a..0000000 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/SimpleTimeEditor.jaxx +++ /dev/null @@ -1,61 +0,0 @@ -<!-- - #%L - JAXX :: Widgets - %% - Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - %% - 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% - --> - -<Table constraints='BorderLayout.NORTH' fill='horizontal' insets='0'> - <import> - java.io.Serializable - java.util.Date - java.awt.BorderLayout - javax.swing.SpinnerNumberModel - javax.swing.DefaultBoundedRangeModel - </import> - - <!-- ui handler --> - <SimpleTimeEditorModel id='model'/> - - <!-- spinner minute editor --> - <SpinnerDateModel id="minuteModel"/> - - <SimpleTimeEditorHandler id='handler' constructorParams='this'/> - - <script><![CDATA[ -public void init() { handler.init(); } -public void setBean(Serializable bean) { model.setBean(bean); } -public void setProperty(String property ) { model.setProperty(property); } -public void setDate(Date date) { model.setDate(date); } -]]> - </script> - - <row> - <cell weightx='0.5'> - <JSpinner id='hour' - onStateChanged='handler.updateTimeModelFromHour((Integer)hour.getValue())'/> - </cell> - <cell> - <JLabel id='labelH'/> - </cell> - <cell weightx='0.5'> - <JSpinner id='minute' - onStateChanged='handler.updateTimeModelFromMinute(minuteModel.getDate())'/> - </cell> - </row> -</Table> diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/SimpleTimeEditor.jcss b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/SimpleTimeEditor.jcss deleted file mode 100644 index a27234a..0000000 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/SimpleTimeEditor.jcss +++ /dev/null @@ -1,42 +0,0 @@ -/* - * #%L - * JAXX :: Widgets - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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% - */ - -#hour { - value: {model.getTimeModel() / 60}; - enabled: {isEnabled()}; - model: {new SpinnerNumberModel(0, 0, 23, 1)}; -} - -#labelH { - text: "timeeditor.H"; - horizontalAlignment: center; -} - -#minuteModel { - calendarField: {java.util.Calendar.MINUTE}; - value: {handler.setMinuteModel(model.getDate())}; -} - -#minute { - enabled: {isEnabled()}; - model: {minuteModel}; -} diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/SimpleTimeEditorHandler.java b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/SimpleTimeEditorHandler.java deleted file mode 100644 index 649c379..0000000 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/SimpleTimeEditorHandler.java +++ /dev/null @@ -1,283 +0,0 @@ -package org.nuiton.jaxx.runtime.swing.editor; - -/* - * #%L - * JAXX :: Widgets - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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.nuiton.util.beans.BeanUtil; - -import javax.swing.JFormattedTextField; -import javax.swing.JSpinner; -import javax.swing.SpinnerDateModel; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.beans.PropertyChangeListener; -import java.lang.reflect.Method; -import java.util.Calendar; -import java.util.Date; - -/** - * @author Tony Chemit - dev@tchemit.fr - * @since 2.6 - */ -public class SimpleTimeEditorHandler { - - /** Logger. */ - private static final Log log = - LogFactory.getLog(SimpleTimeEditorHandler.class); - - private static final KeyAdapter MOVE_TO_MINUTES_KEY_LISTENER = new KeyAdapter() { - - @Override - public void keyReleased(KeyEvent e) { - JFormattedTextField source = (JFormattedTextField) e.getSource(); - String text = source.getText(); - - // if the user typed 2 digits or if he typed an hour which cannot be the tens digit, - // then transfer the focus to the minute editor (cf #3833) - if (text.length() >= 2 || !text.equals("0") && !text.equals("1") && !text.equals("2")) { - source.transferFocus(); - } - } - - }; - - private final PropertyChangeListener propertyDateChanged; - - private final PropertyChangeListener propertyTimeChanged; - - private final SimpleTimeEditor editor; - - private final SimpleTimeEditorModel model; - - /** the mutator method on the property of boxed bean in the editor */ - protected Method mutator; - - protected final Calendar calendarMinute; - - protected final Calendar calendarHour; - - protected final Calendar calendarDate; - - public SimpleTimeEditorHandler(SimpleTimeEditor editor) { - this.editor = editor; - this.model = editor.getModel(); - this.calendarMinute = Calendar.getInstance(); - this.calendarHour = Calendar.getInstance(); - this.calendarDate = Calendar.getInstance(); - this.propertyDateChanged = evt -> { - Date date = (Date) evt.getNewValue(); - - if (date != null) { - calendarDate.setTime(date); - int hours = calendarDate.get(Calendar.HOUR_OF_DAY); - int minutes = calendarDate.get(Calendar.MINUTE); - if (log.isDebugEnabled()) { - log.debug("date changed : new value " + hours + ":" + minutes); - } - model.setTimeModel(hours * 60 + minutes); - - } else { - model.setTimeModel(null); - } - - }; - this.propertyTimeChanged = evt -> { - Integer time = (Integer) evt.getNewValue(); - - int hours = time / 60; - int minutes = time % 60; - - calendarDate.set(Calendar.HOUR_OF_DAY, hours); - calendarDate.set(Calendar.MINUTE, minutes); - - // push it back into the bean - - Date newValue = calendarDate.getTime(); - - if (log.isDebugEnabled()) { - log.debug(model.getProperty() + " on " + model.getBean().getClass() + " :: " + newValue); - } - - try { - getMutator().invoke(model.getBean(), newValue); - - } catch (Exception e) { - throw new RuntimeException(e); - } - }; - } - - public void init() { - - if (model.getBean() == null) { - throw new NullPointerException("can not have a null bean in ui " + editor); - } - - editor.getMinute().setEditor(new JSpinner.DateEditor(editor.getMinute(), "mm")); -// editor.getHour().setEditor(new JSpinner.DateEditor(editor.getHour(), "HH")); - - // listen to the typed text and automatically focus the minute when the user typed the hour - JSpinner.DefaultEditor hourEditor = (JSpinner.DefaultEditor) editor.getHour().getEditor(); - hourEditor.getTextField().addKeyListener(MOVE_TO_MINUTES_KEY_LISTENER); - -// TuttiUIUtil.autoSelectOnFocus(minuteEditor.getTextField()); -// JSpinner.NumberEditor hourEditor = (JSpinner.NumberEditor) editor.getHour().getEditor(); -// TuttiUIUtil.autoSelectOnFocus(hourEditor.getTextField()); - - // listen when date changes (should come from outside) - - model.addPropertyChangeListener(SimpleTimeEditorModel.PROPERTY_DATE, propertyDateChanged); - - // When time model change, let's push it back in bean - model.addPropertyChangeListener(SimpleTimeEditorModel.PROPERTY_TIME_MODEL, propertyTimeChanged); - } - - public SimpleTimeEditor getEditor() { - return editor; - } - - protected Date setMinuteModel(Date incomingDate) { - if (incomingDate == null) { - incomingDate = new Date(); - calendarMinute.setTime(incomingDate); - calendarMinute.set(Calendar.HOUR_OF_DAY, 0); - calendarMinute.set(Calendar.MINUTE, 0); - } else { - calendarMinute.setTime(incomingDate); - calendarMinute.set(Calendar.HOUR_OF_DAY, 0); - } - incomingDate = calendarMinute.getTime(); - return incomingDate; - } - - public void updateTimeModelFromHour(Integer hour) { - model.setTimeModel(hour * 60 + model.getMinute()); - } - - public void updateTimeModelFromMinute(Date minuteDate) { - - calendarMinute.setTime(minuteDate); - int newHour = calendarMinute.get(Calendar.HOUR_OF_DAY); - int newMinute = calendarMinute.get(Calendar.MINUTE); - - int oldHour = model.getHour(); - int oldMinute = model.getMinute(); - - if (oldHour == newHour && oldMinute == newMinute) { - - // do nothing, same data - if (log.isDebugEnabled()) { - log.debug("Do not update time model , stay on same time = " + oldHour + ":" + oldMinute); - } - return; - } - - // by default stay on same hour - int hour = oldHour; - - // by default, use the new minute data - - if (log.isDebugEnabled()) { - log.debug("hh:mm (old from dateModel) = " + oldHour + ":" + oldMinute); - log.debug("hh:mm (new from minuteModel) = " + newHour + ":" + newMinute); - } - - SpinnerDateModel minuteModel = editor.getMinuteModel(); - - if (newMinute == 0) { - - // minute pass to zero (check if a new hour is required) - if (newHour == 1) { - - if (oldHour == 23) { - - // can't pass from 23:59 to 0:00, stay on 23:59 - if (log.isDebugEnabled()) { - log.debug("Do not update time model , stay on hh:mm = " + oldHour + ":" + oldMinute); - } - minuteModel.setValue(minuteModel.getPreviousValue()); - return; - } - hour = (oldHour + 1) % 24; - } - } else if (newMinute == 59) { - - // minute pass to 59 (check if a new hour is required) - - if (newHour == 23) { - - if (oldHour == 0) { - - // can't pass from 0:00 to 23:59, stay on 0:00 - if (log.isDebugEnabled()) { - log.debug("Do not update time model , stay on hh:mm = " + oldHour + ":" + oldMinute); - } - minuteModel.setValue(minuteModel.getNextValue()); - return; - } - - // decrease hour - hour = (oldHour - 1) % 24; - } - } - - // date has changed - if (log.isDebugEnabled()) { - log.debug("Update time model to hh:mm = " + hour + ":" + newMinute); - } - model.setTimeModel(hour * 60 + newMinute); - } - - protected void setDate(Date oldValue, Date newValue) { - if (model.getBean() != null) { - - if (log.isDebugEnabled()) { - log.debug(model.getProperty() + " on " + model.getBean().getClass() + " :: " + oldValue + " to " + newValue); - } - - try { - getMutator().invoke(model.getBean(), newValue); - - } catch (Exception e) { - throw new RuntimeException(e); - } - } - } - - protected Method getMutator() { - if (mutator == null) { - Object bean = model.getBean(); - if (bean == null) { - throw new NullPointerException("could not find bean in " + editor); - } - String property = model.getProperty(); - if (property == null) { - throw new NullPointerException("could not find property in " + editor); - } - - mutator = BeanUtil.getMutator(bean, property); - } - return mutator; - } -} diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/SimpleTimeEditorModel.java b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/SimpleTimeEditorModel.java deleted file mode 100644 index 6aff51d..0000000 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/SimpleTimeEditorModel.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.nuiton.jaxx.runtime.swing.editor; - -/* - * #%L - * JAXX :: Widgets - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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; - -import java.io.Serializable; -import java.util.Date; - -/** - * @author Tony Chemit - dev@tchemit.fr - * @since 2.6 - */ -public class SimpleTimeEditorModel extends AbstractSerializableBean { - - private static final long serialVersionUID = 1L; - - public static final String PROPERTY_DATE = "date"; - - public static final String PROPERTY_TIME_MODEL = "timeModel"; - - public static final String PROPERTY_PROPERTY = "property"; - - public static final String PROPERTY_BEAN = "bean"; - - /** Bean where to push data. */ - protected Serializable bean; - - /** Property of the bean to use. */ - protected String property; - - /** Time model in minutes. */ - protected Integer timeModel = 0; - - /** Real date which contains the edited time. */ - protected Date date; - - public Serializable getBean() { - return bean; - } - - public void setBean(Serializable bean) { - Object oldValue = getBean(); - this.bean = bean; - firePropertyChange(PROPERTY_BEAN, oldValue, bean); - } - - public String getProperty() { - return property; - } - - public void setProperty(String property) { - Object oldValue = getProperty(); - this.property = property; - firePropertyChange(PROPERTY_PROPERTY, oldValue, property); - } - - public Date getDate() { - return date; - } - - public void setDate(Date date) { - Object oldValue = getDate(); - this.date = date; - firePropertyChange(PROPERTY_DATE, oldValue, date); - } - - public Integer getTimeModel() { - return timeModel; - } - - public void setTimeModel(Integer timeModel) { - if (timeModel == null) { - timeModel = 0; - } - Object oldValue = getTimeModel(); - this.timeModel = timeModel; - firePropertyChange(PROPERTY_TIME_MODEL, oldValue, timeModel); - } - - public int getMinute() { - return timeModel % 60; - } - - public int getHour() { - return timeModel / 60; - } - -} diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/TimeEditor.jaxx b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/TimeEditor.jaxx deleted file mode 100644 index a83a9e6..0000000 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/TimeEditor.jaxx +++ /dev/null @@ -1,87 +0,0 @@ -<!-- - #%L - JAXX :: Widgets - %% - Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - %% - 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 layout='{new BorderLayout()}'> - - <import> - java.util.Date - java.awt.BorderLayout - javax.swing.SpinnerNumberModel - javax.swing.DefaultBoundedRangeModel - </import> - - <!-- bean property --> - <String id='property' javaBean='""'/> - - <!-- title --> - <String id='label' javaBean='""'/> - - <!-- bean --> - <Object id='bean' javaBean='null'/> - - <!-- time model --> - <Integer id="timeModel" javaBean='0'/> - - <!-- the real date --> - <java.util.Date id="date" javaBean='null'/> - - <!-- spinner minute editor --> - <SpinnerDateModel id="minuteModel"/> - - <!-- ui handler --> - <TimeEditorHandler id='handler' constructorParams='this'/> - - <script><![CDATA[ -public void init() { - minute.setEditor(new JSpinner.DateEditor(minute, "mm")); - handler.init(); -} -]]> - </script> - - <Table constraints='BorderLayout.NORTH' fill='horizontal' insets='0'> - <row> - <cell> - <JLabel id='title'/> - </cell> - <cell weightx='1'> - <JLabel/> - </cell> - <cell> - <JSpinner id='hour' - onStateChanged='setTimeModel((Integer)hour.getValue() * 60 + getHandler().getMinute())'/> - </cell> - <cell> - <JLabel id='labelH'/> - </cell> - <cell> - <JSpinner id='minute' - onStateChanged='getHandler().updateTimeModelFromMinuteModel(minuteModel.getDate())'/> - </cell> - </row> - </Table> - - <JSlider id='slider' constraints='BorderLayout.SOUTH' - onStateChanged='if (!slider.getValueIsAdjusting()) setTimeModel(slider.getValue());'/> - -</JPanel> diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/TimeEditor.jcss b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/TimeEditor.jcss deleted file mode 100644 index 9656671..0000000 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/TimeEditor.jcss +++ /dev/null @@ -1,58 +0,0 @@ -/* - * #%L - * JAXX :: Widgets - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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% - */ - -#title { - text:{getLabel()}; - horizontalAlignment:center; -} - -#hour { - value:{getTimeModel() / 60}; - enabled:{isEnabled()}; - model:{new SpinnerNumberModel(0, 0, 23, 1)}; -} - -#labelH { - text:"timeeditor.H"; - horizontalAlignment:center; -} - -#minuteModel { - calendarField:{java.util.Calendar.MINUTE}; - value:{getHandler().setMinuteModel(getDate())}; -} - -#minute { - enabled:{isEnabled()}; - model:{minuteModel}; -} - -#slider { - font-size: 11; - paintTicks:true; - paintLabels:true; - majorTickSpacing:60; - minorTickSpacing:30; - value:{getTimeModel()}; - enabled:{isEnabled()}; - model:{new DefaultBoundedRangeModel(0, 1, 0, 60 * 24)}; -} diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/TimeEditorHandler.java b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/TimeEditorHandler.java deleted file mode 100644 index 64343ea..0000000 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/TimeEditorHandler.java +++ /dev/null @@ -1,319 +0,0 @@ -/* - * #%L - * JAXX :: Widgets - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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% - */ - -package org.nuiton.jaxx.runtime.swing.editor; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.swing.JLabel; -import javax.swing.JSlider; -import javax.swing.plaf.basic.BasicSliderUI; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseWheelEvent; -import java.lang.reflect.Method; -import java.util.Calendar; -import java.util.Date; -import java.util.Dictionary; -import java.util.Hashtable; -import java.util.Map; - -import org.nuiton.util.beans.BeanUtil; - -/** @author Tony Chemit - dev@tchemit.fr */ -public class TimeEditorHandler { - - public static final Log log = LogFactory.getLog(TimeEditorHandler.class); - - public static final String BEAN_PROPERTY = "bean"; - - public static final String PROPERTY_PROPERTY = "property"; - - public static final String DATE_PROPERTY = "date"; - - public static final String TIME_MODEL_PROPERTY = "timeModel"; - - /** editor ui */ - protected final TimeEditor editor; - - /** the mutator method on the property of boxed bean in the editor */ - protected Method mutator; - - protected final Calendar calendar; - - protected final Calendar calendarMinute; - - public TimeEditorHandler(TimeEditor ui) { - editor = ui; - calendar = Calendar.getInstance(); - calendarMinute = Calendar.getInstance(); - } - - public void init() { - - if (editor.getBean() == null) { - throw new NullPointerException("can not have a null bean in ui " + editor); - } - - // create slider labels - Map<Integer, JLabel> labelTable = new Hashtable<>(); - for (int i = 0; i < 25; i += 2) { - labelTable.put(i * 60, new JLabel(i + "")); - } - JSlider slider = editor.getSlider(); - slider.setLabelTable((Dictionary<?, ?>) labelTable); - - MouseAdapter m = new MouseAdapter() { - - @Override - public void mouseClicked(MouseEvent e) { - // set the value - int value = getSliderValue(e); - JSlider slider = (JSlider) e.getComponent(); - slider.setValueIsAdjusting(true); - slider.setValue(value); - slider.setValueIsAdjusting(false); - showToolTip(e); - e.consume(); - } - - @Override - public void mouseDragged(MouseEvent e) { - showToolTip(e); - } - - @Override - public void mouseEntered(MouseEvent e) { - showToolTip(e); - } - - @Override - public void mouseMoved(MouseEvent e) { - showToolTip(e); - } - - @Override - public void mouseReleased(MouseEvent e) { - showToolTip(e); - } - - @Override - public void mouseWheelMoved(MouseWheelEvent e) { - JSlider slider = (JSlider) e.getComponent(); - - // compute new value - int nb = e.getWheelRotation(); - int value = slider.getValue() - nb; - - // set the value - slider.setValueIsAdjusting(true); - slider.setValue(value); - slider.setValueIsAdjusting(false); - e.consume(); - } - - int getSliderValue(MouseEvent e) { - JSlider slider = (JSlider) e.getSource(); - int value = -1; - if (slider.getUI() instanceof BasicSliderUI) { - BasicSliderUI ui = (BasicSliderUI) slider.getUI(); - value = slider.getOrientation() == JSlider.HORIZONTAL - ? ui.valueForXPosition(e.getX()) - : ui.valueForYPosition(e.getY()); - } - return value; - } - - void showToolTip(MouseEvent e) { - - int value = getSliderValue(e); - if (value == -1) { - return; - } - int h = value / 60; - int m = value % 60; - - String text = ""; - if (h < 10) { - text = "0"; - } - text += h + " : "; - if (m < 10) { - text += "0"; - } - text += m; - - JSlider slider = (JSlider) e.getSource(); - slider.setToolTipText(text); - - } - }; - slider.addMouseListener(m); - slider.addMouseMotionListener(m); - slider.addMouseWheelListener(m); - - // listen when date changes (should come from outside) - editor.addPropertyChangeListener(DATE_PROPERTY, evt -> { - Date date = (Date) evt.getNewValue(); - - if (date == null) { - return; - } - calendar.setTime(date); - int hours = calendar.get(Calendar.HOUR_OF_DAY); - int minutes = calendar.get(Calendar.MINUTE); - if (log.isDebugEnabled()) { - log.debug("date changed : new value " + hours + ":" + minutes); - } - getEditor().setTimeModel(hours * 60 + minutes); - }); - - // listen when time model changes (should come from editor) - editor.addPropertyChangeListener(TIME_MODEL_PROPERTY, evt -> { - Integer time = (Integer) evt.getNewValue(); - int hours = time / 60; - int minutes = time % 60; - calendar.set(Calendar.HOUR_OF_DAY, hours); - calendar.set(Calendar.MINUTE, minutes); - setDate(null, calendar.getTime()); - }); - } - - public TimeEditor getEditor() { - return editor; - } - - protected Date setMinuteModel(Date incomingDate) { - if (incomingDate == null) { - incomingDate = new Date(); - } - calendarMinute.setTime(incomingDate); - calendarMinute.set(Calendar.HOUR_OF_DAY, 0); - incomingDate = calendarMinute.getTime(); - return incomingDate; - } - - public int getMinute() { - return getEditor().getTimeModel() % 60; - } - - public int getHour() { - return getEditor().getTimeModel() / 60; - } - - public void updateTimeModelFromMinuteModel(Date minuteDate) { - - calendarMinute.setTime(minuteDate); - int newHour = calendarMinute.get(Calendar.HOUR_OF_DAY); - int newMinute = calendarMinute.get(Calendar.MINUTE); - - int oldHour = getHour(); - int oldMinute = getMinute(); - - if (oldHour == newHour && oldMinute == newMinute) { - - // do nothing, same data - if (log.isDebugEnabled()) { - log.debug("Do not update time model , stay on same time = " + oldHour + ":" + oldMinute); - } - return; - } - - // by default stay on same hour - int hour = oldHour; - - // by default, use the new minute data - - if (log.isDebugEnabled()) { - log.debug("hh:mm (old from dateModel) = " + oldHour + ":" + oldMinute); - log.debug("hh:mm (new from minuteModel) = " + newHour + ":" + newMinute); - } - - if (newMinute == 0) { - - // minute pass to zero (check if a new hour is required) - if (newHour == 1) { - - if (oldHour == 23) { - - // can't pass from 23:59 to 0:00, stay on 23:59 - if (log.isDebugEnabled()) { - log.debug("Do not update time model , stay on hh:mm = " + oldHour + ":" + oldMinute); - } - getEditor().getMinuteModel().setValue(getEditor().getMinuteModel().getPreviousValue()); - return; - } - hour = (oldHour + 1) % 24; - } - } else if (newMinute == 59) { - - // minute pass to 59 (check if a new hour is required) - - if (newHour == 23) { - - if (oldHour == 0) { - - // can't pass from 0:00 to 23:59, stay on 0:00 - if (log.isDebugEnabled()) { - log.debug("Do not update time model , stay on hh:mm = " + oldHour + ":" + oldMinute); - } - getEditor().getMinuteModel().setValue(getEditor().getMinuteModel().getNextValue()); - return; - } - - // decrease hour - hour = (oldHour - 1) % 24; - } - } - - // date has changed - if (log.isDebugEnabled()) { - log.debug("Update time model to hh:mm = " + hour + ":" + newMinute); - } - getEditor().setTimeModel(hour * 60 + newMinute); - } - - protected void setDate(Date oldValue, Date newValue) { - if (editor.getBean() == null) { - return; - } - - if (log.isDebugEnabled()) { - log.debug(editor.getProperty() + " on " + editor.getBean().getClass() + " :: " + oldValue + " to " + newValue); - } - - try { - getMutator().invoke(editor.getBean(), newValue); - - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - protected Method getMutator() { - if (mutator == null) { - mutator = BeanUtil.getMutator(editor.getBean(), editor.getProperty()); - } - return mutator; - } -} diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinate.java b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinate.java deleted file mode 100644 index ffe46da..0000000 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinate.java +++ /dev/null @@ -1,336 +0,0 @@ -package org.nuiton.jaxx.runtime.swing.editor.gis; - -/* - * #%L - * JAXX :: Widgets - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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; - -import java.util.regex.Pattern; - -/** - * Geo coordinate in degree decimal, minute format. - * - * Created on 10/23/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.6 - */ -public class DmdCoordinate extends AbstractSerializableBean { - - private static final long serialVersionUID = 1L; - - public static final String COORDINATE_STRING_PATTERN = "%s%s°%s'%s"; - - public static final Pattern COORDINATE_PATTERN = - Pattern.compile("(.*)°(.*)'(.*)"); - - public static final String PROPERTY_SIGN = "sign"; - - public static final String PROPERTY_DEGREE = "degree"; - - public static final String PROPERTY_MINUTE = "minute"; - - public static final String PROPERTY_DECIMAL = "decimal"; - - protected boolean sign; - - protected Integer degree; - - protected Integer minute; - - protected Integer decimal; - - public static DmdCoordinate empty() { - return new DmdCoordinate(); - } - - /** - * Methode statique de fabrique de position a partir d'un autre {@link DmdCoordinate}. - * - * Note : Si la valeur vaut <code>null</code>, alors on - * reinitialise les composants de la position a <code>null</code> et la - * methode {@link #isNull()} vaudra alors {@code true}. - * - * @param decimal la valeur au format decimal - * @return une nouvelle instance de position convertie - */ - public static DmdCoordinate valueOf(DmdCoordinate decimal) { - DmdCoordinate r = empty(); - if (decimal != null) { - r.setSign(decimal.isSign()); - r.setDegree(decimal.getDegree()); - r.setMinute(decimal.getMinute()); - r.setDecimal(decimal.getDecimal()); - } - return r; - } - - /** - * Methode statique de fabrique de position a partir d'une valeur du format - * decimal. - * - * Note : Si la valeur (au format decimal) vaut <code>null</code>, alors on - * reinitialise les composants de la position a <code>null</code> et la - * methode {@link #isNull()} vaudra alors {@code true}. - * - * @param decimal la valeur au format decimal - * @return une nouvelle instance de position convertie - */ - public static DmdCoordinate valueOf(Float decimal) { - DmdCoordinate r = new DmdCoordinate(); - r.fromDecimal(decimal); - return r; - } - - /** - * Methode statique de fabrique de position a partir d'une valeur du format - * degre décimale minute. - * - * @param d la valeur des degres - * @param m la valeur des minutes - * @param dc la valeur des décimales de minutes - * @return une nouvelle instance de position convertie - */ - public static DmdCoordinate valueOf(boolean sign, - Integer d, - Integer m, - Integer dc) { - DmdCoordinate r = new DmdCoordinate(); - r.setSign(sign); - r.setDegree(d); - r.setMinute(m); - r.setDecimal(dc); - return r; - } - - public boolean isSign() { - return sign; - } - - public Integer getDegree() { - return degree; - } - - public Integer getMinute() { - return minute; - } - - public Integer getDecimal() { - return decimal; - } - - public void setSign(boolean sign) { - Object oldValue = isSign(); - this.sign = sign; - firePropertyChange(PROPERTY_SIGN, oldValue, sign); - } - - public void setDegree(Integer degree) { - Object oldValue = getDegree(); - this.degree = degree; - firePropertyChange(PROPERTY_DEGREE, oldValue, degree); - } - - public void setMinute(Integer minute) { - Object oldValue = getMinute(); - this.minute = minute; - firePropertyChange(PROPERTY_MINUTE, oldValue, minute); - } - - public void setDecimal(Integer decimal) { - Object oldValue = getDecimal(); - this.decimal = decimal; - firePropertyChange(PROPERTY_DECIMAL, oldValue, decimal); - } - - /** - * @return {@code true} si aucune composante n'est renseignée, - * {@code false} autrement. - */ - public boolean isNull() { - return degree == null && minute == null && decimal == null; - } - - public boolean isDegreeNull() { - return degree == null || degree == 0; - } - - public boolean isMinuteNull() { - return minute == null || minute == 0; - } - - public boolean isDecimalNull() { - return decimal == null || decimal == 0; - } - - /** - * Mets a jour les composants de la position a partir d'une valeur decimal. - * - * Note : Si la valeur (au format decimal) vaut <code>null</code>, alors on - * reinitialise les composants de la position a <code>null</code> et la - * methode {@link #isNull()} vaudra alors {@code true}. - * - * @param decimalValue la valeur decimale a convertir (qui peut etre nulle). - */ - public void fromDecimal(Float decimalValue) { - Integer d = null; - Integer m = null; - Integer dc = null; - boolean si = false; - if (decimalValue != null) { - si = decimalValue < 0; - - float absDecimal = Math.abs(decimalValue); - - d = (int) (Math.round(absDecimal + 0.5) - 1); - int rest = Math.round(100 * 60.0f * (absDecimal - d)); - if (rest > 0) { - m = rest / 100; - dc = (rest - m * 100); - } - } - - degree = d; - minute = m; - decimal = dc; - sign = si; - - if (decimal != null) { - removeTrailingZero(); - } - } - - public Float toDecimal() { - if (isNull()) { - return null; - } - Integer d = getNotNullDegree(); - Integer m = getNotNullMinute(); - Integer dc = getNotNullDecimal(); - Float result = Float.valueOf(d); - result += (m + (dc / 100f)) / 60.0f; - if (sign) { - result *= -1; - } - return result; - } - - public void addTrailingZero() { - - if (degree == null) { - degree = 0; - } - if (minute == null) { - minute = 0; - } - if (decimal == null) { - decimal = 0; - } - } - - public void removeTrailingZero() { - if (degree != null && degree == 0) { - degree = null; - } - if (minute != null && minute == 0) { - minute = null; - } - if (decimal != null && decimal == 0) { - decimal = null; - } - } - - public Integer getSignedDegree() { - Integer result = null; - if (!isDegreeNull()) { - result = degree; - if (isSign()) { - result *= -1; - } - } - return result; - } - - public int getNotNullDegree() { - return isDegreeNull() ? 0 : degree; - } - - public int getNotNullMinute() { - return isMinuteNull() ? 0 : minute; - } - - public int getNotNullDecimal() { - return isDecimalNull() ? 0 : decimal; - } - - public boolean isLatitudeDegreeValid() { - return isDegreeValid(false); - } - - public boolean isLongitudeDegreeValid() { - return isDegreeValid(true); - } - - public boolean isMinuteValid() { - boolean result = true; - if (!isMinuteNull()) { - if (minute == 60) { - - // can not have decimal - result = isDecimalNull(); - } else { - result = 0 <= minute && minute < 60; - } - } - return result; - } - - public boolean isDecimalValid() { - return isDecimalNull() || (0 <= decimal && decimal < 100); - } - - @Override - public String toString() { - return "DmdCoordinateComponent{" + - "sign=" + sign + - ", degree=" + degree + - ", minute=" + minute + - ", decimal=" + decimal + - '}'; - } - - protected boolean isDegreeValid(boolean longitude) { - boolean result = true; - if (!isDegreeNull()) { - int bound = longitude ? 180 : 90; - if (bound == degree) { - - // can not have minute nor decimal - result = isMinuteNull() && isDecimalNull(); - } else { - result = 0 <= degree && degree < bound; - } - } - return result; - } - -} diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateConverter.java b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateConverter.java deleted file mode 100644 index 42de403..0000000 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateConverter.java +++ /dev/null @@ -1,143 +0,0 @@ -package org.nuiton.jaxx.runtime.swing.editor.gis; - -/* - * #%L - * JAXX :: Widgets - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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.beanutils.ConversionException; -import org.apache.commons.lang3.StringUtils; -import org.nuiton.converter.NuitonConverter; - -import java.util.regex.Matcher; - -import static org.nuiton.i18n.I18n.t; - -/** - * Created on 11/25/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.6 - */ -public class DmdCoordinateConverter implements NuitonConverter<DmdCoordinate> { - - protected boolean useSign; - - protected boolean forLongitude; - - public void setUseSign(boolean useSign) { - this.useSign = useSign; - } - - public void setForLongitude(boolean forLongitude) { - this.forLongitude = forLongitude; - } - - @Override - public <T> T convert(Class<T> aClass, Object value) { - - if (!isEnabled(aClass)) { - throw new ConversionException( - t("jaxx.error.no.convertor.coordinateDmd", value)); - } - - Object result = null; - - if (value == null) { - - if (aClass.equals(String.class)) { - - result = String.format( - DmdCoordinate.COORDINATE_STRING_PATTERN, - useSign ? "-" : "", - StringUtils.leftPad("", forLongitude ? 3 : 2, ' '), - StringUtils.leftPad("", 2, ' '), - StringUtils.leftPad("", 2, ' ')); - } - } else { - - if (aClass.equals(value.getClass())) { - - // same class, no convertion to do - result = value; - } else if (value instanceof String) { - - // String to Value - - Matcher matcher = DmdCoordinate.COORDINATE_PATTERN.matcher((String) value); - - if (matcher.matches()) { - - String degresStr = matcher.group(1).replaceAll("\\s", ""); - String minutesStr = matcher.group(2).replaceAll("\\s", ""); - String decimalesStr = matcher.group(3).replaceAll("\\s", ""); - - Integer degre = degresStr.isEmpty() || "-".equals(degresStr) ? null : Math.abs(Integer.valueOf(degresStr)); - Integer minutes = minutesStr.isEmpty() ? null : Integer.valueOf(minutesStr); - Integer decimal = decimalesStr.isEmpty() ? null : Integer.valueOf(decimalesStr); - - boolean signed = degresStr.contains("-"); - result = DmdCoordinate.valueOf(signed, - degre, - minutes, - decimal); - } - - } else if (value instanceof DmdCoordinate) { - - // Value to String - - DmdCoordinate coordinate = (DmdCoordinate) value; - - boolean sign = coordinate.isSign(); - String signStr = sign ? "-" : ""; - - Integer degree = coordinate.getDegree(); - String degreeStr = degree == null ? "" : degree.toString(); - - Integer minute = coordinate.getMinute(); - String minuteStr = minute == null ? "" : minute.toString(); - - Integer decimal = coordinate.getDecimal(); - String decimalStr = decimal == null ? "" : decimal.toString(); - - result = String.format( - DmdCoordinate.COORDINATE_STRING_PATTERN, - signStr, - StringUtils.leftPad(degreeStr, forLongitude ? 3 : 2, ' '), - StringUtils.leftPad(minuteStr, 2, ' '), - StringUtils.leftPad(decimalStr, 2, ' ')); - } - } - return aClass.cast(result); - } - - protected boolean isEnabled(Class<?> aClass) { - return String.class.isAssignableFrom(aClass) || - DmdCoordinate.class.isAssignableFrom(aClass); - } - - @Override - public Class<DmdCoordinate> getType() { - return DmdCoordinate.class; - } - -} - diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateEditor.jaxx b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateEditor.jaxx deleted file mode 100644 index f1bec14..0000000 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateEditor.jaxx +++ /dev/null @@ -1,58 +0,0 @@ -<!-- - #%L - JAXX :: Widgets - %% - Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - %% - 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> - java.io.Serializable - java.awt.BorderLayout - javax.swing.JFormattedTextField - </import> - - <!-- show reset property --> - <Boolean id='showReset' javaBean='false'/> - - <!-- show reset tip --> - <String id='showResetTip' javaBean=''/> - - <!-- model --> - <DmdCoordinateEditorModel id='model'/> - - <!--<!– handler –>--> - <!--<DmdCoordinateEditorHandler id='handler' constructorParams='this'/>--> - - <script><![CDATA[ -public void init(boolean longitudeEditor) { handler.init(longitudeEditor); } -public void setBean(Serializable bean) { model.setBean(bean); } -public void setPropertySign(String property ) { model.setPropertySign(property); } -public void setPropertyDegree(String property ) { model.setPropertyDegree(property); } -public void setPropertyMinute(String property ) { model.setPropertyMinute(property); } -public void setPropertyDecimal(String property ) { model.setPropertyDecimal(property); } -public void setValue(DmdCoordinate value) { handler.setValue(value, true); } -]]> - </script> - - <JToolBar id='toolbarLeft' constraints='BorderLayout.WEST'> - <JButton id='resetButton' onActionPerformed='handler.resetEditor()'/> - </JToolBar> - <JFormattedTextField id='editor' constraints='BorderLayout.CENTER' - onKeyReleased='handler.onKeyReleased(event)'/> -</JPanel> diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateEditor.jcss b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateEditor.jcss deleted file mode 100644 index ee35e04..0000000 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateEditor.jcss +++ /dev/null @@ -1,38 +0,0 @@ -/* - * #%L - * JAXX :: Widgets - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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; - visible:{isShowReset()}; -} - -#resetButton { - actionIcon:"combobox-reset"; - toolTipText: {getShowResetTip()}; - focusable:false; - focusPainted:false; - enabled:{isEnabled()}; -} - -#editor { - enabled:{isEnabled()}; -} diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateEditorHandler.java b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateEditorHandler.java deleted file mode 100644 index 854b032..0000000 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateEditorHandler.java +++ /dev/null @@ -1,303 +0,0 @@ -package org.nuiton.jaxx.runtime.swing.editor.gis; - -/* - * #%L - * JAXX :: Widgets - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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 org.nuiton.jaxx.runtime.spi.UIHandler; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.util.beans.BeanUtil; - -import javax.swing.JFormattedTextField; -import javax.swing.text.DefaultFormatterFactory; -import java.awt.event.KeyEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.lang.reflect.Method; -import java.text.ParseException; - -/** - * Created on 10/16/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.6 - */ -public class DmdCoordinateEditorHandler implements UIHandler<DmdCoordinateEditor> { - - /** Logger. */ - private static final Log log = - LogFactory.getLog(DmdCoordinateEditorHandler.class); - - private DmdCoordinateEditor ui; - - protected Method signMutator; - - protected Method degreMutator; - - protected Method minuteMutator; - - protected Method decimalMutator; - - protected boolean valueIsAdjusting; - - protected boolean valueModelIsAdjusting; - - protected DmdCoordinateConverter signedConverter; - - protected DmdCoordinateConverter unsignedConverter; - - protected DefaultFormatterFactory signedFormatterFactory; - - protected DefaultFormatterFactory unsignedFormatterFactory; - - @Override - public void beforeInit(DmdCoordinateEditor ui) { - this.ui = ui; - // can't use the one from ConverterUtil since we deal with some internal states - this.signedConverter = new DmdCoordinateConverter(); - this.signedConverter.setUseSign(true); - this.unsignedConverter = new DmdCoordinateConverter(); - } - - @Override - public void afterInit(DmdCoordinateEditor ui) { - // nothing special to do here - } - - public void init(boolean longitudeEditor) { - - final DmdCoordinateEditorModel model = ui.getModel(); - - Preconditions.checkNotNull(model.getBean(), "could not find bean in " + ui); - Preconditions.checkNotNull(model.getPropertySign(), "could not find propertySign in " + ui); - Preconditions.checkNotNull(model.getPropertyDegree(), "could not find propertyDegree in " + ui); - Preconditions.checkNotNull(model.getPropertyMinute(), "could not find propertyMinute in " + ui); - Preconditions.checkNotNull(model.getPropertyDecimal(), "could not find propertyDecimal in " + ui); - - Object bean = model.getBean(); - signMutator = BeanUtil.getMutator(bean, model.getPropertySign()); - Preconditions.checkNotNull(signMutator, "could not find mutator for " + model.getPropertySign()); - - degreMutator = BeanUtil.getMutator(bean, model.getPropertyDegree()); - Preconditions.checkNotNull(degreMutator, "could not find mutator for " + model.getPropertyDegree()); - - minuteMutator = BeanUtil.getMutator(bean, model.getPropertyMinute()); - Preconditions.checkNotNull(minuteMutator, "could not find mutator for " + model.getPropertyMinute()); - - decimalMutator = BeanUtil.getMutator(bean, model.getPropertyDecimal()); - Preconditions.checkNotNull(decimalMutator, "could not find mutator for " + model.getPropertyDecimal()); - - signedConverter.setForLongitude(longitudeEditor); - unsignedConverter.setForLongitude(longitudeEditor); - - { - // prepare unsigned formatter factory - String pattern = getMaskFormatterPattern(longitudeEditor, false); - MaskFormatterFromConverter<DmdCoordinate> maskFormatter; - try { - maskFormatter = MaskFormatterFromConverter.newFormatter( - DmdCoordinate.class, - pattern, unsignedConverter); - maskFormatter.setValidCharacters(" 01234567890"); - maskFormatter.setCommitsOnValidEdit(true); - unsignedFormatterFactory = new DefaultFormatterFactory(maskFormatter); - } catch (ParseException e) { - // can't happen here - throw new RuntimeException(e); - } - } - { - // prepare signed formatter factory - String pattern = getMaskFormatterPattern(longitudeEditor, true); - MaskFormatterFromConverter<DmdCoordinate> maskFormatter; - try { - maskFormatter = MaskFormatterFromConverter.newFormatter( - DmdCoordinate.class, - pattern, signedConverter); - maskFormatter.setValidCharacters(" 01234567890"); - maskFormatter.setCommitsOnValidEdit(true); - signedFormatterFactory = new DefaultFormatterFactory(maskFormatter); - } catch (ParseException e) { - // can't happen here - throw new RuntimeException(e); - } - } - - JFormattedTextField editor = ui.getEditor(); - editor.setFormatterFactory(model.isSign() ? - signedFormatterFactory : - unsignedFormatterFactory); - editor.setFocusLostBehavior(JFormattedTextField.COMMIT); - - // When editor changes his value, propagate it to model - editor.addPropertyChangeListener("value", evt -> { - DmdCoordinate newValue = (DmdCoordinate) evt.getNewValue(); - if (log.isDebugEnabled()) { - log.debug("Value has changed: " + newValue); - } - model.setValue(newValue); - }); - - // When model sign changed, let's push it back in bean - model.addPropertyChangeListener( - DmdCoordinateEditorModel.PROPERTY_SIGN, - new ModelPropertyChangeListener(model, signMutator)); - - // When model degre changed, let's push it back in bean - model.addPropertyChangeListener( - DmdCoordinateEditorModel.PROPERTY_DEGREE, - new ModelPropertyChangeListener(model, degreMutator)); - - // When model minute changed, let's push it back in bean - model.addPropertyChangeListener( - DmdCoordinateEditorModel.PROPERTY_MINUTE, - new ModelPropertyChangeListener(model, minuteMutator)); - - // When model decimal changed, let's push it back in bean - model.addPropertyChangeListener( - DmdCoordinateEditorModel.PROPERTY_DECIMAL, - new ModelPropertyChangeListener(model, decimalMutator)); - } - - public void setValue(DmdCoordinate value, boolean pushToModel) { - - if (valueModelIsAdjusting) { - // avoid re-entrant code - return; - } - - valueIsAdjusting = !pushToModel; - - try { - ui.getEditor().setValue(value); - } finally { - valueIsAdjusting = false; - } - } - - public void resetEditor() { - // set null value to model - setValue(null, true); - - // use back unsigned format - ui.getEditor().setFormatterFactory(unsignedFormatterFactory); - } - - public void onKeyReleased(KeyEvent e) { - - JFormattedTextField source = (JFormattedTextField) e.getSource(); - - char keyChar = e.getKeyChar(); - int caretPosition = source.getCaretPosition(); - if (log.isDebugEnabled()) { - log.debug("Key pressed: " + keyChar + " (caret position: " + caretPosition + ")"); - } - - if (keyChar == '-') { - - DmdCoordinate value = (DmdCoordinate) source.getValue(); - - DefaultFormatterFactory newFactory; - - // try to switch unsigned to signed - - boolean useSign = ui.getModel().isSign(); - - if (useSign) { - - if (log.isDebugEnabled()) { - log.debug("Switch to unsigned"); - } - - newFactory = unsignedFormatterFactory; - - // remove a sign - caretPosition--; - } else { - // switch to signed - if (log.isDebugEnabled()) { - log.debug("Switch to signed"); - } - newFactory = signedFormatterFactory; - - // add a sign - caretPosition++; - } - - DmdCoordinate newValue = DmdCoordinate.valueOf(value); - newValue.setSign(!useSign); - - source.setFormatterFactory(newFactory); - source.setValue(newValue); - - e.consume(); - - source.setCaretPosition(caretPosition); - } - } - - protected String getMaskFormatterPattern(boolean longitudeEditor, boolean useSign) { - String pattern = "**°**''**"; - if (longitudeEditor) { - // add one more degre - pattern = "*" + pattern; - } - if (useSign) { - pattern = "-" + pattern; - } - return pattern; - } - - private class ModelPropertyChangeListener implements PropertyChangeListener { - - private final DmdCoordinateEditorModel model; - - private final Method mutator; - - private ModelPropertyChangeListener(DmdCoordinateEditorModel model, - Method mutator) { - this.model = model; - this.mutator = mutator; - } - - @Override - public void propertyChange(PropertyChangeEvent evt) { - if (!valueIsAdjusting) { - Object newValue = evt.getNewValue(); - - try { - - valueModelIsAdjusting = true; - try { - mutator.invoke(model.getBean(), newValue); - } finally { - valueModelIsAdjusting = false; - } - - } catch (Exception e) { - throw new RuntimeException(e); - } - } - } - } -} diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateEditorModel.java b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateEditorModel.java deleted file mode 100644 index acf3396..0000000 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateEditorModel.java +++ /dev/null @@ -1,122 +0,0 @@ -package org.nuiton.jaxx.runtime.swing.editor.gis; - -/* - * #%L - * JAXX :: Widgets - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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; - -/** - * Created on 10/16/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.6 - */ -public class DmdCoordinateEditorModel extends DmdCoordinate { - - public static final String PROPERTY_BEAN = "bean"; - - public static final String PROPERTY_PROPERTY_SIGN = "propertySign"; - - public static final String PROPERTY_PROPERTY_DEGREE = "propertyDegree"; - - public static final String PROPERTY_PROPERTY_MINUTE = "propertyMinute"; - - public static final String PROPERTY_PROPERTY_DECIMAL = "propertyDecimal"; - - private static final long serialVersionUID = 1L; - - /** Bean where to push data. */ - protected Serializable bean; - - /** Name of the property of the bean to fire the change of the {@link #sign}. */ - protected String propertySign; - - /** Name of the property of the bean to fire the change of the {@link #degree}. */ - protected String propertyDegre; - - /** Name of the property of the bean to fire the change of the {@link #minute}. */ - protected String propertyMinute; - - /** Name of the property of the bean to fire the change of the {@link #decimal}. */ - protected String propertyDecimal; - - public Serializable getBean() { - return bean; - } - - public void setBean(Serializable bean) { - Object oldValue = getBean(); - this.bean = bean; - firePropertyChange(PROPERTY_BEAN, oldValue, bean); - } - - public String getPropertySign() { - return propertySign; - } - - public void setPropertySign(String propertySign) { - Object oldValue = getPropertySign(); - this.propertySign = propertySign; - firePropertyChange(PROPERTY_PROPERTY_SIGN, oldValue, propertySign); - } - - public String getPropertyDegree() { - return propertyDegre; - } - - public void setPropertyDegree(String propertyDegree) { - Object oldValue = getPropertyDegree(); - this.propertyDegre = propertyDegree; - firePropertyChange(PROPERTY_PROPERTY_DEGREE, oldValue, propertyDegree); - } - - public String getPropertyMinute() { - return propertyMinute; - } - - public void setPropertyMinute(String propertyMinute) { - Object oldValue = getPropertyMinute(); - this.propertyMinute = propertyMinute; - firePropertyChange(PROPERTY_PROPERTY_MINUTE, oldValue, propertyMinute); - } - - public String getPropertyDecimal() { - return propertyDecimal; - } - - public void setPropertyDecimal(String propertyDecimal) { - Object oldValue = getPropertyDecimal(); - this.propertyDecimal = propertyDecimal; - firePropertyChange(PROPERTY_PROPERTY_DECIMAL, oldValue, propertyDecimal); - } - - public void setValue(DmdCoordinate value) { - setSign(value != null && value.isSign()); - setDegree(value == null ? null : value.getDegree()); - setMinute(value == null ? null : value.getMinute()); - setDecimal(value == null ? null : value.getDecimal()); - } - - public String getStringPattern() { - return COORDINATE_STRING_PATTERN; - } -} diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinate.java b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinate.java deleted file mode 100644 index 8331c4c..0000000 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinate.java +++ /dev/null @@ -1,364 +0,0 @@ -package org.nuiton.jaxx.runtime.swing.editor.gis; - -/* - * #%L - * JAXX :: Widgets - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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; - -import java.util.regex.Pattern; - -/** - * Geo coordinate in degree, minute, second format. - * - * Created on 10/23/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.6 - */ -public class DmsCoordinate extends AbstractSerializableBean { - - public static final String COORDINATE_STRING_PATTERN = "%s%s°%s'%s''"; - - public static final Pattern COORDINATE_PATTERN = - Pattern.compile("(.*)°(.*)'(.*)''"); - - private static final long serialVersionUID = 1L; - - public static final String PROPERTY_SIGN = "sign"; - - public static final String PROPERTY_DEGREE = "degree"; - - public static final String PROPERTY_MINUTE = "minute"; - - public static final String PROPERTY_SECOND = "second"; - - protected boolean sign; - - protected Integer degree; - - protected Integer minute; - - protected Integer second; - - public static DmsCoordinate empty() { - return new DmsCoordinate(); - } - - /** - * Methode statique de fabrique de position a partir d'un autre {@link DmsCoordinate}. - * - * Note : Si la valeur vaut <code>null</code>, alors on - * reinitialise les composants de la position a <code>null</code> et la - * methode {@link #isNull()} vaudra alors {@code true}. - * - * @param decimal la valeur au format decimal - * @return une nouvelle instance de position convertie - */ - public static DmsCoordinate valueOf(DmsCoordinate decimal) { - DmsCoordinate r = new DmsCoordinate(); - if (decimal != null) { - r.setSign(decimal.isSign()); - r.setDegree(decimal.getDegree()); - r.setMinute(decimal.getMinute()); - r.setSecond(decimal.getSecond()); - } - return r; - } - - /** - * Methode statique de fabrique de position a partir d'une valeur du format - * decimal. - * - * Note : Si la valeur (au format decimal) vaut <code>null</code>, alors on - * reinitialise les composants de la position a <code>null</code> et la - * methode {@link #isNull()} vaudra alors {@code true}. - * - * @param decimal la valeur au format decimal - * @return une nouvelle instance de position convertie - */ - public static DmsCoordinate valueOf(Float decimal) { - DmsCoordinate r = new DmsCoordinate(); - r.fromDecimal(decimal); - return r; - } - - /** - * Methode statique de fabrique de position a partir d'une valeur du format - * degre-minute-seconde. - * - * @param d la valeur des degres - * @param m la valeur des minutes - * @param s la valeur des secondes - * @return une nouvelle instance de position convertie - */ - public static DmsCoordinate valueOf(boolean sign, Integer d, Integer m, Integer s) { - DmsCoordinate r = new DmsCoordinate(); - r.setSign(sign); - r.setDegree(d); - r.setMinute(m); - r.setSecond(s); - return r; - } - - public boolean isSign() { - return sign; - } - - public Integer getDegree() { - return degree; - } - - public Integer getMinute() { - return minute; - } - - public Integer getSecond() { - return second; - } - - public void setSign(boolean sign) { - Object oldValue = isSign(); - this.sign = sign; - firePropertyChange(PROPERTY_SIGN, oldValue, sign); - } - - public void setDegree(Integer degree) { - Object oldValue = getDegree(); - this.degree = degree; - firePropertyChange(PROPERTY_DEGREE, oldValue, degree); - } - - public void setMinute(Integer minute) { - Object oldValue = getMinute(); - this.minute = minute; - firePropertyChange(PROPERTY_MINUTE, oldValue, minute); - } - - public void setSecond(Integer second) { - Object oldValue = getSecond(); - this.second = second; - firePropertyChange(PROPERTY_SECOND, oldValue, second); - } - - public boolean isDegreeNull() { - return degree == null || degree == 0; - } - - public boolean isMinuteNull() { - return minute == null || minute == 0; - } - - public boolean isSecondNull() { - return second == null || second == 0; - } - - /** - * @return {@code true} si aucune composante n'est renseignée, - * {@code false} autrement. - */ - public boolean isNull() { - return degree == null && minute == null && second == null; - } - - /** - * Mets a jour les composants de la position a partir d'une valeur decimal. - * - * Note : Si la valeur (au format decimal) vaut <code>null</code>, alors on - * reinitialise les composants de la position a <code>null</code> et la - * methode {@link #isNull()} vaudra alors {@code true}. - * - * @param decimal la valeur decimale a convertir (qui peut etre nulle). - */ - public void fromDecimal(Float decimal) { - Integer d = null; - Integer m = null; - Integer s = null; - boolean si = false; - if (decimal != null) { - si = decimal < 0; - - decimal = Math.abs(decimal); - int remain = 0; - - d = (int) (Math.round(decimal + 0.5) - 1); - m = 0; - s = 0; - decimal = 60.0f * (decimal - d); - if (decimal > 0) { - m = (int) (Math.round(decimal + 0.5) - 1); - decimal = 60 * (decimal - m); - if (decimal > 0) { - s = (int) (Math.round(decimal + 0.5) - 1); - remain = (int) (10 * (decimal - s)); - } - } - if (remain > 9) { - s++; - } - if (s == 60) { - m++; - s = 0; - } - if (m == 60) { - d++; - m = 0; - } - } - - degree = d; - minute = m; - second = s; - sign = si; - - if (decimal != null) { - removeTrailingZero(); - } - } - - public Float toDecimal() { - if (isNull()) { - return null; - } - Integer d = getNotNullDegree(); - Integer m = getNotNullMinute(); - - Integer s = getNotNullSecond(); - - Float result = Float.valueOf(d); - - if (m > 0) { - result += (float) m / 60; - if (s == 0) { - result += 0.5f / 3600; - } - } - if (s > 0) { - result += ((float) s + 0.5f) / 3600; - } - - if (sign) { - result *= -1; - } - return result; - } - - public DmsCoordinate addTrailingZero() { - if (degree == null) { - degree = 0; - } - if (minute == null) { - minute = 0; - } - if (second == null) { - second = 0; - } - return this; - } - - public DmsCoordinate removeTrailingZero() { - if (degree != null && degree == 0) { - degree = null; - } - if (minute != null && minute == 0) { - minute = null; - } - if (second != null && second == 0) { - second = null; - } - return this; - } - - public Integer getSignedDegree() { - Integer result = null; - if (!isDegreeNull()) { - result = degree; - if (isSign()) { - result *= -1; - } - } - return result; - } - - public int getNotNullDegree() { - return isDegreeNull() ? 0 : degree; - } - - public int getNotNullMinute() { - return isMinuteNull() ? 0 : minute; - } - - - public int getNotNullSecond() { - return isSecondNull() ? 0 : second; - } - - public boolean isLatitudeDegreeValid() { - return isDegreeValid(false); - } - - public boolean isLongitudeDegreeValid() { - return isDegreeValid(true); - } - - public boolean isMinuteValid() { - boolean result = true; - if (!isMinuteNull()) { - if (60 == minute) { - - // check minute and second are null - result = isSecondNull(); - } else { - result = 0 <= minute && minute < 60; - } - } - return result; - } - - public boolean isSecondValid() { - return isSecondNull() || (0 <= second && second < 60); - } - - @Override - public String toString() { - return "DmsCoordinateComponent{" + - "sign=" + sign + - ", degree=" + degree + - ", minute=" + minute + - ", second=" + second + - '}'; - } - - protected boolean isDegreeValid(boolean longitude) { - boolean result = true; - if (!isDegreeNull()) { - int bound = longitude ? 180 : 90; - if (bound == degree) { - - // check minute and second are null - result = isMinuteNull() && isSecondNull(); - } else { - result = degree < bound; - } - } - return result; - } -} diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateConverter.java b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateConverter.java deleted file mode 100644 index bbd42e9..0000000 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateConverter.java +++ /dev/null @@ -1,144 +0,0 @@ -package org.nuiton.jaxx.runtime.swing.editor.gis; - -/* - * #%L - * JAXX :: Widgets - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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.beanutils.ConversionException; -import org.apache.commons.lang3.StringUtils; -import org.nuiton.converter.NuitonConverter; - -import java.util.regex.Matcher; - -import static org.nuiton.i18n.I18n.t; - -/** - * Created on 11/25/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.6 - */ -public class DmsCoordinateConverter implements NuitonConverter<DmsCoordinate> { - - protected boolean useSign; - - protected boolean forLongitude; - - public void setUseSign(boolean useSign) { - this.useSign = useSign; - } - - public void setForLongitude(boolean forLongitude) { - this.forLongitude = forLongitude; - } - - @Override - public <T> T convert(Class<T> aClass, Object value) { - - if (!isEnabled(aClass)) { - throw new ConversionException( - t("jaxx.error.no.convertor.coordinateDms", value)); - } - - Object result = null; - - if (value == null) { - - if (aClass.equals(String.class)) { - - result = String.format( - DmsCoordinate.COORDINATE_STRING_PATTERN, - useSign ? "-" : "", - StringUtils.leftPad("", forLongitude ? 3 : 2, ' '), - StringUtils.leftPad("", 2, ' '), - StringUtils.leftPad("", 2, ' ')); - } - } else { - - if (aClass.equals(value.getClass())) { - - // same class, no convertion to do - result = value; - } else if (value instanceof String) { - - // String to Value - - Matcher matcher = DmsCoordinate.COORDINATE_PATTERN.matcher((String) value); - - if (matcher.matches()) { - - String degresStr = matcher.group(1).replaceAll("\\s", ""); - String minutesStr = matcher.group(2).replaceAll("\\s", ""); - String secondsStr = matcher.group(3).replaceAll("\\s", ""); - - Integer degre = degresStr.isEmpty() || "-".equals(degresStr) ? null : Math.abs(Integer.valueOf(degresStr)); - Integer minutes = minutesStr.isEmpty() ? null : Integer.valueOf(minutesStr); - Integer seconds = secondsStr.isEmpty() ? null : Integer.valueOf(secondsStr); - - boolean signed = degresStr.contains("-"); - result = DmsCoordinate.valueOf(signed, - degre, - minutes, - seconds); - } - - } else if (value instanceof DmsCoordinate) { - - // Value to String - - DmsCoordinate coordinate = (DmsCoordinate) value; - - boolean sign = coordinate.isSign(); - String signStr = sign ? "-" : ""; - - Integer degree = coordinate.getDegree(); - String degreeStr = degree == null ? "" : degree.toString(); - - Integer minute = coordinate.getMinute(); - String minuteStr = minute == null ? "" : minute.toString(); - - Integer second = coordinate.getSecond(); - String secondStr = second == null ? "" : second.toString(); - - result = String.format( - DmsCoordinate.COORDINATE_STRING_PATTERN, - signStr, - StringUtils.leftPad(degreeStr, forLongitude ? 3 : 2, ' '), - StringUtils.leftPad(minuteStr, 2, ' '), - StringUtils.leftPad(secondStr, 2, ' ')); - } - } - return aClass.cast(result); - - } - - protected boolean isEnabled(Class<?> aClass) { - return String.class.isAssignableFrom(aClass) || - DmsCoordinate.class.isAssignableFrom(aClass); - } - - @Override - public Class<DmsCoordinate> getType() { - return DmsCoordinate.class; - } - -} - diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateEditor.jaxx b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateEditor.jaxx deleted file mode 100644 index 11d4435..0000000 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateEditor.jaxx +++ /dev/null @@ -1,59 +0,0 @@ -<!-- - #%L - JAXX :: Widgets - %% - Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - %% - 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> - java.io.Serializable - java.awt.BorderLayout - javax.swing.JFormattedTextField - </import> - - <!-- show reset property --> - - <Boolean id='showReset' javaBean='false'/> - - <!-- show reset tip --> - <String id='showResetTip' javaBean=''/> - - <!-- model --> - <DmsCoordinateEditorModel id='model'/> - - <!--<!– handler –>--> - <!--<DmsCoordinateEditorHandler id='handler' constructorParams='this'/>--> - - <script><![CDATA[ -public void init(boolean longitudeEditor) { handler.init(longitudeEditor); } -public void setBean(Serializable bean) { model.setBean(bean); } -public void setPropertySign(String property ) { model.setPropertySign(property); } -public void setPropertyDegree(String property ) { model.setPropertyDegree(property); } -public void setPropertyMinute(String property ) { model.setPropertyMinute(property); } -public void setPropertySecond(String property ) { model.setPropertySecond(property); } -public void setValue(DmsCoordinate value) { handler.setValue(value, true); } -]]> - </script> - - <JToolBar id='toolbarLeft' constraints='BorderLayout.WEST'> - <JButton id='resetButton' onActionPerformed='handler.resetEditor()'/> - </JToolBar> - <JFormattedTextField id='editor' constraints='BorderLayout.CENTER' - onKeyReleased='handler.onKeyReleased(event)'/> -</JPanel> diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateEditor.jcss b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateEditor.jcss deleted file mode 100644 index ee35e04..0000000 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateEditor.jcss +++ /dev/null @@ -1,38 +0,0 @@ -/* - * #%L - * JAXX :: Widgets - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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; - visible:{isShowReset()}; -} - -#resetButton { - actionIcon:"combobox-reset"; - toolTipText: {getShowResetTip()}; - focusable:false; - focusPainted:false; - enabled:{isEnabled()}; -} - -#editor { - enabled:{isEnabled()}; -} diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateEditorHandler.java b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateEditorHandler.java deleted file mode 100644 index ffe7f18..0000000 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateEditorHandler.java +++ /dev/null @@ -1,314 +0,0 @@ -package org.nuiton.jaxx.runtime.swing.editor.gis; - -/* - * #%L - * JAXX :: Widgets - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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 org.nuiton.jaxx.runtime.spi.UIHandler; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.util.beans.BeanUtil; - -import javax.swing.JFormattedTextField; -import javax.swing.text.DefaultFormatterFactory; -import java.awt.event.KeyEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.lang.reflect.Method; -import java.text.ParseException; - -/** - * Created on 10/16/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.6 - */ -public class DmsCoordinateEditorHandler implements UIHandler<DmsCoordinateEditor>{ - - /** Logger. */ - private static final Log log = - LogFactory.getLog(DmsCoordinateEditorHandler.class); - - protected DmsCoordinateEditor ui; - - protected Method signMutator; - - protected Method degreMutator; - - protected Method minuteMutator; - - protected Method secondMutator; - - protected boolean valueIsAdjusting; - - protected boolean valueModelIsAdjusting; - - protected DmsCoordinateConverter signedConverter; - - protected DmsCoordinateConverter unsignedConverter; - - protected DefaultFormatterFactory signedFormatterFactory; - - protected DefaultFormatterFactory unsignedFormatterFactory; - -// public DmsCoordinateEditorHandler(DmsCoordinateEditor ui) { -// this.ui = ui; -// -// // can't use the one from ConverterUtil since we deal with some internal states -// this.signedConverter = new DmsCoordinateConverter(); -// this.signedConverter.setUseSign(true); -// this.unsignedConverter = new DmsCoordinateConverter(); -// } - - @Override - public void beforeInit(DmsCoordinateEditor ui) { - this.ui=ui; - // can't use the one from ConverterUtil since we deal with some internal states - this.signedConverter = new DmsCoordinateConverter(); - this.signedConverter.setUseSign(true); - this.unsignedConverter = new DmsCoordinateConverter(); - } - - @Override - public void afterInit(DmsCoordinateEditor ui) { - // nothing special to do here - } - - public void init(boolean longitudeEditor) { - - final DmsCoordinateEditorModel model = ui.getModel(); - - Preconditions.checkNotNull(model.getBean(), "could not find bean in " + ui); - Preconditions.checkNotNull(model.getPropertySign(), "could not find propertySign in " + ui); - Preconditions.checkNotNull(model.getPropertyDegree(), "could not find propertyDegree in " + ui); - Preconditions.checkNotNull(model.getPropertyMinute(), "could not find propertyMinute in " + ui); - Preconditions.checkNotNull(model.getPropertySecond(), "could not find propertySecond in " + ui); - - Object bean = model.getBean(); - signMutator = BeanUtil.getMutator(bean, model.getPropertySign()); - Preconditions.checkNotNull(signMutator, "could not find mutator for " + model.getPropertySign()); - - degreMutator = BeanUtil.getMutator(bean, model.getPropertyDegree()); - Preconditions.checkNotNull(degreMutator, "could not find mutator for " + model.getPropertyDegree()); - - minuteMutator = BeanUtil.getMutator(bean, model.getPropertyMinute()); - Preconditions.checkNotNull(minuteMutator, "could not find mutator for " + model.getPropertyMinute()); - - secondMutator = BeanUtil.getMutator(bean, model.getPropertySecond()); - Preconditions.checkNotNull(secondMutator, "could not find mutator for " + model.getPropertySecond()); - - signedConverter.setForLongitude(longitudeEditor); - unsignedConverter.setForLongitude(longitudeEditor); - - { - // prepare unsigned formatter factory - String pattern = getMaskFormatterPattern(longitudeEditor, false); - MaskFormatterFromConverter<DmsCoordinate> maskFormatter; - try { - maskFormatter = MaskFormatterFromConverter.newFormatter( - DmsCoordinate.class, - pattern, unsignedConverter); - maskFormatter.setValidCharacters(" 01234567890"); - maskFormatter.setCommitsOnValidEdit(true); - unsignedFormatterFactory = new DefaultFormatterFactory(maskFormatter); - } catch (ParseException e) { - // can't happen here - throw new RuntimeException(e); - } - } - { - // prepare signed formatter factory - String pattern = getMaskFormatterPattern(longitudeEditor, true); - MaskFormatterFromConverter<DmsCoordinate> maskFormatter; - try { - maskFormatter = MaskFormatterFromConverter.newFormatter( - DmsCoordinate.class, - pattern, signedConverter); - maskFormatter.setValidCharacters(" 01234567890"); - maskFormatter.setCommitsOnValidEdit(true); - signedFormatterFactory = new DefaultFormatterFactory(maskFormatter); - } catch (ParseException e) { - // can't happen here - throw new RuntimeException(e); - } - } - - JFormattedTextField editor = ui.getEditor(); - editor.setFormatterFactory(model.isSign() ? - signedFormatterFactory : - unsignedFormatterFactory); - editor.setFocusLostBehavior(JFormattedTextField.COMMIT); - - // When editor changes his value, propagate it to model - editor.addPropertyChangeListener("value", evt -> { - DmsCoordinate newValue = (DmsCoordinate) evt.getNewValue(); - if (log.isDebugEnabled()) { - log.debug("Value has changed: " + newValue); - } - model.setValue(newValue); - }); - - // When model sign changed, let's push it back in bean - model.addPropertyChangeListener( - DmsCoordinateEditorModel.PROPERTY_SIGN, - new ModelPropertyChangeListener(model, signMutator)); - - // When model degre changed, let's push it back in bean - model.addPropertyChangeListener( - DmsCoordinateEditorModel.PROPERTY_DEGREE, - new ModelPropertyChangeListener(model, degreMutator)); - - // When model minute changed, let's push it back in bean - model.addPropertyChangeListener( - DmsCoordinateEditorModel.PROPERTY_MINUTE, - new ModelPropertyChangeListener(model, minuteMutator)); - - // When model second changed, let's push it back in bean - model.addPropertyChangeListener( - DmsCoordinateEditorModel.PROPERTY_SECOND, - new ModelPropertyChangeListener(model, secondMutator)); - } - - public void setValue(DmsCoordinate value, boolean pushToModel) { - - if (valueModelIsAdjusting) { - // avoid re-entrant code - return; - } - - valueIsAdjusting = !pushToModel; - - try { - ui.getEditor().setValue(value); - } finally { - valueIsAdjusting = false; - } - } - - public void resetEditor() { - - // set null value to model - setValue(null, true); - - // use back unsigned format - ui.getEditor().setFormatterFactory(unsignedFormatterFactory); - } - - public void onKeyReleased(KeyEvent e) { - - JFormattedTextField source = (JFormattedTextField) e.getSource(); - - char keyChar = e.getKeyChar(); - int caretPosition = source.getCaretPosition(); - if (log.isDebugEnabled()) { - log.debug("Key pressed: " + keyChar + " (caret position: " + caretPosition + ")"); - } - - if (keyChar == '-') { - - DmsCoordinate value = (DmsCoordinate) source.getValue(); - - DefaultFormatterFactory newFactory; - - // try to switch unsigned to signed - - boolean useSign = ui.getModel().isSign(); - - if (useSign) { - - if (log.isDebugEnabled()) { - log.debug("Switch to unsigned"); - } - - newFactory = unsignedFormatterFactory; - - // remove a sign - caretPosition--; - } else { - // switch to signed - if (log.isDebugEnabled()) { - log.debug("Switch to signed"); - } - newFactory = signedFormatterFactory; - - // add a sign - caretPosition++; - } - - DmsCoordinate newValue = DmsCoordinate.valueOf(value); - newValue.setSign(!useSign); - - source.setFormatterFactory(newFactory); - source.setValue(newValue); - - e.consume(); - - source.setCaretPosition(caretPosition); - } - } - - protected String getMaskFormatterPattern(boolean longitudeEditor, - boolean useSign) { - String pattern = "**°**''**''''"; - if (longitudeEditor) { - // add one more degre - pattern = "*" + pattern; - } - if (useSign) { - pattern = "-" + pattern; - } - return pattern; - } - - private class ModelPropertyChangeListener implements PropertyChangeListener { - - private final DmsCoordinateEditorModel model; - - private final Method mutator; - - private ModelPropertyChangeListener(DmsCoordinateEditorModel model, Method mutator) { - this.model = model; - this.mutator = mutator; - } - - @Override - public void propertyChange(PropertyChangeEvent evt) { - if (!valueIsAdjusting) { - Object newValue = evt.getNewValue(); - - try { - - valueModelIsAdjusting = true; - try { - mutator.invoke(model.getBean(), newValue); - } finally { - valueModelIsAdjusting = false; - } - - } catch (Exception e) { - throw new RuntimeException(e); - } - } - } - - } -} diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateEditorModel.java b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateEditorModel.java deleted file mode 100644 index 0868d6f..0000000 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateEditorModel.java +++ /dev/null @@ -1,122 +0,0 @@ -package org.nuiton.jaxx.runtime.swing.editor.gis; - -/* - * #%L - * JAXX :: Widgets - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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; - -/** - * Created on 10/16/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.6 - */ -public class DmsCoordinateEditorModel extends DmsCoordinate { - - public static final String PROPERTY_BEAN = "bean"; - - public static final String PROPERTY_PROPERTY_SIGN = "propertySign"; - - public static final String PROPERTY_PROPERTY_DEGREE = "propertyDegree"; - - public static final String PROPERTY_PROPERTY_MINUTE = "propertyMinute"; - - public static final String PROPERTY_PROPERTY_SECOND = "propertySecond"; - - private static final long serialVersionUID = 1L; - - /** Bean where to push data. */ - protected Serializable bean; - - /** Name of the property of the bean to fire the change of the {@link #sign}. */ - protected String propertySign; - - /** Name of the property of the bean to fire the change of the {@link #degree}. */ - protected String propertyDegree; - - /** Name of the property of the bean to fire the change of the {@link #minute}. */ - protected String propertyMinute; - - /** Name of the property of the bean to fire the change of the {@link #second}. */ - protected String propertySecond; - - public Serializable getBean() { - return bean; - } - - public void setBean(Serializable bean) { - Object oldValue = getBean(); - this.bean = bean; - firePropertyChange(PROPERTY_BEAN, oldValue, bean); - } - - public String getPropertySign() { - return propertySign; - } - - public void setPropertySign(String propertySign) { - Object oldValue = getPropertySign(); - this.propertySign = propertySign; - firePropertyChange(PROPERTY_PROPERTY_SIGN, oldValue, propertySign); - } - - public String getPropertyDegree() { - return propertyDegree; - } - - public void setPropertyDegree(String propertyDegree) { - Object oldValue = getPropertyDegree(); - this.propertyDegree = propertyDegree; - firePropertyChange(PROPERTY_PROPERTY_DEGREE, oldValue, propertyDegree); - } - - public String getPropertyMinute() { - return propertyMinute; - } - - public void setPropertyMinute(String propertyMinute) { - Object oldValue = getPropertyMinute(); - this.propertyMinute = propertyMinute; - firePropertyChange(PROPERTY_PROPERTY_MINUTE, oldValue, propertyMinute); - } - - public String getPropertySecond() { - return propertySecond; - } - - public void setPropertySecond(String propertySecond) { - Object oldValue = getPropertySecond(); - this.propertySecond = propertySecond; - firePropertyChange(PROPERTY_PROPERTY_SECOND, oldValue, propertySecond); - } - - public void setValue(DmsCoordinate value) { - setSign(value != null && value.isSign()); - setDegree(value == null ? null : value.getDegree()); - setMinute(value == null ? null : value.getMinute()); - setSecond(value == null ? null : value.getSecond()); - } - - public String getStringPattern() { - return COORDINATE_STRING_PATTERN; - } -} diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/MaskFormatterFromConverter.java b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/MaskFormatterFromConverter.java deleted file mode 100644 index b505de9..0000000 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/gis/MaskFormatterFromConverter.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.nuiton.jaxx.runtime.swing.editor.gis; - -/* - * #%L - * JAXX :: Widgets - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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.beanutils.Converter; - -import javax.swing.text.MaskFormatter; -import java.text.ParseException; - -/** - * Created on 11/25/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.6 - */ -public class MaskFormatterFromConverter<O> extends MaskFormatter { - - private static final long serialVersionUID = 1L; - - private final Converter converter; - - private final Class<O> type; - - public static <O> MaskFormatterFromConverter<O> newFormatter(Class<O> type, - String pattern, - Converter converter) throws ParseException { - return new MaskFormatterFromConverter<>(type, pattern, converter); - } - - protected MaskFormatterFromConverter(Class<O> type, - String pattern, - Converter converter) throws ParseException { - super(pattern); - this.type = type; - this.converter = converter; - } - - @Override - public String valueToString(Object value) throws ParseException { - return converter.convert(String.class, value); - } - - @Override - public Object stringToValue(String value) throws ParseException { - return converter.convert(type, value); - } - - protected Converter getConverter() { - return converter; - } - - protected Class<O> getType() { - return type; - } -} diff --git a/jaxx-widgets/src/main/resources/META-INF/services/org.nuiton.converter.NuitonConverter b/jaxx-widgets/src/main/resources/META-INF/services/org.nuiton.converter.NuitonConverter deleted file mode 100644 index e26305d..0000000 --- a/jaxx-widgets/src/main/resources/META-INF/services/org.nuiton.converter.NuitonConverter +++ /dev/null @@ -1,2 +0,0 @@ -org.nuiton.jaxx.runtime.swing.editor.gis.DmsCoordinateConverter -org.nuiton.jaxx.runtime.swing.editor.gis.DmdCoordinateConverter \ No newline at end of file diff --git a/jaxx-widgets/src/test/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateConverterTest.java b/jaxx-widgets/src/test/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateConverterTest.java deleted file mode 100644 index d21af49..0000000 --- a/jaxx-widgets/src/test/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateConverterTest.java +++ /dev/null @@ -1,102 +0,0 @@ -package org.nuiton.jaxx.runtime.swing.editor.gis; - -/* - * #%L - * JAXX :: Widgets - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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; -import org.nuiton.converter.ConverterUtil; - -/** - * Created on 11/25/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.6 - */ -public class DmdCoordinateConverterTest { - - @Test - public void testConvert() throws Exception { - - ConverterUtil.initConverters(); - - testConversion(false, "- ° '44", DmdCoordinate.valueOf(-0.007333f)); - testConversion(false, " ° '44", DmdCoordinate.valueOf(0.007333f)); - testConversion(false, " ° '99", DmdCoordinate.valueOf(false, null, null, 99)); - testConversion(false, " ° ' ", DmdCoordinate.empty()); - testConversion(false, " °39'99", DmdCoordinate.valueOf(false, null, 39, 99)); - testConversion(false, " °39' ", DmdCoordinate.valueOf(false, null, 39, null)); - testConversion(false, " 0°39'99", DmdCoordinate.valueOf(false, 0, 39, 99)); - testConversion(false, " 0° ' ", DmdCoordinate.valueOf(false, 0, null, null)); - - testConversion(true, "- ° '44", DmdCoordinate.valueOf(-0.007333f)); - testConversion(true, " ° '44", DmdCoordinate.valueOf(0.007333f)); - testConversion(true, " ° ' ", DmdCoordinate.empty()); - testConversion(true, " ° '99", DmdCoordinate.valueOf(false, null, null, 99)); - testConversion(true, " °39'99", DmdCoordinate.valueOf(false, null, 39, 99)); - testConversion(true, " °39' ", DmdCoordinate.valueOf(false, null, 39, null)); - testConversion(true, " 0°39'99", DmdCoordinate.valueOf(false, 0, 39, 99)); - testConversion(true, " 0° ' ", DmdCoordinate.valueOf(false, 0, null, null)); - } - - protected void testConversion(boolean forLongitude, String expectedString, DmdCoordinate expectedCoordinate) { - - DmdCoordinateConverter converter = (DmdCoordinateConverter) ConverterUtil.getConverter(DmdCoordinate.class); - converter.setForLongitude(forLongitude); - Assert.assertNotNull(converter); - - String actualStr; - DmdCoordinate actualCoordinate; - - // String -> DmdCoordinate - - actualCoordinate = converter.convert(DmdCoordinate.class, expectedString); - Assert.assertNotNull(actualCoordinate); - Assert.assertEquals(actualCoordinate.isSign(), expectedCoordinate.isSign()); - Assert.assertEquals(actualCoordinate.getDegree(), expectedCoordinate.getDegree()); - Assert.assertEquals(actualCoordinate.getMinute(), expectedCoordinate.getMinute()); - Assert.assertEquals(actualCoordinate.getDecimal(), expectedCoordinate.getDecimal()); - - // DmdCoordinate -> String - - actualStr = converter.convert(String.class, expectedCoordinate); - - Assert.assertNotNull(actualStr); - Assert.assertEquals(expectedString, actualStr); - - // String -> String - - actualStr = converter.convert(String.class, expectedString); - - Assert.assertNotNull(actualStr); - Assert.assertEquals(expectedString, actualStr); - - // DmdCoordinate -> DmdCoordinate - - actualCoordinate = converter.convert(DmdCoordinate.class, expectedCoordinate); - Assert.assertNotNull(actualCoordinate); - Assert.assertEquals(actualCoordinate.isSign(), expectedCoordinate.isSign()); - Assert.assertEquals(actualCoordinate.getDegree(), expectedCoordinate.getDegree()); - Assert.assertEquals(actualCoordinate.getMinute(), expectedCoordinate.getMinute()); - Assert.assertEquals(actualCoordinate.getDecimal(), expectedCoordinate.getDecimal()); - } -} diff --git a/jaxx-widgets/src/test/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateEditorTest.java b/jaxx-widgets/src/test/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateEditorTest.java deleted file mode 100644 index f6b0c15..0000000 --- a/jaxx-widgets/src/test/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateEditorTest.java +++ /dev/null @@ -1,204 +0,0 @@ -package org.nuiton.jaxx.runtime.swing.editor.gis; - -/* - * #%L - * JAXX :: Widgets - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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.text.ParseException; - -/** - * To test the {@link DmsCoordinateEditor}. - * - * Created on 10/17/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @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.setShowReset(true); - longitudeEditor.init(true); - - 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.setShowReset(true); - latitudeEditor.init(false); - - final JLabel latitudeResult = new JLabel(); - final JLabel longitudeResult = new JLabel(); - - bean.addPropertyChangeListener(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(() -> { - frame.setSize(800, 200); - frame.setVisible(true); - }); - } -} diff --git a/jaxx-widgets/src/test/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateTest.java b/jaxx-widgets/src/test/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateTest.java deleted file mode 100644 index bf638f8..0000000 --- a/jaxx-widgets/src/test/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmdCoordinateTest.java +++ /dev/null @@ -1,136 +0,0 @@ -package org.nuiton.jaxx.runtime.swing.editor.gis; - -/* - * #%L - * JAXX :: Widgets - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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 - dev@tchemit.fr - * @since 2.6 - */ -public class DmdCoordinateTest { - - @Test - public void testFromDecimal() throws Exception { - - { - DmdCoordinate coordinate = DmdCoordinate.empty(); - - coordinate.fromDecimal(42.7f); - - assertDmdCoordinate(coordinate, false, 42, 42, null); - - coordinate.addTrailingZero(); - - assertDmdCoordinate(coordinate, false, 42, 42, 0); - - coordinate.removeTrailingZero(); - - assertDmdCoordinate(coordinate, false, 42, 42, null); - } - - { - DmdCoordinate coordinate = DmdCoordinate.empty(); - - float decimalExcepted = 42.707f; - coordinate.fromDecimal(decimalExcepted); - - assertDmdCoordinate(coordinate, false, 42, 42, 42); - - Float decimal = coordinate.toDecimal(); - Assert.assertEquals(decimalExcepted, decimal, 0.001); - } - } - - @Test - public void testToDecimal() throws Exception { - - { - DmdCoordinate coordinate = DmdCoordinate.empty(); - coordinate.setDegree(42); - coordinate.setMinute(42); - coordinate.setDecimal(42); - Float actual = coordinate.toDecimal(); - Float expected = 42.707f; - Assert.assertEquals(expected, actual, 0.001); - } - - { - DmdCoordinate coordinate = DmdCoordinate.empty(); - coordinate.setDegree(12); - coordinate.setMinute(12); - Float actual = coordinate.toDecimal(); - Float expected = 12.2f; - Assert.assertEquals(expected, actual, 0.0001); - - coordinate.fromDecimal(expected); - - assertDmdCoordinate(coordinate, false, 12, 12, null); - } - - { - 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); - - assertDmdCoordinate(component, false, 12, 12, 20); - - } - } - - @Test - public void testValueOf() throws Exception { - - DmdCoordinate coordinate = DmdCoordinate.valueOf(-0.007333f); - Assert.assertNotNull(coordinate); - Assert.assertTrue(coordinate.isDegreeNull()); - Assert.assertTrue(coordinate.isMinuteNull()); - - Assert.assertTrue(coordinate.isDegreeValid(true)); - Assert.assertTrue(coordinate.isMinuteValid()); - Assert.assertTrue(coordinate.isDecimalValid()); - - assertDmdCoordinate(coordinate, true, null, null, 44); - } - - public static void assertDmdCoordinate(DmdCoordinate coordinate, - boolean expectedSign, - Integer expectedDegree, - Integer expectedMinute, - Integer expectedDecimal) { - Assert.assertNotNull(coordinate); - Assert.assertEquals(expectedSign, coordinate.isSign()); - Assert.assertEquals(expectedDegree, coordinate.getDegree()); - Assert.assertEquals(expectedMinute, coordinate.getMinute()); - Assert.assertEquals(expectedDecimal, coordinate.getDecimal()); - } -} diff --git a/jaxx-widgets/src/test/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateConverterTest.java b/jaxx-widgets/src/test/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateConverterTest.java deleted file mode 100644 index b2c4ca1..0000000 --- a/jaxx-widgets/src/test/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateConverterTest.java +++ /dev/null @@ -1,105 +0,0 @@ -package org.nuiton.jaxx.runtime.swing.editor.gis; - -/* - * #%L - * JAXX :: Widgets - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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; -import org.nuiton.converter.ConverterUtil; - -/** - * Created on 11/25/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.6 - */ -public class DmsCoordinateConverterTest { - - - @Test - public void testConvert() throws Exception { - - ConverterUtil.initConverters(); - - testConversion(false, "- ° '26''", DmsCoordinate.valueOf(-0.007333f)); - testConversion(false, " ° '26''", DmsCoordinate.valueOf(0.007333f)); - testConversion(false, " ° '59''", DmsCoordinate.valueOf(false, null, null, 59)); - testConversion(false, " ° ' ''", DmsCoordinate.empty()); - testConversion(false, " °39'59''", DmsCoordinate.valueOf(false, null, 39, 59)); - testConversion(false, " °39' ''", DmsCoordinate.valueOf(false, null, 39, null)); - testConversion(false, " 0°39'59''", DmsCoordinate.valueOf(false, 0, 39, 59)); - testConversion(false, " 0° ' ''", DmsCoordinate.valueOf(false, 0, null, null)); - - testConversion(true, "- ° '26''", DmsCoordinate.valueOf(-0.007333f)); - testConversion(true, " ° '26''", DmsCoordinate.valueOf(0.007333f)); - testConversion(true, " ° ' ''", DmsCoordinate.empty()); - testConversion(true, " ° '59''", DmsCoordinate.valueOf(false, null, null, 59)); - testConversion(true, " °39'59''", DmsCoordinate.valueOf(false, null, 39, 59)); - testConversion(true, " °39' ''", DmsCoordinate.valueOf(false, null, 39, null)); - testConversion(true, " 0°39'59''", DmsCoordinate.valueOf(false, 0, 39, 59)); - testConversion(true, " 0° ' ''", DmsCoordinate.valueOf(false, 0, null, null)); - } - - protected void testConversion(boolean forLongitude, - String expectedString, - DmsCoordinate expectedCoordinate) { - - DmsCoordinateConverter converter = (DmsCoordinateConverter) ConverterUtil.getConverter(DmsCoordinate.class); - converter.setForLongitude(forLongitude); - Assert.assertNotNull(converter); - - String actualStr; - DmsCoordinate actualCoordinate; - - // String -> DmsCoordinate - - actualCoordinate = converter.convert(DmsCoordinate.class, expectedString); - Assert.assertNotNull(actualCoordinate); - Assert.assertEquals(actualCoordinate.isSign(), expectedCoordinate.isSign()); - Assert.assertEquals(actualCoordinate.getDegree(), expectedCoordinate.getDegree()); - Assert.assertEquals(actualCoordinate.getMinute(), expectedCoordinate.getMinute()); - Assert.assertEquals(actualCoordinate.getSecond(), expectedCoordinate.getSecond()); - - // DmsCoordinate -> String - - actualStr = converter.convert(String.class, expectedCoordinate); - - Assert.assertNotNull(actualStr); - Assert.assertEquals(expectedString, actualStr); - - // String -> String - - actualStr = converter.convert(String.class, expectedString); - - Assert.assertNotNull(actualStr); - Assert.assertEquals(expectedString, actualStr); - - // DmsCoordinate -> DmsCoordinate - - actualCoordinate = converter.convert(DmsCoordinate.class, expectedCoordinate); - Assert.assertNotNull(actualCoordinate); - Assert.assertEquals(actualCoordinate.isSign(), expectedCoordinate.isSign()); - Assert.assertEquals(actualCoordinate.getDegree(), expectedCoordinate.getDegree()); - Assert.assertEquals(actualCoordinate.getMinute(), expectedCoordinate.getMinute()); - Assert.assertEquals(actualCoordinate.getSecond(), expectedCoordinate.getSecond()); - } -} diff --git a/jaxx-widgets/src/test/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateEditorTest.java b/jaxx-widgets/src/test/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateEditorTest.java deleted file mode 100644 index 4a8c10a..0000000 --- a/jaxx-widgets/src/test/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateEditorTest.java +++ /dev/null @@ -1,206 +0,0 @@ -package org.nuiton.jaxx.runtime.swing.editor.gis; - -/* - * #%L - * JAXX :: Widgets - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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.text.ParseException; - -/** - * To test the {@link DmsCoordinateEditor}. - * - * Created on 10/17/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @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 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 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 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 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.setShowReset(true); - longitudeEditor.init(true); - - 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.setShowReset(true); - latitudeEditor.init(false); - - final JLabel latitudeResult = new JLabel(); - final JLabel longitudeResult = new JLabel(); - - bean.addPropertyChangeListener(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(() -> { - frame.setSize(800, 200); - frame.setVisible(true); - }); - } -} diff --git a/jaxx-widgets/src/test/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateTest.java b/jaxx-widgets/src/test/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateTest.java deleted file mode 100644 index 4fe48d2..0000000 --- a/jaxx-widgets/src/test/java/org/nuiton/jaxx/runtime/swing/editor/gis/DmsCoordinateTest.java +++ /dev/null @@ -1,131 +0,0 @@ -package org.nuiton.jaxx.runtime.swing.editor.gis; - -/* - * #%L - * JAXX :: Widgets - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * 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 11/25/13. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.6 - */ -public class DmsCoordinateTest { - - @Test - public void testFromDecimal() throws Exception { - - { - DmsCoordinate actual = DmsCoordinate.empty(); - - actual.fromDecimal(42.7f); - - assertDmsCoordinate(actual, false, 42, 42, null); - } - - { - DmsCoordinate actual = DmsCoordinate.empty(); - - float decimalExcepted = 42.711f; - actual.fromDecimal(decimalExcepted); - - assertDmsCoordinate(actual, false, 42, 42, 39); - - Float decimal = actual.toDecimal(); - Assert.assertEquals(decimalExcepted, decimal, 0.001); - } - } - - @Test - public void testToDecimal() throws Exception { - - { - DmsCoordinate coordinate = DmsCoordinate.empty(); - coordinate.setDegree(42); - coordinate.setMinute(42); - coordinate.setSecond(42); - Float floatValue = coordinate.toDecimal(); - Float expected = 42.711f; - Assert.assertEquals(expected, floatValue, 0.001); - } - - { - DmsCoordinate coordinate = DmsCoordinate.empty(); - coordinate.setDegree(12); - coordinate.setMinute(12); - - Float floatValue = coordinate.toDecimal(); - Float expected = 12.2001f; - Assert.assertEquals(expected, floatValue, 0.001); - - coordinate.fromDecimal(expected); - assertDmsCoordinate(coordinate, false, 12, 12, null); - - } - - { - DmsCoordinate coordinate = DmsCoordinate.empty(); - coordinate.setDegree(12); - coordinate.setMinute(12); - coordinate.setSecond(20); - Float floatValue = coordinate.toDecimal(); - Float expected = 12.20569f; - Assert.assertEquals(expected, floatValue, 0.001); - - coordinate.fromDecimal(expected); - - assertDmsCoordinate(coordinate, false, 12, 12, 20); - } - } - - - @Test - public void testValueOf() throws Exception { - - DmsCoordinate coordinate = DmsCoordinate.valueOf(-0.007333f); - Assert.assertNotNull(coordinate); - Assert.assertTrue(coordinate.isDegreeNull()); - Assert.assertTrue(coordinate.isMinuteNull()); - Assert.assertFalse(coordinate.isSecondNull()); - - - Assert.assertTrue(coordinate.isDegreeValid(true)); - Assert.assertTrue(coordinate.isMinuteValid()); - Assert.assertTrue(coordinate.isSecondValid()); - - assertDmsCoordinate(coordinate, true, null, null, 26); - } - - public static void assertDmsCoordinate(DmsCoordinate coordinate, - boolean expectedSign, - Integer expectedDegree, - Integer expectedMinute, - Integer expectedSecond) { - Assert.assertNotNull(coordinate); - Assert.assertEquals(expectedSign, coordinate.isSign()); - Assert.assertEquals(expectedDegree, coordinate.getDegree()); - Assert.assertEquals(expectedMinute, coordinate.getMinute()); - Assert.assertEquals(expectedSecond, coordinate.getSecond()); - } -} diff --git a/jaxx-widgets/src/test/resources/log4j.properties b/jaxx-widgets/src/test/resources/log4j.properties deleted file mode 100644 index b7b98bb..0000000 --- a/jaxx-widgets/src/test/resources/log4j.properties +++ /dev/null @@ -1,30 +0,0 @@ -### -# #%L -# JAXX :: Widgets -# %% -# Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit -# %% -# 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% -### -# Global logging configuration -log4j.rootLogger=ERROR, stdout -# Console output... -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n - -log4j.logger.org.nuiton=WARN -log4j.logger.org.nuiton.jaxx=INFO -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository jaxx. See https://gitlab.nuiton.org/nuiton/jaxx.git commit 91a98aba3e5c5f8f42332a9907b56a43f5c9ccb3 Author: Tony CHEMIT <dev@tchemit.fr> Date: Sat Dec 31 13:31:38 2016 +0100 Introduce jaxx-widgets-file module (Fixes #4105) --- jaxx-config/pom.xml | 6 + .../org/nuiton/jaxx/config/ConfigTableEditor.java | 2 +- jaxx-demo/pom.xml | 6 + .../demo/component/jaxx/editor/FileEditorDemo.jaxx | 2 +- .../feature/databinding/BindingExtremeDemo.jaxx | 2 +- jaxx-widgets-file/LICENSE.txt | 165 +++++++++++++++++++++ jaxx-widgets-file/README.md | 2 + jaxx-widgets-file/changelog.txt | 5 + {jaxx-config => jaxx-widgets-file}/pom.xml | 58 +++----- .../src/license/THIRD-PARTY.properties | 20 +++ .../nuiton/jaxx/widgets/file}/FileCellEditor.java | 4 +- .../org/nuiton/jaxx/widgets/file}/FileEditor.jaxx | 0 .../jaxx/widgets/file}/FileEditorHandler.java | 3 +- .../nuiton/jaxx/widgets/file}/JaxxFileChooser.java | 2 +- .../i18n/jaxx-widgets-file_en_GB.properties | 69 +++++++++ .../i18n/jaxx-widgets-file_es_ES.properties | 69 +++++++++ .../i18n/jaxx-widgets-file_fr_FR.properties | 69 +++++++++ .../resources/icons/action-fileeditor-reset.png | Bin 0 -> 396 bytes .../src/main/resources/icons/action-filter.png | Bin 0 -> 3615 bytes .../src/main/resources/icons/action-open.png | Bin 0 -> 606 bytes jaxx-widgets-file/src/site/site.xml | 46 ++++++ jaxx-widgets/pom.xml | 10 -- .../nuiton/jaxx/runtime/swing/JAXXWidgetUtil.java | 5 - pom.xml | 1 + 24 files changed, 485 insertions(+), 61 deletions(-) diff --git a/jaxx-config/pom.xml b/jaxx-config/pom.xml index 8e48d5c..8e387c8 100644 --- a/jaxx-config/pom.xml +++ b/jaxx-config/pom.xml @@ -66,6 +66,12 @@ </dependency> <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>jaxx-widgets-file</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> <groupId>org.swinglabs.swingx</groupId> <artifactId>swingx-common</artifactId> </dependency> diff --git a/jaxx-config/src/main/java/org/nuiton/jaxx/config/ConfigTableEditor.java b/jaxx-config/src/main/java/org/nuiton/jaxx/config/ConfigTableEditor.java index ae89df6..6cb21d1 100644 --- a/jaxx-config/src/main/java/org/nuiton/jaxx/config/ConfigTableEditor.java +++ b/jaxx-config/src/main/java/org/nuiton/jaxx/config/ConfigTableEditor.java @@ -30,7 +30,7 @@ import org.nuiton.jaxx.runtime.swing.editor.ClassCellEditor; import org.nuiton.jaxx.runtime.swing.editor.ColorCellEditor; import org.nuiton.jaxx.runtime.swing.editor.EnumEditor; import org.nuiton.jaxx.runtime.swing.editor.LocaleEditor; -import org.nuiton.jaxx.runtime.swing.editor.cell.FileCellEditor; +import org.nuiton.jaxx.widgets.file.FileCellEditor; import org.apache.commons.lang3.StringUtils; import javax.swing.DefaultCellEditor; diff --git a/jaxx-demo/pom.xml b/jaxx-demo/pom.xml index f605d87..0f4baee 100644 --- a/jaxx-demo/pom.xml +++ b/jaxx-demo/pom.xml @@ -98,6 +98,12 @@ <dependency> <groupId>${project.groupId}</groupId> + <artifactId>jaxx-widgets-file</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>${project.groupId}</groupId> <artifactId>jaxx-widgets-gis</artifactId> <version>${project.version}</version> </dependency> diff --git a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/FileEditorDemo.jaxx b/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/FileEditorDemo.jaxx index 6e10e52..258e9b5 100644 --- a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/FileEditorDemo.jaxx +++ b/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/component/jaxx/editor/FileEditorDemo.jaxx @@ -21,7 +21,7 @@ --> <org.nuiton.jaxx.demo.DemoPanel layout='{new BorderLayout()}'> <import> - org.nuiton.jaxx.runtime.swing.editor.FileEditor + org.nuiton.jaxx.widgets.file.FileEditor </import> <String id='title' javaBean='"Open file"'/> diff --git a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/feature/databinding/BindingExtremeDemo.jaxx b/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/feature/databinding/BindingExtremeDemo.jaxx index 05f3e29..4396594 100644 --- a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/feature/databinding/BindingExtremeDemo.jaxx +++ b/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/feature/databinding/BindingExtremeDemo.jaxx @@ -26,7 +26,7 @@ <import> org.nuiton.jaxx.runtime.JAXXBinding - org.nuiton.jaxx.runtime.JaxxFileChooser + org.nuiton.jaxx.widgets.file.JaxxFileChooser java.awt.Color javax.swing.border.TitledBorder javax.swing.DefaultListModel diff --git a/jaxx-widgets-file/LICENSE.txt b/jaxx-widgets-file/LICENSE.txt new file mode 100644 index 0000000..cca7fc2 --- /dev/null +++ b/jaxx-widgets-file/LICENSE.txt @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/jaxx-widgets-file/README.md b/jaxx-widgets-file/README.md new file mode 100644 index 0000000..d2e50d3 --- /dev/null +++ b/jaxx-widgets-file/README.md @@ -0,0 +1,2 @@ +To deploy new version of pom: mvn deploy +To install localy: mvn install diff --git a/jaxx-widgets-file/changelog.txt b/jaxx-widgets-file/changelog.txt new file mode 100644 index 0000000..1e285bd --- /dev/null +++ b/jaxx-widgets-file/changelog.txt @@ -0,0 +1,5 @@ +1.6.0 + * introduce StatusMessageBar and AboutPanel (fork from nuiton-widgets but in JAXX :)) + +1.5 + * 20090404 [chemit] - initial version diff --git a/jaxx-config/pom.xml b/jaxx-widgets-file/pom.xml similarity index 80% copy from jaxx-config/pom.xml copy to jaxx-widgets-file/pom.xml index 8e48d5c..eeec01c 100644 --- a/jaxx-config/pom.xml +++ b/jaxx-widgets-file/pom.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- #%L - JAXX :: Widgets + JAXX :: Widgets File $Id$ $HeadURL$ @@ -35,16 +35,16 @@ </parent> <groupId>org.nuiton.jaxx</groupId> - <artifactId>jaxx-config</artifactId> + <artifactId>jaxx-widgets-file</artifactId> + + <name>JAXX :: Widgets File</name> + <description>Collection of widgets around File</description> - <name>JAXX :: Config</name> - <description> - Config UI based on org.nuiton.config.ApplicationConfig - </description> <properties> <jaxx.addSourcesToClassPath>true</jaxx.addSourcesToClassPath> <jaxx.autoImportCss>true</jaxx.autoImportCss> + <jaxx.addAutoHandlerUI>true</jaxx.addAutoHandlerUI> <jaxx.cssExtension>jcss</jaxx.cssExtension> <!--jaxx.useUIManagerForIcon>true</jaxx.useUIManagerForIcon--> </properties> @@ -58,7 +58,13 @@ <artifactId>jaxx-runtime</artifactId> <version>${project.version}</version> </dependency> - + <!--Should use this--> + <!--dependency> + <groupId>${project.groupId}</groupId> + <artifactId>jaxx-widgets-common</artifactId> + <version>${project.version}</version> + </dependency--> + <!--Remove this--> <dependency> <groupId>${project.groupId}</groupId> <artifactId>jaxx-widgets</artifactId> @@ -66,31 +72,11 @@ </dependency> <dependency> - <groupId>org.swinglabs.swingx</groupId> - <artifactId>swingx-common</artifactId> - </dependency> - - <dependency> - <groupId>org.swinglabs.swingx</groupId> - <artifactId>swingx-core</artifactId> - </dependency> - - <dependency> <groupId>org.nuiton.i18n</groupId> <artifactId>nuiton-i18n</artifactId> </dependency> <dependency> - <groupId>org.nuiton</groupId> - <artifactId>nuiton-config</artifactId> - </dependency> - - <dependency> - <groupId>org.nuiton</groupId> - <artifactId>nuiton-converter</artifactId> - </dependency> - - <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> </dependency> @@ -104,12 +90,6 @@ <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> </dependency> - - - <dependency> - <groupId>commons-beanutils</groupId> - <artifactId>commons-beanutils</artifactId> - </dependency> <dependency> <groupId>log4j</groupId> @@ -117,11 +97,6 @@ <scope>provided</scope> </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - </dependency> - </dependencies> <build> @@ -148,6 +123,13 @@ </goals> </execution> </executions> + <dependencies> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>jaxx-widgets</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> </plugin> <plugin> diff --git a/jaxx-widgets-file/src/license/THIRD-PARTY.properties b/jaxx-widgets-file/src/license/THIRD-PARTY.properties new file mode 100644 index 0000000..81b2769 --- /dev/null +++ b/jaxx-widgets-file/src/license/THIRD-PARTY.properties @@ -0,0 +1,20 @@ +# Generated by org.codehaus.mojo.license.AddThirdPartyMojo +#------------------------------------------------------------------------------- +# Already used licenses in project : +# - BSD License +# - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 +# - Common Public License Version 1.0 +# - GNU General Public License - Version 2 with the class path exception +# - Indiana University Extreme! Lab Software License, vesion 1.1.1 +# - Lesser General Public License (LGPL) +# - Lesser General Public License (LGPL) v 3.0 +# - Lesser General Public License (LPGL) +# - Lesser General Public License (LPGL) v 2.1 +# - MIT License +# - The Apache Software License, Version 2.0 +#------------------------------------------------------------------------------- +# Please fill the missing licenses for dependencies : +# +# +#Thu Aug 18 07:10:57 CEST 2011 +commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0 diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/cell/FileCellEditor.java b/jaxx-widgets-file/src/main/java/org/nuiton/jaxx/widgets/file/FileCellEditor.java similarity index 94% rename from jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/cell/FileCellEditor.java rename to jaxx-widgets-file/src/main/java/org/nuiton/jaxx/widgets/file/FileCellEditor.java index 2c71fbe..3f56930 100644 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/cell/FileCellEditor.java +++ b/jaxx-widgets-file/src/main/java/org/nuiton/jaxx/widgets/file/FileCellEditor.java @@ -19,14 +19,14 @@ * <http://www.gnu.org/licenses/lgpl-3.0.html>. * #L% */ -package org.nuiton.jaxx.runtime.swing.editor.cell; +package org.nuiton.jaxx.widgets.file; import java.awt.Component; import java.io.File; import javax.swing.AbstractCellEditor; import javax.swing.JTable; import javax.swing.table.TableCellEditor; -import org.nuiton.jaxx.runtime.swing.editor.FileEditor; +import org.nuiton.jaxx.widgets.file.FileEditor; /** * @author Sylvain Lletellier diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/FileEditor.jaxx b/jaxx-widgets-file/src/main/java/org/nuiton/jaxx/widgets/file/FileEditor.jaxx similarity index 100% rename from jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/FileEditor.jaxx rename to jaxx-widgets-file/src/main/java/org/nuiton/jaxx/widgets/file/FileEditor.jaxx diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/FileEditorHandler.java b/jaxx-widgets-file/src/main/java/org/nuiton/jaxx/widgets/file/FileEditorHandler.java similarity index 98% rename from jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/FileEditorHandler.java rename to jaxx-widgets-file/src/main/java/org/nuiton/jaxx/widgets/file/FileEditorHandler.java index 1b48850..c746dda 100644 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/FileEditorHandler.java +++ b/jaxx-widgets-file/src/main/java/org/nuiton/jaxx/widgets/file/FileEditorHandler.java @@ -19,11 +19,10 @@ * <http://www.gnu.org/licenses/lgpl-3.0.html>. * #L% */ -package org.nuiton.jaxx.runtime.swing.editor; +package org.nuiton.jaxx.widgets.file; import com.google.common.io.Files; import org.apache.commons.lang3.StringUtils; -import org.nuiton.jaxx.runtime.swing.editor.FileEditor; import javax.swing.JDialog; import javax.swing.JFileChooser; diff --git a/jaxx-runtime/src/main/java/org/nuiton/jaxx/runtime/JaxxFileChooser.java b/jaxx-widgets-file/src/main/java/org/nuiton/jaxx/widgets/file/JaxxFileChooser.java similarity index 99% rename from jaxx-runtime/src/main/java/org/nuiton/jaxx/runtime/JaxxFileChooser.java rename to jaxx-widgets-file/src/main/java/org/nuiton/jaxx/widgets/file/JaxxFileChooser.java index 7e5aa05..8043f5f 100644 --- a/jaxx-runtime/src/main/java/org/nuiton/jaxx/runtime/JaxxFileChooser.java +++ b/jaxx-widgets-file/src/main/java/org/nuiton/jaxx/widgets/file/JaxxFileChooser.java @@ -1,4 +1,4 @@ -package org.nuiton.jaxx.runtime; +package org.nuiton.jaxx.widgets.file; /* * #%L diff --git a/jaxx-widgets-file/src/main/resources/i18n/jaxx-widgets-file_en_GB.properties b/jaxx-widgets-file/src/main/resources/i18n/jaxx-widgets-file_en_GB.properties new file mode 100644 index 0000000..954b4ea --- /dev/null +++ b/jaxx-widgets-file/src/main/resources/i18n/jaxx-widgets-file_en_GB.properties @@ -0,0 +1,69 @@ +aboutframe.about=About +aboutframe.license=License +aboutframe.ok=OK +aboutframe.thirdparty=Third party +bean.action.selected.move.down=Move down +bean.action.selected.move.down.tip=Move down the selected item +bean.action.selected.move.up=Move up +bean.action.selected.move.up.tip=Move up the selected item +bean.action.selected.remove=Unselect +bean.action.selected.remove.tip=Unselect the selected item +bean.popup.label=Object '%1$s' +bean.sort.down=Descending sort +bean.sort.down.tip=Actually, sort order is descending +bean.sort.down.toSelect.tip=To sort in Descending order +bean.sort.label=Sort order +bean.sort.off=Click to activate the sort on this property +bean.sort.on=This is the property actually used +bean.sort.up=Ascending sort +bean.sort.up.tip=Actually, sort order is acending +bean.sort.up.toSelect.tip=Click here to sort in ascending order +bean.unknown.type=Object of unkown type +beancombobox.action.reset.tip=Reset the selected value +beancombobox.action.sort.tip=Change the sorted property +beancombobox.popup.title=Change the sorted property +beandoublelist.action.reset.tip=Reset the value of the filter +beandoublelist.action.sort.tip=Change the sorted property +beandoublelist.button.add=Add +beandoublelist.button.remove=Remove +beandoublelist.popup.title=Change the sorted property +beanlist.action.reset.tip=Reset the selected selection +beanlist.action.sort.tip=Change the sorted property +beanlist.popup.title=Change the sorted property +errorUI.action.close=Close +errorUI.message=An error wad detected... +errorUI.title=Error... +fileeditor.action.reset.tip=Reset +fontsize.action.default.tip=Restore default font size +fontsize.action.down.tip=Decrease font size +fontsize.action.up.tip=Increase font size +hidor.hideTip=Hide +hidor.showTip=Show +i18neditor.empty.locales=< No locale to select > +i18neditor.popup.title=Change language +i18neditor.selected=Selected language \: %1$s +i18neditor.unselected=Select this langage \: %1$s +jaxx.error.no.convertor.coordinateDmd=Impossible to convert form (or to) a DMD coordinate (incoming value\: %s) +jaxx.error.no.convertor.coordinateDms=Impossible to convert form (or to) a DMS coordinate (incoming value\: %s) +jaxx.list.check.all=All +jaxx.table.filter.popup.button.apply=Apply +jaxx.table.filter.popup.button.cancel=Cancel +jaxx.table.filter.popup.button.clearAll=Clear all the filters +memorywidget.memory=%d/%dMb +numbereditor..=. +numbereditor.0=0 +numbereditor.1=1 +numbereditor.2=2 +numbereditor.3=3 +numbereditor.4=4 +numbereditor.5=5 +numbereditor.6=6 +numbereditor.7=7 +numbereditor.8=8 +numbereditor.9=9 +numbereditor.action.reset.tip=Reset +numbereditor.action.show.tip=Show numeric panel +numbereditor.clearAll=C +numbereditor.clearOne=CE +numbereditor.toggleSign=+/- +timeeditor.H=H diff --git a/jaxx-widgets-file/src/main/resources/i18n/jaxx-widgets-file_es_ES.properties b/jaxx-widgets-file/src/main/resources/i18n/jaxx-widgets-file_es_ES.properties new file mode 100644 index 0000000..4d58091 --- /dev/null +++ b/jaxx-widgets-file/src/main/resources/i18n/jaxx-widgets-file_es_ES.properties @@ -0,0 +1,69 @@ +aboutframe.about=A cerca de +aboutframe.license=Licecia +aboutframe.ok=OK +aboutframe.thirdparty=Tierce partie +bean.action.selected.move.down=Descendre +bean.action.selected.move.down.tip=Descendre l'élément sélectionné +bean.action.selected.move.up=Monter +bean.action.selected.move.up.tip=Monter l'élément sélectionné +bean.action.selected.remove=Supprimer +bean.action.selected.remove.tip=Supprimer l'élément sélectionné +bean.popup.label=Objeto '%1$s' +bean.sort.down=Calsificación decreciente +bean.sort.down.tip=Clasificación decreciente actualmente utilizada +bean.sort.down.toSelect.tip=Clic para clasificar según orden decreciente +bean.sort.label=Orden de clasificación +bean.sort.off=Click para activar la clasificación de la propiedad '%1$s' +bean.sort.on=Clasificación realizada sobre la propiedad '%1$s' +bean.sort.up=Clasificación creciente +bean.sort.up.tip=Clasificación creciente actualmente utilizada +bean.sort.up.toSelect.tip=Clic para clasificar según orden creciente +bean.unknown.type=Objeto de tipo desconocido +beancombobox.action.reset.tip=Reiniciar el valor de la lista desplegable +beancombobox.action.sort.tip=Modificar la clasificación de la lista desplegable +beancombobox.popup.title=Modificar la clasificación +beandoublelist.action.reset.tip=Reiniciar el valor de la lista desplegable +beandoublelist.action.sort.tip=Modificar la clasificación de la lista +beandoublelist.button.add=Add +beandoublelist.button.remove=Remove +beandoublelist.popup.title=Modificar la clasificación +beanlist.action.reset.tip=Eliminar la selección +beanlist.action.sort.tip=Modificar la clasificación de la lista despleglable +beanlist.popup.title=Modificar la clasificación +errorUI.action.close=Cerrar +errorUI.message=ha habido un error \! +errorUI.title=Error... +fileeditor.action.reset.tip=Reinicializar +fontsize.action.default.tip=Volver al tamaño por defecto +fontsize.action.down.tip=Disminuir el tamaño del origen +fontsize.action.up.tip=Aumentar el tamaño de la fuente +hidor.hideTip=Ocultar +hidor.showTip=Ver +i18neditor.empty.locales=< Aucune locale à sélectionner > +i18neditor.popup.title=Cambiar idioma +i18neditor.selected=Idioma usado actualmente \: %1$s +i18neditor.unselected=Para usar este idioma \: %1$s +jaxx.error.no.convertor.coordinateDmd=Impossible to convert form (or to) a DMD coordinate (incoming value\: %s) +jaxx.error.no.convertor.coordinateDms=Impossible to convert form (or to) a DMS coordinate (incoming value\: %s) +jaxx.list.check.all=Todos +jaxx.table.filter.popup.button.apply=Applicar +jaxx.table.filter.popup.button.cancel=Anular +jaxx.table.filter.popup.button.clearAll=Eliminar +memorywidget.memory=%d/%dMo +numbereditor..=. +numbereditor.0=0 +numbereditor.1=1 +numbereditor.2=2 +numbereditor.3=3 +numbereditor.4=4 +numbereditor.5=5 +numbereditor.6=6 +numbereditor.7=7 +numbereditor.8=8 +numbereditor.9=9 +numbereditor.action.reset.tip=Reinicializar +numbereditor.action.show.tip=Mostar el teclado numérico +numbereditor.clearAll=C +numbereditor.clearOne=CE +numbereditor.toggleSign=+/- +timeeditor.H=H diff --git a/jaxx-widgets-file/src/main/resources/i18n/jaxx-widgets-file_fr_FR.properties b/jaxx-widgets-file/src/main/resources/i18n/jaxx-widgets-file_fr_FR.properties new file mode 100644 index 0000000..abb0e71 --- /dev/null +++ b/jaxx-widgets-file/src/main/resources/i18n/jaxx-widgets-file_fr_FR.properties @@ -0,0 +1,69 @@ +aboutframe.about=À propos +aboutframe.license=Licence +aboutframe.ok=OK +aboutframe.thirdparty=Tierce partie +bean.action.selected.move.down=Descendre +bean.action.selected.move.down.tip=Descendre l'élément sélectionné +bean.action.selected.move.up=Monter +bean.action.selected.move.up.tip=Monter l'élément sélectionné +bean.action.selected.remove=Supprimer +bean.action.selected.remove.tip=Supprimer l'élément sélectionné +bean.popup.label=Objet '%1$s' +bean.sort.down=Tri décroissant +bean.sort.down.tip=Tri décroissant actuellement utilisé +bean.sort.down.toSelect.tip=Cliquer pour trier selon l'ordre décroissant +bean.sort.label=Ordre de tri +bean.sort.off=Cliquer pour activer le tri sur la propriété '%1$s' +bean.sort.on=Le tri est effectué sur la propriété '%1$s' +bean.sort.up=Tri croissant +bean.sort.up.tip=Tri croissant actuellement utilisé +bean.sort.up.toSelect.tip=Cliquer pour trier selon l'ordre croissant +bean.unknown.type=Objet de type inconnu +beancombobox.action.reset.tip=Réinitialiser la valeur de la liste déroulante +beancombobox.action.sort.tip=Modifier le tri de la liste déroulante +beancombobox.popup.title=Modifier le tri +beandoublelist.action.reset.tip=Réinitialiser la valeur du filtre +beandoublelist.action.sort.tip=Modifier le tri de la liste +beandoublelist.button.add=Ajouter +beandoublelist.button.remove=Enlever +beandoublelist.popup.title=Modifier le tri +beanlist.action.reset.tip=Supprimer la sélection +beanlist.action.sort.tip=Modifier le tri de la liste déroulante +beanlist.popup.title=Modifier le tri +errorUI.action.close=Fermer +errorUI.message=Une erreur est survenue \! +errorUI.title=Erreur... +fileeditor.action.reset.tip=Réinitialiser +fontsize.action.default.tip=Retour sur la taille par défaut +fontsize.action.down.tip=Diminuer la taille de la police +fontsize.action.up.tip=Augmenter la taille de la police +hidor.hideTip=Cacher +hidor.showTip=Voir +i18neditor.empty.locales=< Aucune locale à sélectionner > +i18neditor.popup.title=Changer de langue +i18neditor.selected=Langue actuellement utilisée \: %1$s +i18neditor.unselected=Pour utiliser cette langue \: %1$s +jaxx.error.no.convertor.coordinateDmd=Impossible de convertir en (ou depuis) une coordonée DMD depuis la valeur %s +jaxx.error.no.convertor.coordinateDms=Impossible de convertir en (ou depuis) une coordonée DMS depuis la valeur %s +jaxx.list.check.all=Tous +jaxx.table.filter.popup.button.apply=Appliquer +jaxx.table.filter.popup.button.cancel=Annuler +jaxx.table.filter.popup.button.clearAll=Supprimer tous les filtres +memorywidget.memory=%d/%dMo +numbereditor..=. +numbereditor.0=0 +numbereditor.1=1 +numbereditor.2=2 +numbereditor.3=3 +numbereditor.4=4 +numbereditor.5=5 +numbereditor.6=6 +numbereditor.7=7 +numbereditor.8=8 +numbereditor.9=9 +numbereditor.action.reset.tip=Réinitialiser +numbereditor.action.show.tip=Afficher le pavé numérique +numbereditor.clearAll=C +numbereditor.clearOne=CE +numbereditor.toggleSign=+/- +timeeditor.H=H diff --git a/jaxx-widgets-file/src/main/resources/icons/action-fileeditor-reset.png b/jaxx-widgets-file/src/main/resources/icons/action-fileeditor-reset.png new file mode 100644 index 0000000..0fb00f9 Binary files /dev/null and b/jaxx-widgets-file/src/main/resources/icons/action-fileeditor-reset.png differ diff --git a/jaxx-widgets-file/src/main/resources/icons/action-filter.png b/jaxx-widgets-file/src/main/resources/icons/action-filter.png new file mode 100644 index 0000000..397e078 Binary files /dev/null and b/jaxx-widgets-file/src/main/resources/icons/action-filter.png differ diff --git a/jaxx-widgets-file/src/main/resources/icons/action-open.png b/jaxx-widgets-file/src/main/resources/icons/action-open.png new file mode 100755 index 0000000..e9c4476 Binary files /dev/null and b/jaxx-widgets-file/src/main/resources/icons/action-open.png differ diff --git a/jaxx-widgets-file/src/site/site.xml b/jaxx-widgets-file/src/site/site.xml new file mode 100644 index 0000000..8d5a39f --- /dev/null +++ b/jaxx-widgets-file/src/site/site.xml @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + JAXX :: Widgets + %% + Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit + %% + 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% + --> + +<project name="${project.name}" + xmlns="http://maven.apache.org/DECORATION/1.4.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/DECORATION/1.4.0 http://maven.apache.org/xsd/decoration-1.4.0.xsd"> + + <bannerLeft> + <name>${project.name}</name> + <src>${siteCommonResourcesUrl}/images/logos/jaxx-logo.png</src> + <href>index.html</href> + </bannerLeft> + + <body> + + <breadcrumbs> + <item name="${project.name}" href="index.html"/> + </breadcrumbs> + + <menu ref="parent"/> + + <menu ref="reports"/> + + </body> +</project> diff --git a/jaxx-widgets/pom.xml b/jaxx-widgets/pom.xml index 1464273..3bad327 100644 --- a/jaxx-widgets/pom.xml +++ b/jaxx-widgets/pom.xml @@ -90,11 +90,6 @@ </dependency> <dependency> - <groupId>org.nuiton</groupId> - <artifactId>nuiton-converter</artifactId> - </dependency> - - <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> </dependency> @@ -125,11 +120,6 @@ </dependency> <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - </dependency> - - <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <scope>provided</scope> diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/JAXXWidgetUtil.java b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/JAXXWidgetUtil.java index cff617d..0de7547 100644 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/JAXXWidgetUtil.java +++ b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/JAXXWidgetUtil.java @@ -23,7 +23,6 @@ package org.nuiton.jaxx.runtime.swing; import org.nuiton.jaxx.runtime.SwingUtil; import org.nuiton.jaxx.runtime.swing.editor.cell.DateCellEditor; -import org.nuiton.jaxx.runtime.swing.editor.cell.FileCellEditor; import org.nuiton.jaxx.runtime.swing.editor.cell.KeyStrokeCellEditor; import org.nuiton.jaxx.runtime.swing.renderer.DateCellRenderer; @@ -47,10 +46,6 @@ public class JAXXWidgetUtil extends SwingUtil { return new DateCellEditor(); } - public static TableCellEditor newFileTableCellEditor() { - return new FileCellEditor(); - } - public static TableCellEditor newKeyStrokeTableCellEditor() { return new KeyStrokeCellEditor(); } diff --git a/pom.xml b/pom.xml index bdd0ef9..4fac0b4 100644 --- a/pom.xml +++ b/pom.xml @@ -40,6 +40,7 @@ <module>jaxx-compiler</module> <module>jaxx-maven-plugin</module> <module>jaxx-widgets-common</module> + <module>jaxx-widgets-file</module> <module>jaxx-widgets-about</module> <module>jaxx-widgets-number</module> <module>jaxx-widgets-select</module> -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm