r1559 - in branches/jaxx-2.X: . jaxx-compiler jaxx-compiler/src/main/java/jaxx jaxx-compiler/src/main/java/jaxx/compiler jaxx-compiler/src/main/java/jaxx/tags jaxx-compiler/src/main/java/jaxx/tags/swing jaxx-compiler/src/main/java/jaxx/tags/validator jaxx-compiler/src/test/java/jaxx/beaninfos jaxx-compiler/src/test/java/jaxx/junit jaxx-compiler/src/test/java/jaxx/runtime/swing/navigation jaxx-demo jaxx-demo/src/main/filters jaxx-demo/src/main/java/jaxx/demo jaxx-demo/src/main/java/jaxx/demo/c
Author: tchemit Date: 2009-10-05 21:15:44 +0200 (Mon, 05 Oct 2009) New Revision: 1559 Added: branches/jaxx-2.X/jaxx-runtime/ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/HBoxBeanInfo.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/VBoxBeanInfo.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JaxxHelpUI.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Application.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BooleanCellRenderer.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EmptyNumberTableCellRenderer.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EnumTableCellRenderer.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/GBC.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBox.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxLayout.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/I18nTableCellRenderer.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Item.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXButtonGroup.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXComboBox.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXList.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTab.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXToggleButton.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTree.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/MyDefaultCellEditor.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/OneClicListSelectionModel.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Spacer.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Table.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBox.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxLayout.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/ClassCellEditor.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/EnumEditor.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/LocaleEditor.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationCardPanel.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationPanel.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemTreeNavigationAdapter.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-en_GB.properties branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-fr_FR.properties branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/ branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-delete.png branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-config-16.png branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-config.png branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-message-16.png branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-message.png branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-next-16.png branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-next.png branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-pause-16.png branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-pause.png branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-previous-16.png branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-previous.png branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-refresh-16.png branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-refresh.png branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-start-16.png branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-start.png branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-canceled-16.png branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-canceled.png branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-failed-16.png branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-failed.png branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-need_fix-16.png branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-need_fix.png branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-pending-16.png branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-pending.png branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-running-16.png branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-running.png branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-successed-16.png branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-successed.png branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/error.png branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/info.png branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/warning.png branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/ branches/jaxx-2.X/jaxx-widgets/ Removed: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/EnumEditorHandler.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/LocaleEditorHandler.java branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/ branches/jaxx-2.X/jaxx-example/ branches/jaxx-2.X/jaxx-runtime-api/ branches/jaxx-2.X/jaxx-runtime-swing-widget/ branches/jaxx-2.X/jaxx-runtime-swing/ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/BeanValidatorUtil.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Decorator.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DecoratorUtils.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JXPathDecorator.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/MultiJXPathDecorator.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/PropertyDecorator.java branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-api-en_GB.properties branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-api-fr_FR.properties branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/JXPathDecoratorTest.java branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/MultiJXPathDecoratorTest.java Modified: branches/jaxx-2.X/jaxx-compiler/pom.xml branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/DefaultComponentHandler.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/DefaultObjectHandler.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/TagManager.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/ItemHandler.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JComboBoxHandler.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JSliderHandler.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JWindowHandler.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/RowHandler.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/TabHandler.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/BeanValidatorHandler.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/ExcludeFieldValidatorHandler.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/FieldValidatorHandler.java branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/beaninfos/BeanIntoUtilTest.java branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/junit/TagManagerTest.java branches/jaxx-2.X/jaxx-demo/pom.xml branches/jaxx-2.X/jaxx-demo/src/main/filters/jaxx-demo.properties branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.css branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/BoxedDecoratorDemo.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/StatusMessagePanelDemo.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/ComboEditorDemo.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/I18nEditorDemo.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JButtonDemo.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxDemo.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxMenuItemDemo.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JComboBoxDemo.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JDialogDemo.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JListDemo.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JMenuItemDemo.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JPasswordFieldDemo.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JProgressBarDemo.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonDemo.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonMenuItemDemo.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSliderDemo.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSpinnerDemo.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSplitPaneDemo.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextAreaDemo.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextFieldDemo.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JToggleButtonDemo.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BaseBeanDataBinding.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BeanDataBindingDemo.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorDemo.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/CounterDemo.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyleDemo.jaxx branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties branches/jaxx-2.X/jaxx-demo/src/main/resources/log4j.properties branches/jaxx-2.X/jaxx-runtime/pom.xml branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataContext.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DefaultApplicationContext.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Util.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorField.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidator.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingFileFieldValidator.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/RequiredFileFieldValidator.java branches/jaxx-2.X/jaxx-runtime/src/test/resources/log4j.properties branches/jaxx-2.X/jaxx-swing-action/pom.xml branches/jaxx-2.X/jaxx-widgets/pom.xml branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties branches/jaxx-2.X/maven-jaxx-plugin/pom.xml branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JComboBoxTest1.jaxx branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JComboBoxTest2.jaxx branches/jaxx-2.X/pom.xml Log: simplify modules + refactor NavigationTree and Decorator api + add real JComboBox tag handler (incompatible with JAXX 1.X) Modified: branches/jaxx-2.X/jaxx-compiler/pom.xml =================================================================== --- branches/jaxx-2.X/jaxx-compiler/pom.xml 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-compiler/pom.xml 2009-10-05 19:15:44 UTC (rev 1559) @@ -10,7 +10,7 @@ <parent> <groupId>org.nuiton</groupId> <artifactId>jaxx</artifactId> - <version>1.7.2-SNAPSHOT</version> + <version>2.0.0-SNAPSHOT</version> </parent> <groupId>org.nuiton.jaxx</groupId> @@ -22,17 +22,11 @@ <dependency> <groupId>${project.groupId}</groupId> - <artifactId>jaxx-runtime-api</artifactId> + <artifactId>jaxx-runtime</artifactId> <version>${project.version}</version> </dependency> - + <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>jaxx-runtime-swing</artifactId> - <version>${project.version}</version> - </dependency> - - <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> </dependency> @@ -43,8 +37,8 @@ <!-- *** Project Information ************************************* --> <!-- ************************************************************* --> - <name>${project.artifactId}</name> - <description>Jaxx compiler api</description> + <name>JAXX Compiler</name> + <description>JAXX Compiler api</description> <!-- ************************************************************* --> <!-- *** Build Settings ****************************************** --> Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -4,64 +4,29 @@ */ package jaxx; -import jaxx.tags.swing.JTextComponentHandler; -import jaxx.tags.swing.JTabbedPaneHandler; -import jaxx.tags.swing.TabHandler; -import jaxx.tags.swing.CellHandler; -import jaxx.tags.swing.JComboBoxHandler; -import jaxx.tags.swing.JSliderHandler; -import jaxx.tags.swing.RowHandler; -import jaxx.tags.swing.JSpinnerHandler; -import jaxx.tags.swing.TableHandler; -import jaxx.tags.swing.JScrollPaneHandler; -import jaxx.tags.swing.JProgressBarHandler; -import jaxx.tags.swing.JInternalFrameHandler; -import jaxx.tags.swing.JToolBarHandler; -import jaxx.tags.swing.JRadioButtonHandler; -import jaxx.tags.swing.JSplitPaneHandler; -import jaxx.tags.swing.LocaleEditorHandler; -import jaxx.tags.swing.JCheckBoxHandler; -import jaxx.tags.swing.EnumEditorHandler; -import jaxx.tags.swing.JWindowHandler; -import jaxx.tags.swing.JAXXTabHandler; -import jaxx.tags.swing.JPasswordFieldHandler; -import jaxx.tags.swing.ApplicationHandler; -import jaxx.tags.swing.JMenuHandler; -import jaxx.tags.swing.ItemHandler; -import jaxx.tags.swing.JListHandler; -import jaxx.tags.swing.JPopupMenuHandler; -import jaxx.tags.swing.JTreeHandler; -import jaxx.tags.swing.*; -import jaxx.compiler.JAXXCompiler; -import jaxx.reflect.ClassDescriptorLoader; -import jaxx.runtime.swing.Application; -import jaxx.runtime.swing.JAXXButtonGroup; -import jaxx.runtime.swing.JAXXComboBox; -import jaxx.runtime.swing.JAXXList; -import jaxx.runtime.swing.JAXXTab; -import jaxx.runtime.swing.JAXXTree; -import jaxx.runtime.swing.Table; -import jaxx.spi.Initializer; -import jaxx.tags.DefaultObjectHandler; -import jaxx.tags.TagManager; -import jaxx.types.ColorConverter; -import jaxx.types.GridBagConstraintsConverter; -import jaxx.types.InsetsConverter; -import jaxx.types.KeyStrokeConverter; -import jaxx.types.TypeManager; import jaxx.beaninfos.BeanInfoUtil; -import javax.swing.*; -import javax.swing.text.JTextComponent; -import java.awt.Color; -import java.awt.GridBagConstraints; -import java.awt.Insets; +import jaxx.compiler.JAXXCompiler; import jaxx.compiler.BoxedCompiledObjectDecorator; import jaxx.compiler.CompiledObjectDecorator; import jaxx.compiler.HelpRootCompiledObjectDecorator; + +import jaxx.reflect.ClassDescriptorLoader; + import jaxx.runtime.swing.editor.EnumEditor; import jaxx.runtime.swing.editor.LocaleEditor; +import jaxx.spi.Initializer; + +import jaxx.runtime.swing.*; +import jaxx.tags.*; +import jaxx.tags.swing.*; +import jaxx.types.*; + +import java.awt.*; +import javax.swing.text.JTextComponent; +import javax.swing.*; + public class SwingInitializer implements Initializer { @Override @@ -69,15 +34,21 @@ BeanInfoUtil.addJaxxBeanInfoPath("jaxx.beaninfos"); - TagManager.registerTag("java.awt.*", "ButtonGroup", new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(JAXXButtonGroup.class))); + //TC-20091005 why the namespace was on awt ? ButtonGroup is from javax.swing + TagManager.registerTag("javax.swing.*", "ButtonGroup", new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(JAXXButtonGroup.class))); +// TagManager.registerTag("java.awt.*", "ButtonGroup", new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(JAXXButtonGroup.class))); TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(Application.class), ApplicationHandler.class); TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JCheckBox.class), JCheckBoxHandler.class); TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JCheckBoxMenuItem.class), JCheckBoxHandler.class); - TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(EnumEditor.class), EnumEditorHandler.class); - TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(LocaleEditor.class), LocaleEditorHandler.class); - TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXComboBox.class), JComboBoxHandler.class); - TagManager.registerTag("javax.swing.*", "JComboBox", new JComboBoxHandler(ClassDescriptorLoader.getClassDescriptor(JAXXComboBox.class))); + //TC-20091005 : JAXXComboBox and JComboBox are not the same +// TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXComboBox.class), JComboBoxHandler.class); +// TagManager.registerTag("javax.swing.*", "JComboBox", new JComboBoxHandler(ClassDescriptorLoader.getClassDescriptor(JAXXComboBox.class))); + TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JComboBox.class), JComboBoxHandler.class); + TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(EnumEditor.class), JComboBoxHandler.class); + TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(LocaleEditor.class), JComboBoxHandler.class); + TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXComboBox.class), JAXXComboBoxHandler.class); + TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JDialog.class), JWindowHandler.class); TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JFrame.class), JWindowHandler.class); TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JInternalFrame.class), JInternalFrameHandler.class); Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -371,6 +371,7 @@ final String finalClassName = fullClassName; registerInitializer(new Runnable() { // register an initializer which will create the CompiledObject after pass 1 + @Override public void run() { DefaultObjectHandler handler = (DefaultObjectHandler) TagManager.getTagHandler(null, finalClassName, JAXXCompiler.this); if (handler == null) { @@ -725,15 +726,15 @@ lineNumber = lineAttr; } } - File src = sourceFiles.peek(); + File srcFile = sourceFiles.peek(); try { - src = src.getCanonicalFile(); + srcFile = srcFile.getCanonicalFile(); } catch (IOException e) { // ignore ? } - System.err.print(src); + System.err.print(srcFile); if (lineNumber != null) { System.err.print(":" + ((sourceFiles.size() == 1) ? Integer.parseInt(lineNumber) + lineOffset : lineOffset + 1)); } @@ -789,17 +790,17 @@ } public void reportError(int lineNumber, String error) { - File src = sourceFiles.isEmpty() ? null : sourceFiles.peek(); + File errorFile = sourceFiles.isEmpty() ? null : sourceFiles.peek(); try { - if (src != null) { - src = src.getCanonicalFile(); + if (errorFile != null) { + errorFile = errorFile.getCanonicalFile(); } } catch (IOException e) { // ignore ? } - System.err.print(src != null ? src.getPath() : "<unknown source>"); + System.err.print(errorFile != null ? errorFile.getPath() : "<unknown source>"); if (lineNumber > 0) { System.err.print(":" + lineNumber); } @@ -970,12 +971,12 @@ components[i].getStyleClass(), parentIndex != -1 ? descriptors[parentIndex] : null); } - Stylesheet stylesheet = getStylesheet(); - if (stylesheet == null) { - stylesheet = new Stylesheet(); + Stylesheet css = getStylesheet(); + if (css == null) { + css = new Stylesheet(); } - return new JAXXObjectDescriptor(descriptors, stylesheet); + return new JAXXObjectDescriptor(descriptors, css); } /*---------------------------------------------------------------------------------*/ @@ -1227,6 +1228,7 @@ break; } else { reportError("error parsing parameter list: " + parameters); + break; } default: current.append(c); @@ -1381,7 +1383,7 @@ } // 1.5 adds getCanonicalName; unfortunately we can't depend on 1.5 features yet - public static String getCanonicalName(Class clazz) { + public static String getCanonicalName(Class<?> clazz) { if (clazz.isArray()) { String canonicalName = getCanonicalName(clazz.getComponentType()); if (canonicalName != null) { @@ -1496,14 +1498,17 @@ TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(); transformer.setErrorListener(new ErrorListener() { + @Override public void warning(TransformerException ex) throws TransformerException { throw ex; } + @Override public void error(TransformerException ex) throws TransformerException { throw ex; } + @Override public void fatalError(TransformerException ex) throws TransformerException { throw ex; } Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/DefaultComponentHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/DefaultComponentHandler.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/DefaultComponentHandler.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -183,9 +183,9 @@ return ""; } if (ClassDescriptorLoader.getClassDescriptor(Container.class).isAssignableFrom(getBeanClass()) && name.equals("layout")) { // handle containerDelegate (e.g. contentPane on JFrame) - String containerDelegate = (String) getJAXXBeanInfo().getJAXXBeanDescriptor().getValue("containerDelegate"); - if (containerDelegate != null) { - return id + '.' + containerDelegate + "().setLayout(" + valueCode + ");"; + String cDelegate = (String) getJAXXBeanInfo().getJAXXBeanDescriptor().getValue("containerDelegate"); + if (cDelegate != null) { + return id + '.' + cDelegate + "().setLayout(" + valueCode + ");"; } } // ajout du support i18n Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/DefaultObjectHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/DefaultObjectHandler.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/DefaultObjectHandler.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -57,21 +57,17 @@ * name of a property (e.g. <code>"document"</code>). */ public class DefaultObjectHandler implements TagHandler { + /** The class that this handler provides support for. */ private ClassDescriptor beanClass; - /** The JAXXBeanInfo for the beanClass. */ protected JAXXBeanInfo jaxxBeanInfo; - /** Maps property names to their respective JAXXPropertyDescriptors. */ private Map<String, JAXXPropertyDescriptor> properties; - /** Maps event names to their respective JAXXEventSetDescriptors. */ private Map<String, JAXXEventSetDescriptor> events; - /** Maps property names to their respective ProxyEventInfos. */ private Map<String, ProxyEventInfo> eventInfos; - /** Maps XML tags to the CompiledObjects created from them. */ protected static Map<Element, CompiledObject> objectMap = new WeakHashMap<Element, CompiledObject>(); @@ -82,12 +78,11 @@ * normally throw something else, like <code>DocumentEvent</code>. */ private class ProxyEventInfo { + /** The name of the method or field being proxied, e.g. "getText". */ String memberName; - /** The "actual" event listener for the property in question, e.g. DocumentListener. */ ClassDescriptor listenerClass; - /** * In cases where a different object (such as a model) is more directly responsible for * managing the property, this is the name of the property where that object can be @@ -97,15 +92,12 @@ * attached to the new value, and the data binding to be processed. */ String modelName; - /** The name of the method used to add the "native" event listener, e.g. "addDocumentListener". */ String addMethod; - /** The name of the method used to remove the "native" event listener, e.g. "removeDocumentListener". */ String removeMethod; } - /** * Creates a new <code>DefaultObjectHandler</code> which provides support for the specified class. The * class is not actually introspected until the {@link #compileFirstPass} method is invoked. @@ -116,7 +108,6 @@ this.beanClass = beanClass; } - /** * Performs introspection on the beanClass and stores the results. * @@ -147,7 +138,6 @@ } } - /** * Returns * @@ -157,7 +147,6 @@ return beanClass; } - /** * @return the <code>JAXXBeanInfo</code> for the class which this <code>DefaultObjectHandler</code> * supports. @@ -171,7 +160,6 @@ return jaxxBeanInfo; } - /** * Returns the <code>JAXXBeanInfo</code> for the specified class. * @@ -184,7 +172,6 @@ return JAXXIntrospector.getJAXXBeanInfo(beanClass); } - /** * Returns the type of the named property. This is the return type of the property's <code>get</code> method; * for instance <code>JLabel</code>'s <code>text</code> property is a <code>String</code>. @@ -209,7 +196,6 @@ throw new UnsupportedAttributeException("property '" + propertyName + "' not found in " + object); } - /** * @param name ? * @return <code>true</code> if the named member is <i>bound</i> (fires <code>PropertyChangeEvent</code> @@ -253,12 +239,10 @@ } } - private static ClassDescriptor getEventClass(ClassDescriptor listenerClass) { return listenerClass.getMethodDescriptors()[0].getParameterTypes()[0]; } - /** * @param memberName name of the member * @return an array of members on which the given property depends. For @@ -270,7 +254,6 @@ return eventInfo == null ? null : new String[]{eventInfo.modelName}; } - /** * Returns a snippet of Java code which will cause a <code>PropertyChangeListener</code> to be notified * when the member's value changes. The <code>PropertyChangeListener</code> is provided in the form @@ -342,7 +325,6 @@ } } - public String getRemoveMemberListenerCode(String objectCode, String dataBinding, String memberName, String propertyChangeListenerCode, JAXXCompiler compiler) { if ("getClass".equals(memberName)) { return null; @@ -370,8 +352,7 @@ compiler)); } return result.toString(); - } - catch (NoSuchMethodException e) { + } catch (NoSuchMethodException e) { throw new CompilerException("Internal error: " + e); } } else { @@ -403,7 +384,6 @@ } } - /** * Configures the event handling for members which do not fire <code>PropertyChangeEvent</code> when * modified. The default implementation does nothing. Subclasses should override this method to call @@ -412,7 +392,6 @@ protected void configureProxyEventInfo() { } - /** * Configures a proxy event handler which fires <code>PropertyChangeEvents</code> when a non-bound * member is updated. This is necessary for all fields (which cannot be bound) and for methods that are @@ -427,11 +406,10 @@ * @param memberName the name of the field or method being proxied * @param listenerClass the type of listener which receives events when the field or method is updated */ - public void addProxyEventInfo(String memberName, Class listenerClass) { + public void addProxyEventInfo(String memberName, Class<?> listenerClass) { addProxyEventInfo(memberName, listenerClass, null); } - /** * Configures a proxy event handler which fires <code>PropertyChangeEvents</code> when a non-bound * member is updated. This is necessary for all fields (which cannot be bound) and for methods that are @@ -453,16 +431,15 @@ * @param listenerClass the type of listener which receives events when the field or method is updated * @param modelName the JavaBeans-style name of the model property */ - public void addProxyEventInfo(String memberName, Class listenerClass, String modelName) { + public void addProxyEventInfo(String memberName, Class<?> listenerClass, String modelName) { String listenerName = listenerClass.getName(); listenerName = listenerName.substring(listenerName.lastIndexOf(".") + 1); addProxyEventInfo(memberName, listenerClass, modelName, "add" + listenerName, "remove" + listenerName); } - // TODO: remove this temporary method, complete switchover to ClassDescriptors - public void addProxyEventInfo(String memberName, Class listenerClass, - String modelName, String addMethod, String removeMethod) { + public void addProxyEventInfo(String memberName, Class<?> listenerClass, + String modelName, String addMethod, String removeMethod) { try { addProxyEventInfo(memberName, ClassDescriptorLoader.getClassDescriptor(listenerClass.getName()), modelName, addMethod, removeMethod); } catch (ClassNotFoundException e) { @@ -470,7 +447,6 @@ } } - /** * Configures a proxy event handler which fires <code>PropertyChangeEvents</code> when a non-bound * member is updated. This is necessary for all fields (which cannot be bound) and for methods that are @@ -499,7 +475,7 @@ * @param removeMethod remove method name */ public void addProxyEventInfo(String memberName, ClassDescriptor listenerClass, - String modelName, String addMethod, String removeMethod) { + String modelName, String addMethod, String removeMethod) { ProxyEventInfo info = new ProxyEventInfo(); info.memberName = memberName; info.listenerClass = listenerClass; @@ -512,14 +488,12 @@ eventInfos.put(memberName, info); } - @Override public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { scanAttributesForDependencies(tag, compiler); compileChildrenFirstPass(tag, compiler); } - @Override public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { try { @@ -548,7 +522,6 @@ compileChildrenSecondPass(tag, compiler); } - public void registerCompiledObject(Element tag, JAXXCompiler compiler) { String id = tag.getAttribute("id"); if (id == null || id.length() == 0) { @@ -563,7 +536,6 @@ compiler.registerCompiledObject(object); } - /** * Creates the <code>CompiledObject</code> which will represent the object created by this <code>TagHandler</code>. * @@ -575,7 +547,6 @@ return new CompiledObject(id, getBeanClass(), compiler); } - /** * Initializes the default settings of the object, prior to setting its attribute values. The default * implementation does nothing. @@ -587,7 +558,6 @@ protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) { } - /** * @param property property name to test * @return <code>true</code> if the specified property should be inherited by child components when specified @@ -599,7 +569,6 @@ return false; } - /** * @param name name of event * @return <code>true</code> if the specified name has the form of an event handler attribute @@ -609,7 +578,6 @@ return name.length() > 2 && name.startsWith("on") && Character.isUpperCase(name.charAt(2)); } - /** * Scans all attributes for any dependency classes and adds them to the current compilation * set. Called by <code>compileFirstPass()</code> (it is an error to add dependencies after @@ -632,7 +600,7 @@ if (name.equals("javaBean")) { //compiler.preprocessScript(value); continue; - } + } if (name.equals("constraints") || isEventHandlerName(name)) { compiler.preprocessScript(value); // adds dependencies as a side effect } else if (name.equals("constructorParams")) { @@ -645,7 +613,6 @@ } } - /** * Processes the attributes of an XML tag. Four kinds of attributes are supported: simple property values (of any * datatype supported by {@link #convertFromString}), data binding expressions (attributes containing curly-brace @@ -663,7 +630,7 @@ attributes.add((Attr) children.item(i)); } Collections.sort(attributes, getAttributeComparator()); - + for (Attr attribute : attributes) { String name = attribute.getName(); String value = attribute.getValue().trim(); @@ -702,7 +669,7 @@ if (name.equals("genericType")) { //TC-20090313 check after all atributes been processed - if (object == compiler.getRootObject() ) { + if (object == compiler.getRootObject()) { compiler.setGenericType(value); } else { object.setGenericTypes(value.split(",")); @@ -741,7 +708,6 @@ } } - /** * Returns a <code>Comparator</code> which defines the ordering in which the tag's attributes should be processed. The * default implementation sorts the attributes according to the order defined by the {@link #getAttributeOrdering} method. @@ -750,6 +716,7 @@ */ protected Comparator<Attr> getAttributeComparator() { return new Comparator<Attr>() { + @Override public int compare(Attr a, Attr b) { int aOrder = getAttributeOrdering(a); @@ -760,7 +727,6 @@ }; } - /** * Returns the priority with which a particular attribute should be processed. Lower numbers should be processed before * higher numbers. This value is used by the {@link #getAttributeComparator} method to define the sort ordering. @@ -775,7 +741,6 @@ return 0; } - public String getApplyPropertyOrDataBindingCode(CompiledObject object, String propertyName, String stringValue, JAXXCompiler compiler) { ClassDescriptor type = getPropertyType(object, propertyName, compiler); String binding = compiler.processDataBindings(stringValue, type); @@ -783,7 +748,7 @@ return ""; } try { - Class typeClass = type != null ? ClassDescriptorLoader.getClass(type.getName(), type.getClassLoader()) : null; + Class<?> typeClass = type != null ? ClassDescriptorLoader.getClass(type.getName(), type.getClassLoader()) : null; Object value = convertFromString(propertyName, stringValue, typeClass); return getSetPropertyCode(object.getJavaCode(), propertyName, TypeManager.getJavaCode(value), compiler); } catch (NumberFormatException e) { @@ -796,7 +761,6 @@ return ""; } - /** * Set a single property on an object. The value may be either a simple value or contain data binding expressions. * Simple values are first converted to the property's type using {@link #convertFromString}. @@ -843,7 +807,7 @@ compiler.addInlineStyle(object, propertyName, false); } try { - Class typeClass = type != null ? ClassDescriptorLoader.getClass(type.getName(), type.getClassLoader()) : null; + Class<?> typeClass = type != null ? ClassDescriptorLoader.getClass(type.getName(), type.getClassLoader()) : null; Object value = convertFromString(propertyName, stringValue, typeClass); setProperty(object, propertyName, value, compiler); } catch (NumberFormatException e) { @@ -859,17 +823,14 @@ } } - public void applyStylesheets(CompiledObject object, JAXXCompiler compiler) { applyStylesheets(object, compiler, null); } - private void applyStylesheets(final CompiledObject object, JAXXCompiler compiler, Stylesheet overrides) { applyStylesheets(object, compiler, overrides, true); } - private void applyStylesheets(final CompiledObject object, JAXXCompiler compiler, Stylesheet overrides, boolean recurse) { try { Stylesheet stylesheet = compiler.getStylesheet(); @@ -883,7 +844,7 @@ String id = isRoot ? object.getId() + ' ' + descriptor.getId() : "( " + object.getId() + " ) " + descriptor.getId(); CompiledObject child = new CompiledObject(id, "((" + JAXXCompiler.getCanonicalName(classDescriptor) + ") " + - object.getJavaCode() + ".getObjectById(" + TypeManager.getJavaCode(descriptor.getId()) + "))", + object.getJavaCode() + ".getObjectById(" + TypeManager.getJavaCode(descriptor.getId()) + "))", classDescriptor, compiler, true); @@ -916,15 +877,13 @@ } else if (stylesheet != null) { StylesheetHelper.applyTo(object, compiler, stylesheet, overrides); } - } - catch (ClassNotFoundException e) { + } catch (ClassNotFoundException e) { throw new CompilerException(e); } catch (IllegalArgumentException e) { compiler.reportError(e.getMessage()); } } - /** * Adds the necessary Java code to a <code>CompiledObject</code> to add an event listener at runtime. * @@ -958,7 +917,6 @@ } } - /** * Returns a snippet of Java code which will retrieve an object property at runtime. Typically the code is * just a call to the property's <code>get</code> method, but it can be arbitrarily complex. @@ -986,7 +944,6 @@ throw new UnsupportedAttributeException("property '" + name + "' could not be found in class " + getBeanClass().getName()); } - /** * Returns a snippet of Java code which will set an object property at runtime. Typically the code is * just a call to the property's <code>set</code> method, but it can be arbitrarily complex. @@ -1009,7 +966,6 @@ throw new UnsupportedAttributeException("property '" + name + "' could not be found in class " + getBeanClass().getName()); } - /** * Appends Java code to a <code>CompiledObject</code> in order to implement a property assignment. * <code>setProperty</code> is invoked in response to most XML attributes (those which are not more @@ -1029,7 +985,6 @@ object.appendInitializationCode(getSetPropertyCode(object.getJavaCodeForProperty(name), name, TypeManager.getJavaCode(value), compiler)); } - /** * Maps string values onto integers, so that int-valued enumeration properties can be specified by strings. For * example, when passed a key of 'alignment', this method should normally map the values 'left', 'center', and @@ -1074,7 +1029,6 @@ throw new NumberFormatException(value); } - /** * As {@link TypeManager#convertFromString(String, Class)}, except that it additionally supports constant names * for <code>int</code>-valued types. @@ -1085,7 +1039,7 @@ * @return the converted object * @see #constantValue */ - protected Object convertFromString(String key, String value, Class type) { + protected Object convertFromString(String key, String value, Class<?> type) { if (type == null || type == Object.class) { return value; } @@ -1100,7 +1054,6 @@ } } - /** * Compiles the child tags of the current tag. The default implementation invokes {@link #compileChildTagFirstPass} * for each child tag. @@ -1122,7 +1075,6 @@ } } - /** * Compiles the child tags of the current tag. The default implementation invokes {@link #compileChildTagFirstPass} * for each child tag. @@ -1149,7 +1101,6 @@ } } - /** * Compiles a child of the current tag. The default implementation calls {@link JAXXCompiler#compileFirstPass * JAXXCompiler.compileFirstPass}. @@ -1163,7 +1114,6 @@ compiler.compileFirstPass(tag); } - /** * Compiles a child of the current tag. The default implementation calls {@link JAXXCompiler#compileFirstPass * JAXXCompiler.compileSecondPass}. @@ -1181,4 +1131,4 @@ public String toString() { return getClass().getName() + "[" + getBeanClass().getName() + "]"; } -} \ No newline at end of file +} Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/TagManager.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/TagManager.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/TagManager.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -53,8 +53,9 @@ private String localPart; public QName(String namespaceURI, String localPart) { - if (localPart == null) + if (localPart == null) { throw new NullPointerException(); + } this.namespaceURI = namespaceURI; this.localPart = localPart; } @@ -71,8 +72,9 @@ @Override public boolean equals(Object o) { - if (o == null || !(o instanceof QName)) + if (o == null || !(o instanceof QName)) { return false; + } QName qname = (QName) o; return qname.getNamespaceURI().equals(getNamespaceURI()) && qname.getLocalPart().equals(getLocalPart()); } @@ -101,6 +103,7 @@ * encountered (either the class' simple name, if it is unambiguous, or its fully-qualified name), the specified * <code>TagHandler</code> will be invoked to compile it. * + * @param <T> * @param beanClass the class to associate with a <code>TagHandler</code> * @param handler the <code>TagHandler</code> class, which must descend from <code>DefaultObjectHandler</code> * @throws IllegalArgumentException if the handler class does not descend from <code>DefaultObjectHandler</code> @@ -152,6 +155,7 @@ * It is not an error to register an already-registered tag and namespace combination. The new mapping * will replace the old mapping. * + * @param <T> * @param namespace the tag's namespace * @param tag the simple name of the tag * @param handler the <code>TagHandler</code> which should process the tag @@ -385,15 +389,18 @@ * @return the resolved fqn class name */ public static String resolveClassName(String name, JAXXCompiler compiler) { - if (name.endsWith("[]")) + if (name.endsWith("[]")) { return resolveClassName(name.substring(0, name.length() - 2), compiler) + "[]"; - if (name.indexOf("<") != -1) + } + if (name.indexOf("<") != -1) { name = name.substring(0, name.indexOf("<")); // strip off generic types + } name = name.intern(); if (name.equals("boolean") || name.equals("byte") || name.equals("short") || name.equals("int") || - name.equals("long") || name.equals("float") || name.equals("double") || name.equals("char")) + name.equals("long") || name.equals("float") || name.equals("double") || name.equals("char")) { return name; + } String result = null; String originalName = name; @@ -452,14 +459,16 @@ // else we found a class by the same name, but in the wrong package } - if (dotPos <= 0) + if (dotPos <= 0) { break; + } dotPos = originalName.lastIndexOf('.', dotPos - 1); } } - if (result != null && !result.equals(originalName)) + if (result != null && !result.equals(originalName)) { result = resolveClassName(result, compiler); // check for aliases against the new name as well + } return result; } @@ -468,8 +477,9 @@ public static ClassDescriptor resolveClass(String className, JAXXCompiler compiler) { try { className = resolveClassName(className, compiler); - if (className == null) + if (className == null) { return null; + } return ClassDescriptorLoader.getClassDescriptor(className, compiler.getClassLoader()); } catch (ClassNotFoundException e) { Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/EnumEditorHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/EnumEditorHandler.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/EnumEditorHandler.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,56 +0,0 @@ -/* - * Copyright 2006 Ethan Nicholas. All rights reserved. - * Use is subject to license terms. - */ -package jaxx.tags.swing; - -import jaxx.CompilerException; -import jaxx.compiler.CompiledObject; -import jaxx.compiler.JAXXCompiler; -import jaxx.reflect.ClassDescriptor; -import jaxx.reflect.ClassDescriptorLoader; -import jaxx.tags.DefaultComponentHandler; - -import java.awt.event.ItemListener; -import jaxx.runtime.swing.editor.EnumEditor; - -public class EnumEditorHandler extends DefaultComponentHandler { - - public EnumEditorHandler(ClassDescriptor beanClass) { - super(beanClass); - ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, EnumEditor.class); - } - - @Override - protected void configureProxyEventInfo() { - super.configureProxyEventInfo(); - addProxyEventInfo("getSelectedIndex", ItemListener.class); - addProxyEventInfo("getSelectedItem", ItemListener.class); - } - - @Override - protected CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException { - return new CompiledItemContainer(id, getBeanClass(), compiler); - } -// @Override -// public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { -// super.compileChildrenSecondPass(tag, compiler); -// CompiledItemContainer list = (CompiledItemContainer) compiler.getOpenComponent(); -// List<Item> items = list.getItems(); -// if (items != null && !items.isEmpty()) { -// String listName = list.getId() + "$items"; -// list.appendAdditionCode("java.util.List<jaxx.runtime.swing.Item> " + listName + " = new java.util.ArrayList<jaxx.runtime.swing.Item>();"); -// for (Item item : items) { -// String id = item.getId(); -// CompiledObject compiledItem = new CompiledObject(id, ClassDescriptorLoader.getClassDescriptor(Item.class), compiler); -// compiledItem.setConstructorParams(TypeManager.getJavaCode(id) + ", " + TypeManager.getJavaCode(item.getLabel()) + ", " + TypeManager.getJavaCode(item.getValue()) + ", " + item.isSelected()); -// compiler.registerCompiledObject(compiledItem); -// list.appendAdditionCode(listName + ".add(" + id + ");"); -// } -// list.appendAdditionCode(list.getId() + ".setItems(" + listName + ");"); -// } -// } -} - - - Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/ItemHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/ItemHandler.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/ItemHandler.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -24,14 +24,17 @@ public class ItemHandler implements TagHandler { private String DATA_BINDING = "<data binding has not been processed yet>"; + @Override public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { compileChildrenFirstPass(tag, compiler); } + @Override public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { String id = tag.getAttribute("id"); - if (id == null || id.length() == 0) + if (id == null || id.length() == 0) { id = compiler.getAutoId(ClassDescriptorLoader.getClassDescriptor(Item.class)); + } String label = null; String value = null; boolean selected = false; @@ -47,10 +50,12 @@ } if (name.equals(Item.LABEL_PROPERTY)) { String labelBinding = compiler.processDataBindings(attrValue, ClassDescriptorLoader.getClassDescriptor(String.class)); - if (labelBinding != null) + if (labelBinding != null) { compiler.registerDataBinding(labelBinding, id + ".label", id + ".setLabel(" + labelBinding + ");"); - else + } + else { label = attrValue; + } continue; } if (name.equals(Item.VALUE_PROPERTY)) { @@ -58,16 +63,19 @@ if (valueBinding != null) { value = DATA_BINDING; compiler.registerDataBinding(valueBinding, id + ".value", id + ".setValue(" + valueBinding + ");"); - } else + } else { value = attrValue; + } continue; } if (name.equals(Item.SELECTED_PROPERTY)) { String selectedBinding = compiler.processDataBindings(attrValue, ClassDescriptorLoader.getClassDescriptor(Boolean.class)); - if (selectedBinding != null) + if (selectedBinding != null) { compiler.registerDataBinding(selectedBinding, id + ".selected", id + ".setSelected(" + selectedBinding + ");"); - else + } + else { selected = (Boolean) TypeManager.convertFromString(attrValue, Boolean.class); + } continue; } @@ -78,8 +86,9 @@ Item item = new Item(id, label, value, selected); CompiledItemContainer list = (CompiledItemContainer) compiler.getOpenComponent(); - if (value == null) + if (value == null) { compiler.reportError("<item> tag is missing required 'value' attribute"); + } else { if (!value.equals(DATA_BINDING)) { List<Item> items = list.getItems(); @@ -108,8 +117,9 @@ } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) { String text = ((Text) node).getData().trim(); - if (text.length() > 0) + if (text.length() > 0) { compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')"); + } } } } @@ -126,8 +136,9 @@ } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) { String text = ((Text) node).getData().trim(); - if (text.length() > 0) + if (text.length() > 0) { compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')"); + } } } } Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JComboBoxHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JComboBoxHandler.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JComboBoxHandler.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -4,26 +4,23 @@ */ package jaxx.tags.swing; +import java.io.IOException; import jaxx.CompilerException; -import jaxx.compiler.CompiledObject; import jaxx.compiler.JAXXCompiler; import jaxx.reflect.ClassDescriptor; import jaxx.reflect.ClassDescriptorLoader; -import jaxx.runtime.swing.Item; -import jaxx.runtime.swing.JAXXComboBox; import jaxx.tags.DefaultComponentHandler; -import jaxx.types.TypeManager; -import org.w3c.dom.Element; import java.awt.event.ItemListener; -import java.io.IOException; -import java.util.List; +import javax.swing.JComboBox; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; public class JComboBoxHandler extends DefaultComponentHandler { public JComboBoxHandler(ClassDescriptor beanClass) { super(beanClass); - ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JAXXComboBox.class); + ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JComboBox.class); } @Override @@ -34,26 +31,10 @@ } @Override - protected CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException { - return new CompiledItemContainer(id, getBeanClass(), compiler); - } - - @Override public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - super.compileChildrenSecondPass(tag, compiler); - CompiledItemContainer list = (CompiledItemContainer) compiler.getOpenComponent(); - List<Item> items = list.getItems(); - if (items != null && !items.isEmpty()) { - String listName = list.getId() + "$items"; - list.appendAdditionCode("java.util.List<jaxx.runtime.swing.Item> " + listName + " = new java.util.ArrayList<jaxx.runtime.swing.Item>();"); - for (Item item : items) { - String id = item.getId(); - CompiledObject compiledItem = new CompiledObject(id, ClassDescriptorLoader.getClassDescriptor(Item.class), compiler); - compiledItem.setConstructorParams(TypeManager.getJavaCode(id) + ", " + TypeManager.getJavaCode(item.getLabel()) + ", " + TypeManager.getJavaCode(item.getValue()) + ", " + item.isSelected()); - compiler.registerCompiledObject(compiledItem); - list.appendAdditionCode(listName + ".add(" + id + ");"); - } - list.appendAdditionCode(list.getId() + ".setItems(" + listName + ");"); + NodeList children = tag.getChildNodes(); + if (children.getLength() > 0) { + compiler.reportError("JComboBox does not accept childs"); } } } Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JSliderHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JSliderHandler.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JSliderHandler.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -17,29 +17,32 @@ import javax.swing.event.ChangeListener; public class JSliderHandler extends DefaultComponentHandler { + public JSliderHandler(ClassDescriptor beanClass) { super(beanClass); - if (!ClassDescriptorLoader.getClassDescriptor(JSlider.class).isAssignableFrom(beanClass)) + if (!ClassDescriptorLoader.getClassDescriptor(JSlider.class).isAssignableFrom(beanClass)) { throw new IllegalArgumentException(getClass().getName() + " does not support the class " + beanClass.getName()); + } } - + @Override protected int getAttributeOrdering(Attr attr) { - if (attr.getName().equals("value")) + if (attr.getName().equals("value")) { return 1; - else + } else { return super.getAttributeOrdering(attr); + } } - - protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException { + @Override + protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException { super.setDefaults(object, tag, compiler); setAttribute(object, "value", "0", false, compiler); } - + @Override protected void configureProxyEventInfo() { super.configureProxyEventInfo(); addProxyEventInfo("getValue", ChangeListener.class, "model"); } -} \ No newline at end of file +} Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JWindowHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JWindowHandler.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JWindowHandler.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -53,7 +53,7 @@ public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { super.compileSecondPass(tag, compiler); CompiledObject object = objectMap.get(tag); - Map properties = object.getProperties(); + Map<?,?> properties = object.getProperties(); if (!properties.containsKey("width") && !properties.containsKey("height")) { compiler.appendLateInitializer(object.getId() + ".pack();\n"); } Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/LocaleEditorHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/LocaleEditorHandler.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/LocaleEditorHandler.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,56 +0,0 @@ -/* - * Copyright 2006 Ethan Nicholas. All rights reserved. - * Use is subject to license terms. - */ -package jaxx.tags.swing; - -import jaxx.CompilerException; -import jaxx.compiler.CompiledObject; -import jaxx.compiler.JAXXCompiler; -import jaxx.reflect.ClassDescriptor; -import jaxx.reflect.ClassDescriptorLoader; -import jaxx.tags.DefaultComponentHandler; - -import java.awt.event.ItemListener; -import jaxx.runtime.swing.editor.LocaleEditor; - -public class LocaleEditorHandler extends DefaultComponentHandler { - - public LocaleEditorHandler(ClassDescriptor beanClass) { - super(beanClass); - ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, LocaleEditor.class); - } - - @Override - protected void configureProxyEventInfo() { - super.configureProxyEventInfo(); - addProxyEventInfo("getSelectedIndex", ItemListener.class); - addProxyEventInfo("getSelectedItem", ItemListener.class); - } - - @Override - protected CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException { - return new CompiledItemContainer(id, getBeanClass(), compiler); - } -// @Override -// public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { -// super.compileChildrenSecondPass(tag, compiler); -// CompiledItemContainer list = (CompiledItemContainer) compiler.getOpenComponent(); -// List<Item> items = list.getItems(); -// if (items != null && !items.isEmpty()) { -// String listName = list.getId() + "$items"; -// list.appendAdditionCode("java.util.List<jaxx.runtime.swing.Item> " + listName + " = new java.util.ArrayList<jaxx.runtime.swing.Item>();"); -// for (Item item : items) { -// String id = item.getId(); -// CompiledObject compiledItem = new CompiledObject(id, ClassDescriptorLoader.getClassDescriptor(Item.class), compiler); -// compiledItem.setConstructorParams(TypeManager.getJavaCode(id) + ", " + TypeManager.getJavaCode(item.getLabel()) + ", " + TypeManager.getJavaCode(item.getValue()) + ", " + item.isSelected()); -// compiler.registerCompiledObject(compiledItem); -// list.appendAdditionCode(listName + ".add(" + id + ");"); -// } -// list.appendAdditionCode(list.getId() + ".setItems(" + listName + ");"); -// } -// } -} - - - Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/RowHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/RowHandler.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/RowHandler.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -18,10 +18,13 @@ import java.io.IOException; public class RowHandler implements TagHandler { + + @Override public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { compileChildrenFirstPass(tag, compiler); } + @Override public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { if (!ClassDescriptorLoader.getClassDescriptor(Table.class).isAssignableFrom(compiler.getOpenComponent().getObjectClass())) { compiler.reportError("row tag may only appear within Table tag"); @@ -82,4 +85,4 @@ protected void compileChildTagSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { compiler.compileSecondPass(tag); } -} \ No newline at end of file +} Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/TabHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/TabHandler.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/TabHandler.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -26,11 +26,13 @@ public class TabHandler implements TagHandler { + @Override public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { compileChildrenFirstPass(tag, compiler); } + @Override public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { if (!ClassDescriptorLoader.getClassDescriptor(JTabbedPane.class).isAssignableFrom(compiler.getOpenComponent().getObjectClass())) { compiler.reportError("tab tag may only appear within JTabbedPane tag"); Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/BeanValidatorHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/BeanValidatorHandler.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/BeanValidatorHandler.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -11,7 +11,7 @@ import jaxx.introspection.JAXXPropertyDescriptor; import jaxx.reflect.ClassDescriptor; import jaxx.reflect.ClassDescriptorLoader; -import jaxx.runtime.SwingValidatorUtil; +import jaxx.runtime.validator.swing.SwingValidatorUtil; import jaxx.runtime.validator.swing.SwingValidator; import jaxx.runtime.validator.swing.ui.AbstractBeanValidatorUI; import jaxx.tags.DefaultObjectHandler; Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/ExcludeFieldValidatorHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/ExcludeFieldValidatorHandler.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/ExcludeFieldValidatorHandler.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -25,6 +25,7 @@ /** to use log facility, just put in your code: log.info(\"...\"); */ static private Log log = LogFactory.getLog(ExcludeFieldValidatorHandler.class); + @Override public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { if (compiler.getOptions().isVerbose()) { log.info(tag); @@ -32,6 +33,7 @@ //todo check there is no child } + @Override public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { if (compiler.getOptions().isVerbose()) { log.debug(tag); Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/FieldValidatorHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/FieldValidatorHandler.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/FieldValidatorHandler.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -25,6 +25,7 @@ /** to use log facility, just put in your code: log.info(\"...\"); */ static private Log log = LogFactory.getLog(FieldValidatorHandler.class); + @Override public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { if (compiler.getOptions().isVerbose()) { log.info(tag); @@ -32,6 +33,7 @@ //todo check there is no child } + @Override public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { if (compiler.getOptions().isVerbose()) { log.info(tag); Modified: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/beaninfos/BeanIntoUtilTest.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/beaninfos/BeanIntoUtilTest.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/beaninfos/BeanIntoUtilTest.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -21,7 +21,7 @@ BeanInfoUtil.reset(); Assert.assertEquals(searchPath0.length, Introspector.getBeanInfoSearchPath().length); - String packageName = getClass().getPackage().getName()+".dummy"; + String packageName = getClass().getPackage().getName() + ".dummy"; BeanInfoUtil.addJaxxBeanInfoPath("jaxx.beaninfos", packageName); searchPath = Introspector.getBeanInfoSearchPath(); Modified: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/junit/TagManagerTest.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/junit/TagManagerTest.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/junit/TagManagerTest.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -135,8 +135,10 @@ @Test public void testAliasing() { - Assert.assertEquals("JComboBox is not aliased to jaxx.runtime.swing.JAXXComboBox", "jaxx.runtime.swing.JAXXComboBox", TagManager.resolveClassName("JComboBox", compiler)); - Assert.assertEquals("javax.swing.JComboBox is not aliased to jaxx.runtime.swing.JAXXComboBox", "jaxx.runtime.swing.JAXXComboBox", TagManager.resolveClassName("javax.swing.JComboBox", compiler)); + Assert.assertEquals("ButtonGroup is not aliased to jaxx.runtime.swing.JAXXButtonGroup", "jaxx.runtime.swing.JAXXButtonGroup", TagManager.resolveClassName("ButtonGroup", compiler)); + Assert.assertEquals("javax.swing.ButtonGroup is not aliased to jaxx.runtime.swing.JAXXButtonGroup", "jaxx.runtime.swing.JAXXButtonGroup", TagManager.resolveClassName("javax.swing.ButtonGroup", compiler)); +// Assert.assertEquals("JComboBox is not aliased to jaxx.runtime.swing.JAXXComboBox", "jaxx.runtime.swing.JAXXComboBox", TagManager.resolveClassName("JComboBox", compiler)); +// Assert.assertEquals("javax.swing.JComboBox is not aliased to jaxx.runtime.swing.JAXXComboBox", "jaxx.runtime.swing.JAXXComboBox", TagManager.resolveClassName("javax.swing.JComboBox", compiler)); } Deleted: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,394 +0,0 @@ -package jaxx.runtime.swing.navigation; - -import jaxx.runtime.swing.navigation.*; -import jaxx.runtime.DefaultJAXXContext; -import jaxx.runtime.JAXXContext; -import jaxx.runtime.JAXXContextEntryDef; -import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode; -import org.junit.Assert; -import org.junit.Test; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - - -/** - * Test du model de navigation. - * - * @author chemit - */ -public class NavigationTreeModelTest { - - private static final String ROOT_CONTEXT = "$root"; - private static final String FAKE = "-fake"; - - private static final String separator = "/"; - - @Test - public void testFindNode() throws Exception { - - NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder(separator); - - NavigationTreeNode rootNode = builder.build(null, (String) null, (String) null, ROOT_CONTEXT, null, null); - - for (int i = 0; i < 4; i++) { - NavigationTreeNode sonNode = builder.build(rootNode, (String) null, (String) null, getNodeContext(i), null, null); - for (int j = 0; j < 4; j++) { - NavigationTreeNode sonSonNode = builder.build(sonNode, (String) null, (String) null, getNodeContext(i, j), null, null); - for (int k = 0; k < 4; k++) { - builder.build(sonSonNode, (String) null, (String) null, getNodeContext(i, j, k), null, null); - } - } - } - - NavigationTreeModel model = builder.getModel(); - - NavigationTreeNode node; - String contextPath; - String currentNode; - - contextPath = ROOT_CONTEXT; - node = model.findNode(contextPath); - assertNodeEquals(contextPath, ROOT_CONTEXT, 0, node, true); - - node = model.findNode(ROOT_CONTEXT + FAKE); - Assert.assertNull(node); - - for (int i = 0; i < 4; i++) { - currentNode = getNodeContext(i); - contextPath = ROOT_CONTEXT + separator + currentNode; - node = model.findNode(contextPath); - assertNodeEquals(contextPath, currentNode, 1, node, false); - - for (int j = 0; j < 4; j++) { - currentNode = getNodeContext(i, j); - contextPath = ROOT_CONTEXT + separator + getNodeContext(i) + separator + currentNode; - node = model.findNode(contextPath); - assertNodeEquals(contextPath, currentNode, 2, node, false); - - for (int k = 0; k < 4; k++) { - currentNode = getNodeContext(i, j, k); - contextPath = ROOT_CONTEXT + separator + getNodeContext(i) + separator + getNodeContext(i, j) + separator + currentNode; - node = model.findNode(contextPath); - assertNodeEquals(contextPath, currentNode, 3, node, false); - } - - node = model.findNode(ROOT_CONTEXT + separator + getNodeContext(i) + separator + getNodeContext(i, j) + separator + currentNode + FAKE); - Assert.assertNull(node); - } - - node = model.findNode(ROOT_CONTEXT + separator + getNodeContext(i) + separator + currentNode + FAKE); - Assert.assertNull(node); - - } - - } - - /** - * Test the {@link NavigationTreeModel#getJAXXContextValue(jaxx.runtime.JAXXContext, String)} with an entry point - * as a bean. - * <p/> - * Tree is like this - * <pre> - * $root + - * - name <-- attached to context entry : java.lang.String.class,"name" - * - name2 <-- attached to context entry : java.lang.String.class,"name2" - * - model + <-- attached to context entry : Model.class,null - * - name - * -integerValue - * - sons + - * - 0 + - * - name - * - integerValue - * - sons - * - 1 + - * - name - * - integerValue - * - sons - * - 2 + - * - name - * - integerValue - * - sons - * </pre> - * <p/> - * With this tree, we will have to results : - * <pre> - * $root.name => context.get(String.class,"name") - * $root.name2 => context.get(String.class,"name2") - * $root.model => context.get(Model.class) - * $root.model.name => context.get(Model.class).getName() - * $root.model.integerValue => context.get(Model.class).getIntegerValue() - * $root.model.sons => context.get(Model.class).getSons() - * $root.model.sons.0 => context.get(Model.class).getSons().get(0) - * </pre> - * - * @throws Exception if any pb - */ - @Test - public void testGetJAXXContextValue() throws Exception { - - NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder(separator); - - NavigationTreeNode rootNode = builder.build(null, (String) null, (String) null, ROOT_CONTEXT, null, null); - - NavigationTreeNode sonNode; - NavigationTreeNode sonSonNode; - NavigationTreeNode sonSonSonNode; - - builder.build(rootNode, (String) null, JAXXContextEntryDef.newDef("name", String.class), "name", null, null); - builder.build(rootNode, (String) null, JAXXContextEntryDef.newDef("name2", String.class), "name2", null, null); - - sonNode = builder.build(rootNode, (String) null, JAXXContextEntryDef.newDef(Model.class), "model", null, null); - - builder.build(sonNode, (String) null, "../name", "name", null, null); - builder.build(sonNode, (String) null, "../integerValue", "integerValue", null, null); - - sonSonNode = builder.build(sonNode, (String) null, "../sons", "sons", null, null); - - sonSonSonNode = builder.build(sonSonNode, (String) null, "..[1]", 0 + "", null, null); - - builder.build(sonSonSonNode, (String) null, "../name", "name", null, null); - builder.build(sonSonSonNode, (String) null, "../integerValue", "integerValue", null, null); - builder.build(sonSonSonNode, (String) null, "../sons", "sons", null, null); - - sonSonSonNode = builder.build(sonSonNode, (String) null, "..[2]", 1 + "", null, null); - - builder.build(sonSonSonNode, (String) null, "../name", "name", null, null); - builder.build(sonSonSonNode, (String) null, "../integerValue", "integerValue", null, null); - builder.build(sonSonSonNode, (String) null, "../sons", "sons", null, null); - - sonSonSonNode = builder.build(sonSonNode, (String) null, (String) null, 2 + "", null, null); - //sonSonSonNode = model.new NavigationTreeNode(null, "..[3]", 2 + "", null, null); - sonSonNode.insert(sonSonSonNode, 2); - builder.build(sonSonSonNode, (String) null, "../..[3]/name", "name", null, null); - builder.build(sonSonSonNode, (String) null, "../..[3]/integerValue", "integerValue", null, null); - builder.build(sonSonSonNode, (String) null, "../..[3]/sons", "sons", null, null); - - NavigationTreeModel model = builder.getModel(); - - JAXXContext context = new DefaultJAXXContext(); - context.setContextValue("the name", "name"); - context.setContextValue("the name2", "name2"); - - - context.setContextValue( - new Model("modelName", 10, - Arrays.asList( - new Model("one", 1, Collections.<Model>emptyList()), - new Model("two", 2, Collections.<Model>emptyList()), - new Model("three", 3, Collections.<Model>emptyList()) - ) - ) - ); - - Assert.assertNull(model.getJAXXContextValue(context, "$root.name" + FAKE)); - - testBinding(model, context, "$root/name", context.getContextValue(String.class, "name")); - testBinding(model, context, "$root/name2", context.getContextValue(String.class, "name2")); - - Model bean = context.getContextValue(Model.class); - - testBinding(model, context, "$root/model", bean); - testBinding(model, context, "$root/model/name", bean.getName()); - testBinding(model, context, "$root/model/integerValue", bean.getIntegerValue()); - testBinding(model, context, "$root/model/sons", bean.getSons()); - - testBinding(model, context, "$root/model/sons/0/name", bean.getSons().get(0).getName()); - testBinding(model, context, "$root/model/sons/0/integerValue", bean.getSons().get(0).getIntegerValue()); - testBinding(model, context, "$root/model/sons/0/sons", bean.getSons().get(0).getSons()); - - - testBinding(model, context, "$root/model/sons/1/name", bean.getSons().get(1).getName()); - testBinding(model, context, "$root/model/sons/1/integerValue", bean.getSons().get(1).getIntegerValue()); - testBinding(model, context, "$root/model/sons/1/sons", bean.getSons().get(1).getSons()); - - testBinding(model, context, "$root/model/sons/2/name", bean.getSons().get(2).getName()); - testBinding(model, context, "$root/model/sons/2/integerValue", bean.getSons().get(2).getIntegerValue()); - testBinding(model, context, "$root/model/sons/2/sons", bean.getSons().get(2).getSons()); - } - - /** - * Test the {@link NavigationTreeModel#getJAXXContextValue(jaxx.runtime.JAXXContext, String)} with an entry point - * as a list. - * <p/> - * Tree is like this - * <pre> - * $root + - * - models + <-- attached to context entry : java.util.List.class,"models" - * - 0 + - * - name - * -integerValue - * - sons + - * - 0 + - * - name - * - 1 + - * - name - * - integerValue - * - sons - * - 2 + - * - name - * - integerValue - * - sons - * </pre> - * <p/> - * With this tree, we will have to results : - * <pre> - * $root.models => context.get(List.class,"models") - * $root.models.0 => context.get(List.class,"models").get(0) - * $root.models.0.name => context.get(List.class,"models").get(0).getName() - * </pre> - * - * @throws Exception if any pb - */ - @Test - public void testGetJAXXContextValueFromList() throws Exception { - - NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder(separator); - - NavigationTreeNode rootNode = builder.build(null, (String) null, (String) null, ROOT_CONTEXT, null, null); - - NavigationTreeNode sonNode; - NavigationTreeNode sonSonNode; - NavigationTreeNode sonSonSonNode; - - // first son is a list of models - sonNode = builder.build(rootNode, (String) null, JAXXContextEntryDef.newListDef("models"), "models", null, null); - - // first son son is a model - sonSonNode = builder.build(sonNode, (String) null, "..[1]", "0", null, null); - - builder.build(sonSonNode, (String) null, "../name", "name", null, null); - builder.build(sonSonNode, (String) null, "../integerValue", "integerValue", null, null); - sonSonNode = builder.build(sonSonNode, (String) null, "../sons", "sons", null, null); - - sonSonSonNode = builder.build(sonSonNode, (String) null, "..[1]", "0", null, null); - builder.build(sonSonSonNode, (String) null, "../name", "name", null, null); - - // second son son is a model - sonSonNode = builder.build(sonNode, (String) null, "..[2]", "1", null, null); - - builder.build(sonSonNode, (String) null, "../name", "name", null, null); - builder.build(sonSonNode, (String) null, "../integerValue", "integerValue", null, null); - builder.build(sonSonNode, (String) null, "../sons", "sons", null, null); - - // third son son is a model - sonSonNode = builder.build(sonNode, (String) null, "..[3]", "2", null, null); - - builder.build(sonSonNode, (String) null, "../name", "name", null, null); - builder.build(sonSonNode, (String) null, "../integerValue", "integerValue", null, null); - builder.build(sonSonNode, (String) null, "../sons", "sons", null, null); - - NavigationTreeModel model = builder.getModel(); - - - List<Model> list = Arrays.asList( - new Model("entryOne", 10, - Arrays.asList( - new Model("one", 1, Collections.<Model>emptyList()), - new Model("two", 2, Collections.<Model>emptyList()), - new Model("three", 3, Collections.<Model>emptyList()) - ) - ), - new Model("entryTwo", 20, - Arrays.asList( - new Model("2one", 1, Collections.<Model>emptyList()), - new Model("2two", 2, Collections.<Model>emptyList()), - new Model("2three", 3, Collections.<Model>emptyList()) - ) - ), - new Model("entryThree", 30, - Arrays.asList( - new Model("3one", 1, Collections.<Model>emptyList()), - new Model("3two", 2, Collections.<Model>emptyList()), - new Model("3three", 3, Collections.<Model>emptyList()) - ) - ) - ); - JAXXContext context = new DefaultJAXXContext(); - context.setContextValue(list, "models"); - - Model bean; - - testBinding(model, context, "$root/models", list); - - bean = list.get(0); - testBinding(model, context, "$root/models/0", bean); - testBinding(model, context, "$root/models/0/name", bean.getName()); - testBinding(model, context, "$root/models/0/integerValue", bean.getIntegerValue()); - testBinding(model, context, "$root/models/0/sons", bean.getSons()); - testBinding(model, context, "$root/models/0/sons/0", bean.getSons().get(0)); - testBinding(model, context, "$root/models/0/sons/0/name", bean.getSons().get(0).getName()); - - bean = list.get(1); - testBinding(model, context, "$root/models/1", bean); - testBinding(model, context, "$root/models/1/name", bean.getName()); - testBinding(model, context, "$root/models/1/integerValue", bean.getIntegerValue()); - testBinding(model, context, "$root/models/1/sons", bean.getSons()); - - bean = list.get(2); - testBinding(model, context, "$root/models/2", bean); - testBinding(model, context, "$root/models/2/name", bean.getName()); - testBinding(model, context, "$root/models/2/integerValue", bean.getIntegerValue()); - testBinding(model, context, "$root/models/2/sons", bean.getSons()); - - } - - protected void testBinding(NavigationTreeModel model, JAXXContext context, String contextPath, Object expected) throws Exception { - - Object value; - value = model.getJAXXContextValue(context, contextPath); - Assert.assertNotNull(value); - Assert.assertEquals(expected, value); - } - - protected String getNodeContext(int... context) { - String result = ""; - for (int i : context) { - result += i; - } - return result; - } - - protected void assertNodeEquals(String contextPath, String nodeContext, int level, NavigationTreeNode node, boolean root) { - //System.out.println(contextPath + " : " + (node == null ? null : node.getContextPath())); - Assert.assertNotNull(node); - Assert.assertEquals(root, node.isRoot()); - Assert.assertEquals(level, node.getLevel()); - Assert.assertEquals(nodeContext, node.getNavigationPath()); - Assert.assertEquals(contextPath, node.getContextPath()); - } - - public static class Model { - - protected String name; - - protected int integerValue; - - protected List<Model> sons; - - public Model(String name, int integerValue, List<Model> sons) { - this.name = name; - this.integerValue = integerValue; - this.sons = sons; - } - - public String getName() { - return name; - } - - public int getIntegerValue() { - return integerValue; - } - - public List<Model> getSons() { - return sons; - } - - @Override - public String toString() { - return super.toString() + "<name:" + name + ",integerValue:" + integerValue + ",sons: " + sons + ">"; - } - } - -} Modified: branches/jaxx-2.X/jaxx-demo/pom.xml =================================================================== --- branches/jaxx-2.X/jaxx-demo/pom.xml 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/pom.xml 2009-10-05 19:15:44 UTC (rev 1559) @@ -10,7 +10,7 @@ <parent> <groupId>org.nuiton</groupId> <artifactId>jaxx</artifactId> - <version>1.7.2-SNAPSHOT</version> + <version>2.0.0-SNAPSHOT</version> </parent> <groupId>org.nuiton.jaxx</groupId> @@ -22,12 +22,12 @@ <dependency> <groupId>${project.groupId}</groupId> - <artifactId>jaxx-runtime-swing</artifactId> + <artifactId>jaxx-runtime</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>${project.groupId}</groupId> - <artifactId>jaxx-runtime-swing-widget</artifactId> + <artifactId>jaxx-widgets</artifactId> <version>${project.version}</version> </dependency> @@ -35,7 +35,7 @@ <dependency> <groupId>${project.groupId}</groupId> - <artifactId>jaxx-runtime-api</artifactId> + <artifactId>jaxx-runtime</artifactId> <version>${project.version}</version> <scope>test</scope> <classifier>tests</classifier> @@ -52,8 +52,8 @@ <!-- *** Project Information ************************************* --> <!-- ************************************************************* --> - <name>${project.artifactId}</name> - <description>Jaxx Demo module</description> + <name>JAXX Demo</name> + <description>JAXX Demo</description> <!-- ************************************************************* --> <!-- *** Build Settings ****************************************** --> Modified: branches/jaxx-2.X/jaxx-demo/src/main/filters/jaxx-demo.properties =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/filters/jaxx-demo.properties 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/filters/jaxx-demo.properties 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,6 +1,9 @@ application.name=${project.name} application.version=${project.version} application.site.url=http://maven-site.nuiton.org/jaxx/jaxx-example +application.icon.path=/icons/jaxx.png +application.license.path=META-INF/${project.artifactId}-LICENSE.txt +application.third-party.path=META-INF/${project.artifactId}-THIRD-PARTY.txt #licence.name=${project.licenses[0].license.name} #licence.url=${project.licenses.0.url} application.organisation.name=${project.organization.name} Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,87 +1,110 @@ - -<JTabbedPane id='top'> - - <script><![CDATA[ -import org.apache.commons.io.IOUtils; - -protected String[] getSources() { - if (getClass() == DemoPanel.class) { - return new String[0]; - } - return new String[]{ getDefaultSource() }; -} - -protected String getDefaultSource() { - return getClass().getSimpleName() + ".jaxx"; -} - -public String getLabel() { - String name = getClass().getSimpleName(); - if (name.endsWith("Demo")) { - name = name.substring(0, name.length() - "Demo".length()); - } - return name; -} - -public String getDemoTabTitle() { - return getLabel() + " Demo"; -} - -public String loadSource(String filename) { - try { - if (log.isDebugEnabled()) { - log.debug(filename + " from " + getClass()); - } - String result = IOUtils.toString(getClass().getResourceAsStream(filename)); - - return result; - } catch (Exception e) { - log.error("could not load file " + filename, e); - return "could not load file " + filename; - } -} - -private void $afterCompleteSetup() { - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - if (getSources().length == 0) { - top.remove(sourceTabs); - return; - } - for (String extra : getSources()) { - JScrollPane pane = new JScrollPane( - JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, - JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); - pane.setBorder(null); - // creation du contenu du fichier - JTextArea content = new JTextArea(); - content.setFont(content.getFont().deriveFont((float) 11)); - content.setMinimumSize(jaxx.runtime.SwingUtil.newMinDimension()); - content.setEditable(false); - content.setWrapStyleWord(false); - content.setText(loadSource(extra)); - content.setColumns(80); - pane.getViewport().add(content); - // ajout de l'onglet - sourceTabs.addTab(extra, pane); - int index = sourceTabs.indexOfComponent(pane); - JLabel l = new JLabel(extra); - l.setFont(l.getFont().deriveFont((float) 10)); - sourceTabs.setTabComponentAt(index,l); - } - } - }); -} - ]]> - </script> - - <tab title='{getDemoTabTitle()}'> - <JPanel id='demoPanel'/> - </tab> - - <tab title='Sources'> - <JTabbedPane id='sourceTabs' tabPlacement='{JTabbedPane.BOTTOM}'/> - </tab> +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> + +<JTabbedPane id='top'> + + <script><![CDATA[ +import org.apache.commons.io.IOUtils; + +protected String[] getSources() { + if (getClass() == DemoPanel.class) { + return new String[0]; + } + return new String[]{ getDefaultSource() }; +} + +protected String getDefaultSource() { + return getClass().getSimpleName() + ".jaxx"; +} + +public String getLabel() { + String name = getClass().getSimpleName(); + if (name.endsWith("Demo")) { + name = name.substring(0, name.length() - "Demo".length()); + } + return name; +} + +public String getDemoTabTitle() { + return getLabel() + " Demo"; +} + +public String loadSource(String filename) { + try { + if (log.isDebugEnabled()) { + log.debug(filename + " from " + getClass()); + } + String result = IOUtils.toString(getClass().getResourceAsStream(filename)); + + return result; + } catch (Exception e) { + log.error("could not load file " + filename, e); + return "could not load file " + filename; + } +} + +private void $afterCompleteSetup() { + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + if (getSources().length == 0) { + top.remove(sourceTabs); + return; + } + for (String extra : getSources()) { + JScrollPane pane = new JScrollPane( + JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + pane.setBorder(null); + //pane.setMinimumSize(jaxx.runtime.SwingUtil.newMinDimension()); + // creation du contenu du fichier + JTextArea content = new JTextArea(); + content.setFont(content.getFont().deriveFont((float) 11)); + content.setMinimumSize(jaxx.runtime.SwingUtil.newMinDimension()); + content.setEditable(false); + content.setWrapStyleWord(false); + content.setText(loadSource(extra)); + content.setColumns(80); + content.setLineWrap(true); + pane.getViewport().add(content); + content.setCaretPosition(0); + // ajout de l'onglet + sourceTabs.addTab(extra, pane); + int index = sourceTabs.indexOfComponent(pane); + JLabel l = new JLabel(extra); + l.setFont(l.getFont().deriveFont((float) 10)); + sourceTabs.setTabComponentAt(index,l); + } + } + }); +} + ]]> + </script> + + <tab title='{getDemoTabTitle()}'> + <JPanel id='demoPanel'/> + </tab> + + <tab title='Sources'> + <JTabbedPane id='sourceTabs' tabPlacement='{JTabbedPane.BOTTOM}'/> + </tab> </JTabbedPane> \ No newline at end of file Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -25,8 +25,8 @@ import jaxx.demo.component.swing.*; import jaxx.demo.component.jaxx.*; import jaxx.demo.component.jaxx.editor.*; -import jaxx.demo.component.jaxx.navigation.full.FullNavigationTreeDemo; import jaxx.demo.component.jaxx.navigation.item.ItemTreeNavigationDemo; +import jaxx.demo.component.jaxx.tree.FullNavigationTreeDemo; import jaxx.demo.feature.databinding.BeanDataBindingDemo; import jaxx.demo.feature.validation.*; import jaxx.demo.fun.*; @@ -38,13 +38,8 @@ import jaxx.runtime.JAXXObject; import jaxx.runtime.swing.CardLayout2; import jaxx.runtime.swing.ErrorDialogUI; -import jaxx.runtime.swing.navigation.NavigationTreeModel; -import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode; -import jaxx.runtime.swing.navigation.NavigationTreeModelBuilder; -import jaxx.runtime.swing.navigation.NavigationTreeHandler; -import jaxx.runtime.swing.navigation.NavigationTreeHandler.Strategy; -import jaxx.runtime.swing.navigation.NavigationTreeHandlerWithCardLayout; -import jaxx.runtime.swing.navigation.NavigationTreeHelper; +import jaxx.runtime.swing.tree.*; +import jaxx.runtime.swing.tree.NavigationTreeHandler.Strategy; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -67,7 +62,7 @@ log.debug("start creating demo model"); } - TreeModelBuilder builder = new TreeModelBuilder(); + TreeModelBuilder builder = new TreeModelBuilder(context); builder.addText(n_("jaxxdemo.tree.component.swing")). addText(n_("jaxxdemo.tree.component.swing.buttons")). @@ -121,6 +116,7 @@ addDemo(ValidationListDemo.class). addDemo(ValidationTableDemo.class). goUp(). + goUp(). addText(n_("jaxxdemo.tree.fun")). addDemo(LabelStyleDemo.class). addDemo(CounterDemo.class). @@ -129,7 +125,7 @@ NavigationTreeModel model = builder.getModel(); if (log.isDebugEnabled()) { - builder.printModel(context, model.getRoot()); + builder.printModel(model.getRoot()); } // save tree model in context setTreeModel(context, model); @@ -139,10 +135,10 @@ @Override public NavigationTreeHandler createTreeHandler(JAXXObject context) { - NavigationTreeHandler handler = new NavigationTreeHandlerWithCardLayout( + NavigationTreeHandler handler; + + handler = new NavigationTreeHandlerWithCardLayout( getPrefix(), - DemoPanel.class, - null, context, Strategy.PER_UI_TYPE) { @@ -168,7 +164,8 @@ ErrorDialogUI.showError(e); } - protected DemoUI getContext() { + @Override + public DemoUI getContext() { return (DemoUI) context; } }; @@ -189,34 +186,34 @@ /** * la pile des noeuds parent */ - protected Stack<NavigationTreeNode> parentNodes; + protected Stack<NavigationTreeNode> nodes; - protected TreeModelBuilder() { - super("/"); - parentNodes = new Stack<NavigationTreeNode>(); - parentNodes.add(buildEmptyRoot(def, "$root")); + protected TreeModelBuilder(JAXXContext context) { + super("/", context, DemoPanel.class, null); + nodes = new Stack<NavigationTreeNode>(); + nodes.add(buildEmptyRoot(def, "$root")); } protected TreeModelBuilder goUp() { - parentNodes.pop(); + nodes.pop(); return this; } protected TreeModelBuilder addText(String label) { - NavigationTreeNode parentNode = parentNodes.peek(); + NavigationTreeNode parentNode = nodes.peek(); parentNode = build(parentNode, label, def, label, null, null); if (log.isDebugEnabled()) { - log.debug(label + " [" + parentNode.getContextPath() + "]"); + log.debug(label + " [" + parentNode.getFullPath() + "]"); } - parentNodes.push(parentNode); + nodes.push(parentNode); return this; } protected TreeModelBuilder addDemo(Class<? extends DemoPanel> demoClass) { - NavigationTreeNode parentNode = parentNodes.peek(); + NavigationTreeNode parentNode = nodes.peek(); String label = demoClass.getSimpleName(); if (log.isDebugEnabled()) { - log.debug(label + " [" + parentNode.getContextPath() + "]"); + log.debug(label + " [" + parentNode.getFullPath() + "]"); } build(parentNode, label, def, label, demoClass, null); return this; Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.css =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.css 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.css 2009-10-05 19:15:44 UTC (rev 1559) @@ -15,7 +15,7 @@ * 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>. ##%* - */ +*/ JToolBar { borderPainted:false; floatable:false; @@ -28,6 +28,12 @@ dividerSize:6; } +#mainFrame { + title:"JAXX Demo"; + iconImage:{jaxx.runtime.SwingUtil.createIcon(getConfig().getOption("application.icon.path")).getImage()}; + undecorated:{getConfig().isFullScreen()}; +} + #menu { _help:{"ui.main.menu"}; } @@ -61,8 +67,8 @@ toolTipText:"jaxxdemo.action.locale.fr.tip"; actionIcon:"i18n-fr"; enabled:{!acceptLocale(getConfig().getLocale(), "fr_FR")}; - mnemonic:F; - _help:{"ui.main.menu.file.locale.fr"}; +mnemonic:F; +_help:{"ui.main.menu.file.locale.fr"}; } #menuFileLanguageUK { @@ -70,8 +76,8 @@ toolTipText:"jaxxdemo.action.locale.uk.tip"; actionIcon:"i18n-uk"; enabled:{!acceptLocale(getConfig().getLocale(), "en_GB")}; - mnemonic:U; - _help:{"ui.main.menu.file.locale.uk"}; +mnemonic:U; +_help:{"ui.main.menu.file.locale.uk"}; } #menuFileFullscreen { @@ -80,7 +86,7 @@ actionIcon:"fullscreen"; mnemonic:P; visible:{!isUndecorated()}; - _help:{"ui.main.menu.file.fullscreen"}; +_help:{"ui.main.menu.file.fullscreen"}; } #menuFileNormalscreen { @@ -89,7 +95,7 @@ actionIcon:"leave-fullscreen"; mnemonic:N; visible:{isUndecorated()}; - _help:{"ui.main.menu.file.leave-fullscreen"}; +_help:{"ui.main.menu.file.leave-fullscreen"}; } #menuFileExit{ @@ -137,17 +143,24 @@ visible:true; } +#navigationPane{ + border:{null}; +minimumSize:{new Dimension(230,0)}; +horizontalScrollBarPolicy:{JScrollPane.HORIZONTAL_SCROLLBAR_NEVER}; +} + #navigation{ rootVisible:false; + showsRootHandles:false; largeModel:true; font-size:11; } -/* + #splitpane{ orientation:{JSplitPane.HORIZONTAL_SPLIT}; _help:{"ui.main.body.db"}; resizeWeight:1.0; -}*/ +} #contentLayout{ useOnlyVisibleComponentDimension:true; @@ -155,7 +168,7 @@ #content{ layout:{contentLayout}; - _help:{"ui.main.body.db.view.content"}; +_help:{"ui.main.body.db.view.content"}; } /* #toolbar { Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,81 +1,113 @@ - -<JFrame id='mainFrame' - title="JAXX Demo" - width='1024' - height='800' - decorator='help' - undecorated='{getConfig().isFullScreen()}' - onWindowClosing='getHandler().close(mainFrame)'> - - <style source='DemoUI.css'/> - - <jaxx.runtime.swing.CardLayout2 id='contentLayout'/> - - <script><![CDATA[ -import jaxx.runtime.swing.navigation.*; -import java.util.Locale; - -public DemoConfig getConfig() { - return getContextValue(DemoConfig.class); -} - -protected DemoUIHandler getHandler() { - return getContextValue(DemoUIHandler.class); -} - -protected DemoTreeHelper getTreeHelper() { - return getContextValue(DemoTreeHelper.class); -} - -public boolean acceptLocale(Locale l, String expected) { - return l !=null && l.toString().equals(expected); -} - -]]> - </script> - - <JMenuBar id='menu'> - - <JMenu id='menuFile'> - <JMenuItem id='menuFileConfiguration' - onActionPerformed="getHandler().showConfig(this)"/> - <JMenu id='menuFileLanguage'> - <JMenuItem id='menuFileLanguageFR' - onActionPerformed="getHandler().changeLanguage(this, Locale.FRANCE)"/> - <JMenuItem id='menuFileLanguageUK' - onActionPerformed="getHandler().changeLanguage(this, Locale.UK)"/> - </JMenu> - <JSeparator/> - <JMenuItem id='menuFileFullscreen' - onActionPerformed="getHandler().changeScreen(this, true)"/> - <JMenuItem id='menuFileNormalscreen' - onActionPerformed="getHandler().changeScreen(this, false)"/> - <JSeparator/> - <JMenuItem id='menuFileExit' - onActionPerformed="getHandler().close(this)"/> - </JMenu> - - <JMenu id='menuHelp'> - <JMenuItem id='menuHelpHelp' - onActionPerformed="getHandler().showHelp(this, null)"/> - <JMenuItem id='menuHelpSite' - onActionPerformed="getHandler().gotoSite(this)"/> - <JMenuItem id='menuHelpAbout' - onActionPerformed="getHandler().showAbout(this)"/> - </JMenu> - - </JMenuBar> - - <JSplitPane id='splitPane'> - <JScrollPane border='{null}'> - <JTree id='navigation' - model='{getTreeHelper().createTreeModel(this)}' - selectionModel="{getTreeHelper().createTreeHandler(this)}" - cellRenderer='{new NavigationTreeCellRenderer(this, 200)}'> - </JTree> - </JScrollPane> - - <JPanel id='content'/> - - </JSplitPane> +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> + +<JFrame id='mainFrame' width='1024' height='800' + decorator='help' + onWindowClosing='getHandler().close(mainFrame)'> + + <style source='DemoUI.css'/> + + <jaxx.runtime.swing.CardLayout2 id='contentLayout'/> + + <script><![CDATA[ +import jaxx.runtime.SwingUtil; +import jaxx.runtime.swing.tree.*; +import java.util.Locale; + +public DemoConfig getConfig() { + return getContextValue(DemoConfig.class); +} + +protected DemoUIHandler getHandler() { + return getContextValue(DemoUIHandler.class); +} + +protected DemoTreeHelper getTreeHelper() { + return getContextValue(DemoTreeHelper.class); +} + +public boolean acceptLocale(Locale l, String expected) { + return l !=null && l.toString().equals(expected); +} + +private void $afterCompleteSetup() { + // share the tree + getTreeHelper().setTree(this, navigation); + // auto-expand node when selected + SwingUtil.addExpandOnClickListener(navigation); + +} + +]]> + </script> + + <JMenuBar id='menu'> + + <JMenu id='menuFile'> + <JMenuItem id='menuFileConfiguration' + onActionPerformed="getHandler().showConfig(this)"/> + <JMenu id='menuFileLanguage'> + <JMenuItem id='menuFileLanguageFR' + onActionPerformed="getHandler().changeLanguage(this, Locale.FRANCE)"/> + <JMenuItem id='menuFileLanguageUK' + onActionPerformed="getHandler().changeLanguage(this, Locale.UK)"/> + </JMenu> + <JSeparator/> + <JMenuItem id='menuFileFullscreen' + onActionPerformed="getHandler().changeScreen(this, true)"/> + <JMenuItem id='menuFileNormalscreen' + onActionPerformed="getHandler().changeScreen(this, false)"/> + <JSeparator/> + <JMenuItem id='menuFileExit' + onActionPerformed="getHandler().close(this)"/> + </JMenu> + + <JMenu id='menuHelp'> + <JMenuItem id='menuHelpHelp' + onActionPerformed="getHandler().showHelp(this, null)"/> + <JMenuItem id='menuHelpSite' + onActionPerformed="getHandler().gotoSite(this)"/> + <JMenuItem id='menuHelpAbout' + onActionPerformed="getHandler().showAbout(this)"/> + </JMenu> + + </JMenuBar> + + <JPanel id='mainPane' layout='{new BorderLayout()}'> + + <JSplitPane id='splitPane' constraints='BorderLayout.CENTER'> + <JScrollPane id='navigationPane'> + <JTree id='navigation' + model='{getTreeHelper().createTreeModel(this)}' + selectionModel="{getTreeHelper().createTreeHandler(this)}"> + <!--cellRenderer='{new NavigationTreeCellRenderer(this)}'>--> + <!--cellRenderer='{new NavigationTreeCellRenderer(this,185)}'>--> + </JTree> + </JScrollPane> + + <JPanel id='content'/> + + </JSplitPane> + + <jaxx.runtime.swing.StatusMessagePanel id='p' constraints='BorderLayout.SOUTH'/> + + </JPanel> </JFrame> \ No newline at end of file Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -23,7 +23,7 @@ import jaxx.runtime.swing.ErrorDialogUI; import jaxx.runtime.JAXXContext; import jaxx.runtime.JAXXInitialContext; -import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode; +import jaxx.runtime.swing.tree.NavigationTreeNode; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import static org.nuiton.i18n.I18n._; @@ -102,8 +102,6 @@ @Override public void run() { -// // use best dimensions -// ui.getSplitPane().resetToPreferredSizes(); String path; if (node == null) { @@ -111,23 +109,25 @@ path = "$root/jaxxdemo.tree.component.swing"; } else { // take selected node - path = node.getContextPath(); + path = node.getFullPath(); } + log.info("node to re select " + path); // select node - ui.getTreeHelper().selectNode(ui, ui.getNavigation(), path); -// -// // show ui -// ui.setVisible(true); + ui.getTreeHelper().selectNode(ui, path); + + // use best dimensions + ui.getSplitPane().resetToPreferredSizes(); } }); + + // show ui after all (in another invocation, tu avoid layout adjustement + // to be seen). + SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - // use best dimensions - ui.getSplitPane().resetToPreferredSizes(); - // show ui ui.setVisible(true); } @@ -154,7 +154,7 @@ node = ui.getTreeHelper().getSelectedNode(ui); if (node != null) { - log.info("selected node " + node.getContextPath()); + log.info("selected node " + node.getFullPath()); } ErrorDialogUI.init(null); @@ -284,14 +284,20 @@ public void showAbout(DemoUI ui) { + DemoConfig config = ui.getConfig(); + + String iconPath = config.getOption("application.icon.path"); + String licensePath = config.getOption("application.license.path"); + String thirdPartyPath = config.getOption("application.third-party.path"); + AboutPanel about = new AboutPanel(); - about.setTitle(_("jaxxdemo.title.about")); - about.setIconPath("/icons/jaxx.png"); about.setAboutText(_("jaxxdemo.about.message")); about.setBottomText(ui.getConfig().getCopyrightText()); - about.setLicenseFile("META-INF/jaxx-example-LICENSE.txt"); - about.setThirdpartyFile("META-INF/jaxx-example-THIRD-PARTY.txt"); + about.setIconPath(iconPath); + about.setLicenseFile(licensePath); + about.setThirdpartyFile(thirdPartyPath); + about.buildTopPanel(); about.init(); about.showInDialog(ui, true); } Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/BoxedDecoratorDemo.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/BoxedDecoratorDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/BoxedDecoratorDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +1,23 @@ +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> <jaxx.demo.DemoPanel> <jaxx.runtime.swing.BlockingLayerUI id='layerUI' Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/StatusMessagePanelDemo.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/StatusMessagePanelDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/StatusMessagePanelDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +1,23 @@ +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> <jaxx.demo.DemoPanel> <JPanel id='demoPanel' layout='{new BorderLayout()}'> <JPanel layout='{new GridLayout(0,1)}' constraints='BorderLayout.CENTER'> Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/ComboEditorDemo.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/ComboEditorDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/ComboEditorDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +1,23 @@ +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> <jaxx.demo.DemoPanel> <Table id='demoPanel' fill='both'> Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/I18nEditorDemo.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/I18nEditorDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/I18nEditorDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +1,23 @@ +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> <jaxx.demo.DemoPanel> <script><![CDATA[ Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +1,23 @@ +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> <jaxx.demo.DemoPanel> <script><![CDATA[ Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +1,23 @@ +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> <jaxx.demo.DemoPanel> <String id='string' javaBean='null'/> Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JButtonDemo.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JButtonDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JButtonDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +1,23 @@ +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> <jaxx.demo.DemoPanel> <style> JButton.fancy { Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxDemo.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +1,23 @@ +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> <jaxx.demo.DemoPanel> <script><![CDATA[ public String getText(boolean bold, boolean italic, boolean underline) { Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxMenuItemDemo.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxMenuItemDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxMenuItemDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +1,23 @@ +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> <JMenuItemDemo> <style> .form { Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JComboBoxDemo.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JComboBoxDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JComboBoxDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,22 +1,65 @@ - -<jaxx.demo.DemoPanel> - <Table id='demoPanel'> - <row> - <cell> - <JLabel text='Button label:'/> - </cell> - - <cell> - <JComboBox id='comboBox' editable='true'> - <item value='OK' selected='true'/> - <item value='Cancel'/> - <item value='Help'/> - </JComboBox> - </cell> - - <cell> - <JButton text='{comboBox.getSelectedItem()}'/> - </cell> - </row> - </Table> +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> + +<jaxx.demo.DemoPanel> + <script><![CDATA[ +import static org.nuiton.i18n.I18n.n_; + +private void $afterCompleteSetup() { + jaxxComboBox.setSelectedIndex(0); +} +]]> + </script> + <Table id='demoPanel'> + <row> + <cell> + <JLabel text='Button label:'/> + </cell> + + <cell> + <JAXXComboBox id='jaxxComboBox' editable='true'> + <item value='{_("OK")}' selected='true'/> + <item value='{_("Cancel")}'/> + <item value='{_("Help")}'/> + </JAXXComboBox> + </cell> + + <cell> + <JButton text='{jaxxComboBox.getSelectedItem()}'/> + </cell> + </row> + <row> + <cell> + <JLabel text='Button label:'/> + </cell> + + <cell> + <JComboBox id='comboBox' + editable='true' + model='{new DefaultComboBoxModel(new Object[]{n_("OK"),n_("Cancel"),n_("Help")})}'/> + </cell> + + <cell> + <JButton text='{comboBox.getSelectedItem()}'/> + </cell> + </row> + </Table> </jaxx.demo.DemoPanel> \ No newline at end of file Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JDialogDemo.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JDialogDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JDialogDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +1,23 @@ +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> <jaxx.demo.DemoPanel> <script> String username; Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JListDemo.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JListDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JListDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +1,23 @@ +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> <jaxx.demo.DemoPanel> <Table id='demoPanel'> <row> Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JMenuItemDemo.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JMenuItemDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JMenuItemDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +1,23 @@ +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> <jaxx.demo.DemoPanel> <script> void $afterCompleteSetup(){} Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JPasswordFieldDemo.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JPasswordFieldDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JPasswordFieldDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +1,23 @@ +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> <jaxx.demo.DemoPanel> <VBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'> <HBox> Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JProgressBarDemo.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JProgressBarDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JProgressBarDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +1,23 @@ +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> <jaxx.demo.DemoPanel> <script><![CDATA[ import javax.swing.Timer; Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonDemo.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +1,23 @@ +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> <jaxx.demo.DemoPanel> <HBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'> <VBox> Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonMenuItemDemo.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonMenuItemDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonMenuItemDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +1,23 @@ +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> <JMenuItemDemo> <JMenuBar id='menuBar'> <JMenu text='Font size'> Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSliderDemo.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSliderDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSliderDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +1,23 @@ +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> <jaxx.demo.DemoPanel> <HBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'> <VBox> Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSpinnerDemo.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSpinnerDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSpinnerDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +1,23 @@ +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> <jaxx.demo.DemoPanel> <HBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'> <JLabel text='Spacing:' displayedMnemonic='S' labelFor='{spinner}'/> Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSplitPaneDemo.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSplitPaneDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSplitPaneDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +1,23 @@ +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> <jaxx.demo.DemoPanel> <JPanel id='demoPanel' layout='{new BorderLayout()}'> <JSplitPane> Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextAreaDemo.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextAreaDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextAreaDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +1,23 @@ +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> <jaxx.demo.DemoPanel> <Table id='demoPanel' anchor='northwest'> <row> Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextFieldDemo.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextFieldDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextFieldDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +1,23 @@ +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> <jaxx.demo.DemoPanel> <JPanel id='demoPanel'> <Table> Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JToggleButtonDemo.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JToggleButtonDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JToggleButtonDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +1,23 @@ +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> <jaxx.demo.DemoPanel> <HBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'> <JToggleButton text='1' id='one'/> Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BaseBeanDataBinding.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BaseBeanDataBinding.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BaseBeanDataBinding.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +1,23 @@ +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> <jaxx.demo.DemoPanel> <!-- a full java bean property of the class --> Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BeanDataBindingDemo.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BeanDataBindingDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BeanDataBindingDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +1,23 @@ +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> <BaseBeanDataBinding> <Boolean id='editing3' javaBean='true'/> Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +1,23 @@ +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> <jaxx.demo.DemoPanel> <style source="Validation.css"/> @@ -3,4 +23,6 @@ <script><![CDATA[ import static org.nuiton.i18n.I18n.n_; +import jaxx.runtime.validator.swing.SwingValidatorMessageListRenderer; + void $afterCompleteSetup() { } @@ -310,7 +332,7 @@ width='500'> <JScrollPane> <JList id='errorList' model='{errors}' - cellRenderer='{new jaxx.runtime.validator.swing.SwingValidatorMessageListRenderer()}'/> + cellRenderer='{new SwingValidatorMessageListRenderer()}'/> </JScrollPane> </JPanel> </cell> Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +1,23 @@ +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> <jaxx.demo.DemoPanel> <style source="Validation.css"/> @@ -31,9 +51,11 @@ <script><![CDATA[ import static org.nuiton.i18n.I18n.n_; import jaxx.runtime.SwingUtil; +import jaxx.runtime.validator.swing.SwingValidatorUtil; +import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer; void $afterCompleteSetup() { - jaxx.runtime.SwingValidatorUtil.installUI(errorTable, new jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer()); + SwingValidatorUtil.installUI(errorTable, new SwingValidatorMessageTableRenderer()); } @Override Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorDemo.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +1,23 @@ +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> <jaxx.demo.DemoPanel> <style source='Calculator.css'/> <script><![CDATA[ Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/CounterDemo.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/CounterDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/CounterDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +1,23 @@ +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> <jaxx.demo.DemoPanel> <script>int count;</script> <JPanel id='demoPanel'> Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyleDemo.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyleDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyleDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +1,23 @@ +<!-- + *##% + jaxx-demo + Copyright (C) 2008 - 2009 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>. + ##%* +--> <jaxx.demo.DemoPanel> <style source="LabelStyle.css"/> <script><![CDATA[ Modified: branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties 2009-10-05 19:15:44 UTC (rev 1559) @@ -47,6 +47,7 @@ Green= Green\:= Greet= +Help= I18n\ editor\ with\ no\ icon\ \:= I18n\ editor\ with\ no\ text\ \:= I18n\ editor\:= @@ -111,7 +112,7 @@ form2.ratio=Form 2 Ratio form2.text=Form 2 Text form2.text2=Form 2 Text 2 -jaxxdemo.about.message=<h3>JAXX Demo</h3>Demo du framework JAXX <hr/><p>Ce projet a \u00E9t\u00E9 r\u00E9alis\u00E9 par la soci\u00E9t\u00E9 <a href\="http\://codelutin.com">Codelutin</a> en 2009.</p><br/><hr/>Pour plus d'informations, vous pouvez visiter le <a href\="http\://maven-site.nuiton.org/jaxx/jaxx-example">site du projet</a>. +jaxxdemo.about.message=<h3>JAXX Demo</h3><hr/>For more informations, viste the <a href\="http\://maven-site.nuiton.org/jaxx/jaxx-demo">website of the project</a>. jaxxdemo.action.about=About... jaxxdemo.action.about.tip=About JAXXDemo... jaxxdemo.action.configuration=Preferences @@ -120,7 +121,7 @@ jaxxdemo.action.exit.tip=Quit JAXXDemo jaxxdemo.action.fullscreen=Full screen jaxxdemo.action.fullscreen.tip=Change to full screen mode -jaxxdemo.action.help=Help +jaxxdemo.action.help= jaxxdemo.action.help.tip=Display help jaxxdemo.action.locale.fr=French jaxxdemo.action.locale.fr.tip=Change to french language @@ -142,7 +143,7 @@ jaxxdemo.init.ui.done=UI initialized. jaxxdemo.menu.file=File jaxxdemo.menu.file.locale=Languages -jaxxdemo.menu.help=Help +jaxxdemo.menu.help= jaxxdemo.message.config.loaded=Configuration of JAXXDemo v. %1$s loaded. jaxxdemo.message.goto.site=Go to JAXXDemo Web site jaxxdemo.title.about=About JAXXDemo... Modified: branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties 2009-10-05 19:15:44 UTC (rev 1559) @@ -20,7 +20,7 @@ Blue=Bleu Blue\:=bleu \: Bold=En gras -Button\ label\:=Libell\u00E9 du label +Button\ label\:=Libell\u00E9 de l'action C=C CE=CE Cancel=Annuler @@ -47,6 +47,7 @@ Green=Vert Green\:=Vert \: Greet= +Help= I18n\ editor\ with\ no\ icon\ \:=Editeur I18n sans icone \: I18n\ editor\ with\ no\ text\ \:=Editeur I18n sans texte \: I18n\ editor\:=Editeur I18n @@ -111,7 +112,7 @@ form2.ratio=Form2 \: ratio form2.text=Form2 \: text form2.text2=Form2 \: text2 -jaxxdemo.about.message=<h3>JAXX Demo</h3><hr/>Pour plus d'informations, vous pouvez visiter le <a href\="http\://maven-site.nuiton.org/kaxx/jaxx-demo">site du projet</a>. +jaxxdemo.about.message=<h3>JAXX Demo</h3><hr/>Pour plus d'informations, vous pouvez visiter le <a href\="http\://maven-site.nuiton.org/jaxx/jaxx-demo">site du projet</a>. jaxxdemo.action.about=A propos jaxxdemo.action.about.tip=A propos de JAXX Demo... jaxxdemo.action.configuration=Configuration @@ -159,7 +160,7 @@ jaxxdemo.tree.feature=Fonctionnalit\u00E9s jaxxdemo.tree.features.databinding=Data binding jaxxdemo.tree.features.validation=Validation -jaxxdemo.tree.fun=Contestes +jaxxdemo.tree.fun=Fun jaxxdemo.warning.nimbus.landf=Le look and Feel Nimbus n'a pas \u00E9t\u00E9 trouv\u00E9, il faut au moins la version 1.6u10 de java. jaxxdemo.warning.no.ui=Aucun environnement graphique d\u00E9tect\u00E9 movies=Films Modified: branches/jaxx-2.X/jaxx-demo/src/main/resources/log4j.properties =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/resources/log4j.properties 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-demo/src/main/resources/log4j.properties 2009-10-05 19:15:44 UTC (rev 1559) @@ -6,5 +6,7 @@ log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n log4j.logger.jaxx.demo=INFO -#log4j.logger.jaxx.runtime.swing.navigation.NavigationTreeHandler=DEBUG +#log4j.logger.jaxx.runtime.swing.tree.NavigationTreeCellRenderer=DEBUG +#log4j.logger.jaxx.runtime.swing.tree.NavigationTreeNodeRenderer=DEBUG +#log4j.logger.jaxx.runtime.swing.tree.NavigationTreeModel=DEBUG log4j.logger.org.nuiton=WARN Property changes on: branches/jaxx-2.X/jaxx-runtime ___________________________________________________________________ Added: svn:ignore + target *.log *.iml Added: svn:mergeinfo + Modified: branches/jaxx-2.X/jaxx-runtime/pom.xml =================================================================== --- branches/jaxx-2.X/jaxx-runtime-api/pom.xml 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-runtime/pom.xml 2009-10-05 19:15:44 UTC (rev 1559) @@ -10,11 +10,11 @@ <parent> <groupId>org.nuiton</groupId> <artifactId>jaxx</artifactId> - <version>1.7.2-SNAPSHOT</version> + <version>2.0.0-SNAPSHOT</version> </parent> <groupId>org.nuiton.jaxx</groupId> - <artifactId>jaxx-runtime-api</artifactId> + <artifactId>jaxx-runtime</artifactId> <dependencies> @@ -62,8 +62,8 @@ <!-- *** Project Information ************************************* --> <!-- ************************************************************* --> - <name>${project.artifactId}</name> - <description>Jaxx runtime api</description> + <name>JAXX Runtime</name> + <description>JAXX Runtime api</description> <!-- ************************************************************* --> <!-- *** Build Settings ****************************************** --> @@ -81,6 +81,14 @@ <goal>parserJava</goal> <goal>gen</goal> </goals> + <configuration> + <treateDefaultEntry>false</treateDefaultEntry> + <entries> + <entry> + <basedir>src/main/java/jaxx/runtime/validator</basedir> + </entry> + </entries> + </configuration> </execution> </executions> </plugin> Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/HBoxBeanInfo.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/beaninfos/HBoxBeanInfo.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/HBoxBeanInfo.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/HBoxBeanInfo.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,58 @@ +/* + * Copyright 2006 Ethan Nicholas. All rights reserved. + * Use is subject to license terms. + */ +package jaxx.beaninfos; + +import jaxx.runtime.swing.HBox; + +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.beans.BeanInfo; +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; +import java.beans.SimpleBeanInfo; + +public class HBoxBeanInfo extends SimpleBeanInfo { + public BeanInfo[] getAdditionalBeanInfo() { + try { + return new BeanInfo[]{Introspector.getBeanInfo(JPanel.class)}; + } + catch (IntrospectionException e) { + throw new RuntimeException(e); + } + } + + + public PropertyDescriptor[] getPropertyDescriptors() { + try { + PropertyDescriptor spacing = new PropertyDescriptor("spacing", HBox.class); + spacing.setBound(true); + + PropertyDescriptor margin = new PropertyDescriptor("margin", HBox.class); + margin.setBound(true); + + PropertyDescriptor horizontalAlignment = new PropertyDescriptor("horizontalAlignment", HBox.class); + horizontalAlignment.setBound(true); + horizontalAlignment.setValue("enumerationValues", new Object[]{ + "left", SwingConstants.LEFT, "SwingConstants.LEFT", + "center", SwingConstants.CENTER, "SwingConstants.CENTER", + "right", SwingConstants.RIGHT, "SwingConstants.RIGHT" + }); + + PropertyDescriptor verticalAlignment = new PropertyDescriptor("verticalAlignment", HBox.class); + verticalAlignment.setBound(true); + verticalAlignment.setValue("enumerationValues", new Object[]{ + "top", SwingConstants.TOP, "SwingConstants.TOP", + "middle", SwingConstants.CENTER, "SwingConstants.CENTER", + "bottom", SwingConstants.BOTTOM, "SwingConstants.BOTTOM" + }); + + return new PropertyDescriptor[]{spacing, margin, horizontalAlignment, verticalAlignment}; + } + catch (IntrospectionException e) { + throw new RuntimeException(e); + } + } +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/HBoxBeanInfo.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/VBoxBeanInfo.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/beaninfos/VBoxBeanInfo.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/VBoxBeanInfo.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/VBoxBeanInfo.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,58 @@ +/* + * Copyright 2006 Ethan Nicholas. All rights reserved. + * Use is subject to license terms. + */ +package jaxx.beaninfos; + +import jaxx.runtime.swing.VBox; + +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.beans.BeanInfo; +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; +import java.beans.SimpleBeanInfo; + +public class VBoxBeanInfo extends SimpleBeanInfo { + public BeanInfo[] getAdditionalBeanInfo() { + try { + return new BeanInfo[]{Introspector.getBeanInfo(JPanel.class)}; + } + catch (IntrospectionException e) { + throw new RuntimeException(e); + } + } + + + public PropertyDescriptor[] getPropertyDescriptors() { + try { + PropertyDescriptor spacing = new PropertyDescriptor("spacing", VBox.class); + spacing.setBound(true); + + PropertyDescriptor margin = new PropertyDescriptor("margin", VBox.class); + margin.setBound(true); + + PropertyDescriptor horizontalAlignment = new PropertyDescriptor("horizontalAlignment", VBox.class); + horizontalAlignment.setBound(true); + horizontalAlignment.setValue("enumerationValues", new Object[]{ + "left", SwingConstants.LEFT, "SwingConstants.LEFT", + "center", SwingConstants.CENTER, "SwingConstants.CENTER", + "right", SwingConstants.RIGHT, "SwingConstants.RIGHT" + }); + + PropertyDescriptor verticalAlignment = new PropertyDescriptor("verticalAlignment", VBox.class); + verticalAlignment.setBound(true); + verticalAlignment.setValue("enumerationValues", new Object[]{ + "top", SwingConstants.TOP, "SwingConstants.TOP", + "middle", SwingConstants.CENTER, "SwingConstants.CENTER", + "bottom", SwingConstants.BOTTOM, "SwingConstants.BOTTOM" + }); + + return new PropertyDescriptor[]{spacing, margin, horizontalAlignment, verticalAlignment}; + } + catch (IntrospectionException e) { + throw new RuntimeException(e); + } + } +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/VBoxBeanInfo.java ___________________________________________________________________ Added: svn:mergeinfo + Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/BeanValidatorUtil.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/BeanValidatorUtil.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/BeanValidatorUtil.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,176 +0,0 @@ -package jaxx.runtime; - -import jaxx.runtime.*; -import com.opensymphony.xwork2.config.Configuration; -import com.opensymphony.xwork2.config.ConfigurationManager; -import com.opensymphony.xwork2.util.ValueStack; -import com.opensymphony.xwork2.util.ValueStackFactory; -import jaxx.runtime.validator.*; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.beans.BeanInfo; -import java.beans.EventSetDescriptor; -import java.beans.IntrospectionException; -import java.beans.Introspector; -import java.beans.PropertyDescriptor; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; - -/** - * The helper class for validation module. - * - * @author chemit - */ -public class BeanValidatorUtil { - - /** to use log facility, just put in your code: log.info(\"...\"); */ - static private final Log log = LogFactory.getLog(BeanValidatorUtil.class); - /** - * a shared value stack to allow external operations on it (for example - * add some datas in stack to be usedby validators - */ - static private ValueStack sharedValueStack; - - public static synchronized ValueStack getSharedValueStack() { - if (sharedValueStack == null) { - - // init context - ConfigurationManager confManager = new ConfigurationManager(); - Configuration conf = confManager.getConfiguration(); - - sharedValueStack = conf.getContainer().getInstance(ValueStackFactory.class).createValueStack(); - if (log.isDebugEnabled()) { - log.debug("init shared value stack " + sharedValueStack); - } - } - return sharedValueStack; - } - - protected BeanValidatorUtil() { - // no instance - } - - /** - * Convinient method to attach a bean to all validators of an JAXXObject. - * <p/> - * It is possible to exclude some validator to be treated. - * - * @param ui the ui containing the validatros to treate - * @param bean the bean to attach in validators (can be null) - * @param excludeIds the list of validator id to exclude - */ - @SuppressWarnings({"unchecked"}) - public static void setValidatorBean(JAXXObject ui, Object bean, String... excludeIds) { - if (!JAXXValidator.class.isAssignableFrom(ui.getClass())) { - return; - } - JAXXValidator jaxxValidator = (JAXXValidator) ui; - List<String> validatorIds = jaxxValidator.getValidatorIds(); - if (excludeIds.length > 0) { - validatorIds = new ArrayList<String>(validatorIds); - for (String excludeId : excludeIds) { - validatorIds.remove(excludeId); - } - } - for (String validatorId : validatorIds) { - BeanValidator beanValidator = jaxxValidator.getValidator(validatorId); - if (bean == null || beanValidator.getBeanClass().isAssignableFrom(bean.getClass())) { - // touch validator, only if fits the bean type (or bean is null) - beanValidator.setBean(bean); - } - } - } - - /** - * Convinient method to set the changed property to all validators of an JAXXObject. - * <p/> - * It is possible to exclude some validator to be treated. - * - * @param ui the ui containing the validatros to treate - * @param newValue the new value to set in changed validator property - * @param excludeIds the list of validator id to exclude - */ - @SuppressWarnings({"unchecked"}) - public static void setValidatorChanged(JAXXObject ui, boolean newValue, String... excludeIds) { - if (!JAXXValidator.class.isAssignableFrom(ui.getClass())) { - return; - } - JAXXValidator jaxxValidator = (JAXXValidator) ui; - List<String> validatorIds = jaxxValidator.getValidatorIds(); - if (excludeIds.length > 0) { - validatorIds = new ArrayList<String>(validatorIds); - for (String excludeId : excludeIds) { - validatorIds.remove(excludeId); - } - } - for (String validatorId : validatorIds) { - BeanValidator beanValidator = jaxxValidator.getValidator(validatorId); - beanValidator.setChanged(newValue); - } - } - - /** - * Convert a value to a given type and then if was succesffull try to set it in the bean manage by the validator. - * - * @param validator validator to be involved - * @param fieldName the name of the bean property - * @param value the actual value to convert - * @param valueClass the type of the conversion - */ - public static void convert(BeanValidator<?> validator, String fieldName, String value, Class<?> valueClass) { - - Object result = validator.convert(fieldName, value, valueClass); - if (result != null) { - try { - BeanInfo info = Introspector.getBeanInfo(validator.getBean().getClass()); - - for (PropertyDescriptor descriptor : info.getPropertyDescriptors()) { - if (fieldName.equals(descriptor.getName()) && descriptor.getWriteMethod() != null) { - - descriptor.getWriteMethod().invoke(validator.getBean(), result); - break; - } - } - } catch (IntrospectionException e) { - log.error("could not obtain beanInfo for " + valueClass.getClass() + ", reason : " + e.getMessage(), e); - } catch (InvocationTargetException e) { - log.error("could not obtain beanInfo for " + valueClass.getClass() + ", reason : " + e.getMessage(), e); - } catch (IllegalAccessException e) { - log.error("could not obtain beanInfo for " + valueClass.getClass() + ", reason : " + e.getMessage(), e); - } - } else { - //fixme : conversion failed, we should be able to notify ui that values has changed ? - // otherwise, bean value has not changed,... - } - } - - public static EventSetDescriptor getPropertyChangeListenerDescriptor(Class beanClass) { - try { - // check that the bean is listenable, otherwise, can't use - // the validator on it - BeanInfo infos = Introspector.getBeanInfo(beanClass); - EventSetDescriptor[] events = infos.getEventSetDescriptors(); - for (EventSetDescriptor event : events) { - if ("propertyChange".equals(event.getName())) { - - if (event.getAddListenerMethod() == null) { - // no property event listener, so can not use the validator - throw new IllegalStateException("no addPropertyChangeListener method found for " + beanClass); - } - if (event.getRemoveListenerMethod() == null) { - // no property event listener, so can not use the validator - throw new IllegalStateException("no removePropertyChangeListener method found for " + beanClass); - } - return event; - } - } - - // no property event listener, so can not use the validator - throw new IllegalStateException("no PropertyChangeListener access method found for " + beanClass); - } catch (IntrospectionException ex) { - throw new IllegalStateException("could not acquire PropertyChangeListener bean info for " + beanClass + " for reason " + ex.getMessage(), ex); - } - } -} Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataContext.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/DataContext.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataContext.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -150,12 +150,12 @@ return result; } - public void setContextValue(DataContextEntry entry, Object value, String key) { + public void setContextValue(DataContextEntry<?> entry, Object value, String key) { String contextKey = getKey(entry, key); delegate.setContextValue(value, contextKey); } - public void removeContextValue(DataContextEntry entry, Object value, String key) { + public void removeContextValue(DataContextEntry<?> entry, Object value, String key) { String contextKey = getKey(entry, key); delegate.removeContextValue(value.getClass(), contextKey); } @@ -246,7 +246,7 @@ pcs.firePropertyChange(name, oldValue, newValue); } - protected String getKey(DataContextEntry entry, String key) { + protected String getKey(DataContextEntry<?> entry, String key) { String result = null; if (key != null) { result = entry.hashCode() + "#" + key; @@ -259,7 +259,7 @@ // suppression des ecouteurs - for (PropertyChangeListener l : getPropertyChangeListeners()) { + for (PropertyChangeListener l : getPropertyChangeListeners()) { removePropertyChangeListener(l); } } @@ -272,14 +272,14 @@ private final int level; private final DataContextEntry<?> previous; - private final DataContextEntry[] parents; + private final DataContextEntry<?>[] parents; private Class<E> klass; public DataContextEntry(Class<E> klass, DataContextEntry<?> previous) { this.previous = previous; this.level = previous.level + 1; this.klass = klass; - this.parents = new DataContextEntry[level]; + this.parents = new DataContextEntry<?>[level]; int i = level; while (i > 0) { parents[--i] = previous; @@ -291,7 +291,7 @@ this.level = 0; this.klass = klass; this.previous = null; - this.parents = new DataContextEntry[0]; + this.parents = new DataContextEntry<?>[0]; } public Class<E> getKlass() { @@ -302,7 +302,7 @@ return level; } - public DataContextEntry[] getParents() { + public DataContextEntry<?>[] getParents() { return parents; } @@ -321,7 +321,7 @@ @Override public Iterator<DataContextEntry<?>> iterator() { int length = parents.length; - DataContextEntry[] t = new DataContextEntry[length + 1]; + DataContextEntry<?>[] t = new DataContextEntry<?>[length + 1]; System.arraycopy(parents, 0, t, 0, length); t[length] = this; return new DataContextEntryIterator(t, true); @@ -335,31 +335,31 @@ public static interface UpdateDataContext<D extends DataContext> { - void onRemovingData(D context, DataContextEntry<?> entry); + void onRemovingData(D context, DataContextEntry<D> entry); - void onAddingData(D context, DataContextEntry entry, String path); + void onAddingData(D context, DataContextEntry<D> entry, String path); } public static class DataContextEntryIterator implements Iterator<DataContextEntry<?>> { - protected final DataContextEntry[] datas; + protected final DataContextEntry<?>[] datas; protected final boolean reverse; protected final int level; protected int index; - public DataContextEntryIterator(DataContextEntry[] datas) { + public DataContextEntryIterator(DataContextEntry<?>[] datas) { this(datas, false, -1); } - public DataContextEntryIterator(DataContextEntry[] datas, int level) { + public DataContextEntryIterator(DataContextEntry<?>[] datas, int level) { this(datas, false, level); } - public DataContextEntryIterator(DataContextEntry[] datas, boolean reverse) { + public DataContextEntryIterator(DataContextEntry<?>[] datas, boolean reverse) { this(datas, reverse, -1); } - DataContextEntryIterator(DataContextEntry[] datas, boolean reverse, int level) { + DataContextEntryIterator(DataContextEntry<?>[] datas, boolean reverse, int level) { this.datas = datas; this.reverse = reverse; if (reverse) { Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Decorator.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/Decorator.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Decorator.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,36 +0,0 @@ -package jaxx.runtime; - -/** - * A simple contract to define a String decorator on any java objet. - * - * @param <O> the type of decorated object - * @author chemit - */ -public abstract class Decorator<O> implements java.io.Serializable { - - protected final Class<O> internalClass; - private static final long serialVersionUID = -1L; - - /** - * @param internalClass the class of objects to be decorated. - * @throws NullPointerException if internalClass parameter is null - */ - public Decorator(Class<O> internalClass) throws NullPointerException { - if (internalClass == null) { - throw new NullPointerException("internalClass can not be null."); - } - this.internalClass = internalClass; - } - - /** - * @param bean the bean to decorate - * @return the string value of the given bean - */ - public abstract String toString(Object bean); - - - public final Class<O> getInternalClass() { - return internalClass; - } - -} Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DecoratorUtils.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/DecoratorUtils.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DecoratorUtils.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,111 +0,0 @@ -package jaxx.runtime; - -import java.util.List; - -/** - * - * Some usefull methods on {@link Decorator} to store and obtain decorators. - * - * Use the method {@link #registerDecorator(String, Decorator)} to register a new - * decorator. - * - * Use the method {@link #getDecorator(String)} to obtain a registred - * decorator based on his registred name. - * - * Use the method {@link #getDecorator(Class, tring)} to obtain a registred - * decorator based on the type of decorator and the registred name. - * - * @author tony - * @since 1.3 - */ -public class DecoratorUtils { - - protected static List<DecoratorContext<?>> cache; - - public static <T> void registerDecorator(String context, Decorator<T> decorator) { - DecoratorContext<T> result = getDecoratorContext(decorator.getInternalClass(), context); - - if (result != null) { - throw new IllegalArgumentException("there is an already register decorator " + result); - } - - if (cache == null) { - cache = new java.util.ArrayList<DecoratorContext<?>>(); - } - cache.add(new DecoratorContext<T>(context, decorator)); - } - - public static <T> Decorator<T> getDecorator(String context) { - Decorator<T> result = getDecorator(null, context); - return result; - } - - public static <T> Decorator<T> getDecorator(Class<T> type, String context) { - DecoratorContext<T> decoratorContext = getDecoratorContext(type, context); - Decorator<T> result = decoratorContext == null ? null : decoratorContext.getDecorator(); - return result; - } - - public static void clear() { - if (cache != null) { - cache.clear(); - } - } - - @SuppressWarnings({"unchecked"}) - protected static <T> DecoratorContext<T> getDecoratorContext(Class<T> type, String context) { - DecoratorContext<T> result = null; - if (cache != null) { - for (DecoratorContext<?> d : cache) { - if (type == null) { - if (d.accept(context)) { - result = (DecoratorContext<T>) d; - break; - } - continue; - } - if (d.accept(type, context)) { - result = (DecoratorContext<T>) d; - break; - } - } - } - return result; - } - - public static class DecoratorContext<T> { - - final String context; - final Decorator<T> decorator; - - public DecoratorContext(String context, Decorator<T> decorator) { - this.context = context; - this.decorator = decorator; - } - - public String getContext() { - return context; - } - - public Decorator<T> getDecorator() { - return decorator; - } - - public Class<T> getType() { - return decorator.getInternalClass(); - } - - public boolean accept(Class<?> type, String context) { - return getType().isAssignableFrom(type) && accept(context); - } - - public boolean accept(String context) { - return ((this.context == null && context == null) || (this.context != null && this.context.equals(context))); - } - - @Override - public String toString() { - return super.toString() + "<type: " + getType().getName() + ", context :" + context + ">"; - } - } -} Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DefaultApplicationContext.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/DefaultApplicationContext.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DefaultApplicationContext.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -78,11 +78,11 @@ /** * Map of forwarded classes (key) to classes (values). */ - protected Map<Class, Class> forwards; + protected Map<Class<?>, Class<?>> forwards; public DefaultApplicationContext() { super(); - forwards = new HashMap<Class, Class>(); + forwards = new HashMap<Class<?>, Class<?>>(); pcs = new PropertyChangeSupport(this); } @@ -165,10 +165,10 @@ @Override public <T> void removeContextValue(Class<T> klazz, String name) { - Entry<Class, Class> entry; + Entry<Class<?>, Class<?>> entry; if (name == null && forwards.containsValue(klazz)) { // remove forward - Iterator<Entry<Class, Class>> itr = forwards.entrySet().iterator(); + Iterator<Entry<Class<?>, Class<?>>> itr = forwards.entrySet().iterator(); while (itr.hasNext()) { entry = itr.next(); if (entry.getValue().equals(klazz)) { Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/JAXXContext.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -29,6 +29,7 @@ * <p/> * If a previous entry exists in context (unamed and same class), it will be removed. * + * @param <T> type of data to set in context * @param o the value to push in context */ public <T> void setContextValue(T o); @@ -38,6 +39,7 @@ * <p/> * If a previous entry exists in context (same name and class), it will be removed. * + * @param <T> type of data to set in context * @param o the value to push in context * @param name the name of the new entry */ @@ -46,6 +48,7 @@ /** * Remove from context the value with the given klazz as an unamed entry * + * @param <T> type of data to remove from context * @param klazz the klazz entry */ public <T> void removeContextValue(Class<T> klazz); @@ -53,6 +56,7 @@ /** * Remove from context the value with the given klazz as an unamed (if name is null) or named entry * + * @param <T> type of data to remove from context * @param klazz the klazz entry * @param name extra name of the entry */ @@ -66,6 +70,7 @@ * <p/> * <code><JButton onActionPerformed='{getContextValue(Action.class).method(args[])}'/></code> * + * @param <T> type of data to obtain from context * @param clazz the class of unamed entry to seek in context * @return the value of the unamed entry for the given class, or <code>null</code> if no such entry. */ @@ -74,6 +79,7 @@ /** * Seek for a named entry in the context * + * @param <T> type of data to obtain from context * @param clazz the class of named entry to seek in context * @param name the name of the entry to seek in context * @return the value of the named entry for the given class, or <code>null</code> if no such entry. @@ -83,6 +89,7 @@ /** * Return parent's container corresponding to the Class clazz * + * @param <O> type of container to obtain from context * @param clazz clazz desired * @return parent's container */ @@ -91,6 +98,7 @@ /** * Return parent's container corresponding to the Class clazz * + * @param <O> type of container to obtain from context * @param top the top container * @param clazz desired * @return parent's container Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JXPathDecorator.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/JXPathDecorator.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JXPathDecorator.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,278 +0,0 @@ -package jaxx.runtime; - -import org.apache.commons.jxpath.JXPathContext; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * JXPath decorator based on {@link String#format(String, Object[])} method. - * <p/> - * To use it, give to him a expression where all jxpath to apply on bean are boxed in <code>${}</code>. - * <p/> - * After the jxpath token you must specifiy the formatter to apply of the jxpath token. - * <p/> - * For example : - * <pre> - * Decorator<Object> d = JXPathDecorator.newDecorator(JXPathDecorator.class,"expr = ${expressions}$s"); - * assert "expr = %1$s" == d.getExpression(); - * assert 1 == d.getNbToken(); - * assert java.util.Arrays.asList("expression") == d.getTokens(); - * assert "expr = %1$s" == d.toString(d); - * </pre> - * - * @param <O> type of data - * @author chemit - * @see Decorator - */ -public class JXPathDecorator<O> extends Decorator<O> { - - /** to use log facility, just put in your code: log.info(\"...\"); */ - private static final Log log = LogFactory.getLog(JXPathDecorator.class); - private static final long serialVersionUID = 1L; - - /** - * Factory method to instanciate a new {@link JXPathDecorator} for the given class {@link O} and expression. - * - * @param internalClass the class of the objects decorated by the new decorator - * @param expression the expression to use to decorated objects - * @param <O> the generic type of class to be decorated by the new decorator - * @return the new instanciated decorator - * @throws IllegalArgumentException if the expression is not valid, says: - * <p/> - * - a missing right brace was detected. - * <p/> - * - a ${ was found in a jxpath token. - * @throws NullPointerException if internalClass parameter is null. - */ - public static <O> JXPathDecorator<O> newDecorator(Class<O> internalClass, String expression) - throws IllegalArgumentException, NullPointerException { - return new JXPathDecorator<O>(internalClass, expression, true); - } - - /** - * Sort a list of data based on the first token property of a given context - * in a given decorator. - * - * @param <O> type of data to sort - * @param decorator the decorator to use to sort - * @param datas the list of data to sort - * @param pos the index of context to used in decorator to obtain sorted property. - */ - public static <O> void sort(JXPathDecorator<O> decorator, List<O> datas, int pos) { - Comparator<O> c = null; - boolean cachedComparator = false; - try { - c = decorator.getComparator(pos); - cachedComparator = c instanceof JXPathComparator<?>; - - if (cachedComparator) { - ((JXPathComparator<O>) c).init(decorator, datas); - } - Collections.sort(datas, c); - } finally { - if (cachedComparator) { - ((JXPathComparator<?>) c).clear(); - } - } - } - - public static class JXPathComparator<O> implements Comparator<O> { - - protected Map<O, Comparable<Comparable<?>>> valueCache; - private final String expression; - - public JXPathComparator(String expression) { - this.expression = expression; - this.valueCache = new HashMap<O, Comparable<Comparable<?>>>(); - } - - @Override - public int compare(O o1, O o2) { - Comparable<Comparable<?>> c1 = valueCache.get(o1); - Comparable<Comparable<?>> c2 = valueCache.get(o2); - return c1.compareTo(c2); - } - - public void clear() { - valueCache.clear(); - } - - public void init(JXPathDecorator<O> decorator, List<O> datas) { - clear(); - for (O data : datas) { - JXPathContext jxcontext = JXPathContext.newContext(data); - Comparable<Comparable<?>> key = decorator.getTokenValue(jxcontext, expression); - valueCache.put(data, key); - } - } - } - - public static class Context<O> implements java.io.Serializable { - - /** - * expression to format using {@link String#format(String, Object[])}, all variables are compute - * using using the jxpath tokens. - */ - protected String expression; - /** list of jxpath tokens to apply on expression */ - protected String[] tokens; - protected transient Comparator<O> comparator; - private static final long serialVersionUID = 1L; - - public Context(String expression, String[] tokens) { - this.expression = expression; - this.tokens = tokens; - } - - public String getFirstProperty() { - return tokens[0]; - } - - public Comparator<O> getComparator(int pos) { - if (comparator == null) { - comparator = new JXPathComparator<O>(tokens[pos]); - } - return comparator; - } - - public void setComparator(Comparator<O> comparator) { - this.comparator = comparator; - } - - @Override - public String toString() { - return "<expression:" + expression + ", tokens:" + Arrays.toString(tokens) + ">"; - } - } - /** the computed context of the decorator */ - protected Context<O> context; - /** nb jxpath tokens to compute */ - protected int nbToken; - /** the initial expression used to compute the decorator context. */ - protected String initialExpression; - - @Override - public String toString(Object bean) { - if (bean == null) { - return null; - } - JXPathContext jxcontext = JXPathContext.newContext(bean); - Object[] args = new Object[nbToken]; - - for (int i = 0; i < nbToken; i++) { - try { - args[i] = getTokenValue(jxcontext, context.tokens[i]); - } catch (Exception e) { - log.error("can not obtain token " + context.tokens[i] + "on object " + bean + " for reason " + e.getMessage(), e); - - } - } - - return String.format(context.expression, args); - } - - @SuppressWarnings({"unchecked"}) - protected Comparable<Comparable<?>> getTokenValue(JXPathContext jxcontext, String token) { - // assume all values are comparable - return (Comparable<Comparable<?>>) jxcontext.getValue(token); - } - - public String getProperty(int pos) { - return getTokens()[pos]; - } - - public String getExpression() { - return context.expression; - } - - public String[] getTokens() { - return context.tokens; - } - - public int getNbToken() { - return nbToken; - } - - public String getInitialExpression() { - return initialExpression; - } - - @Override - public String toString() { - return super.toString() + "<" + context + ">"; - } - - public void setContext(Context<O> context) { - this.context = context; - this.nbToken = context.tokens.length; - // always reset comparator - //this.context.comparator = null; - if (log.isDebugEnabled()) { - log.debug(context); - } - } - - public JXPathDecorator(Class<O> internalClass, String expression, boolean creatContext) throws IllegalArgumentException, NullPointerException { - super(internalClass); - this.initialExpression = expression; - if (creatContext) { - setContext(JXPathDecorator.<O>createInitialContext(expression)); - if (log.isDebugEnabled()) { - log.debug(expression + " --> " + this.context); - } - } - } - - @SuppressWarnings({"unchecked"}) - protected Comparator<O> getComparator(int pos) { - ensureTokenIndex(this, pos); - return context.getComparator(pos); - } - - public static <O> Context<O> createInitialContext(String expression) { - List<String> lTokens = new ArrayList<String>(); - StringBuilder buffer = new StringBuilder(); - int size = expression.length(); - int end = -1; - int start; - while ((start = expression.indexOf("${", end + 1)) > -1) { - if (start > end + 1) { - // prefix of next jxpath token - buffer.append(expression.substring(end + 1, start)); - } - // seek end of jxpath - end = expression.indexOf("}", start + 1); - if (end == -1) { - throw new IllegalArgumentException("could not find the rigth brace starting at car " + start + " : " + expression.substring(start + 2)); - } - String jxpath = expression.substring(start + 2, end); - // not allowed ${ inside a jxpath token - if (jxpath.indexOf("${") > -1) { - throw new IllegalArgumentException("could not find a ${ inside a jxpath expression at car " + (start + 2) + " : " + jxpath); - } - // save the jxpath token - lTokens.add(jxpath); - // replace jxpath token in expresion with a string format variable - buffer.append("%").append(lTokens.size()); - } - if (size > (end + 1)) { - // suffix after end jxpath (or all expression if no jxpath) - buffer.append(expression.substring(end + 1)); - } - return new Context<O>(buffer.toString(), lTokens.toArray(new String[lTokens.size()])); - } - - protected static void ensureTokenIndex(JXPathDecorator<?> decorator, int pos) { - if (pos < -1 || pos > decorator.getNbToken()) { - throw new ArrayIndexOutOfBoundsException("token index " + pos + " is out of bound, can be inside [" + 0 + "," + decorator.nbToken + "]"); - } - } -} Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JaxxHelpUI.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/JaxxHelpUI.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JaxxHelpUI.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JaxxHelpUI.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,23 @@ +package jaxx.runtime; + +import java.awt.Component; +import jaxx.runtime.swing.JaxxHelpBroker; + +/** + * + * Contract to be added on JAXXObject wihch wants to use javax help. + * + * @param <B> type of broker. + * + * @author tony + * @since 1.3 + * @see JaxxHelpBroker + */ +public interface JaxxHelpUI<B extends JaxxHelpBroker<?>> { + + B getBroker(); + + void registerHelpId(B broker, Component component, String helpId); + + void showHelp(String helpId); +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JaxxHelpUI.java ___________________________________________________________________ Added: svn:mergeinfo + Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/MultiJXPathDecorator.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/MultiJXPathDecorator.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/MultiJXPathDecorator.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,129 +0,0 @@ -package jaxx.runtime; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; -import java.util.StringTokenizer; - -/** - * TODO - * - * @param <O> type of decorated objects - * @author chemit - * @see jaxx.runtime.Decorator - */ -public class MultiJXPathDecorator<O> extends JXPathDecorator<O> { - - /** to use log facility, just put in your code: log.info(\"...\"); */ - private static final Log log = LogFactory.getLog(MultiJXPathDecorator.class); - - private static final long serialVersionUID = 1L; - - public static <O> MultiJXPathDecorator<O> newDecorator(Class<O> internalClass, - String expression, - String separator) - throws IllegalArgumentException, NullPointerException { - - return newDecorator(internalClass, expression, separator, separator); - } - - public static <O> MultiJXPathDecorator<O> newDecorator(Class<O> internalClass, - String expression, - String separator, - String separatorReplacement) - throws IllegalArgumentException, NullPointerException { - - Context<O>[] contexts = createInitialContexts(expression, separator, separatorReplacement); - - return new MultiJXPathDecorator<O>(internalClass, expression, separator, separatorReplacement, contexts); - } - - protected Context<O>[] contexts; - protected String separator; - protected String separatorReplacement; - - - public MultiJXPathDecorator(Class<O> internalClass, String expression, - String separator, String separatorReplacement, - Context<O>[] contexts) throws IllegalArgumentException, NullPointerException { - super(internalClass, expression, false); - this.separator = separator; - this.separatorReplacement = separatorReplacement; - this.contexts = contexts; - - setContextIndex(0); - - if (log.isDebugEnabled()) { - log.debug(expression + " --> " + this.context); - } - } - - public void setContextIndex(int index) { - ensureContextIndex(this, index); - setContext(contexts[index]); - } - - public int getNbContext() { - return contexts.length; - } - - public String getSeparator() { - return separator; - } - - public String getSeparatorReplacement() { - return separatorReplacement; - } - - @Override - protected Comparator<O> getComparator(int pos) { - ensureContextIndex(this, pos); - Context<O> context1 = contexts[pos]; - return context1.getComparator(0); - } - - public static <O> Context<O>[] createInitialContexts(String expression, String separator, String separatorReplacement) { - int sep = expression.indexOf(separator); - if (sep == -1) { - Context<O>[] result = MultiJXPathDecorator.newInstance(1); - result[0] = createInitialContext(expression); - return result; - } - - List<String> tokens = new ArrayList<String>(); - StringTokenizer stk = new StringTokenizer(expression, separator); - while (stk.hasMoreTokens()) { - tokens.add(stk.nextToken()); - } - - int nbTokens = tokens.size(); - Context<O>[] contexts = newInstance(nbTokens); - for (int i = 0; i < nbTokens; i++) { - StringBuilder buffer = new StringBuilder(expression.length()); - for (int j = 0; j < nbTokens; j++) { - int index = (i + j) % nbTokens; - String str = tokens.get(index); - //todo replace %index with %j - buffer.append(separatorReplacement).append(str); - } - contexts[i] = createInitialContext(buffer.substring(separatorReplacement.length())); - } - return contexts; - } - - protected static void ensureContextIndex(MultiJXPathDecorator<?> decorator, int pos) { - if (pos < -1 || pos > decorator.contexts.length) { - throw new ArrayIndexOutOfBoundsException("context index " + pos + " is out of bound, can be inside [" + 0 + "," + decorator.contexts.length + "]"); - } - } - - @SuppressWarnings("unchecked") - protected static <O> Context<O>[] newInstance(int size) { - // fixme how to instanciate a typed array with no checking warning ? - return new Context[size]; - } - -} \ No newline at end of file Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/PropertyDecorator.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/PropertyDecorator.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/PropertyDecorator.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,94 +0,0 @@ -package jaxx.runtime; - -import org.apache.commons.beanutils.PropertyUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.beans.PropertyDescriptor; -import java.lang.reflect.Method; - -/** - * Simple property decorator based on {@link String#format(String, Object[])} method. - * <p/> - * To use it, give him a class and the property name to render. - * <p/> - * For example : - * <pre> - * Decorator<Object> d = PropertyDecorator.newDecorator(PropertyDecorator.class,"expressions"); - * </pre> - * - * @param <O> type of decorated objects - * @author chemit - * @see Decorator - */ -public class PropertyDecorator<O> extends Decorator<O> { - - private static final long serialVersionUID = 1L; - - /** to use log facility, just put in your code: log.info(\"...\"); */ - static private final Log log = LogFactory.getLog(PropertyDecorator.class); - - /** - * Factory method to instanciate a new {@link jaxx.runtime.PropertyDecorator} for the given class {@link O} and a - * readable property name. - * - * @param internalClass the class of the objects decorated by the new decorator - * @param property the property - * @param <O> the generic type of class to be decorated by the new decorator - * @return the new instanciated decorator - * @throws IllegalArgumentException if the expression is not valid, says: - * <p/> - * - a missing right brace was detected. - * <p/> - * - a ${ was found in a jxpath token. - * @throws NullPointerException if internalClass parameter is null. - */ - public static <O> PropertyDecorator<O> newDecorator(Class<O> internalClass, String property) - throws IllegalArgumentException, NullPointerException { - return new PropertyDecorator<O>(internalClass, property); - } - - protected String property; - - protected transient Method m; - - @Override - public String toString(Object bean) { - try { - return getM().invoke(bean) + ""; - } catch (Exception e) { - log.error("could not convert for reason : " + e, e); - return ""; - } - } - - public String getProperty() { - return property; - } - - protected PropertyDecorator(Class<O> internalClass, String property) throws NullPointerException { - super(internalClass); - if (property == null) { - throw new NullPointerException("property can not be null."); - } - this.property = property; - // init method - getM(); - } - - - protected Method getM() { - if (m == null) { - for (PropertyDescriptor propertyDescriptor : PropertyUtils.getPropertyDescriptors(internalClass)) { - if (propertyDescriptor.getName().equals(property)) { - this.m = propertyDescriptor.getReadMethod(); - break; - } - } - if (m == null) { - throw new IllegalArgumentException("could not find the property " + property + " in " + internalClass); - } - } - return m; - } -} Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,762 @@ +package jaxx.runtime; + +import jaxx.runtime.*; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Desktop; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Rectangle; +import java.beans.BeanInfo; +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JComboBox; +import javax.swing.JTable; +import javax.swing.SwingUtilities; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.text.AbstractDocument; +import javax.swing.text.JTextComponent; +import java.lang.reflect.Field; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.ListIterator; +import java.util.Map; +import java.util.Map.Entry; +import java.util.NoSuchElementException; +import java.util.Properties; +import javax.swing.Icon; +import javax.swing.ImageIcon; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JLayeredPane; +import javax.swing.JRootPane; +import javax.swing.JTabbedPane; +import javax.swing.JTree; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; +import javax.swing.event.HyperlinkEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.tree.TreeNode; +import javax.swing.tree.TreePath; +import jaxx.runtime.swing.BooleanCellRenderer; +import jaxx.runtime.swing.EmptyNumberTableCellRenderer; +import jaxx.runtime.swing.EnumTableCellRenderer; +import jaxx.runtime.swing.I18nTableCellRenderer; +import jaxx.runtime.swing.Item; +import jaxx.runtime.swing.JAXXComboBox; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.jxlayer.JXLayer; + +/** + * The runtime swing util class with some nice stuff. + * + * Note : Replace previous class jaxx.runtime.swing.Utils in previous versions. + * + * @author tony + * @since 1.2 + */ +public class SwingUtil extends Util { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private final Log log = LogFactory.getLog(SwingUtil.class); + private static Field numReaders; + private static Field notifyingListeners; + public static final String ICON_PREFIX = "icon."; + public static final String COLOR_PREFIX = "color."; + + public static Dimension newMinDimension() { + return new Dimension(0, 0); + } + + public static Dimension newMaxXDimension() { + return new Dimension(Short.MAX_VALUE, 0); + } + + public static Dimension newMaxYDimension() { + return new Dimension(0, Short.MAX_VALUE); + } + + public static Dimension newMaxXYDimension() { + return new Dimension(Short.MAX_VALUE, Short.MAX_VALUE); + } + + public static void setText(final JTextComponent c, final String text) { + try { + // AbstractDocument deadlocks if we try to acquire a write lock while a read lock is held by the current thread + // If there are any readers, dispatch an invokeLater. This should only happen in the event of circular bindings. + // Similarly, circular bindings can result in an "Attempt to mutate in notification" error, which we deal with + // by checking for the 'notifyingListeners' property. + AbstractDocument document = (AbstractDocument) c.getDocument(); + if (numReaders == null) { + numReaders = AbstractDocument.class.getDeclaredField("numReaders"); + numReaders.setAccessible(true); + } + if (notifyingListeners == null) { + notifyingListeners = AbstractDocument.class.getDeclaredField("notifyingListeners"); + notifyingListeners.setAccessible(true); + } + + if (notifyingListeners.get(document).equals(Boolean.TRUE)) { + return; + } + + if ((Integer) numReaders.get(document) > 0) { + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + if (!c.getText().equals(text)) { + c.setText(text); + } + } + }); + return; + } + + String oldText = c.getText(); + if (oldText == null || !oldText.equals(text)) { + c.setText(text); + } + } catch (NoSuchFieldException e) { + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } catch (SecurityException e) { + c.setText(text); + } + } + + /** + * Fill a combo box model with some datas, and select after all the given object + * + * @param combo the combo to fill + * @param data data ot inject in combo + * @param select the object to select in combo after reflling his model + */ + public static void fillComboBox(JComboBox combo, Collection<?> data, Object select) { + if (!(combo.getModel() instanceof DefaultComboBoxModel)) { + throw new IllegalArgumentException("this method need a DefaultComboBoxModel for this model but was " + combo.getModel().getClass()); + } + DefaultComboBoxModel model = (DefaultComboBoxModel) combo.getModel(); + // evince the model + model.removeListDataListener(combo); + model.removeAllElements(); + if (data != null) { + for (Object o : data) { + model.addElement(o); + } + } + // attach the model + model.addListDataListener(combo); + model.setSelectedItem(select); + } + + /** + * Fill a combo box model with some datas, and select after all the given object + * + * @param combo the combo to fill + * @param data data ot inject in combo + * @param select the object to select in combo after reflling his model + * @param firstNull add a first null element + */ + public static void fillComboBox(JAXXComboBox combo, Collection<?> data, Object select, boolean firstNull) { + List<Item> items = new ArrayList<Item>(); + if (firstNull) { + items.add(new Item("null", " ", null, false)); + } + if (data != null) { + for (Object d : data) { + items.add(new Item(d.toString(), d.toString(), d, d.equals(select))); + } + } + combo.setItems(items); + } + + public static int computeTableColumnWidth(JTable table, Font font, int columnIndex, String suffix) { + int width = 0; + if (font == null) { + font = table.getFont(); + } +// if (font == null) { +// TableColumn column = table.getColumnModel().getColumn(columnIndex); +// font = ((JComponent) column.getCellRenderer()).getFont(); +// } + FontMetrics fontMetrics = table.getFontMetrics(font); + for (int i = 0, rowCount = table.getRowCount(); i < rowCount; i++) { + String key = (String) table.getModel().getValueAt(i, 0); + int w = fontMetrics.stringWidth(key + suffix); + if (w > width) { + width = w; + } + } + return width; + } + + public static void fixTableColumnWidth(JTable table, int columnIndex, int width) { + TableColumn column = table.getColumnModel().getColumn(columnIndex); + column.setMaxWidth(width); + column.setMinWidth(width); + column.setWidth(width); + column.setPreferredWidth(width); + } + + public static void setTableColumnEditor(JTable table, int columnIndex, TableCellEditor editor) { + TableColumn column = table.getColumnModel().getColumn(columnIndex); + column.setCellEditor(editor); + } + + public static void setTableColumnRenderer(JTable table, int columnIndex, TableCellRenderer editor) { + TableColumn column = table.getColumnModel().getColumn(columnIndex); + column.setCellRenderer(editor); + } + + public static void setI18nTableHeaderRenderer(JTable table, String... libelles) { + table.getTableHeader().setDefaultRenderer(new I18nTableCellRenderer(table.getTableHeader().getDefaultRenderer(), libelles)); + } + + public static TableCellRenderer newStringTableCellRenderer(final DefaultTableCellRenderer renderer, final int length, final boolean tooltip) { + + return new DefaultTableCellRenderer() { + + private static final long serialVersionUID = 1l; + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + + renderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + String val = renderer.getText(); + String val2 = val; + if (val.length() > length) { + val2 = val.substring(0, length - 3) + "..."; + } + + JComponent comp = (JComponent) super.getTableCellRendererComponent(table, val2, isSelected, hasFocus, row, column); + if (tooltip) { + comp.setToolTipText(val); + } + return comp; + } + }; + } + + /** + * Box a component in a {@link org.jdesktop.jxlayer.JXLayer}. + * + * @param component the component to box + * @return the {@link org.jdesktop.jxlayer.JXLayer} boxing the component + */ + public static JXLayer<?> boxComponentWithJxLayer(JComponent component) { + JXLayer<?> layer = getLayer(component); + if (layer != null) { + return layer; + } + layer = new org.jdesktop.jxlayer.JXLayer<JComponent>(); + layer.add(component); + return layer; + } + + public static List<JComponent> getLayeredComponents(JAXXObject object) { + List<JComponent> result = new ArrayList<JComponent>(); + for (Entry<String, Object> child : object.get$objectMap().entrySet()) { + if (child.getValue() == null) { + log.warn("find a null object in $objectMap " + child.getKey()); + continue; + } + if (JComponent.class.isAssignableFrom(child.getValue().getClass())) { + JComponent comp = (JComponent) child.getValue(); + if (isLayered(comp)) { + result.add(comp); + } + } + } + return result; + } + + @SuppressWarnings("unchecked") + public static JXLayer<JComponent> getLayer(JComponent comp) { + if (!isLayered(comp)) { + return null; + } + return (JXLayer<JComponent>) comp.getParent(); + } + + public static boolean isLayered(JComponent comp) { + Container parent = comp.getParent(); + return parent != null && parent instanceof JXLayer<?>; + } + + /** + * recherche les composants portant le meme nom que les champs de la classe + * clazz. Cette methode est statique pour pouvoir eventuellement l'utiliser + * dans un autre context (je pense par exemple a la generation jaxx). + * <p/> + * <p/> + * Si la recherche echoue pour quelque raison que se soit, aucune exception + * n'est leve, et la map retournee est tout simplement vide ou incomplete + * + * @param clazz la classe ou recherche les champs + * @param container le container ou rechercher les composants d'edition + * @return le dictionnaire des composants recherches. + */ + public static Map<String, JComponent> lookingForEditor(Class<?> clazz, Container container) { + Map<String, JComponent> result = new HashMap<String, JComponent>(); + try { + // looking for all component with name set + Map<String, JComponent> allNamedComponent = new HashMap<String, JComponent>(); + List<Container> todo = new LinkedList<Container>(); + todo.add(container); + while (todo.size() > 0) { + for (ListIterator<Container> i = todo.listIterator(); i.hasNext();) { + Container parent = i.next(); + i.remove(); + for (Component c : parent.getComponents()) { + if (c instanceof Container) { + i.add((Container) c); + String name = c.getName(); + if (c instanceof JComponent && + name != null && !"".equals(name)) { + allNamedComponent.put(name, (JComponent) c); + } + } + } + } + } + + // looking for all properties on class + BeanInfo info = Introspector.getBeanInfo(clazz); + PropertyDescriptor[] props = info.getPropertyDescriptors(); + + // find if one properties have same name that component + for (PropertyDescriptor prop : props) { + String name = prop.getName(); + if (allNamedComponent.containsKey(name)) { + result.put(name, allNamedComponent.get(name)); + } + } + + } catch (IntrospectionException eee) { + log.warn("Can't introspect bean", eee); + } + + if (log.isDebugEnabled()) { + log.debug("Result: " + result); + } + + return result; + } + + /** + * Centrer un component graphique au center d'un autre component. + * + * <b>Note:</b> si le parent est null, alors on ne fait rien. + * + * @param parent le component parent + * @param component le component à centrer + */ + public static void center(Component parent, Component component) { + if (parent == null) { + return; + } + Rectangle r = parent.getBounds(); + int x = r.x + (r.width - component.getSize().width) / 2; + int y = r.y + (r.height - component.getSize().height) / 2; + component.setLocation(x, y); + } + + /** + * Try to load the Nimbus look and feel. + * <p/> + * @throws UnsupportedLookAndFeelException + * if nimbus is not applicable + * @throws ClassNotFoundException + * @throws InstantiationException + * @throws IllegalAccessException + */ + public static void initNimbusLoookAndFeel() throws UnsupportedLookAndFeelException, ClassNotFoundException, InstantiationException, IllegalAccessException { + + for (UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(laf.getName())) { + UIManager.setLookAndFeel(laf.getClassName()); + } + } + } + + /** + * Load the ui.properties file and set in {@link UIManager} colors and icons found. + * + * @param defaultUIConfig le path vers le fichier de la config d'ui par défaut (doit etre dansle class-path) + * @param extraUIConfig le path vers une surcharge de la config d'ui (doit etre dans le class-path) + * + * @throws IOException if could not load the ui.properties file + */ + public static void loadUIConfig(String defaultUIConfig, String extraUIConfig) throws IOException { + + Properties p = new Properties(); + log.info("loading default UI config " + defaultUIConfig); + p.load(SwingUtil.class.getResourceAsStream(defaultUIConfig)); + if (log.isDebugEnabled()) { + log.debug(p.toString()); + } + if (extraUIConfig != null) { + InputStream extraStream = SwingUtil.class.getResourceAsStream(extraUIConfig); + if (extraStream == null) { + log.warn("could not find extraUIConfig : " + extraUIConfig); + } else { + log.info("loading extra UI config " + extraUIConfig); + Properties p2 = new Properties(p); + p2.load(extraStream); + if (log.isDebugEnabled()) { + log.debug(p2.toString()); + } + p.putAll(p2); + } + } + for (Entry<Object, Object> entry : p.entrySet()) { + String key = (String) entry.getKey(); + if (key.startsWith(ICON_PREFIX)) { + ImageIcon icon; + try { + icon = createImageIcon((String) entry.getValue()); + UIManager.put(key.substring(ICON_PREFIX.length()), icon); + } catch (Exception e) { + log.warn("could not load icon " + entry.getValue()); + } + continue; + } + if (key.startsWith(COLOR_PREFIX)) { + String value = (String) entry.getValue(); + String[] rgb = value.split(","); + UIManager.put(key.substring(COLOR_PREFIX.length()), new Color(Integer.valueOf(rgb[0]), Integer.valueOf(rgb[1]), Integer.valueOf(rgb[2]))); + } + } + } + + /** + * Iterate the components of a {@link JTabbedPane} in natural order. + * + * Says using method {@link JTabbedPane#getComponent(int)} + * @param tabs the + * @return + * @since 1.4 + */ + public static TabbedPaneIterator<Component> newTabbedPaneIterator(JTabbedPane tabs) { + return new TabbedPaneIterator<Component>(false, tabs) { + + @Override + protected Component get(int index, Component comp) { + return comp; + } + }; + } + + /** + * A simple iterator on a {@link JTabbedPane}. + * + * Implements the method {@link #get(int, java.awt.Component)} to obtain + * the data required given the component (or index). + * + * You can also inverse the order by usin the method {@link #reverse()}. + * + * Note: After the use of the method {@link #reverse()} the iterator returns + * to the first element. + * + * @param <O> the type of return elements. + * @since 1.4 + */ + public static abstract class TabbedPaneIterator<O> implements Iterator<O> { + + final JTabbedPane tabs; + boolean reverse; + int index; + int increment; + + protected abstract O get(int index, Component comp); + + public TabbedPaneIterator(boolean reverse, JTabbedPane tabs) { + this.tabs = tabs; + setReverse(reverse); + } + + public void reset() { + setReverse(reverse); + } + + public int size() { + return tabs.getTabCount(); + } + + public TabbedPaneIterator<O> reverse() { + setReverse(!reverse); + return this; + } + + @Override + public boolean hasNext() { + return reverse ? index > 0 : index < tabs.getTabCount(); + } + + public int getIndex() { + return index; + } + + @Override + public O next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + Component next = tabs.getComponentAt(index); + O result = get(index, next); + index += increment; + return result; + } + + @Override + public void remove() { + throw new IllegalStateException("not implemented for " + this); + } + + @Override + public String toString() { + return super.toString() + "< reverse:" + reverse + ", index:" + index + ", size:" + tabs.getTabCount() + " >"; + } + + protected void setReverse(boolean reverse) { + if (reverse) { + index = tabs.getTabCount() - 1; + increment = -1; + } else { + index = 0; + increment = 1; + } + this.reverse = reverse; + } + } + + public static JLabel newLabel(String text, Object iconKey, int aligment) { + Icon icon = null; + if (iconKey instanceof Icon) { + icon = (Icon) iconKey; + } else if (iconKey instanceof String) { + icon = jaxx.runtime.Util.getUIManagerActionIcon((String) iconKey); + } + JLabel result; + if (icon == null) { + result = new JLabel(text, aligment); + } else { + result = new JLabel(text, icon, aligment); + } + return result; + } + + /** + * Gets the higest visible component in a ancestor hierarchy at + * specific x,y coordinates + * @param parent + * @param x + * @param y + * @return + */ + public static Component getDeepestObjectAt(Component parent, int x, int y) { + + if (parent instanceof Container) { + Container cont = (Container) parent; + // use a copy of 1.3 Container.findComponentAt + Component child = findComponentAt(cont, cont.getWidth(), cont.getHeight(), x, y); + if (child != null && child != cont) { + //log.info("child find : " + child.getName()); + if (child instanceof JRootPane) { + JLayeredPane lp = ((JRootPane) child).getLayeredPane(); + Rectangle b = lp.getBounds(); + child = getDeepestObjectAt(lp, x - b.x, y - b.y); + } + if (child != null) { + return child; + } + } + } + // if the parent is not a Container then it might be a MenuItem. + // But even if it isn't a MenuItem just return the parent because + // that's a close as we can come. + return parent; + } + + public static Component findComponentAt(Container cont, int width, int height, int x, int y) { + //log.info("container : " + cont.getName()); + synchronized (cont.getTreeLock()) { + + if (!((x >= 0) && (x < width) && (y >= 0) && (y < height) && cont.isVisible() && cont.isEnabled())) { + return null; + } + + Component[] component = cont.getComponents(); + int ncomponents = cont.getComponentCount(); + + // Two passes: see comment in sun.awt.SunGraphicsCallback + for (int i = 0; i < ncomponents; i++) { + Component comp = component[i]; + Rectangle rect = null; + + if (comp != null && !comp.isLightweight()) { + if (rect == null || rect.width == 0 || rect.height == 0) { + rect = comp.getBounds(); + } + if (comp instanceof JXLayer<?>) { + JXLayer<?> layer = (JXLayer<?>) comp; + comp = layer.getView(); + } + if (comp instanceof Container) { + comp = findComponentAt((Container) comp, rect.width, rect.height, x - rect.x, y - rect.y); + } else { + comp = comp.getComponentAt(x - rect.x, y - rect.y); + } + if (comp != null && comp.isVisible() && comp.isEnabled()) { + return comp; + } + } + } + + for (int i = 0; i < ncomponents; i++) { + Component comp = component[i]; + Rectangle rect = null; + + if (comp != null && comp.isLightweight()) { + if (rect == null || rect.width == 0 || rect.height == 0) { + rect = comp.getBounds(); + } + if (comp instanceof JXLayer<?>) { + JXLayer<?> layer = (JXLayer<?>) comp; + comp = layer.getView(); + } + if (comp instanceof Container) { + comp = findComponentAt((Container) comp, rect.width, rect.height, x - rect.x, y - rect.y); + } else { + comp = comp.getComponentAt(x - rect.x, y - rect.y); + } + if (comp != null && comp.isVisible() && comp.isEnabled()) { + return comp; + } + } + } + return cont; + } + } + + public static TableCellRenderer newDeleteCellRenderer(DefaultTableCellRenderer renderer) { + Icon icon = UIManager.getIcon("Table.removeIcon"); + if (icon == null) { + // try with default icon + icon = createActionIcon("delete"); + } + return new BooleanCellRenderer(renderer, icon); + } + + public static TableCellRenderer newBooleanTableCellRenderer(DefaultTableCellRenderer renderer) { + return new BooleanCellRenderer(renderer); + } + + public static EmptyNumberTableCellRenderer newEmptyNumberTableCellRenderer(TableCellRenderer renderer) { + return new EmptyNumberTableCellRenderer(renderer); + } + + public static <E extends Enum<E>> EnumTableCellRenderer<E> newEnumTableCellRenderer(TableCellRenderer renderer, Class<E> enumClass) { + return new EnumTableCellRenderer<E>(renderer, enumClass); + } + + /** + * Open a link coming from a {@link HyperlinkEvent}. + * + * And try to open the link if an url in a browser. + * + * @param he the event to treate + * @since 1.6.0 + */ + public static void openLink(HyperlinkEvent he) { + if (he.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { + + if (Desktop.isDesktopSupported()) { + try { + URL u = he.getURL(); + if (u.getProtocol().equalsIgnoreCase("mailto") || u.getProtocol().equalsIgnoreCase("http") || u.getProtocol().equalsIgnoreCase("ftp")) { + Desktop.getDesktop().browse(u.toURI()); + } + } catch (IOException e) { + if (log.isErrorEnabled()) { + log.error("Error while opening link", e); + } + } catch (URISyntaxException e) { + if (log.isErrorEnabled()) { + log.error("Error while opening link", e); + } + } + } + } + } + + /** + * Expand all childs of a tree. + * + * @param tree the tree to expand + */ + public static void expandTree(final JTree tree) { + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + int i = 0; + while (i < tree.getRowCount()) { + tree.expandRow(i++); + } + } + }); + } + + /** + * Add a listener of tree selection model to expand a new selected node + * when it is selected. + * + * @param tree the tree to treate + */ + public static void addExpandOnClickListener(final JTree tree) { + + tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { + + @Override + public void valueChanged(final TreeSelectionEvent e) { + TreeNode node = (TreeNode) e.getPath().getLastPathComponent(); + if (node != null && !node.isLeaf()) { + + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + for (TreePath path : e.getPaths()) { + if (e.isAddedPath(path) && !tree.isExpanded(path)) { + log.info("expand node [" + path + "]"); + // will expand the node + tree.expandPath(path); + } + } + } + }); + } + } + }); + } +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java ___________________________________________________________________ Added: svn:mergeinfo + Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Util.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/Util.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Util.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -4,11 +4,9 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import javax.swing.DefaultListCellRenderer; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JComponent; -import javax.swing.JList; import javax.swing.UIManager; import java.awt.Component; import java.awt.Dimension; @@ -31,24 +29,20 @@ public static final String DEFAULT_ICON_PATH = "/icons/"; public static final String DEFAULT_ICON_PATH_PROPERTY = "default.icon.path"; - /** to use log facility, just put in your code: log.info(\"...\"); */ static private final Log log = LogFactory.getLog(Util.class); - - // Maps root objects to lists of event listeners private static Map<Object, WeakReference<List<EventListenerDescriptor>>> eventListeners = new WeakHashMap<Object, WeakReference<List<EventListenerDescriptor>>>(); private static Map<JAXXObject, WeakReference<List<DataBindingUpdateListener>>> dataBindingUpdateListeners = new WeakHashMap<JAXXObject, WeakReference<List<DataBindingUpdateListener>>>(); - private static class EventListenerDescriptor { - Class listenerClass; + + Class<?> listenerClass; String listenerMethodName; String methodName; Object eventListener; } - /** * Decodes the serialized representation of a JAXXObjectDescriptor. The string must be a byte-to-character mapping * of the binary serialization data for a JAXXObjectDescriptor. See the comments in JAXXCompiler.createJAXXObjectDescriptorField @@ -66,16 +60,13 @@ //descriptor.getBytes(0, descriptor.length(), data, 0); ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(data)); return (JAXXObjectDescriptor) in.readObject();*/ - } - catch (IOException e) { + } catch (IOException e) { throw new RuntimeException("Internal error: can't-happen error", e); - } - catch (ClassNotFoundException e) { + } catch (ClassNotFoundException e) { throw new RuntimeException("Internal error: can't-happen error", e); } } - public static JAXXObjectDescriptor decodeCompressedJAXXObjectDescriptor(String descriptor) { try { return (JAXXObjectDescriptor) Base64Coder.deserialize(descriptor, true); @@ -86,16 +77,13 @@ //descriptor.getBytes(0, descriptor.length(), data, 0); ObjectInputStream in = new ObjectInputStream(new GZIPInputStream(new ByteArrayInputStream(data))); return (JAXXObjectDescriptor) in.readObject();*/ - } - catch (IOException e) { + } catch (IOException e) { throw new RuntimeException("Internal error: can't-happen error", e); - } - catch (ClassNotFoundException e) { + } catch (ClassNotFoundException e) { throw new RuntimeException("Internal error: can't-happen error", e); } } - public static Object getEventListener(Class<? extends EventListener> listenerClass, final String listenerMethodName, final Object methodContainer, final String methodName) { WeakReference<List<EventListenerDescriptor>> ref = eventListeners.get(methodContainer); List<EventListenerDescriptor> descriptors = ref != null ? ref.get() : null; @@ -131,22 +119,22 @@ if (listenerMethodName != null && listenerMethod == null) { throw new IllegalArgumentException("no method named " + listenerMethodName + " found in class " + listenerClass.getName()); } - Class[] parameterTypes = listenerMethods.get(0).getParameterTypes(); + Class<?>[] parameterTypes = listenerMethods.get(0).getParameterTypes(); Class<?> methodContainerClass = methodContainer.getClass(); final Method targetMethod = methodContainerClass.getMethod(methodName, parameterTypes); descriptor.eventListener = Proxy.newProxyInstance(listenerClass.getClassLoader(), - new Class[]{listenerClass}, + new Class<?>[]{listenerClass}, new InvocationHandler() { + + @Override public Object invoke(Object proxy, Method method, Object[] args) { String methodName = method.getName(); if ((listenerMethodName == null && listenerMethods.contains(method)) || methodName.equals(listenerMethodName)) { try { return targetMethod.invoke(methodContainer, args); - } - catch (IllegalAccessException e) { + } catch (IllegalAccessException e) { throw new RuntimeException(e); - } - catch (InvocationTargetException e) { + } catch (InvocationTargetException e) { throw new RuntimeException(e); } } @@ -164,18 +152,15 @@ }); descriptors.add(descriptor); return descriptor.eventListener; - } - catch (NoSuchMethodException e) { + } catch (NoSuchMethodException e) { throw new RuntimeException(e); } } - public static Object getEventListener(Class<? extends EventListener> listenerClass, final Object methodContainer, final String methodName) { return getEventListener(listenerClass, null, methodContainer, methodName); } - public static DataBindingUpdateListener getDataBindingUpdateListener(JAXXObject object, String bindingName) { WeakReference<List<DataBindingUpdateListener>> ref = dataBindingUpdateListeners.get(object); List<DataBindingUpdateListener> listeners = ref == null ? null : ref.get(); @@ -194,7 +179,6 @@ return listener; } - public static void setComponentWidth(Component component, int width) { component.setSize(width, component.getHeight()); if (component instanceof JComponent) { @@ -207,7 +191,6 @@ } } - public static void setComponentHeight(Component component, int height) { component.setSize(component.getWidth(), height); if (component instanceof JComponent) { @@ -220,55 +203,46 @@ } } - public static boolean assignment(boolean value, String name, JAXXObject src) { src.firePropertyChange(name.trim(), null, "dummy value"); return value; } - public static byte assignment(byte value, String name, JAXXObject src) { src.firePropertyChange(name.trim(), null, "dummy value"); return value; } - public static short assignment(short value, String name, JAXXObject src) { src.firePropertyChange(name.trim(), null, "dummy value"); return value; } - public static int assignment(int value, String name, JAXXObject src) { src.firePropertyChange(name.trim(), null, "dummy value"); return value; } - public static long assignment(long value, String name, JAXXObject src) { src.firePropertyChange(name.trim(), null, "dummy value"); return value; } - public static float assignment(float value, String name, JAXXObject src) { src.firePropertyChange(name.trim(), null, "dummy value"); return value; } - public static double assignment(double value, String name, JAXXObject src) { src.firePropertyChange(name.trim(), null, "dummy value"); return value; } - public static char assignment(char value, String name, JAXXObject src) { src.firePropertyChange(name.trim(), null, "dummy value"); return value; } - public static java.lang.Object assignment(java.lang.Object value, String name, JAXXObject src) { src.firePropertyChange(name.trim(), null, "dummy value"); return value; @@ -346,24 +320,6 @@ } } - public static <O> DefaultListCellRenderer newDecoratedListCellRenderer(final Decorator<O> decorator) { - return new DefaultListCellRenderer() { - - private static final long serialVersionUID = 1L; - - @Override - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - String decorated; - if (value instanceof String) { - decorated = (String) value; - } else { - decorated = decorator.toString(value); - } - return super.getListCellRendererComponent(list, decorated, index, isSelected, cellHasFocus); - } - }; - } - public static ImageIcon createIcon(String path) { java.net.URL imgURL = Util.class.getResource(path); if (imgURL != null) { @@ -400,7 +356,6 @@ return getUIManagerIcon("action." + key); } - public static ImageIcon createActionIcon(String name) { String iconPath = getIconPath(); return createIcon(iconPath + "action-" + name + ".png"); @@ -461,5 +416,4 @@ } return iconPath; } - } Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Application.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/Application.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Application.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Application.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,56 @@ +package jaxx.runtime.swing; + +import javax.swing.JFrame; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; +import java.awt.GraphicsConfiguration; + +public class Application extends JFrame { + // Special: jaxxc will automatically add a main() method to any components which + // extend <Application> + + + public Application() { + } + + + public Application(GraphicsConfiguration gc) { + super(gc); + } + + + public Application(String title) { + super(title); + } + + + public Application(String title, GraphicsConfiguration gc) { + super(title, gc); + } + + + public void setLookAndFeel(String lookAndFeel) { + if (lookAndFeel.equals("system")) + lookAndFeel = UIManager.getSystemLookAndFeelClassName(); + else if (lookAndFeel.equals("cross_platform")) + lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName(); + try { + UIManager.setLookAndFeel(lookAndFeel); + if (isDisplayable()) + SwingUtilities.updateComponentTreeUI(this); + } + catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } + catch (InstantiationException e) { + throw new RuntimeException(e); + } + catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + catch (UnsupportedLookAndFeelException e) { + throw new RuntimeException(e); + } + } +} \ No newline at end of file Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Application.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,259 @@ +package jaxx.runtime.swing; + +import java.awt.AlphaComposite; +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics2D; +import java.awt.Point; +import java.awt.RenderingHints; +import java.awt.event.ActionEvent; +import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; +import java.awt.image.BufferedImage; +import javax.swing.Action; +import javax.swing.ImageIcon; +import javax.swing.JComponent; +import org.jdesktop.jxlayer.JXLayer; + +/** + * + * A JXLayer ui implementation that permits to block a component but still + * allow an action when clicking on the right-top icon painted on the layer. + * + * You can change the blocking and accepting icon. + * + * To hook an click on the layer's icon, you can : + * + * <ul><li>pass an Action via method {@link #setAcceptAction(Action)}</li> + * <li>override the method {@link #acceptEvent(java.awt.event.MouseEvent, org.jdesktop.jxlayer.JXLayer)}</li> + * </ul> + * + * @author tony + * @since 1.2 + */ +public class BlockingLayerUI extends org.jdesktop.jxlayer.plaf.AbstractLayerUI<JComponent> { + + public static final String CAN_CLICK_PROPERTY = "canClick"; + public static final String ACCEPT_ICON_PROPERTY = "acceptIcon"; + public static final String BLOCK_ICON_PROPERTY = "blockIcon"; + public static final String BLOCK_PROPERTY = "block"; + private static final long serialVersionUID = 1L; + /** + * Action to be treated when click on icon + */ + protected Action acceptAction; + /** + * Icon when you can not click + */ + protected BufferedImage blockIcon; + /** + * Icon when you can click + */ + protected BufferedImage acceptIcon; + /** + * Optinal color to put fill background when blocking + */ + protected Color blockingColor; + /** + * Internal state to known when we can accept click + */ + protected boolean canClick; + /** + * A flag to enable or disable the use of the icon. + * + * If set to false, no icon will be displayed and no action + * will be possible. + * + * By default, this is active. + */ + protected boolean useIcon = true; + /** + * Internal state when should block event and paint layer + */ + protected boolean block; + + public void setAcceptAction(Action acceptAction) { + this.acceptAction = acceptAction; + } + + public void setAcceptIcon(ImageIcon acceptIcon) { + this.acceptIcon = prepareIcon(acceptIcon); + firePropertyChange(ACCEPT_ICON_PROPERTY, null, acceptIcon); + setDirty(true); + } + + public void setBlockIcon(ImageIcon blockIcon) { + this.blockIcon = prepareIcon(blockIcon); + firePropertyChange(BLOCK_ICON_PROPERTY, null, blockIcon); + setDirty(true); + } + + public void setCanClick(boolean canClick) { + boolean oldvalue = this.canClick; + this.canClick = canClick; + firePropertyChange(CAN_CLICK_PROPERTY, oldvalue, canClick); + if (oldvalue != canClick) { + setDirty(true); + } + } + + public void setBlock(boolean block) { + boolean oldvalue = this.block; + this.block = block; + firePropertyChange(BLOCK_PROPERTY, oldvalue, block); + if (oldvalue != block) { + setDirty(true); + } + } + + @Override + public void setDirty(boolean isDirty) { + super.setDirty(isDirty); + } + + public void setBlockIcon(BufferedImage blockIcon) { + this.blockIcon = blockIcon; + } + + public void setBlockingColor(Color blockingColor) { + this.blockingColor = blockingColor; + } + + public BufferedImage getBlockIcon() { + return blockIcon; + } + + protected BufferedImage getAcceptIcon() { + return acceptIcon; + } + + public boolean isCanClick() { + return canClick; + } + + public void setUseIcon(boolean useIcon) { + boolean oldvalue = this.useIcon; + this.useIcon = useIcon; + if (oldvalue != useIcon) { + setDirty(true); + } + } + + @Override + public BlockingLayerUI clone() { + BlockingLayerUI clone = new BlockingLayerUI(); + clone.acceptAction = acceptAction; + clone.acceptIcon = acceptIcon; + clone.blockIcon = blockIcon; + clone.useIcon = useIcon; + clone.block = block; + clone.blockingColor = blockingColor; + clone.setCanClick(false); + return clone; + } + + @Override + protected void processKeyEvent(KeyEvent e, JXLayer<JComponent> l) { + if (useIcon || block) { + e.consume(); + } + } + + @Override + protected void processMouseMotionEvent(MouseEvent e, JXLayer<JComponent> l) { + if (useIcon) { + updateCanClickState(l, e); + } + if (useIcon || block) { + e.consume(); + } + } + + @Override + protected void processMouseEvent(MouseEvent e, JXLayer<JComponent> l) { + if (useIcon) { + switch (e.getID()) { + case MouseEvent.MOUSE_ENTERED: + updateCanClickState(l, e); + break; + case MouseEvent.MOUSE_EXITED: + setCanClick(false); + break; + case MouseEvent.MOUSE_CLICKED: + if (canClick) { + acceptEvent(e, l); + } + break; + } + } + if (useIcon || block) { + e.consume(); + } + + } + + @Override + protected void paintLayer(Graphics2D g2, JXLayer<JComponent> l) { + super.paintLayer(g2, l); + if (block && blockingColor != null) { + // to be in sync with the view if the layer has a border + /*Insets layerInsets = l.getInsets(); + g2.translate(layerInsets.left, layerInsets.top); + + JComponent view = l.getView(); + // To prevent painting on view's border + Insets insets = view.getInsets(); + g2.clip(new Rectangle(insets.left, insets.top, + view.getWidth() - insets.left - insets.right, + view.getHeight() - insets.top - insets.bottom)); + */ + + g2.setColor(blockingColor); + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .1f)); + g2.fillRect(0, 0, l.getWidth(), l.getHeight()); + } + if (useIcon && getCurrentIcon() != null) { + g2.drawImage(getCurrentIcon(), l.getWidth() - getCurrentIcon().getWidth() - 1, 0, null); + } + } + + protected void acceptEvent(MouseEvent e, JXLayer<JComponent> l) { + if (acceptAction != null) { + acceptAction.putValue("layer", l); + Component source = l.getView(); + acceptAction.actionPerformed(new ActionEvent(source, 0, "accept")); + } + } + + protected BufferedImage getCurrentIcon() { + return canClick ? acceptIcon : blockIcon; + } + + protected BufferedImage prepareIcon(ImageIcon image) { + BufferedImage icon = new BufferedImage(image.getIconWidth(), image.getIconHeight(), BufferedImage.TYPE_INT_ARGB); + Graphics2D g2 = (Graphics2D) icon.getGraphics(); + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); + g2.drawImage(image.getImage(), 0, 0, null); + g2.dispose(); + return icon; + } + + protected void updateCanClickState(JXLayer<JComponent> l, MouseEvent e) { + // udpate toolTipText + Point layerLocation = l.getView().getLocation(); + Point mousePoint = e.getPoint(); + BufferedImage currentIcon = getCurrentIcon(); + if (currentIcon == null) { + setCanClick(false); + return; + } + int minX = (int) layerLocation.getX() + l.getWidth() - currentIcon.getWidth(); + int maxX = (int) layerLocation.getX() + l.getWidth(); + int minY = 0; + int maxY = currentIcon.getHeight(); + boolean accept = minX <= mousePoint.getX() && mousePoint.getX() <= maxX; + accept &= minY <= mousePoint.getLocation().getY() && mousePoint.getLocation().getY() <= maxY; + setCanClick(accept); + } +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,217 @@ +package jaxx.runtime.swing; + +import java.awt.AlphaComposite; +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics2D; +import java.awt.Point; +import java.awt.RenderingHints; +import java.awt.event.ActionEvent; +import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; +import java.awt.image.BufferedImage; +import javax.swing.Action; +import javax.swing.ImageIcon; +import javax.swing.JComponent; +import org.jdesktop.jxlayer.JXLayer; + +/** + * + * A JXLayer ui implementation that permits to block a component but still + * allow an action when clicking everywhere on the layer. + * + * Moreover, an icon can be added on the right-top icon painted and changed + * when the mouse is over the layer. + * + * You can change the blocking and accepting icon. + * + * To hook an click on the layer's icon, you can : + * + * <ul><li>pass an Action via method {@link #setAcceptAction(Action)}</li> + * <li>override the method {@link #acceptEvent(java.awt.event.MouseEvent, org.jdesktop.jxlayer.JXLayer)}</li> + * </ul> + * + * @author tony + * @since 1.3 + */ +public class BlockingLayerUI2 extends org.jdesktop.jxlayer.plaf.AbstractLayerUI<JComponent> { + + public static final String CAN_CLICK_PROPERTY = "canClick"; + public static final String ACCEPT_ICON_PROPERTY = "acceptIcon"; + public static final String BLOCK_ICON_PROPERTY = "blockIcon"; + private static final long serialVersionUID = 1L; + /** + * Action to be treated when click on icon + */ + protected Action acceptAction; + /** + * Icon when you can not click + */ + protected BufferedImage blockIcon; + /** + * Icon when you can click + */ + protected BufferedImage acceptIcon; + /** + * Optinal color to put fill background when blocking + */ + protected Color blockingColor; + /** + * Internal state to known when we can accept click + */ + protected boolean canClick; + + public void setAcceptAction(Action acceptAction) { + this.acceptAction = acceptAction; + } + + public void setAcceptIcon(ImageIcon acceptIcon) { + this.acceptIcon = prepareIcon(acceptIcon); + firePropertyChange(ACCEPT_ICON_PROPERTY, null, acceptIcon); + setDirty(true); + } + + public void setBlockIcon(ImageIcon blockIcon) { + this.blockIcon = prepareIcon(blockIcon); + firePropertyChange(BLOCK_ICON_PROPERTY, null, blockIcon); + setDirty(true); + } + + public void setCanClick(boolean canClick) { + boolean oldvalue = this.canClick; + this.canClick = canClick; + firePropertyChange(CAN_CLICK_PROPERTY, oldvalue, canClick); + if (oldvalue != canClick) { + setDirty(true); + } + } + + @Override + public void setDirty(boolean isDirty) { + super.setDirty(isDirty); + } + + public void setBlockingColor(Color blockingColor) { + this.blockingColor = blockingColor; + } + + public void setBlockIcon(BufferedImage blockIcon) { + this.blockIcon = blockIcon; + } + + public BufferedImage getBlockIcon() { + return blockIcon; + } + + protected BufferedImage getAcceptIcon() { + return acceptIcon; + } + + public boolean isCanClick() { + return canClick; + } + + @Override + public BlockingLayerUI2 clone() { + BlockingLayerUI2 clone = new BlockingLayerUI2(); + clone.acceptAction = acceptAction; + clone.acceptIcon = acceptIcon; + clone.blockIcon = blockIcon; + clone.blockingColor = blockingColor; + clone.setCanClick(false); + return clone; + } + + @Override + protected void processKeyEvent(KeyEvent e, JXLayer<JComponent> l) { + e.consume(); + } + + @Override + protected void processMouseMotionEvent(MouseEvent e, JXLayer<JComponent> l) { + e.consume(); + } + + @Override + protected void processMouseEvent(MouseEvent e, JXLayer<JComponent> l) { + switch (e.getID()) { + case MouseEvent.MOUSE_ENTERED: + setCanClick(true); + break; + case MouseEvent.MOUSE_EXITED: + setCanClick(false); + break; + case MouseEvent.MOUSE_CLICKED: + if (canClick) { + acceptEvent(e, l); + } + break; + } + e.consume(); + } + + @Override + protected void paintLayer(Graphics2D g2, JXLayer<JComponent> l) { + super.paintLayer(g2, l); + if (blockingColor != null) { + // to be in sync with the view if the layer has a border + /*Insets layerInsets = l.getInsets(); + g2.translate(layerInsets.left, layerInsets.top); + + JComponent view = l.getView(); + // To prevent painting on view's border + Insets insets = view.getInsets(); + g2.clip(new Rectangle(insets.left, insets.top, + view.getWidth() - insets.left - insets.right, + view.getHeight() - insets.top - insets.bottom)); + */ + + g2.setColor(blockingColor); + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .1f)); + g2.fillRect(0, 0, l.getWidth(), l.getHeight()); + } + if (getCurrentIcon() != null) { + g2.drawImage(getCurrentIcon(), l.getWidth() - getCurrentIcon().getWidth() - 1, 0, null); + } + } + + protected void acceptEvent(MouseEvent e, JXLayer<JComponent> l) { + if (acceptAction != null) { + acceptAction.putValue("layer", l); + Component source = l.getView(); + acceptAction.actionPerformed(new ActionEvent(source, 0, "accept")); + } + } + + protected BufferedImage getCurrentIcon() { + return canClick ? acceptIcon : blockIcon; + } + + protected BufferedImage prepareIcon(ImageIcon image) { + BufferedImage icon = new BufferedImage(image.getIconWidth(), image.getIconHeight(), BufferedImage.TYPE_INT_ARGB); + Graphics2D g2 = (Graphics2D) icon.getGraphics(); + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); + g2.drawImage(image.getImage(), 0, 0, null); + g2.dispose(); + return icon; + } + + protected void updateCanClickState(JXLayer<JComponent> l, MouseEvent e) { + // udpate toolTipText + Point layerLocation = l.getView().getLocation(); + Point mousePoint = e.getPoint(); + BufferedImage currentIcon = getCurrentIcon(); + if (currentIcon == null) { + setCanClick(false); + return; + } + int minX = (int) layerLocation.getX() + l.getWidth() - currentIcon.getWidth(); + int maxX = (int) layerLocation.getX() + l.getWidth(); + int minY = 0; + int maxY = currentIcon.getHeight(); + boolean accept = minX <= mousePoint.getX() && mousePoint.getX() <= maxX; + accept &= minY <= mousePoint.getLocation().getY() && mousePoint.getLocation().getY() <= maxY; + setCanClick(accept); + } +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BooleanCellRenderer.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BooleanCellRenderer.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BooleanCellRenderer.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BooleanCellRenderer.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,61 @@ +package jaxx.runtime.swing; + +import javax.swing.Icon; +import javax.swing.JCheckBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTable; +import javax.swing.table.TableCellRenderer; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; + +/** @author chemit + * @since 1.5 + */ +public class BooleanCellRenderer extends JPanel implements TableCellRenderer { + + private static final long serialVersionUID = 1L; + protected TableCellRenderer defaultDelegate; + protected JCheckBox checkBox; + + public BooleanCellRenderer(TableCellRenderer delegate) { + //super(new BorderLayout()); + this.checkBox = new JCheckBox(); + add(checkBox, BorderLayout.CENTER); + checkBox.setHorizontalAlignment(JLabel.CENTER); + checkBox.setBorderPainted(true); + this.defaultDelegate = delegate; + } + + public BooleanCellRenderer(TableCellRenderer delegate, Icon icon) { + //super(new BorderLayout()); + this.checkBox = new JCheckBox(icon); + add(checkBox, BorderLayout.NORTH); + checkBox.setHorizontalAlignment(JLabel.CENTER); + checkBox.setVerticalTextPosition(JLabel.TOP); + checkBox.setBorderPainted(true); + this.defaultDelegate = delegate; + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + ((JComponent) defaultDelegate).setBackground(null); + JComponent render = (JComponent) defaultDelegate.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + if (isSelected) { + setForeground(table.getSelectionForeground()); + setBackground(table.getSelectionBackground()); + } else { + setForeground(render.getForeground()); + setBackground(render.getBackground()); + //fixme make this works... and remove the test + if (row % 2 == 1) { + setBackground(Color.WHITE); + } + } + checkBox.setSelected((value != null && (Boolean) value)); + setBorder(render.getBorder()); + return this; + } +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BooleanCellRenderer.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/CardLayout2.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,221 @@ +package jaxx.runtime.swing; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.awt.CardLayout; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Insets; +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; + +/** + * An override of the awt {@link java.awt.CardLayout}. + * <p/> + * Because in the original layout is not overridable : everything is package level accessible. + * <p/> + * This new class offers to test if a constrains (as a Serializable) is actually dealed by the layout, + * via the method {@link #contains(java.io.Serializable)}. + * <p/> + * We had also another method to obtain the current visible component in a container layouted by the class, + * via the method {@link #getVisibleComponent(java.awt.Container)}. + * + * @author chemit + * @version 1.0 + */ +public class CardLayout2 extends CardLayout { + + /** log */ + static private Log log = LogFactory.getLog(CardLayout2.class); + + private static final long serialVersionUID = 1L; + + /** list of already loaded context (since the {@link #vector} attribute is package visible... */ + protected List<Serializable> contexts = new LinkedList<Serializable>(); + + /** + * A flag to compute dimension only on visible component. + * <p/> + * This is usefull when we only care of the visible component. + */ + protected boolean useOnlyVisibleComponentDimension; + + @Override + public void addLayoutComponent(Component comp, Object constraints) { + super.addLayoutComponent(comp, constraints); + contexts.add((Serializable) constraints); + if (log.isDebugEnabled()) { + log.debug(this + " new constraints : " + constraints); + } + } + + /** + * Test if a constrains is contained in the layout. + * + * @param constraints l'identifiant a tester + * @return <code>true</code> si l'identifiant est deja present dans le layout, <code>false</code> autrement. + */ + public boolean contains(Serializable constraints) { + return contexts.contains(constraints); + } + + /** + * Obtain the visible component in the container. + * + * @param container the container using this layout + * @return the component visible in the container. + */ + public Component getVisibleComponent(Container container) { + if (container.getLayout() != this) { + throw new IllegalArgumentException("the container is not managed by the current layout"); + } + for (Component component : container.getComponents()) { + if (component.isVisible()) { + return component; + } + } + // no component actually visible + return null; + } + + public Component getComponent(Container container, String constraints) { + if (container.getLayout() != this) { + throw new IllegalArgumentException("the container is not manage by the current layout"); + } + if (!contexts.contains(constraints)) { + throw new IllegalArgumentException("the constraints '" + constraints + "' is not supported by this layout : " + contexts); + } + int index = contexts.indexOf(constraints); + return container.getComponents()[index]; + } + + /** + * Determines the preferred size of the container argument using + * this card layout. + * + * @param parent the parent container in which to do the layout + * @return the preferred dimensions to lay out the subcomponents + * of the specified container + * @see java.awt.Container#getPreferredSize + * @see java.awt.CardLayout#minimumLayoutSize + */ + @Override + public Dimension preferredLayoutSize(Container parent) { + Dimension dimension = null; + if (useOnlyVisibleComponentDimension) { + Component comp = getVisibleComponent(parent); + if (comp != null) { + dimension = comp.getPreferredSize(); + } + } + if (dimension == null) { + dimension = super.preferredLayoutSize(parent); + } + return dimension; + } + + /** + * Calculates the minimum size for the specified panel. + * + * @param parent the parent container in which to do the layout + * @return the minimum dimensions required to lay out the + * subcomponents of the specified container + * @see java.awt.Container#doLayout + * @see java.awt.CardLayout#preferredLayoutSize + */ + @Override + public Dimension minimumLayoutSize(Container parent) { + Dimension dimension = null; + if (useOnlyVisibleComponentDimension) { + Component comp = getVisibleComponent(parent); + if (comp != null) { + dimension = comp.getMinimumSize(); + } + } + if (dimension == null) { + dimension = super.minimumLayoutSize(parent); + } + return dimension; + } + + /** + * Returns the maximum dimensions for this layout given the components + * in the specified target container. + * + * @param target the component which needs to be laid out + * @see java.awt.Container + * @see #minimumLayoutSize + * @see #preferredLayoutSize + */ + @Override + public Dimension maximumLayoutSize(Container target) { + Dimension dimension = null; + if (useOnlyVisibleComponentDimension) { + Component comp = getVisibleComponent(target); + if (comp != null) { + dimension = comp.getMaximumSize(); + } + } + if (dimension == null) { + dimension = super.maximumLayoutSize(target); + } + return dimension; + } + + /** + * Lays out the specified container using this card layout. + * <p/> + * Each component in the <code>parent</code> container is reshaped + * to be the size of the container, minus space for surrounding + * insets, horizontal gaps, and vertical gaps. + * + * @param parent the parent container in which to do the layout + * @see java.awt.Container#doLayout + */ + @Override + public void layoutContainer(Container parent) { + if (useOnlyVisibleComponentDimension) { + Component comp = getVisibleComponent(parent); + if (comp != null) { + //dimension = comp.getMinimumSize(); + Insets insets = parent.getInsets(); + comp.setBounds(getHgap() + insets.left, getVgap() + insets.top, + parent.getWidth() - (getHgap() * 2 + insets.left + insets.right), + parent.getHeight() - (getVgap() * 2 + insets.top + insets.bottom)); + } else { + super.layoutContainer(parent); + } + } else { + super.layoutContainer(parent); + } + } + + public boolean isUseOnlyVisibleComponentDimension() { + return useOnlyVisibleComponentDimension; + } + + public void setUseOnlyVisibleComponentDimension(boolean useOnlyVisibleComponentDimension) { + this.useOnlyVisibleComponentDimension = useOnlyVisibleComponentDimension; + } + + /** + * remove from cardlayout and linked container all his components. + * + * @param parent the parent container linked with the layout + */ + public void reset(Container parent) { + if (parent.getLayout() != this) { + throw new IllegalArgumentException("wrong parent for CardLayout"); + } + for (Component component : parent.getComponents()) { + removeLayoutComponent(component); + parent.remove(component); + } + contexts.clear(); + + } + +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,99 @@ +package jaxx.runtime.swing; + +import java.awt.Container; +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import jaxx.runtime.JAXXObject; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Une extension de {@link CardLayout2} pour pouvoir automatiquement afficher un + * contenu à partir de la propriété {@link #selected}. + * + * Ainsi, en changeant cette propriété via la méthode {@link #setSelected(String)}, + * le contenu sera changé automatiquement, ce qui permet une utilisation direct + * dans jaxx sans à avoir à écrire d'écouteur. + * + * @author tony + * @since 1.3 + * @see CardLayout2 + */ +public class CardLayout2Ext extends CardLayout2 { + + /** log */ + static private Log log = LogFactory.getLog(CardLayout2.class); + private static final long serialVersionUID = 1L; + public static final String SELECTED_PROPERTY_NAME = "selected"; + /** + * pour propager les changements dans le modèle vers l'ui + */ + protected PropertyChangeSupport pcs; + /** + * le contenu sélectionné + */ + protected String selected; + private String containerName; + private JAXXObject ui; + private Container container; + + public CardLayout2Ext(JAXXObject ui, String containerName) { + pcs = new PropertyChangeSupport(this); + this.ui = ui; + this.containerName = containerName; + } + + public String getSelected() { + return selected; + } + + public String getPreviousSelected() { + int index = contexts.indexOf(selected); + if (index < 1) { + return null; + } + return contexts.get(index - 1) + ""; + } + + public String getNextSelected() { + int index = contexts.indexOf(selected); + if (index >= contexts.size()) { + return null; + } + return contexts.get(index + 1) + ""; + } + + public void setSelected(String selected) { + this.selected = selected; + show(getContainer(), selected); + } + + public Container getContainer() { + if (container == null) { + container = (Container) ui.getObjectById(containerName); + } + return container; + } + + public void addPropertyChangeListener(PropertyChangeListener listener) { + pcs.addPropertyChangeListener(listener); + } + + public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { + pcs.addPropertyChangeListener(propertyName, listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + pcs.removePropertyChangeListener(listener); + } + + public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { + pcs.removePropertyChangeListener(propertyName, listener); + } + + public void removePropertyChangeListeners() { + for (PropertyChangeListener l : pcs.getPropertyChangeListeners()) { + pcs.removePropertyChangeListener(l); + } + } +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EmptyNumberTableCellRenderer.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/EmptyNumberTableCellRenderer.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EmptyNumberTableCellRenderer.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EmptyNumberTableCellRenderer.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,37 @@ +package jaxx.runtime.swing; + +import javax.swing.JTable; +import javax.swing.table.TableCellRenderer; +import java.awt.Component; +import javax.swing.table.DefaultTableCellRenderer; + +/** + * A {@link TableCellRenderer} which does not display numbers when they are + * equals to 0. + * + * @author chemit + * @since 1.5 + */ +public class EmptyNumberTableCellRenderer implements TableCellRenderer { + + protected final Integer ZERO = 0; + protected final Float ZEROF = 0F; + protected final Double ZEROD = 0D; + private TableCellRenderer delegate; + + public EmptyNumberTableCellRenderer() { + this(new DefaultTableCellRenderer()); + } + + public EmptyNumberTableCellRenderer(TableCellRenderer delegate) { + this.delegate = delegate; + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + if (value == null || ZERO.equals(value) || ZEROF.equals(value) || ZEROD.equals(value)) { + value = null; + } + return delegate.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + } +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EmptyNumberTableCellRenderer.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EnumTableCellRenderer.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/EnumTableCellRenderer.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EnumTableCellRenderer.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EnumTableCellRenderer.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,47 @@ +package jaxx.runtime.swing; + +import javax.swing.JTable; +import javax.swing.table.TableCellRenderer; +import java.awt.Component; +import java.util.EnumSet; + +/** + * + * + * A {@link TableCellRenderer} which displays enum values from their ordinal value. + * + * @param <E> le type de l'énumération. + * + * @author chemit + * @since 1.5 + */ +public class EnumTableCellRenderer<E extends Enum<E>> implements TableCellRenderer { + + private TableCellRenderer delegate; + private EnumSet<E> enumValues; + + public EnumTableCellRenderer(TableCellRenderer delegate, Class<E> enumClass) { + this.delegate = delegate; + this.enumValues = EnumSet.allOf(enumClass); + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + + if (value != null) { + //FIXME : should be also able to read it by name ? + Integer ordinal = Integer.valueOf(value + ""); + if (ordinal == -1) { + value = null; + } else { + for (E enumValue : enumValues) { + if (ordinal == enumValue.ordinal()) { + value = enumValue; + break; + } + } + } + } + return delegate.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + } +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EnumTableCellRenderer.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/GBC.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/GBC.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/GBC.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/GBC.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,151 @@ +/** + * *##% Lutin I18n Editor + * Copyright (C) 2008 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>. ##%* + */ +/* +GBC - A convenience class to tame the GridBagLayout + +Copyright (C) 2002 Cay S. Horstmann (http://horstmann.com) + +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 2 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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package jaxx.runtime.swing; + +import java.awt.GridBagConstraints; +import java.awt.Insets; + +/** + * This class simplifies the use of the GridBagConstraints + * class. + */ +public class GBC extends GridBagConstraints { + private static final long serialVersionUID = -3626882543530638704L; + + /** + * Constructs a GBC with a given gridx and gridy position and + * all other grid bag constraint values set to the default. + * + * @param gridx the gridx position + * @param gridy the gridy position + */ + public GBC(int gridx, int gridy) { + this.gridx = gridx; + this.gridy = gridy; + } + + /** + * Constructs a GBC with given gridx, gridy, gridwidth, gridheight + * and all other grid bag constraint values set to the default. + * + * @param gridx the gridx position + * @param gridy the gridy position + * @param gridwidth the cell span in x-direction + * @param gridheight the cell span in y-direction + */ + public GBC(int gridx, int gridy, int gridwidth, int gridheight) { + this.gridx = gridx; + this.gridy = gridy; + this.gridwidth = gridwidth; + this.gridheight = gridheight; + } + + /** + * Sets the anchor. + * + * @param anchor the anchor value + * @return this object for further modification + */ + public GBC setAnchor(int anchor) { + this.anchor = anchor; + return this; + } + + /** + * Sets the fill direction. + * + * @param fill the fill direction + * @return this object for further modification + */ + public GBC setFill(int fill) { + this.fill = fill; + return this; + } + + /** + * Sets the cell weights. + * + * @param weightx the cell weight in x-direction + * @param weighty the cell weight in y-direction + * @return this object for further modification + */ + public GBC setWeight(double weightx, double weighty) { + this.weightx = weightx; + this.weighty = weighty; + return this; + } + + /** + * Sets the insets of this cell. + * + * @param distance the spacing to use in all directions + * @return this object for further modification + */ + public GBC setInsets(int distance) { + this.insets = new Insets(distance, distance, distance, distance); + return this; + } + + /** + * Sets the insets of this cell. + * + * @param top the spacing to use on top + * @param left the spacing to use to the left + * @param bottom the spacing to use on the bottom + * @param right the spacing to use to the right + * @return this object for further modification + */ + public GBC setInsets(int top, int left, int bottom, int right) { + this.insets = new Insets(top, left, bottom, right); + return this; + } + + /** + * Sets the internal padding + * + * @param ipadx the internal padding in x-direction + * @param ipady the internal padding in y-direction + * @return this object for further modification + */ + public GBC setIpad(int ipadx, int ipady) { + this.ipadx = ipadx; + this.ipady = ipady; + return this; + } +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/GBC.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBox.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/HBox.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBox.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBox.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,94 @@ +/* + * Copyright 2006 Ethan Nicholas. All rights reserved. + * Use is subject to license terms. + */ +package jaxx.runtime.swing; + +import javax.swing.JPanel; +import java.awt.Insets; + +/** + * Panel which uses an {@link HBoxLayout} by default. + * + * @author Ethan Nicholas + */ +public class HBox extends JPanel { + + private static final long serialVersionUID = 1L; + public static final String SPACING_PROPERTY = "spacing"; + public static final String MARGIN_PROPERTY = "margin"; + public static final String HORIZONTAL_ALIGNMENT_PROPERTY = "horizontalAlignment"; + public static final String VERTICAL_ALIGNMENT_PROPERTY = "verticalAlignment"; + private Insets margin; + + public HBox() { + super(new HBoxLayout()); + } + + /** + * Returns the spacing between components, in pixels. Spacing is applied between components only, + * not to the top or bottom of the container. + * + * @return spacing between components + */ + public int getSpacing() { + return ((HBoxLayout) getLayout()).getSpacing(); + } + + /** + * Sets the spacing between components. Spacing is applied between components only, + * not to the top or bottom of the container. + * + * @param spacing new spacing value + */ + public void setSpacing(int spacing) { + int oldValue = getSpacing(); + ((HBoxLayout) getLayout()).setSpacing(spacing); + firePropertyChange(SPACING_PROPERTY, oldValue, spacing); + revalidate(); + } + + public int getHorizontalAlignment() { + return ((HBoxLayout) getLayout()).getHorizontalAlignment(); + } + + public void setHorizontalAlignment(int horizontalAlignment) { + int oldValue = getHorizontalAlignment(); + ((HBoxLayout) getLayout()).setHorizontalAlignment(horizontalAlignment); + firePropertyChange(HORIZONTAL_ALIGNMENT_PROPERTY, oldValue, horizontalAlignment); + revalidate(); + } + + public int getVerticalAlignment() { + return ((HBoxLayout) getLayout()).getVerticalAlignment(); + } + + public void setVerticalAlignment(int verticalAlignment) { + int oldValue = getVerticalAlignment(); + ((HBoxLayout) getLayout()).setVerticalAlignment(verticalAlignment); + firePropertyChange(VERTICAL_ALIGNMENT_PROPERTY, oldValue, verticalAlignment); + revalidate(); + } + + public Insets getMargin() { + return margin; + } + + public void setMargin(Insets margin) { + Insets oldValue = this.margin; + this.margin = (Insets) margin.clone(); + firePropertyChange(MARGIN_PROPERTY, oldValue, margin); + } + + @Override + public Insets getInsets() { + Insets result = super.getInsets(); + if (margin != null) { + result.top += margin.top; + result.left += margin.left; + result.right += margin.right; + result.bottom += margin.bottom; + } + return result; + } +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBox.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxLayout.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/HBoxLayout.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxLayout.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxLayout.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,127 @@ +/* + * Copyright 2006 Ethan Nicholas. All rights reserved. + * Use is subject to license terms. + */ +package jaxx.runtime.swing; + +import javax.swing.SwingConstants; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Insets; +import java.awt.LayoutManager; + +/** + * Horizontal box layout. The layout rules followed by this class are quite different than the core BoxLayout class, + * and in general represent a more useful algorithm. + * + * @author Ethan Nicholas + */ +public class HBoxLayout implements LayoutManager { + + private int spacing = 6; + private int horizontalAlignment = SwingConstants.LEFT; + private int verticalAlignment = SwingConstants.TOP; + + public int getSpacing() { + return spacing; + } + + public void setSpacing(int spacing) { + this.spacing = spacing; + } + + public int getHorizontalAlignment() { + return horizontalAlignment; + } + + public void setHorizontalAlignment(int horizontalAlignment) { + this.horizontalAlignment = horizontalAlignment; + } + + public int getVerticalAlignment() { + return verticalAlignment; + } + + public void setVerticalAlignment(int verticalAlignment) { + this.verticalAlignment = verticalAlignment; + } + + @Override + public void addLayoutComponent(String name, Component comp) { + } + + @Override + public void layoutContainer(Container parent) { + Insets insets = parent.getInsets(); + int parentHeight = parent.getSize().height - insets.top - insets.bottom; + int count = parent.getComponentCount(); + Dimension preferredSize = parent.getPreferredSize(); + int x; + switch (horizontalAlignment) { + case SwingConstants.LEFT: + x = insets.left; + break; + case SwingConstants.CENTER: + x = insets.left + (parent.getWidth() - preferredSize.width) / 2; + break; + case SwingConstants.RIGHT: + x = insets.left + (parent.getWidth() - preferredSize.width); + break; + default: + throw new IllegalArgumentException("invalid horizontal alignment: " + horizontalAlignment); + } + + for (int i = 0; i < count; i++) { + Component component = parent.getComponent(i); + Dimension childPreferredSize = component.getPreferredSize(); + int height = Math.min(childPreferredSize.height, parentHeight); + int y; + switch (verticalAlignment) { + case SwingConstants.TOP: + y = insets.top; + break; + case SwingConstants.CENTER: + y = insets.top + (parentHeight - childPreferredSize.height) / 2; + break; + case SwingConstants.BOTTOM: + y = insets.top + (parentHeight - childPreferredSize.height); + break; + default: + throw new IllegalArgumentException("invalid vertical alignment: " + verticalAlignment); + } + component.setBounds(x, y, childPreferredSize.width, height); + x += childPreferredSize.width + spacing; + } + } + + @Override + public Dimension minimumLayoutSize(Container parent) { + int width = (parent.getComponentCount() - 1) * spacing; + int height = 0; + for (int i = parent.getComponentCount() - 1; i >= 0; i--) { + Dimension minimumSize = parent.getComponent(i).getMinimumSize(); + width += minimumSize.width; + height = Math.max(height, minimumSize.height); + } + Insets insets = parent.getInsets(); + return new Dimension(width + insets.left + insets.right, height + insets.top + insets.bottom); + } + + @Override + public Dimension preferredLayoutSize(Container parent) { + int width = (parent.getComponentCount() - 1) * spacing; + int height = 0; + for (int i = parent.getComponentCount() - 1; i >= 0; i--) { + Dimension preferredSize = parent.getComponent(i).getPreferredSize(); + width += preferredSize.width; + height = Math.max(height, preferredSize.height); + } + Insets insets = parent.getInsets(); + return new Dimension(width + insets.left + insets.right, height + insets.top + insets.bottom); + } + + @Override + public void removeLayoutComponent(Component comp) { + } +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxLayout.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/I18nTableCellRenderer.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/I18nTableCellRenderer.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/I18nTableCellRenderer.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/I18nTableCellRenderer.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,66 @@ +package jaxx.runtime.swing; + +import static org.nuiton.i18n.I18n._; + +import javax.swing.JComponent; +import javax.swing.JTable; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import java.awt.Component; + +/** + * A simple TableCellRenderer using a delegate TableCellRenderer to render everything elese thant the text : + * the text is I18nalize. + * + * @author chemit + */ +public class I18nTableCellRenderer implements TableCellRenderer { + + /** i18n keys of libelles to display */ + protected final String[] keys; + + /** i18n keys of toolTipTexts to display */ + protected final String[] tips; + + /** the delegate cell renderer */ + protected TableCellRenderer delegate; + + public I18nTableCellRenderer(TableCellRenderer delegate, String... keysAndTips) { + this.delegate = delegate; + if (keysAndTips.length == 0) { + throw new IllegalArgumentException("can not have empty keysAndTips parameters (means no column ?)"); + } + if (keysAndTips.length % 2 == 1) { + throw new IllegalArgumentException("must have some couple (text,tooltTipText), but had a even number of data in keysAndTips parameter"); + } + int size = keysAndTips.length / 2; + this.keys = new String[size]; + this.tips = new String[size]; + for (int i = 0; i < size; i++) { + this.keys[i] = keysAndTips[2 * i]; + this.tips[i] = keysAndTips[2 * i + 1]; + } + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasfocus, int row, int column) { + if (column > keys.length) { + throw new IndexOutOfBoundsException("colum can not be greater than " + keys.length); + } + TableColumn col = table.getColumn(table.getColumnName(column)); + int index = col.getModelIndex(); + value = _(keys[index]); + JComponent rendererComponent = (JComponent) delegate.getTableCellRendererComponent(table, value, isSelected, hasfocus, row, column); + rendererComponent.setToolTipText(_(tips[index])); + return rendererComponent; + } + + public String[] getKeys() { + return keys; + } + + public String[] getTips() { + return tips; + } + +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/I18nTableCellRenderer.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Item.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/Item.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Item.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Item.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,223 @@ +/* + * Copyright 2006 Ethan Nicholas. All rights reserved. + * Use is subject to license terms. + */ +package jaxx.runtime.swing; + +import javax.swing.event.SwingPropertyChangeSupport; +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.util.ArrayList; +import java.util.List; + +// This needs to be split into two classes, Item and TreeItem +/** + * An item in a component such as <code>JComboBox</code> or <code>JTree</code>. The <code>Item</code> + * class corresponds to the <code><item></code> tag in JAXX source files. + */ +public class Item { + + public static final String LABEL_PROPERTY = "label"; + public static final String VALUE_PROPERTY = "value"; + public static final String SELECTED_PROPERTY = "selected"; + private String id; + private String label; + private Object value; + private boolean selected; + private List<Item> children; + private Item parent; + private PropertyChangeSupport propertyChangeSupport; + + /** + * Creates a new Item. This should only be called from compiled JAXX files. + * + * @param id the item's ID + * @param label the string that should be used to represent the item visually + * @param value the item's actual value + * @param selected <code>true</code> if the item should be selected by default + */ + public Item(String id, String label, Object value, boolean selected) { + this.id = id; + this.label = label; + this.value = value; + this.selected = selected; + } + + /** + * Returns this item's ID. + * + * @return the JAXX ID attribute + */ + public String getId() { + return id; + } + + /** + * Returns the string that should be used to represent the item at display time. If <code>null</code>, + * <code>String.valueOf(getValue())</code> will be used instead. + * + * @return this item's display string + * @see #setLabel + */ + public String getLabel() { + return label; + } + + /** + * Sets the item's display string. If <code>null, String.valueOf(getValue())</code> will be used instead. + * + * @param label the new display string + * @see #getLabel + */ + public void setLabel(String label) { + String oldLabel = this.label; + this.label = label; + firePropertyChange(LABEL_PROPERTY, oldLabel, label); + } + + /** + * Returns the item's actual value as it appears in the component's model. The <code>Item</code> itself is not + * visible from the model, only the value. + * + * @return the item's value + * @see #setValue + */ + public Object getValue() { + return value; + } + + /** + * Sets the item's value as it appears in the component's model. The <code>Item</code> itself is not + * visible from the model, only the value. + * + * @param value the new value + * @see #getValue + */ + public void setValue(Object value) { + Object oldValue = this.value; + this.value = value; + firePropertyChange(VALUE_PROPERTY, oldValue, value); + } + + /** + * Returns <code>true</code> if this item is currently selected. This is a bound property. + * + * @return <code>true</code> if item is selected + * @see #setSelected + */ + public boolean isSelected() { + return selected; + } + + /** + * Sets the item's selection state. This is a bound property. + * + * @param selected the new selection state + * @see #isSelected + */ + public void setSelected(boolean selected) { + boolean oldSelected = this.selected; + this.selected = selected; + firePropertyChange(SELECTED_PROPERTY, oldSelected, selected); + } + + /** + * Adds a new child node (Items can be nested in trees). + * + * @param item the new child item + */ + public void addChild(Item item) { + if (children == null) { + children = new ArrayList<Item>(); + } + children.add(item); + item.parent = this; + } + + /** + * Remove child node a new child node + * + * @param item to remove + */ + public void removeChild(Item item) { + if (children != null) { + children.remove(item); + } + } + + /** + * Remove all childs nodes + * + * @param list of items to remove + */ + public void removeChilds(List<Item> items) { + if (children != null) { + children.removeAll(items); + } + } + + /** + * Returns a list of this item's children. + * + * @return a list of all nested child nodes + */ + public List<Item> getChildren() { + if (children == null) { + children = new ArrayList<Item>(); + } + return children; + } + + /** + * Returns the <code>Item</code> containing this <code>Item</code>, or <code>null</code> for a top-level + * <code>Item</code>. + * + * @return the item parent (or null) + */ + public Item getParent() { + return parent; + } + + /** + * Set the parent of this item + * + * @return the item parent (or null) + */ + public void setParent(Item parent) { + this.parent = parent; + } + + private PropertyChangeSupport getPropertyChangeSupport() { + if (propertyChangeSupport == null) { + propertyChangeSupport = new SwingPropertyChangeSupport(this); + } + return propertyChangeSupport; + } + + public void addPropertyChangeListener(PropertyChangeListener listener) { + getPropertyChangeSupport().addPropertyChangeListener(listener); + } + + public void addPropertyChangeListener(String property, PropertyChangeListener listener) { + getPropertyChangeSupport().addPropertyChangeListener(property, listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + getPropertyChangeSupport().removePropertyChangeListener(listener); + } + + public void removePropertyChangeListener(String property, PropertyChangeListener listener) { + getPropertyChangeSupport().removePropertyChangeListener(property, listener); + } + + protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { + if (propertyChangeSupport != null) { + getPropertyChangeSupport().firePropertyChange(propertyName, oldValue, newValue); + } + } + + @Override + public String toString() { + return getClass().getName() + "[" + value + "]"; + } +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Item.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXButtonGroup.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JAXXButtonGroup.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXButtonGroup.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXButtonGroup.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,222 @@ +/* + * Copyright 2006 Ethan Nicholas. All rights reserved. + * Use is subject to license terms. + */ +package jaxx.runtime.swing; + +import javax.swing.AbstractButton; +import javax.swing.ButtonGroup; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.event.EventListenerList; +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.util.Enumeration; + +public class JAXXButtonGroup extends ButtonGroup { + + public static final String SELECTED_VALUE_PROPERTY = "selectedValue"; + public static final String BUTTON8GROUP_CLIENT_PROPERTY = "$buttonGroup"; + public static final String VALUE_CLIENT_PROPERTY = "$value"; + public static final String SELECTED_TIP_CLIENT_PROPERTY = "$selected.toolTipText"; + public static final String NOT_SELECTED_TIP_CLIENT_PROPERTY = "$not.selected.toolTipText"; + protected EventListenerList listenerList = new EventListenerList(); + private PropertyChangeSupport propertyChangeSupport; + private transient Object selectedValue; + protected boolean useToolTipText; + protected transient ChangeEvent changeEvent = new ChangeEvent(this); + private transient ChangeListener changeListener = new ChangeListener() { + + @Override + public void stateChanged(ChangeEvent e) { + updateSelectedValue(); + if (useToolTipText) { + updateToolTipText(); + } + } + }; + private static final long serialVersionUID = 1L; + + @Override + public void add(AbstractButton button) { + super.add(button); + button.addChangeListener(changeListener); + updateSelectedValue(); + } + + @Override + public void remove(AbstractButton button) { + super.remove(button); + button.removeChangeListener(changeListener); + updateSelectedValue(); + } + + public void updateSelectedValue() { + Enumeration<AbstractButton> e = getElements(); + while (e.hasMoreElements()) { + AbstractButton button = e.nextElement(); + if (button.isSelected()) { + Object buttonValue = button.getClientProperty(VALUE_CLIENT_PROPERTY); + if (buttonValue != getSelectedValue()) { + setSelectedValue(buttonValue); + } + } + } + } + + public void updateToolTipText() { + Enumeration<AbstractButton> e = getElements(); + while (e.hasMoreElements()) { + AbstractButton button = e.nextElement(); + String key = button.isSelected() ? SELECTED_TIP_CLIENT_PROPERTY : NOT_SELECTED_TIP_CLIENT_PROPERTY; + button.setToolTipText((String) button.getClientProperty(key)); + } + } + + public boolean isUseToolTipText() { + return useToolTipText; + } + + public Object getSelectedValue() { + return selectedValue; + } + + public AbstractButton getSelectedButton() { + Enumeration<AbstractButton> e = getElements(); + while (e.hasMoreElements()) { + AbstractButton button = e.nextElement(); + if (button.isSelected()) { + return button; + } + } + return null; + } + + public AbstractButton getButton(Object value) { + Enumeration<AbstractButton> e = getElements(); + while (e.hasMoreElements()) { + AbstractButton button = e.nextElement(); + Object buttonValue = button.getClientProperty(VALUE_CLIENT_PROPERTY); + if (value.equals(buttonValue)) { + return button; + } + } + return null; + } + + public void setSelectedValue(Object value) { + Object oldValue = getSelectedValue(); + this.selectedValue = value; + firePropertyChange(oldValue); + } + + public void setUseToolTipText(boolean useToolTipText) { + this.useToolTipText = useToolTipText; + } + + public void setSelectedButton(Object value) { + setSelectedValue(value); + if (value == null) { + Enumeration<AbstractButton> e = getElements(); + while (e.hasMoreElements()) { + AbstractButton button = e.nextElement(); + setSelected(button.getModel(), false); + } + return; + } + + Enumeration<AbstractButton> e = getElements(); + while (e.hasMoreElements()) { + AbstractButton button = e.nextElement(); + Object buttonValue = button.getClientProperty(VALUE_CLIENT_PROPERTY); + if (value.equals(buttonValue)) { + button.setSelected(true); + break; + } + } + } + + protected PropertyChangeSupport getPropertyChangeSupport() { + if (propertyChangeSupport == null) { + propertyChangeSupport = new PropertyChangeSupport(this); + } + return propertyChangeSupport; + } + + public void addPropertyChangeListener(PropertyChangeListener listener) { + getPropertyChangeSupport().addPropertyChangeListener(listener); + } + + public void addPropertyChangeListener(String property, PropertyChangeListener listener) { + getPropertyChangeSupport().addPropertyChangeListener(property, listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + getPropertyChangeSupport().removePropertyChangeListener(listener); + } + + public void removePropertyChangeListener(String property, PropertyChangeListener listener) { + getPropertyChangeSupport().removePropertyChangeListener(property, listener); + } + + private void firePropertyChange(Object oldValue) { + if (propertyChangeSupport != null) { + getPropertyChangeSupport().firePropertyChange(SELECTED_VALUE_PROPERTY, + oldValue, getSelectedValue()); + } + fireStateChanged(); + } + + /** + * Adds a <code>ChangeListener</code> to the button. + * + * @param l the listener to be added + */ + public void addChangeListener(ChangeListener l) { + listenerList.add(ChangeListener.class, l); + } + + /** + * Removes a ChangeListener from the button. + * + * @param l the listener to be removed + */ + public void removeChangeListener(ChangeListener l) { + listenerList.remove(ChangeListener.class, l); + } + + /** + * Returns an array of all the <code>ChangeListener</code>s added + * to this AbstractButton with addChangeListener(). + * + * @return all of the <code>ChangeListener</code>s added or an empty + * array if no listeners have been added + * @since 1.4 + */ + public ChangeListener[] getChangeListeners() { + return listenerList.getListeners(ChangeListener.class); + } + + /** + * Notifies all listeners that have registered interest for + * notification on this event type. The event instance + * is lazily created. + * + * @see EventListenerList + */ + protected void fireStateChanged() { + // Guaranteed to return a non-null array + Object[] listeners = listenerList.getListenerList(); + // Process the listeners last to first, notifying + // those that are interested in this event + for (int i = listeners.length - 2; i >= 0; i -= 2) { + if (listeners[i] == ChangeListener.class) { + // Lazily create the event: + if (changeEvent == null) { + changeEvent = new ChangeEvent(this); + } + ((ChangeListener) listeners[i + 1]).stateChanged(changeEvent); + } + } + } +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXButtonGroup.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXComboBox.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JAXXComboBox.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXComboBox.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXComboBox.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,292 @@ +/* + * Copyright 2006 Ethan Nicholas. All rights reserved. + * Use is subject to license terms. + */ +package jaxx.runtime.swing; + +import javax.swing.AbstractListModel; +import javax.swing.ComboBoxModel; +import javax.swing.DefaultListCellRenderer; +import javax.swing.JComboBox; +import javax.swing.JList; +import javax.swing.ListModel; +import java.awt.Component; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +public class JAXXComboBox extends JComboBox { + + private static final long serialVersionUID = 1L; + + public class JAXXComboBoxModel extends AbstractListModel implements ComboBoxModel { + + private List<Item> items; + private Object selectedItem; + private static final long serialVersionUID = -8940733376638766414L; + + public JAXXComboBoxModel(List<Item> items) { + this.items = items; + + PropertyChangeListener listener = new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent e) { + if (e.getPropertyName().equals(Item.SELECTED_PROPERTY)) { + Item item = (Item) e.getSource(); + int itemIndex = JAXXComboBoxModel.this.items.indexOf(item); + // TODO: fix cut-and-pasting badness + int[] oldSelection = new int[]{getSelectedIndex()}; + int[] newSelection; + int index = -1; + for (int i = 0; i < oldSelection.length; i++) { + if (oldSelection[i] == itemIndex) { + index = i; + break; + } + } + if (item.isSelected()) { + if (index != -1) // it was already selected + { + return; + } + newSelection = new int[oldSelection.length + 1]; + System.arraycopy(oldSelection, 0, newSelection, 0, oldSelection.length); + newSelection[newSelection.length - 1] = itemIndex; + } else { + if (index == -1) // it already wasn't selected + { + return; + } + newSelection = new int[oldSelection.length - 1]; + System.arraycopy(oldSelection, 0, newSelection, 0, index); + System.arraycopy(oldSelection, index + 1, newSelection, index, oldSelection.length - 1 - index); + } + if (newSelection.length > 0) { + setSelectedIndex(newSelection[0]); + } + } else { + // TODO: more cut-and-pasting badness + for (int i = 0; i < getSize(); i++) { + if (getElementAt(i) == ((Item) e.getSource()).getValue()) { + fireContentsChanged(JAXXComboBoxModel.this, i, i); + if (getSelectedIndex() == i) { + fireItemStateChanged(new ItemEvent(JAXXComboBox.this, ItemEvent.ITEM_STATE_CHANGED, getElementAt(i), ItemEvent.DESELECTED)); + } + return; + } + } + } + } + }; + for (Item item : items) { + item.addPropertyChangeListener(listener); + } + } + + public List<Item> getItems() { + return items; + } + + @Override + public Object getElementAt(int i) { + return items.get(i).getValue(); + } + + @Override + public int getSize() { + return items.size(); + } + + @Override + public Object getSelectedItem() { + return selectedItem; + } + + @Override + public void setSelectedItem(Object selectedItem) { + if ((this.selectedItem != null && !this.selectedItem.equals(selectedItem)) || + this.selectedItem == null && selectedItem != null) { + this.selectedItem = selectedItem; + fireContentsChanged(this, -1, -1); + } + } + } + + public JAXXComboBox() { + setRenderer(new DefaultListCellRenderer() { + + private static final long serialVersionUID = 1L; + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + ListModel model = list.getModel(); + if (model instanceof JAXXComboBoxModel) { + List/*<Item>*/ items = ((JAXXComboBoxModel) model).items; + Item item = null; + if (index == -1) { + for (Object item1 : items) { + Item testItem = (Item) item1; + if (testItem.getValue() == value) { + item = testItem; + break; + } + } + } else { + item = (Item) items.get(index); + } + + if (item != null) { + String label = item.getLabel(); + if (label != null) { + value = label; + } + } + } + return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + } + }); + + addItemListener(new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + ListModel model = getModel(); + if (model instanceof JAXXComboBoxModel) { + List<Item> items = ((JAXXComboBoxModel) model).items; + for (int i = items.size() - 1; i >= 0; i--) { + boolean selected = getSelectedIndex() == i; + Item item = items.get(i); + if (selected != item.isSelected()) { + item.setSelected(selected); + } + } + } + } + }); + } + + /** + * Fill a combo box model with some datas, and select after all the given object + * + * @param data data ot inject in combo + * @param select the object to select in combo after reflling his model + * @param methodName method to invoke to display data's name + */ + public void fillComboBox(Collection<?> data, Object select, String methodName) { + // prepare method to use + Method m; + try { + m = select.getClass().getMethod(methodName); + m.setAccessible(true); + } catch (NoSuchMethodException e) { + throw new IllegalArgumentException("could not find method " + methodName + " on " + select.getClass()); + } + + List<Item> items = new ArrayList<Item>(); + for (Object o : data) { + boolean selected = o.equals(select); + try { + items.add(new Item(o.toString(), (String) m.invoke(o), o, selected)); + } catch (IllegalAccessException e) { + // shoudl never happen ? + throw new RuntimeException(e); + } catch (InvocationTargetException e) { + // shoudl never happen ? + throw new RuntimeException(e); + } + } + setItems(items); + } + + // this way we can keep it marked protected and still allow code in this file to call it + @Override + protected void fireItemStateChanged(ItemEvent e) { + super.fireItemStateChanged(e); + } + + public void setItems(List<Item> items) { + setModel(new JAXXComboBoxModel(items)); + List<Integer> selectedIndexList = new ArrayList<Integer>(); + for (int i = 0; i < items.size(); i++) { + if (items.get(i).isSelected()) { + selectedIndexList.add(i); + } + } + int[] selectedIndices = new int[selectedIndexList.size()]; + for (int i = 0; i < selectedIndexList.size(); i++) { + selectedIndices[i] = selectedIndexList.get(i); + } + if (selectedIndices.length > 0) { + setSelectedIndex(selectedIndices[0]); + } + } + + public List<Item> getItems() { + if (getModel() instanceof JAXXComboBoxModel) { + return ((JAXXComboBoxModel) getModel()).getItems(); + } + return null; + } + + public void setSelectedItem(Item item) { + //TC-20092004 Anomalie #73 fix npe when want to call with a null + // value + super.setSelectedItem(item == null ? null : item.getValue()); + } + + public Item getSelectedJaxxItem() { + Object selected = super.getSelectedItem(); + return findItem(selected); + } + + public Item findItem(Object value) { + List<Item> items = getItems(); + if (items != null) { + for (Item i : items) { + if (i.getValue().equals(value)) { + return i; + } + } + } + return null; + } + + public void addItem(Item item) { + List<Item> items = getItems(); + if (items != null) { + items.add(item); + setItems(items); + } + } + + public void addAllItems(Collection<Item> itemsToAdd) { + List<Item> items = getItems(); + if (items != null) { + items.addAll(itemsToAdd); + setItems(items); + } + } + + public void removeItem(Item item) { + List<Item> items = getItems(); + if (items != null) { + items.remove(item); + setItems(items); + } + } + + public void removeAllItems(Collection<Item> itemsToRemove) { + List<Item> items = getItems(); + if (items != null) { + items.removeAll(itemsToRemove); + setItems(items); + } + } +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXComboBox.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXList.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JAXXList.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXList.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXList.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,396 @@ +/* + * Copyright 2006 Ethan Nicholas. All rights reserved. + * Use is subject to license terms. + */ +package jaxx.runtime.swing; + +import javax.swing.AbstractListModel; +import javax.swing.DefaultListCellRenderer; +import javax.swing.JList; +import javax.swing.ListModel; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import java.awt.Component; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +public class JAXXList extends JList { + + private static final long serialVersionUID = 1L; + + public class JAXXListModel extends AbstractListModel { + + private List<Item> items; + private static final long serialVersionUID = -1598924187490122036L; + + public JAXXListModel(List<Item> items) { + this.items = items; + + PropertyChangeListener listener = new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent e) { + if (e.getPropertyName().equals(Item.SELECTED_PROPERTY)) { + Item item = (Item) e.getSource(); + int itemIndex = JAXXListModel.this.items.indexOf(item); + int[] oldSelection = getSelectedIndices(); + int[] newSelection; + int index = -1; + for (int i = 0; i < oldSelection.length; i++) { + if (oldSelection[i] == itemIndex) { + index = i; + break; + } + } + if (item.isSelected()) { + if (index != -1) // it was already selected + { + return; + } + newSelection = new int[oldSelection.length + 1]; + System.arraycopy(oldSelection, 0, newSelection, 0, oldSelection.length); + newSelection[newSelection.length - 1] = itemIndex; + } else { + if (index == -1) // it already wasn't selected + { + return; + } + newSelection = new int[oldSelection.length - 1]; + System.arraycopy(oldSelection, 0, newSelection, 0, index); + System.arraycopy(oldSelection, index + 1, newSelection, index, oldSelection.length - 1 - index); + } + setSelectedIndices(newSelection); + } else { + for (int i = 0; i < getSize(); i++) { + if (getElementAt(i) == ((Item) e.getSource()).getValue()) { + fireContentsChanged(JAXXListModel.this, i, i); + if (isSelectedIndex(i)) { + fireSelectionValueChanged(i, i, false); + } + return; + } + } + } + } + }; + for (Item item : items) { + item.addPropertyChangeListener(listener); + } + } + + public List<Item> getItems(){ + return items; + } + + @Override + public Object getElementAt(int i) { + return items.get(i).getValue(); + } + + @Override + public int getSize() { + return items.size(); + } + } + + public JAXXList() { + setCellRenderer(new DefaultListCellRenderer() { + + private static final long serialVersionUID = 1L; + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + ListModel model = list.getModel(); + if (model instanceof JAXXListModel) { + Item item = ((JAXXListModel) model).items.get(index); + String label = item.getLabel(); + if (label != null) { + value = label; + } + } + return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + } + }); + + addListSelectionListener(new ListSelectionListener() { + + @Override + public void valueChanged(ListSelectionEvent e) { + ListModel model = getModel(); + if (model instanceof JAXXListModel) { + List<Item> items = ((JAXXListModel) model).items; + for (int i = items.size() - 1; i >= 0; i--) { + boolean selected = isSelectedIndex(i); + Item item = items.get(i); + if (selected != item.isSelected()) { + item.setSelected(selected); + } + } + } + } + }); + } + + // this way we can keep it marked protected and still allow code in this file to call it + @Override + protected void fireSelectionValueChanged(int firstIndex, int lastIndex, boolean isAdjusting) { + super.fireSelectionValueChanged(firstIndex, lastIndex, isAdjusting); + } + + public void setItems(List<Item> items) { + setModel(new JAXXListModel(items)); + List<Integer> selectedIndexList = new ArrayList<Integer>(); + for (int i = 0; i < items.size(); i++) { + if (items.get(i).isSelected()) { + selectedIndexList.add(i); + } + } + int[] selectedIndices = new int[selectedIndexList.size()]; + for (int i = 0; i < selectedIndexList.size(); i++) { + selectedIndices[i] = selectedIndexList.get(i); + } + setSelectedIndices(selectedIndices); + } + + public List<Item> getItems(){ + if (getModel() instanceof JAXXListModel){ + return ((JAXXListModel)getModel()).getItems(); + } + return null; + } + + public void setSelectedValue(Object value) { + super.setSelectedValue(value, true); + } + + /** + * Set the selected Objects + * + * @param values Objects must be selected in the list + */ + public void setSelectedValues(Object[] values) { + if (values != null){ + List<Integer> selectedIndices = new ArrayList<Integer>(); + ListModel model = getModel(); + for (int i = 0; i < model.getSize(); i++) { + Object o = model.getElementAt(i); + for (Object value : values) { + if (o.equals(value)) { + selectedIndices.add(i); + break; + } + } + } + int[] ints = new int[selectedIndices.size()]; + for (int i = 0; i < ints.length; i++) { + ints[i] = selectedIndices.get(i).intValue(); + } + setSelectedIndices(ints); + } + else{ + // No selection if values is null + setSelectedIndex(-1); + } + } + + public void setSelectedItem(Item item) { + super.setSelectedValue(item.getValue(), true); + } + + public void setSelectedItems(List<Item> itemsToSelect) { + if (itemsToSelect != null){ + List<Item> items = getItems(); + int[] indices = new int[itemsToSelect.size()]; + int i = 0; + for (Item item : itemsToSelect){ + indices[i] = items.indexOf(item); + i++; + } + super.setSelectedIndices(indices); + } + } + + public Item getSelectedItem(){ + Object selected = super.getSelectedValue(); + return findItem(selected); + } + + public List<Item> getSelectedItems(){ + Object[] selected = super.getSelectedValues(); + java.util.List<Item> itemsSelected = new ArrayList<Item>(); + for (Object s : selected){ + itemsSelected.add(findItem(s)); + } + return itemsSelected; + } + + public Item findItem(Object value){ + List<Item> items = getItems(); + if (items != null){ + for (Item i : items){ + if (i.getValue().equals(value)){ + return i; + } + } + } + return null; + } + + public void addItem(Item item){ + List<Item> items = getItems(); + if (items != null){ + items.add(item); + setItems(items); + } + } + + public void addAllItems(Collection<Item> itemsToAdd){ + List<Item> items = getItems(); + if (items != null){ + items.addAll(itemsToAdd); + setItems(items); + } + } + + public void removeItem(Item item){ + List<Item> items = getItems(); + if (items != null){ + items.remove(item); + setItems(items); + } + } + + public void removeAllItems(Collection<Item> itemsToRemove){ + List<Item> items = getItems(); + if (items != null){ + items.removeAll(itemsToRemove); + setItems(items); + } + } + + /** + * Fill a list model with some datas, and select after all the given object + * + * @param data data ot inject in combo + * @param selects the objects to select in list after reflling his model + */ + public void fillList(Collection<?> data, Collection<?> selects) { + if (selects == null) { + selects = java.util.Collections.EMPTY_LIST; + } + List<Item> items = new ArrayList<Item>(); + for (Object o : data) { + boolean selected = false; + for (Object select : selects) { + if (selected = o.equals(select)) { + break; + } + } + items.add(new Item(o.toString(), o.toString(), o, selected)); + } + setItems(items); + } + + /** + * Fill a list model with some datas, and select after all the given object + * + * @param data data ot inject in combo + * @param select object to select in list after reflling his model + */ + public void fillList(Collection<?> data, Object select) { + List<Item> items = new ArrayList<Item>(); + for (Object o : data) { + boolean selected = o.equals(select); + items.add(new Item(o.toString(), o.toString(), o, selected)); + } + setItems(items); + } + + /** + * Fill a list model with some datas, and select after all the given object + * + * @param data data ot inject in combo + * @param select object to select in list after reflling his model + * @param methodName method to invoke to display data's name + */ + public void fillList(Collection<?> data, Object select, String methodName) { + // prepare method to use + Method m = null; + + List<Item> items = new ArrayList<Item>(); + for (Object o : data) { + boolean selected = o.equals(select); + if (m == null) { + try { + m = o.getClass().getMethod(methodName); + m.setAccessible(true); + } catch (NoSuchMethodException e) { + throw new IllegalArgumentException("could not find method " + methodName + " on " + o.getClass()); + } + } + try { + items.add(new Item(o.toString(), (String) m.invoke(o), o, selected)); + } catch (SecurityException e) { + // shoudl never happen ? + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + // shoudl never happen ? + throw new RuntimeException(e); + } catch (IllegalArgumentException e) { + // shoudl never happen ? + throw new RuntimeException(e); + } catch (InvocationTargetException e) { + // shoudl never happen ? + throw new RuntimeException(e); + } + } + setItems(items); + } + + /** + * Fill a list model with some datas, and select after all the given object + * + * @param data data ot inject in combo + * @param selects the objects to select in list after reflling his model + * @param methodName method to invoke to display data's name + */ + public void fillList(Collection<?> data, Collection<?> selects, String methodName) { + // prepare method to use + Method m = null; + + List<Item> items = new ArrayList<Item>(); + for (Object o : data) { + boolean selected = selects.contains(o); + if (m == null) { + try { + m = o.getClass().getMethod(methodName); + m.setAccessible(true); + } catch (NoSuchMethodException e) { + throw new IllegalArgumentException("could not find method " + methodName + " on " + o.getClass()); + } + } + try { + items.add(new Item(o.toString(), (String) m.invoke(o), o, selected)); + } catch (SecurityException e) { + // shoudl never happen ? + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + // shoudl never happen ? + throw new RuntimeException(e); + } catch (IllegalArgumentException e) { + // shoudl never happen ? + throw new RuntimeException(e); + } catch (InvocationTargetException e) { + // shoudl never happen ? + throw new RuntimeException(e); + } + } + setItems(items); + } + +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXList.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTab.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JAXXTab.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTab.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTab.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,25 @@ +/* + * ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin, + * 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 2 + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * ##% */ +package jaxx.runtime.swing; + +/** @author chemit */ +public class JAXXTab extends Table { + + private static final long serialVersionUID = 1L; +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTab.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXToggleButton.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JAXXToggleButton.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXToggleButton.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXToggleButton.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,92 @@ +package jaxx.runtime.swing; + +public class JAXXToggleButton extends javax.swing.JToggleButton { + + private static final long serialVersionUID = 1L; + protected String glueText; + protected String normalText; + protected String glueTooltipText; + protected String normalTooltipText; + protected int normalMnemonic; + protected int glueMnemonic; + protected boolean _init; + + public String getGlueText() { + return glueText; + } + + public String getNormalText() { + return normalText; + } + + public String getGlueTooltipText() { + return glueTooltipText; + } + + public String getNormalTooltipText() { + return normalTooltipText; + } + + public void setGlueText(String glueText) { + this.glueText = glueText; + + } + + public void setNormalText(String normalText) { + this.normalText = normalText; + + } + + public void setGlueTooltipText(String glueTooltipText) { + this.glueTooltipText = glueTooltipText; + } + + public int getNormalMnemonic() { + return normalMnemonic; + } + + public void setNormalMnemonic(int normalMnemonic) { + this.normalMnemonic = normalMnemonic; + } + + public int getGlueMnemonic() { + return glueMnemonic; + } + + public void setGlueMnemonic(int glueMnemonic) { + this.glueMnemonic = glueMnemonic; + } + + public void setNormalTooltipText(String normalTooltipText) { + this.normalTooltipText = normalTooltipText; + if (!_init) { + init(); + _init = true; + } + } + + @Override + public void setSelected(boolean b) { + super.setSelected(b); + if (isSelected()) { + setText(getGlueText()); + setToolTipText(getGlueTooltipText()); + setMnemonic(getGlueMnemonic()); + } else { + setText(getNormalText()); + setToolTipText(getNormalTooltipText()); + setMnemonic(getNormalMnemonic()); + } + revalidate(); + } + + public void init() { + setSelected(false); + } + + /* end raw body code */ + public JAXXToggleButton() { + super(); + _init = false; + } +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXToggleButton.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTree.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JAXXTree.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTree.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTree.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,259 @@ +/* + * Copyright 2006 Ethan Nicholas. All rights reserved. + * Use is subject to license terms. + */ +package jaxx.runtime.swing; + +import javax.swing.JTree; +import javax.swing.event.TreeModelEvent; +import javax.swing.event.TreeModelListener; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.TreeModel; +import javax.swing.tree.TreePath; +import java.awt.Component; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.ArrayList; +import java.util.List; + +public class JAXXTree extends JTree { + + private static final long serialVersionUID = 1L; + private static final String SYNTHETIC = "<synthetic root node>"; + + public class JAXXTreeModel implements TreeModel { + + private Item root; + private List<TreeModelListener> listeners = new ArrayList<TreeModelListener>(); + + public JAXXTreeModel(List<Item> items) { + if (items.size() == 1) { + this.root = items.get(0); + } else { + this.root = new Item(null, null, SYNTHETIC, false); + for (Item item : items) { + root.addChild(item); + } + } + + PropertyChangeListener listener = new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent e) { + if (e.getPropertyName().equals(Item.SELECTED_PROPERTY)) { + Item item = (Item) e.getSource(); + if (item.isSelected()) { + addSelectionPath(getTreePath(item)); + } else { + removeSelectionPath(getTreePath(item)); + } + } else { + Item item = (Item) e.getSource(); + boolean root = item.getParent() == null; + TreePath path = !root ? getTreePath(item.getParent()) : null; + fireTreeNodesChanged(new TreeModelEvent(JAXXTreeModel.this, path, + !root ? new int[]{item.getParent().getChildren().indexOf(item)} : null, + new Object[]{item.getValue()})); + } + } + }; + addPropertyChangeListener(root, listener); + } + + private void addPropertyChangeListener(Item item, PropertyChangeListener listener) { + item.addPropertyChangeListener(listener); + List<Item> children = item.getChildren(); + for (Item aChildren : children) { + addPropertyChangeListener(aChildren, listener); + } + } + + @Override + public void addTreeModelListener(TreeModelListener listener) { + listeners.add(listener); + } + + + /* This is an inefficient implementation, but hand-coded tree structures are unlikely to contain + enough nodes for that to really matter. This could be sped up with caching. */ + public Item findItem(Object value) { + return findItem(root, value); + } + + private Item findItem(Item node, Object value) { + if (node.getValue() == value) { + return node; + } else { + List<Item> children = node.getChildren(); + for (Item aChildren : children) { + Item result = findItem(aChildren, value); + if (result != null) { + return result; + } + } + return null; + } + } + + private TreePath getTreePath(Item node) { + List<Object> path = new ArrayList<Object>(); + while (node != null) { + path.add(0, node.getValue()); + node = node.getParent(); + } + return new TreePath(path.toArray()); + } + + @Override + public Object getChild(Object parent, int index) { + Item node = findItem(parent); + return node.getChildren().get(index).getValue(); + } + + @Override + public int getChildCount(Object parent) { + Item node = findItem(parent); + if (node == null){ + return 0; + } + return node.getChildren().size(); + } + + @Override + public int getIndexOfChild(Object parent, Object child) { + Item node = findItem(parent); + List<Item> children = node.getChildren(); + for (int i = 0, j = children.size(); i < j; i++) { + if (children.get(i).getValue() == child) { + return i; + } + } + return -1; + } + + @Override + public Object getRoot() { + return root.getValue(); + } + + public Item getRootItem() { + return root; + } + + @Override + public boolean isLeaf(Object node) { + Item item = findItem(node); + return item != null && item.getChildren().size() == 0; + } + + @Override + public void removeTreeModelListener(TreeModelListener listener) { + listeners.remove(listener); + } + + public void fireTreeNodesChanged(TreeModelEvent e) { + for (TreeModelListener listener : listeners) { + listener.treeNodesChanged(e); + } + } + + @Override + public void valueForPathChanged(TreePath path, Object newValue) { + } + } + + public JAXXTree(TreeModel model) { + super(model); + } + + public JAXXTree() { + setCellRenderer(new DefaultTreeCellRenderer() { + + private static final long serialVersionUID = 1L; + + @Override + public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { + TreeModel model = tree.getModel(); + if (model instanceof JAXXTreeModel) { + Item item = ((JAXXTreeModel) model).findItem(value); + if (item != null) { + String label = item.getLabel(); + if (label != null) { + value = label; + } + } + } + return super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); + } + }); + + addTreeSelectionListener(new TreeSelectionListener() { + + @Override + public void valueChanged(TreeSelectionEvent e) { + TreeModel model = getModel(); + if (model instanceof JAXXTreeModel) { + scan((JAXXTreeModel) model, ((JAXXTreeModel) model).root); + } + } + + private void scan(JAXXTreeModel model, Item item) { + TreePath path = model.getTreePath(item); + if (item.isSelected() != isPathSelected(path)) { + item.setSelected(!item.isSelected()); + } + List<Item> children = item.getChildren(); + for (Item aChildren : children) { + scan(model, aChildren); + } + } + }); + } + + public void setItem(Item items) { + List<Item> newItems = new ArrayList<Item>(); + newItems.add(items); + setItems(newItems); + } + + public void setItems(List<Item> items) { + // Create model + JAXXTreeModel model = new JAXXTreeModel(items); + if (model.getRoot() != null) { + setRootVisible(model.getRoot() != SYNTHETIC); + } + // Atach model + setModel(model); + + // Appli selected items + if (items != null){ + List<TreePath> treePathSelected = new ArrayList<TreePath>(); + for (Item i : items){ + if (i.isSelected()){ + treePathSelected.add(model.getTreePath(i)); + } + } + this.setSelectionPaths(convertToTreePathArray(treePathSelected.toArray())); + } + } + + public Object getSelectionValue() { + TreePath selectionPath = getSelectionPath(); + return selectionPath != null ? selectionPath.getLastPathComponent() : null; + } + + public Item getRootItem(){ + if (getModel() instanceof JAXXTreeModel){ + return ((JAXXTreeModel)getModel()).getRootItem(); + } + return null; + } + + protected TreePath[] convertToTreePathArray(Object[] datas){ + TreePath[] params = new TreePath[datas.length]; + System.arraycopy(datas, 0, params, 0, datas.length); + return params; + } +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTree.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,500 @@ +package jaxx.runtime.swing; + +import java.applet.Applet; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; +import java.net.URL; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Map; +import java.util.Vector; +import javax.help.CSH; +import javax.help.HelpBroker; +import javax.help.HelpSet; +import javax.swing.AbstractButton; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import jaxx.runtime.JAXXContext; +import jaxx.runtime.JAXXObject; +import jaxx.runtime.SwingUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * La classe pour encapsuler l'aide de l'application. + * + * @param <B> le type de broker + * @author tony + * @since 1.4 + */ +public abstract class JaxxHelpBroker<B extends JaxxHelpBroker<?>> { + + public static final String JAXX_CONTEXT_ENTRY = "jaxxcontext"; + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private Log log = LogFactory.getLog(JaxxHelpBroker.class); + protected final String helpsetName; + protected final String defaultID; + protected final String helpKey; + // Main HelpSet & Broker + protected final HelpSet helpset; + protected final HelpBroker helpBroker; + protected Hashtable<Component, Cursor> cursors; + protected Cursor onItemCursor; + protected final Map<Component, String> cache; + + protected JaxxHelpBroker(String helpsetName, String helpKey, String defaultID) { + if (helpsetName == null) { + throw new NullPointerException("parameter helpsetName can not be null!"); + } + this.helpsetName = helpsetName; + this.helpKey = helpKey; + this.defaultID = defaultID; + cache = new HashMap<Component, String>(); + try { + ClassLoader cl = getClass().getClassLoader(); + URL url = HelpSet.findHelpSet(cl, helpsetName); + helpset = new HelpSet(cl, url); + helpBroker = helpset.createHelpBroker(); + } catch (Exception ee) { + throw new IllegalStateException("could not find help set " + helpsetName + " for reason " + ee.getMessage(), ee); + } + } + + public void prepareUI(JAXXObject c) { + if (c == null) { + throw new NullPointerException("parameter c can not be null!"); + } + + // l'ui doit avoir un boutton showHelp + AbstractButton help = getShowHelpButton(c); + + if (help == null) { + if (log.isDebugEnabled()) { + log.debug("no showButton detected for " + c.getClass()); + } + } else { + + // attach context to button + help.putClientProperty(JAXX_CONTEXT_ENTRY, c.getDelegateContext()); + + // add tracking action + ActionListener listener = getShowHelpAction(); + if (log.isDebugEnabled()) { + log.debug("adding tracking action " + listener); + } + help.addActionListener(listener); + + } + if (log.isDebugEnabled()) { + log.debug("done for " + c); + } + } + + public HelpBroker getHelpBroker() { + return helpBroker; + } + + public String getHelpKey() { + return helpKey; + } + + public HelpSet getHelpset() { + return helpset; + } + + public String getHelpsetName() { + return helpsetName; + } + + public String getDefaultID() { + return defaultID; + } + + public void showHelpSet() { + if (log.isDebugEnabled()) { + log.debug(this); + } + new CSH.DisplayHelpFromSource(helpBroker); + } + + public void showHelp(JAXXContext context, String helpId) { + } + + public void installUI(Component comp, String helpId) { + CSH.setHelpIDString(comp, helpId); + if (log.isDebugEnabled()) { + log.debug(helpId + " : " + comp.getName()); + } + cache.put(comp, helpId); + } + + public class ShowHelpForTrackedComponentAction implements ActionListener { + + @Override + public void actionPerformed(ActionEvent e) { + AbstractButton source = (AbstractButton) e.getSource(); + + JAXXContext context = (JAXXContext) source.getClientProperty(JAXX_CONTEXT_ENTRY); + + // prepare cursor + onItemCursor = (Cursor) UIManager.get("HelpOnItemCursor"); + Vector<?> topComponents = null; + cursors = null; + + if (onItemCursor != null) { + cursors = new Hashtable<Component, Cursor>(); + topComponents = getTopContainers(source); + Enumeration<?> enums = topComponents.elements(); + while (enums.hasMoreElements()) { + setAndStoreCursors((Container) enums.nextElement(), onItemCursor); + } + } + + // get the tracked component + Component comp = null; + try { + MouseEvent event = getMouseEvent(); + if (event == null) { + // tracking canceled + return; + } + comp = (Component) event.getSource(); + if (log.isDebugEnabled()) { + log.debug("component traking " + comp.getName() + " : " + comp.getClass().getName()); + } + comp = SwingUtil.getDeepestObjectAt(comp, event.getX(), event.getY()); + if (log.isDebugEnabled()) { + log.debug("deepest component " + comp.getName() + " : " + comp.getClass().getName()); + } + } finally { + // restore the old cursors + if (topComponents != null) { + Enumeration<?> containers = topComponents.elements(); + while (containers.hasMoreElements()) { + resetAndRestoreCursors((Container) containers.nextElement()); + } + } + cursors = null; + } + + String helpID = findHelpId(comp); + showHelp(context, helpID); + } + + public String findHelpId(Component comp) { + String helpID = CSH.getHelpIDString(comp); + if (defaultID.equals(helpID)) { + String id = cache.get(comp); + // on verifie qu'on est bien sur sur le bon id + if (helpID.equals(id)) { + // ok + return helpID; + } + if (log.isDebugEnabled()) { + log.debug("will try to find better id for comp : " + comp.getName()); + } + // on est pas sur le bon id + // on recherche parmis les parents + helpID = findExtactHelpId(comp); + } + if (log.isInfoEnabled()) { + log.info("helpID " + helpID + " for comp " + comp.getName() + " : " + comp.getClass().getName()); + } + return helpID; + } + + protected String findExtactHelpId(Component comp) { + Container parent = comp.getParent(); + while (parent != null) { + String id = cache.get(parent); + if (id == null) { + // ce container n'a pas d'id + // on va directement sur le parent + parent = parent.getParent(); + continue; + } + // le parent possède un id + // on utilise cet id + return id; + } + // on a pas trouve d'id + // on retourne l'id par defaut + return defaultID; + } + } + + protected AbstractButton getShowHelpButton(JAXXObject c) { + return (AbstractButton) c.getObjectById("showHelp"); + } + + protected ActionListener getShowHelpAction() { + return new ShowHelpForTrackedComponentAction(); + } + + //------------------------------------------------------------------------- + //--- Copy CSH code but with accessible modifiers and little improvments + //------------------------------------------------------------------------- + /* + * Get all top level containers to change it's cursors + */ + protected Vector<?> getTopContainers(Object source) { + // This method is used to obtain all top level components of application + // for which the changing of cursor to question mark is wanted. + // Method Frame.getFrames() is used to get list of Frames and + // Frame.getOwnedWindows() method on elements of the list + // returns all Windows, Dialogs etc. It works correctly in application. + // Problem is in applets. There is no way how to get reference to applets + // from elsewhere than applet itself. So, if request for CSH (this means + // pressing help button or select help menu item) does't come from component + // in a Applet, cursor for applets is not changed to question mark. Only for + // Frames, Windows and Dialogs is cursor changed properly. + + Vector<Component> containers = new Vector<Component>(); + Component topComponent = null; + topComponent = getRoot(source); + if (topComponent instanceof Applet) { + try { + Enumeration<Applet> applets = ((Applet) topComponent).getAppletContext().getApplets(); + while (applets.hasMoreElements()) { + containers.add(applets.nextElement()); + } + } catch (NullPointerException npe) { + containers.add(topComponent); + } + } + Frame frames[] = Frame.getFrames(); + for (int i = 0; i < frames.length; i++) { + Window[] windows = frames[i].getOwnedWindows(); + for (int j = 0; j < windows.length; j++) { + containers.add(windows[j]); + } + if (!containers.contains(frames[i])) { + containers.add(frames[i]); + } + } + return containers; + } + + protected Component getRoot(Object comp) { + Object parent = comp; + while (parent != null) { + comp = parent; + if (comp instanceof MenuComponent) { + parent = ((MenuComponent) comp).getParent(); + } else if (comp instanceof Component) { + if (comp instanceof Window) { + break; + } + if (comp instanceof Applet) { + break; + } + parent = ((Component) comp).getParent(); + } else { + break; + } + } + if (comp instanceof Component) { + return ((Component) comp); + } + return null; + } + + /* + * Set the cursor for a component and its children. + * Store the old cursors for future resetting + */ + protected void setAndStoreCursors(Component comp, Cursor cursor) { + if (comp == null) { + return; + } + Cursor compCursor = comp.getCursor(); + if (compCursor != cursor) { + cursors.put(comp, compCursor); + log.debug("set cursor on " + comp); + comp.setCursor(cursor); + } + if (comp instanceof Container) { + Component component[] = ((Container) comp).getComponents(); + for (int i = 0; i < component.length; i++) { + setAndStoreCursors(component[i], cursor); + } + } + } + + /* + * Actually restore the cursor for a component and its children + */ + protected void resetAndRestoreCursors(Component comp) { + if (comp == null) { + return; + } + Cursor oldCursor = cursors.get(comp); + if (oldCursor != null) { + log.debug("restored cursor " + oldCursor + " on " + comp); + comp.setCursor(oldCursor); + } + if (comp instanceof Container) { + Component component[] = ((Container) comp).getComponents(); + for (int i = 0; i < component.length; i++) { + resetAndRestoreCursors(component[i]); + } + } + } + + /** + * Context Sensitive Event Tracking + * + * Creates a new EventDispatchThread from which to dispatch events. This + * method returns when stopModal is invoked. + * + * @return MouseEvent The mouse event occurred. Null if + * cancelled on an undetermined object. + */ + public static MouseEvent getMouseEvent() { + // Should the cursor change to a quesiton mark here or + // require the user to change the cursor externally to this method? + // The problem is that each component can have it's own cursor. + // For that reason it might be better to have the user change the + // cusor rather than us. + + // To track context-sensitive events get the event queue and process + // the events the same way EventDispatchThread does. Filter out + // ContextSensitiveEvents SelectObject & Cancel (MouseDown & ???). + // Note: This code only handles mouse events. Accessiblity might + // require additional functionality or event trapping + + // If the eventQueue can't be retrieved, the thread gets interrupted, + // or the thread isn't a instanceof EventDispatchThread then return + // a null as we won't be able to trap events. + try { + if (EventQueue.isDispatchThread()) { + EventQueue eq = null; + + // Find the eventQueue. If we can't get to it then just return + // null since we won't be able to trap any events. + + try { + eq = Toolkit.getDefaultToolkit().getSystemEventQueue(); + } catch (Exception ee) { + log.debug(ee); + } + + // Safe guard + if (eq == null) { + return null; + } + + int eventNumber = -1; + + // Process the events until an object has been selected or + // the context-sensitive search has been canceled. + while (true) { + // This is essentially the body of EventDispatchThread + // modified to trap context-senstive events and act + // appropriately + eventNumber++; + AWTEvent event = eq.getNextEvent(); + Object src = event.getSource(); + // can't call eq.dispatchEvent + // so I pasted it's body here + + if (log.isDebugEnabled()) { + log.debug(event); + } + + // Not sure if I should suppress ActiveEvents or not + // Modal dialogs do. For now we will not suppress the + // ActiveEvent events + + if (event instanceof ActiveEvent) { + ((ActiveEvent) event).dispatch(); + continue; + } + + if (src instanceof Component) { + // Trap the context-sensitive events here + if (event instanceof KeyEvent) { + KeyEvent e = (KeyEvent) event; + // if this is the cancel key then exit + // otherwise pass all other keys up + if (e.getKeyCode() == KeyEvent.VK_CANCEL || + e.getKeyCode() == KeyEvent.VK_ESCAPE) { + e.consume(); + return null; + } else { + e.consume(); + // dispatchEvent(event); + } + } else if (event instanceof MouseEvent) { + MouseEvent e = (MouseEvent) event; + int eID = e.getID(); + + if ((eID == MouseEvent.MOUSE_CLICKED || + eID == MouseEvent.MOUSE_PRESSED || + eID == MouseEvent.MOUSE_RELEASED) && + SwingUtilities.isRightMouseButton(e)) { + // cancel tracking + e.consume(); + if (log.isDebugEnabled()) { + log.debug("tracking canceled!!!"); + } + return null; + } + + if ((eID == MouseEvent.MOUSE_CLICKED || + eID == MouseEvent.MOUSE_PRESSED || + eID == MouseEvent.MOUSE_RELEASED) && + SwingUtilities.isLeftMouseButton(e)) { + if (eID == MouseEvent.MOUSE_CLICKED) { + if (eventNumber == 0) { + dispatchEvent(event); + continue; + } + } + e.consume(); + return e; + } else { + e.consume(); + } + } else { + dispatchEvent(event); + } + } else if (src instanceof MenuComponent) { + if (event instanceof InputEvent) { + ((InputEvent) event).consume(); + } + } else { + log.error("unable to dispatch event: " + event); + } + } + } + } catch (InterruptedException e) { + if (log.isDebugEnabled()) { + log.debug(e); + } + } + if (log.isDebugEnabled()) { + log.debug("Fall Through code"); + } + return null; + } + + private static void dispatchEvent(AWTEvent event) { + Object src = event.getSource(); + if (event instanceof ActiveEvent) { + // This could become the sole method of dispatching in time. + ((ActiveEvent) event).dispatch(); + } else if (src instanceof Component) { + ((Component) src).dispatchEvent(event); + } else if (src instanceof MenuComponent) { + ((MenuComponent) src).dispatchEvent(event); + } else { + log.error("unable to dispatch event: " + event); + } + } +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,114 @@ +package jaxx.runtime.swing; + +import java.awt.Component; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import javax.swing.DefaultListCellRenderer; +import javax.swing.Icon; +import javax.swing.JLabel; +import javax.swing.JList; +import jaxx.runtime.SwingUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * + * @author chemit + */ +public class LocaleListCellRenderer extends DefaultListCellRenderer { + + public static final Log log = LogFactory.getLog(LocaleListCellRenderer.class); + private static final long serialVersionUID = 1L; + protected Map<Locale, Icon> cache = new HashMap<Locale, Icon>(); + protected boolean showIcon; + protected boolean showText; + + public LocaleListCellRenderer() { + this(true, true); + } + + public LocaleListCellRenderer(boolean showIcon, boolean showText) { + this.showIcon = showIcon; + this.showText = showText; + } + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + JLabel comp = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + Locale locale = (Locale) value; + if (locale != null) { + Icon icon = getIcon(locale); + comp.setIcon(icon); + } + String text = getText(locale); + String tip = getToolTipText(locale); + comp.setText(text); + comp.setToolTipText(tip); + return comp; + } + + public String getText(Locale locale) { + String text = null; + if (showText) { + text = locale.getDisplayName(Locale.getDefault()); + } + return text; + } + + public String getToolTipText(Locale locale) { + String tip = locale.getDisplayName(Locale.getDefault()); + return tip; + } + + public boolean isShowText() { + return showText; + } + + public boolean isShowIcon() { + return showIcon; + } + + public void setShowIcon(boolean showIcon) { + boolean old = this.showIcon; + this.showIcon = showIcon; + firePropertyChange("showIcon", old, showIcon); + } + + public void setShowText(boolean showText) { + boolean old = this.showText; + this.showText = showText; + firePropertyChange("showText", old, showText); + } + + public synchronized Icon getIcon(Locale locale) { + if (!showIcon) { + return null; + } + Icon icon = cache.get(locale); + if (icon != null) { + return icon; + } + + icon = SwingUtil.getUIManagerActionIcon("i18n-" + locale.toString()); + + if (icon == null) { + log.warn("could not find icon action.i18n-" + locale.toString()); + if (locale.getCountry() != null) { + icon = SwingUtil.getUIManagerActionIcon("i18n-" + locale.getCountry().toLowerCase()); + if (icon == null) { + log.warn("could not find icon action.i18n-" + locale.getCountry().toLowerCase()); + + icon = SwingUtil.createActionIcon("i18n-" + locale.getCountry().toLowerCase()); + if (icon == null) { + log.warn("could not find icon action.i18n-" + locale.getCountry().toLowerCase()); + } + } + + } + } + + cache.put(locale, icon); + return icon; + } +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/MyDefaultCellEditor.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/MyDefaultCellEditor.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/MyDefaultCellEditor.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/MyDefaultCellEditor.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,104 @@ +package jaxx.runtime.swing; + +import org.nuiton.util.EnumEditor; + +import javax.swing.DefaultCellEditor; +import javax.swing.Icon; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.table.TableCellEditor; +import java.awt.Component; + +/** + * @author chemit + * @since 1.5 + */ +public class MyDefaultCellEditor extends DefaultCellEditor { + + private static final long serialVersionUID = 1L; + + public static TableCellEditor newTextEditor() { + return new MyDefaultCellEditor(new JTextField()); + } + + public static TableCellEditor newBooleanEditor() { + return new MyDefaultCellEditor(new JCheckBox()); + } + + public static TableCellEditor newListEditor() { + return newListEditor(new JComboBox()); + } + + public static TableCellEditor newListEditor(JComboBox editor) { + return new MyDefaultCellEditor(editor); + } + + public static TableCellEditor newEnumEditor(EnumEditor editor) { + return new MyDefaultCellEditor(editor) { + + private static final long serialVersionUID = 1L; + + @Override + public Object getCellEditorValue() { + Object value = super.getCellEditorValue(); + if (value != null) { + value = ((Enum) value).ordinal(); + } else { + value = -1; + } + return value; + } + }; + } + + public static TableCellEditor newBooleanEditor(Icon icon) { + return new MyDefaultCellEditor(new JCheckBox(icon)); + } + + public static TableCellEditor newBooleanEditor(Icon icon, boolean requireSelect) { + TableCellEditor cellEditor = newBooleanEditor(icon); + ((MyDefaultCellEditor) cellEditor).setRequireSelect(requireSelect); + return cellEditor; + } + + public static TableCellEditor newBooleanEditor(boolean requireSelect) { + TableCellEditor cellEditor = newBooleanEditor(); + ((MyDefaultCellEditor) cellEditor).setRequireSelect(requireSelect); + return cellEditor; + } + protected boolean requireSelect = true; + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + if (!isSelected && requireSelect) { + // force to have select the cell before editing, a way to not modify edition for nothing... + return null; + } + return super.getTableCellEditorComponent(table, value, isSelected, row, column); + } + + public boolean isRequireSelect() { + return requireSelect; + } + + public void setRequireSelect(boolean requireSelect) { + this.requireSelect = requireSelect; + } + + protected MyDefaultCellEditor(JTextField textField) { + super(textField); + setClickCountToStart(1); + } + + protected MyDefaultCellEditor(JCheckBox checkBox) { + super(checkBox); + setClickCountToStart(1); + } + + protected MyDefaultCellEditor(JComboBox comboBox) { + super(comboBox); + setClickCountToStart(1); + } +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/MyDefaultCellEditor.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/OneClicListSelectionModel.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/OneClicListSelectionModel.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/OneClicListSelectionModel.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/OneClicListSelectionModel.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,181 @@ +package jaxx.runtime.swing; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.swing.ListModel; +import javax.swing.ListSelectionModel; +import javax.swing.event.ListSelectionListener; +import java.util.Arrays; + +/** + * @author chemit + * @since 1.5 + */ +public class OneClicListSelectionModel implements ListSelectionModel { + + /** to use log facility, just put in your code: log.info("..."); */ + static private Log log = LogFactory.getLog(OneClicListSelectionModel.class); + protected ListSelectionModel delegate; + protected final ListModel model; + private boolean[] _states; + + public OneClicListSelectionModel(ListSelectionModel delegate, ListModel model) { + this.delegate = delegate; + this.model = model; + delegate.clearSelection(); + } + + protected boolean[] getStates(int selectedIndex) { + int max = model.getSize(); + if (_states == null || _states.length != max) { + _states = new boolean[max]; + } else { + Arrays.fill(_states, false); + } + for (int i = 0; i < max; i++) { + _states[i] = i != selectedIndex && delegate.isSelectedIndex(i); + } + return _states; + } + + @Override + public void setSelectionInterval(int index0, int index1) { + if (index0 != index1) { + // not a single selection (come from a click) + // use default behaviour + delegate.setSelectionInterval(index0, index1); + return; + } + delegate.setValueIsAdjusting(true); + + try { + int max = model.getSize(); + + if (log.isDebugEnabled()) { + log.debug("single [index:" + index0 + "] [selected:" + isSelectedIndex(index0) + "] [size:" + max + "] [anchor:" + delegate.getAnchorSelectionIndex() + "] [lead:" + delegate.getLeadSelectionIndex() + "]"); + } + + if (!isSelectedIndex(index0)) { + // select it + delegate.addSelectionInterval(index0, index1); + return; + } + if (max == index0) { + // last selected index, so can directly remove it + delegate.removeIndexInterval(index0, index0); + return; + } + + // must recompute the selection removing only the index0 item + boolean[] state = getStates(index0); + + if (log.isDebugEnabled()) { + log.debug("state : " + Arrays.toString(state)); + } + delegate.clearSelection(); + for (int i = 0; i < max; i++) { + if (state[i]) { + delegate.addSelectionInterval(i, i); + } + } + } finally { + delegate.setValueIsAdjusting(false); + } + } + + @Override + public void addSelectionInterval(int index0, int index1) { + delegate.addSelectionInterval(index0, index1); + } + + @Override + public void removeSelectionInterval(int index0, int index1) { + delegate.removeSelectionInterval(index0, index1); + } + + @Override + public int getMinSelectionIndex() { + return delegate.getMinSelectionIndex(); + } + + @Override + public int getMaxSelectionIndex() { + return delegate.getMaxSelectionIndex(); + } + + @Override + public boolean isSelectedIndex(int index) { + return delegate.isSelectedIndex(index); + } + + @Override + public int getAnchorSelectionIndex() { + return delegate.getAnchorSelectionIndex(); + } + + @Override + public void setAnchorSelectionIndex(int index) { + delegate.setAnchorSelectionIndex(index); + } + + @Override + public int getLeadSelectionIndex() { + return delegate.getLeadSelectionIndex(); + } + + @Override + public void setLeadSelectionIndex(int index) { + delegate.setLeadSelectionIndex(index); + } + + @Override + public void clearSelection() { + delegate.clearSelection(); + } + + @Override + public boolean isSelectionEmpty() { + return delegate.isSelectionEmpty(); + } + + @Override + public void insertIndexInterval(int index, int length, boolean before) { + delegate.insertIndexInterval(index, length, before); + } + + @Override + public void removeIndexInterval(int index0, int index1) { + delegate.removeIndexInterval(index0, index1); + } + + @Override + public void setValueIsAdjusting(boolean valueIsAdjusting) { + delegate.setValueIsAdjusting(valueIsAdjusting); + } + + @Override + public boolean getValueIsAdjusting() { + return delegate.getValueIsAdjusting(); + } + + @Override + public void setSelectionMode(int selectionMode) { + delegate.setSelectionMode(selectionMode); + } + + @Override + public int getSelectionMode() { + return delegate.getSelectionMode(); + } + + @Override + public void addListSelectionListener(ListSelectionListener x) { + delegate.addListSelectionListener(x); + } + + @Override + public void removeListSelectionListener(ListSelectionListener x) { + delegate.removeListSelectionListener(x); + } +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/OneClicListSelectionModel.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Spacer.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/Spacer.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Spacer.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Spacer.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,12 @@ +/* + * Copyright 2006 Ethan Nicholas. All rights reserved. + * Use is subject to license terms. + */ +package jaxx.runtime.swing; + +import javax.swing.JComponent; + +public class Spacer extends JComponent { + + private static final long serialVersionUID = 1L; +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Spacer.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/TabInfo.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,165 @@ +/* + * Copyright 2006 Ethan Nicholas. All rights reserved. + * Use is subject to license terms. + */ +package jaxx.runtime.swing; + +import javax.swing.Icon; +import javax.swing.event.SwingPropertyChangeSupport; +import java.awt.Color; +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; + +public class TabInfo { + + public static String BACKGROUND_PROPERTY = "background"; + public static String DISABLED_ICON_PROPERTY = "disabledIcon"; + public static String DISPLAYED_MNEMONIC_INDEX_PROPERTY = "displayedMnemonicIndex"; + public static String ENABLED_PROPERTY = "enabled"; + public static String FOREGROUND_PROPERTY = "foreground"; + public static String ICON_PROPERTY = "icon"; + public static String MNEMONIC_PROPERTY = "mnemonic"; + public static String TITLE_PROPERTY = "title"; + public static String TOOL_TIP_TEXT_PROPERTY = "toolTipText"; + private String id; + private Color background; + private Icon disabledIcon; + private int displayedMnemonicIndex = -1; + private boolean enabled = true; + private Color foreground; + private Icon icon; + private int mnemonic = -1; + private String title; + private String toolTipText; + private PropertyChangeSupport propertyChangeSupport; + + public TabInfo() { + } + + public TabInfo(String id) { + this.id = id; + } + + public String getId() { + return id; + } + + public Color getBackground() { + return background; + } + + public void setBackground(Color background) { + Color oldValue = this.background; + this.background = background; + firePropertyChange(BACKGROUND_PROPERTY, oldValue, background); + } + + public Icon getDisabledIcon() { + return disabledIcon; + } + + public void setDisabledIcon(Icon disabledIcon) { + Icon oldValue = this.disabledIcon; + this.disabledIcon = disabledIcon; + firePropertyChange(DISABLED_ICON_PROPERTY, oldValue, disabledIcon); + } + + public int getDisplayedMnemonicIndex() { + return displayedMnemonicIndex; + } + + public void setDisplayedMnemonicIndex(int displayedMnemonicIndex) { + int oldValue = this.displayedMnemonicIndex; + this.displayedMnemonicIndex = displayedMnemonicIndex; + firePropertyChange(DISPLAYED_MNEMONIC_INDEX_PROPERTY, oldValue, displayedMnemonicIndex); + } + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + boolean oldValue = this.enabled; + this.enabled = enabled; + firePropertyChange(ENABLED_PROPERTY, oldValue, enabled); + } + + public Color getForeground() { + return foreground; + } + + public void setForeground(Color foreground) { + Color oldValue = this.foreground; + this.foreground = foreground; + firePropertyChange(FOREGROUND_PROPERTY, oldValue, foreground); + } + + public Icon getIcon() { + return icon; + } + + public void setIcon(Icon icon) { + Icon oldValue = this.icon; + this.icon = icon; + firePropertyChange(ICON_PROPERTY, oldValue, icon); + } + + public int getMnemonic() { + return mnemonic; + } + + public void setMnemonic(int mnemonic) { + int oldValue = this.mnemonic; + this.mnemonic = mnemonic; + firePropertyChange(MNEMONIC_PROPERTY, oldValue, mnemonic); + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + String oldValue = this.title; + this.title = title; + firePropertyChange(TITLE_PROPERTY, oldValue, title); + } + + public String getToolTipText() { + return toolTipText; + } + + public void setToolTipText(String toolTipText) { + String oldValue = this.toolTipText; + this.toolTipText = toolTipText; + firePropertyChange(TOOL_TIP_TEXT_PROPERTY, oldValue, toolTipText); + } + + private PropertyChangeSupport getPropertyChangeSupport() { + if (propertyChangeSupport == null) { + propertyChangeSupport = new SwingPropertyChangeSupport(this); + } + return propertyChangeSupport; + } + + public void addPropertyChangeListener(PropertyChangeListener listener) { + getPropertyChangeSupport().addPropertyChangeListener(listener); + } + + public void addPropertyChangeListener(String property, PropertyChangeListener listener) { + getPropertyChangeSupport().addPropertyChangeListener(property, listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + getPropertyChangeSupport().removePropertyChangeListener(listener); + } + + public void removePropertyChangeListener(String property, PropertyChangeListener listener) { + getPropertyChangeSupport().removePropertyChangeListener(property, listener); + } + + protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { + if (propertyChangeSupport != null) { + getPropertyChangeSupport().firePropertyChange(propertyName, oldValue, newValue); + } + } +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,44 @@ +/* + * Copyright 2006 Ethan Nicholas. All rights reserved. + * Use is subject to license terms. + */ +package jaxx.runtime.swing; + +import javax.swing.Icon; +import javax.swing.JTabbedPane; +import java.awt.Color; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +public class TabInfoPropertyChangeListener implements PropertyChangeListener { + + private JTabbedPane tabs; + private int tabIndex; + + public TabInfoPropertyChangeListener(JTabbedPane tabs, int tabIndex) { + this.tabs = tabs; + this.tabIndex = tabIndex; + } + + @Override + public void propertyChange(PropertyChangeEvent e) { + String name = e.getPropertyName(); + if (name.equals(TabInfo.TITLE_PROPERTY)) { + tabs.setTitleAt(tabIndex, (String) e.getNewValue()); + } else if (name.equals(TabInfo.TOOL_TIP_TEXT_PROPERTY)) { + tabs.setToolTipTextAt(tabIndex, (String) e.getNewValue()); + } else if (name.equals(TabInfo.FOREGROUND_PROPERTY)) { + tabs.setForegroundAt(tabIndex, (Color) e.getNewValue()); + } else if (name.equals(TabInfo.BACKGROUND_PROPERTY)) { + tabs.setBackgroundAt(tabIndex, (Color) e.getNewValue()); + } else if (name.equals(TabInfo.MNEMONIC_PROPERTY)) { + tabs.setMnemonicAt(tabIndex, (Integer) e.getNewValue()); + } else if (name.equals(TabInfo.DISPLAYED_MNEMONIC_INDEX_PROPERTY)) { + tabs.setDisplayedMnemonicIndexAt(tabIndex, (Integer) e.getNewValue()); + } else if (name.equals(TabInfo.ICON_PROPERTY)) { + tabs.setIconAt(tabIndex, (Icon) e.getNewValue()); + } else if (name.equals(TabInfo.DISABLED_ICON_PROPERTY)) { + tabs.setDisabledIconAt(tabIndex, (Icon) e.getNewValue()); + } + } +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Table.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/Table.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Table.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Table.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,58 @@ +/* + * Copyright 2006 Ethan Nicholas. All rights reserved. + * Use is subject to license terms. + */ +package jaxx.runtime.swing; + +import javax.swing.JPanel; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.LayoutManager; + +/** + * Panel which uses a {@link GridBagLayout} by default. + * + * @author Ethan Nicholas + */ +public class Table extends JPanel { + + private static final long serialVersionUID = 1L; + public static final Insets DEFAULT_INSETS = new Insets(3, 3, 3, 3); + private GridBagConstraints tableConstraints = new GridBagConstraints(); + private GridBagConstraints rowConstraints = null; + private GridBagConstraints cellConstraints = null; + + public Table() { + super.setLayout(new GridBagLayout()); + + tableConstraints.insets = DEFAULT_INSETS; + } + + @Override + public void setLayout(LayoutManager layout) { + // do nothing + } + + public GridBagConstraints getTableConstraints() { + return tableConstraints; + } + + public GridBagConstraints getRowConstraints() { + return rowConstraints; + } + + public GridBagConstraints getCellConstraints() { + return cellConstraints; + } + + public void newRow() { + tableConstraints.gridy++; + rowConstraints = (GridBagConstraints) tableConstraints.clone(); + } + + public void newCell() { + rowConstraints.gridx++; + cellConstraints = (GridBagConstraints) rowConstraints.clone(); + } +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Table.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBox.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/VBox.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBox.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBox.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,94 @@ +/* + * Copyright 2006 Ethan Nicholas. All rights reserved. + * Use is subject to license terms. + */ +package jaxx.runtime.swing; + +import javax.swing.JPanel; +import java.awt.Insets; + +/** + * Panel which uses a {@link VBoxLayout} by default. + * + * @author Ethan Nicholas + */ +public class VBox extends JPanel { + + private static final long serialVersionUID = 1L; + public static final String SPACING_PROPERTY = "spacing"; + public static final String MARGIN_PROPERTY = "margin"; + public static final String HORIZONTAL_ALIGNMENT_PROPERTY = "horizontalAlignment"; + public static final String VERTICAL_ALIGNMENT_PROPERTY = "verticalAlignment"; + private Insets margin; + + public VBox() { + super(new VBoxLayout()); + } + + /** + * Returns the spacing between components, in pixels. Spacing is applied between components only, + * not to the top or bottom of the container. + * + * @return spacing between components + */ + public int getSpacing() { + return ((VBoxLayout) getLayout()).getSpacing(); + } + + /** + * Sets the spacing between components. Spacing is applied between components only, + * not to the top or bottom of the container. + * + * @param spacing new spacing value + */ + public void setSpacing(int spacing) { + int oldValue = getSpacing(); + ((VBoxLayout) getLayout()).setSpacing(spacing); + firePropertyChange(SPACING_PROPERTY, oldValue, spacing); + revalidate(); + } + + public int getHorizontalAlignment() { + return ((VBoxLayout) getLayout()).getHorizontalAlignment(); + } + + public void setHorizontalAlignment(int horizontalAlignment) { + int oldValue = getHorizontalAlignment(); + ((VBoxLayout) getLayout()).setHorizontalAlignment(horizontalAlignment); + firePropertyChange(HORIZONTAL_ALIGNMENT_PROPERTY, oldValue, horizontalAlignment); + revalidate(); + } + + public int getVerticalAlignment() { + return ((VBoxLayout) getLayout()).getVerticalAlignment(); + } + + public void setVerticalAlignment(int verticalAlignment) { + int oldValue = getVerticalAlignment(); + ((VBoxLayout) getLayout()).setVerticalAlignment(verticalAlignment); + firePropertyChange(VERTICAL_ALIGNMENT_PROPERTY, oldValue, verticalAlignment); + revalidate(); + } + + public Insets getMargin() { + return margin; + } + + public void setMargin(Insets margin) { + Insets oldValue = this.margin; + this.margin = (Insets) margin.clone(); + firePropertyChange(MARGIN_PROPERTY, oldValue, margin); + } + + @Override + public Insets getInsets() { + Insets result = super.getInsets(); + if (margin != null) { + result.top += margin.top; + result.left += margin.left; + result.right += margin.right; + result.bottom += margin.bottom; + } + return result; + } +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBox.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxLayout.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/VBoxLayout.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxLayout.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxLayout.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,127 @@ +/* + * Copyright 2006 Ethan Nicholas. All rights reserved. + * Use is subject to license terms. + */ +package jaxx.runtime.swing; + +import javax.swing.SwingConstants; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Insets; +import java.awt.LayoutManager; + +/** + * Vertical box layout. The layout rules followed by this class are quite different than the core BoxLayout class, + * and in general represent a more useful algorithm. + * + * @author Ethan Nicholas + */ +public class VBoxLayout implements LayoutManager { + + private int spacing = 6; + private int horizontalAlignment = SwingConstants.LEFT; + private int verticalAlignment = SwingConstants.TOP; + + public int getSpacing() { + return spacing; + } + + public void setSpacing(int spacing) { + this.spacing = spacing; + } + + public int getHorizontalAlignment() { + return horizontalAlignment; + } + + public void setHorizontalAlignment(int horizontalAlignment) { + this.horizontalAlignment = horizontalAlignment; + } + + public int getVerticalAlignment() { + return verticalAlignment; + } + + public void setVerticalAlignment(int verticalAlignment) { + this.verticalAlignment = verticalAlignment; + } + + @Override + public void addLayoutComponent(String name, Component comp) { + } + + @Override + public void layoutContainer(Container parent) { + Insets insets = parent.getInsets(); + int parentWidth = parent.getSize().width - insets.left - insets.right; + int count = parent.getComponentCount(); + Dimension preferredSize = parent.getPreferredSize(); + int y; + switch (verticalAlignment) { + case SwingConstants.TOP: + y = insets.top; + break; + case SwingConstants.CENTER: + y = insets.top + (parent.getHeight() - preferredSize.height) / 2; + break; + case SwingConstants.BOTTOM: + y = insets.top + (parent.getHeight() - preferredSize.height); + break; + default: + throw new IllegalArgumentException("invalid vertical alignment: " + verticalAlignment); + } + + for (int i = 0; i < count; i++) { + Component component = parent.getComponent(i); + Dimension childPreferredSize = component.getPreferredSize(); + int width = Math.min(childPreferredSize.width, parentWidth); + int x; + switch (horizontalAlignment) { + case SwingConstants.LEFT: + x = insets.left; + break; + case SwingConstants.CENTER: + x = insets.left + (parentWidth - childPreferredSize.width) / 2; + break; + case SwingConstants.RIGHT: + x = insets.left + (parentWidth - childPreferredSize.width); + break; + default: + throw new IllegalArgumentException("invalid horizontal alignment: " + horizontalAlignment); + } + component.setBounds(x, y, width, childPreferredSize.height); + y += childPreferredSize.height + spacing; + } + } + + @Override + public Dimension minimumLayoutSize(Container parent) { + int width = 0; + int height = (parent.getComponentCount() - 1) * spacing; + for (int i = parent.getComponentCount() - 1; i >= 0; i--) { + Dimension minimumSize = parent.getComponent(i).getMinimumSize(); + width = Math.max(width, minimumSize.width); + height += minimumSize.height; + } + Insets insets = parent.getInsets(); + return new Dimension(width + insets.left + insets.right, height + insets.top + insets.bottom); + } + + @Override + public Dimension preferredLayoutSize(Container parent) { + int width = 0; + int height = (parent.getComponentCount() - 1) * spacing; + for (int i = parent.getComponentCount() - 1; i >= 0; i--) { + Dimension preferredSize = parent.getComponent(i).getPreferredSize(); + width = Math.max(width, preferredSize.width); + height += preferredSize.height; + } + Insets insets = parent.getInsets(); + return new Dimension(width + insets.left + insets.right, height + insets.top + insets.bottom); + } + + @Override + public void removeLayoutComponent(Component comp) { + } +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxLayout.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/ClassCellEditor.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/editor/ClassCellEditor.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/ClassCellEditor.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/ClassCellEditor.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,119 @@ +/* +* *##% ui + * Copyright (C) 2008 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>. ##%* */ +package jaxx.runtime.swing.editor; + +import org.apache.commons.beanutils.Converter; +import org.nuiton.util.ConverterUtil; + +import javax.swing.DefaultCellEditor; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.event.CellEditorListener; +import javax.swing.table.TableCellEditor; +import java.awt.Component; +import java.util.EventObject; + +/** + * A class cell editor (fork from comandline project). + * + * @author chemit + */ +public class ClassCellEditor implements TableCellEditor { + + protected TableCellEditor delegate; + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + + String valStr = (value + "").trim(); + if (valStr.equals("null")) { + valStr = ""; + } else if (valStr.startsWith("class ")) { + valStr = valStr.substring(6); + } + Component comp; + comp = getDelegate().getTableCellEditorComponent(table, valStr, isSelected, row, column); + return comp; + } + + @Override + public Object getCellEditorValue() { + Object o = !hasDelegate() ? null : delegate.getCellEditorValue(); + if (o == null) { + return null; + } + Converter converter = ConverterUtil.getConverter(Class.class); + + try { + if (converter != null) { + return converter.convert(Class.class, o); + } + o = Class.forName(o + ""); + } catch (Exception e) { + o = null; + } + return o; + } + + @Override + public boolean isCellEditable(EventObject anEvent) { + return !hasDelegate() || delegate.isCellEditable(anEvent); + } + + @Override + public boolean shouldSelectCell(EventObject anEvent) { + return hasDelegate() && delegate.shouldSelectCell(anEvent); + } + + @Override + public boolean stopCellEditing() { + return !hasDelegate() || delegate.stopCellEditing(); + } + + @Override + public void cancelCellEditing() { + if (hasDelegate()) { + delegate.cancelCellEditing(); + } + } + + @Override + public void addCellEditorListener(CellEditorListener l) { + if (hasDelegate()) { + delegate.addCellEditorListener(l); + } + } + + @Override + public void removeCellEditorListener(CellEditorListener l) { + if (hasDelegate()) { + delegate.removeCellEditorListener(l); + } + } + + protected TableCellEditor getDelegate() { + if (delegate == null) { + delegate = new DefaultCellEditor(new JTextField()); + } + return delegate; + } + + protected boolean hasDelegate() { + return delegate != null; + } +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/ClassCellEditor.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/EnumEditor.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/editor/EnumEditor.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/EnumEditor.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/EnumEditor.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,57 @@ +/* + * *##% Lutin utilities library + * Copyright (C) 2004 - 2008 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>. ##%* */ +package jaxx.runtime.swing.editor; + +import javax.swing.JComboBox; +import java.util.EnumSet; +import org.nuiton.util.ReflectUtil; + +/** + * Une éditeur d'enum. + * + * @param <E> le type d'enumeration a editer. + * + * @author chemit + * + * @since 1.6.0 + */ +public class EnumEditor<E extends Enum<E>> extends JComboBox { + + /** serialVersionUID */ + private static final long serialVersionUID = 2693771553067104538L; + protected Class<E> type; + + public static <E extends Enum<E>> EnumEditor<E> newEditor(Class<E> type) { + return new EnumEditor<E>(type); + } + + public EnumEditor(Class<E> type) { + super(buildModel(type)); + } + + @Override + public E getSelectedItem() { + return (E) super.getSelectedItem(); + } + + protected static <E extends Enum<E>> Object[] buildModel(Class<E> type) { + Class<E> enumClass = ReflectUtil.getEnumClass(type); + EnumSet<E> result = EnumSet.allOf(enumClass); + return result.toArray(new Object[result.size()]); + } +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/EnumEditor.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/LocaleEditor.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/editor/LocaleEditor.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/LocaleEditor.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/LocaleEditor.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,64 @@ +/* +* *##% Lutin utilities library + * Copyright (C) 2004 - 2008 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>. ##%* */ +package jaxx.runtime.swing.editor; + +import javax.swing.JComboBox; +import java.util.Locale; +import org.nuiton.i18n.I18n; + +/** + * A {@link Locale} editor. + * <p/> + * use the static method to have an instance of editor {@link #newEditor(java.util.Locale[])} + * <p/> + * If no locale is given to this method, it will go and seek via + * {@link org.nuiton.i18n.I18nLoader#getLocales()} all loaded locales in i18n system + * + * @author chemit + * @since 1.6.0 + */ +public class LocaleEditor extends JComboBox { + + /** serialVersionUID */ + private static final long serialVersionUID = -6777873426011538807L; + + protected Locale[] type; + + public static LocaleEditor newEditor(Locale... type) { + return new LocaleEditor(type); + } + + public LocaleEditor(Locale... type) { + super(buildModel(type)); + } + + @Override + public Locale getSelectedItem() { + return (Locale) super.getSelectedItem(); + } + + protected static Locale[] buildModel(Locale... type) { + if (type.length > 0) { + return type; + } + // get availables locales registred in I18n system + type = I18n.getLoader().getLocales(); + return type; + } + +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/LocaleEditor.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationCardPanel.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationCardPanel.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationCardPanel.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationCardPanel.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,59 @@ +package jaxx.runtime.swing.navigation; + +import java.awt.CardLayout; +import java.awt.Component; +import javax.swing.JPanel; +import jaxx.runtime.swing.Item; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * + * @author letellier + * @since 1.7.2 + */ +public class ItemNavigationCardPanel extends JPanel { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private final Log log = LogFactory.getLog(ItemNavigationCardPanel.class); + private static final long serialVersionUID = 1L; + CardLayout layout; + + public ItemNavigationCardPanel() { + super(); + + layout = new CardLayout(); + setLayout(layout); + } + + public void showItem(Item i) { + if (i != null && i.getValue() != null) { + if (i.getValue() instanceof Class<?>) { + layout.show(this, i.getValue().getClass().getName()); + } else { + layout.show(this, i.getValue().getClass().getName()); + } + } + } + + public Component getShowedComponent() { + Component[] components = getComponents(); + if (components != null) { + for (Component c : components) { + if (c.isVisible()) { + return c; + } + } + } + return null; + } + + @Override + public Component add(Component comp) { + if (!(comp instanceof ItemNavigationPanel)) { + throw new IllegalArgumentException("ItemNavigationCardPanel must be have only ItemNavigationPanel children"); + } + super.add(comp, ((ItemNavigationPanel) comp).getAssociatedClass().getName()); + return comp; + } +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationCardPanel.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationPanel.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationPanel.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationPanel.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationPanel.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,28 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package jaxx.runtime.swing.navigation; + +import javax.swing.JPanel; + +/** + * + * @author letellier + */ +public class ItemNavigationPanel extends JPanel{ + + private static final long serialVersionUID = 1L; + + protected Class associatedClass = null; + + public ItemNavigationPanel(Class associatedClass) { + this.associatedClass = associatedClass; + } + + public Class getAssociatedClass() { + return associatedClass; + } + +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationPanel.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemTreeNavigationAdapter.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation/ItemTreeNavigationAdapter.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemTreeNavigationAdapter.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemTreeNavigationAdapter.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,64 @@ +package jaxx.runtime.swing.navigation; + +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.TreeModel; +import javax.swing.tree.TreePath; +import jaxx.runtime.JAXXObject; +import jaxx.runtime.swing.Item; +import jaxx.runtime.swing.JAXXTree; +import jaxx.runtime.swing.JAXXTree.JAXXTreeModel; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** A {@link javax.swing.event.TreeSelectionListener} implementation@@author letellier */ +public abstract class ItemTreeNavigationAdapter implements TreeSelectionListener { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private final Log log = LogFactory.getLog(ItemTreeNavigationAdapter.class); + + /** l'ui contenant l'arbre de navigation */ + protected JAXXObject context; + + protected JAXXTree tree; + protected ItemNavigationCardPanel cardPanel; + + public ItemTreeNavigationAdapter(JAXXObject context, JAXXTree tree, ItemNavigationCardPanel cardPanel) { + super(); + this.context = context; + this.tree = tree; + this.cardPanel = cardPanel; + + // Attache ce listener a l'arbre de navigation + tree.addTreeSelectionListener(this); + } + + @Override + public void valueChanged(TreeSelectionEvent e) { + log.debug("Selection in JAXXTree changed" + e.getPath()); + + // Recuperation du path selectionne + TreePath path = e.getNewLeadSelectionPath(); + TreeModel model = tree.getModel(); + + if (!(model instanceof JAXXTreeModel)){ + log.error("Its not an JAXXTreeModel"); + return; + } + // Find item coresponding + Item itemSelected = ((JAXXTreeModel) model).findItem(path.getLastPathComponent()); + + // Show corresponding panel + cardPanel.showItem(itemSelected); + + // Notifie change + valueChanged(itemSelected.getValue()); + } + + /** + * Method abstraite pour pouvoir propager la donnee selectionner + * + * @param data value of the node selected + */ + protected abstract void valueChanged(Object data); +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemTreeNavigationAdapter.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,244 @@ +package jaxx.runtime.swing.wizard; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.util.List; + +/** + * Un modèle de wizard. + * + * + * <b>Note:</b> le type des étapes doit être uné énumération qui implante + * {@link WizardStep}. + * + * @param <E> le type des étapes. + * + * @author tony + * @since 1.3 + * @see WizardStep + */ +public class WizardModel<E extends WizardStep> { + + public static final String STEPS_PROPERTY_NAME = "steps"; + public static final String STEP_PROPERTY_NAME = "step"; + public static final String PREVIOUS_STEP_PROPERTY_NAME = "previousStep"; + public static final String NEXT_STEP_PROPERTY_NAME = "nextStep"; + public static final String VALID_STEP_PROPERTY_NAME = "validStep"; + /** + * le type d'une etape du model (doit etre une enumeration) + */ + protected final Class<E> stepClass; + /** + * Toutes les étapes à passer + */ + protected List<E> steps; + /** les etapes a exclure */ + protected List<E> excludeSteps; + /** + * L'étape courante + */ + protected E step; + /** + * drapeau pour valider l'état de l'étape courante + */ + protected boolean validStep; + /** + * drapeau lorsque le modele effectue des operations + * de transformation de modele mais que les écouteurs + * ne devraient pas tenir compte des modifications + */ + protected boolean valueAdjusting; + /** + * pour propager les changements dans le modèle vers l'ui + */ + protected PropertyChangeSupport pcs; + + public WizardModel(Class<E> stepClass, E... steps) { + if (!Enum.class.isAssignableFrom(stepClass)) { + throw new IllegalArgumentException("stepClass must be an Enumeration but was " + stepClass.getName()); + } + this.stepClass = stepClass; + this.pcs = new PropertyChangeSupport(this); + this.steps = new java.util.ArrayList<E>(); + if (steps.length > 0) { + setSteps(steps); + } + } + + public void start() { + if (steps.isEmpty()) { + throw new IllegalStateException("can not start, no step found"); + } + step = null; + E startStep = steps.get(0); + setStep(startStep); + } + + public void gotoNextStep() { + E nextStep = getNextStep(); + if (nextStep == null) { + throw new IllegalStateException("no next step to go"); + } + setStep(nextStep); + } + + public void gotoPreviousStep() { + E previousStep = getPreviousStep(); + if (previousStep == null) { + throw new IllegalStateException("no previous step to go"); + } + setStep(previousStep); + } + + public void gotoStep(E e) { + if (e == null) { + throw new NullPointerException("step can not be null"); + } + if (!steps.contains(e)) { + throw new IllegalStateException("step " + e.toString() + " is not in universe of steps (" + steps + ")"); + } + setStep(e); + } + + public E getStep() { + return step; + } + + public int getStepIndex(E s) { + int index = steps.indexOf(s); + return index; + } + + public boolean isValidStep() { + return validStep; + } + + public E getPreviousStep() { + E e = getPreviousStep(step); + return e; + } + + public E getPreviousStep(E step) { + int index = getStepIndex(step); + if (index < 1) { + // si pas de step ou sur premier step + return null; + } + return steps.get(index - 1); + } + + public E getNextStep(E step) { + int index = getStepIndex(step); + if (index < 1) { + // si pas de step ou sur premier step + return null; + } + return steps.get(index - 1); + } + + public E getNextStep() { + int index = getStepIndex(step); + if (index == -1 || index == steps.size() - 1) { + // si pas de step positionne ou dernier etape + return null; + } + return steps.get(index + 1); + } + + public java.util.List<E> getSteps() { + return steps; + } + + public boolean isValueAdjusting() { + return valueAdjusting; + } + + /** + * Change l'univers des etapes. + * + * Note: on presume ici que l'étape courante est toujours la meme. + * + * @param steps le nouvel univers des etapes + */ + public void setSteps(E... steps) { + java.util.List<E> oldValue = this.steps; + this.steps = java.util.Collections.unmodifiableList(java.util.Arrays.asList(steps)); + firePropertyChange(STEPS_PROPERTY_NAME, oldValue, this.steps); + // la propriete nextStep peut avoir changee + firePropertyChange(NEXT_STEP_PROPERTY_NAME, null, getNextStep()); + } + + public void setValueAdjusting(boolean valueAdjusting) { + this.valueAdjusting = valueAdjusting; + } + + public void setExcludeSteps(List<E> excludeSteps) { + this.excludeSteps = excludeSteps; + } + public boolean validate(E s) { + return step != null; + } + + public void addPropertyChangeListener(PropertyChangeListener listener) { + pcs.addPropertyChangeListener(listener); + } + + public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { + pcs.addPropertyChangeListener(propertyName, listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + pcs.removePropertyChangeListener(listener); + } + + public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { + pcs.removePropertyChangeListener(propertyName, listener); + } + + public void removePropertyChangeListeners() { + for (PropertyChangeListener l : pcs.getPropertyChangeListeners()) { + pcs.removePropertyChangeListener(l); + } + } + + public void validate() { + if (step == null) { + // pas de validation quand aucune etape n'est sélectionnée + return; + } + boolean validate = validate(step); + this.validStep = validate; + // toujours forcer la propagation + firePropertyChange(VALID_STEP_PROPERTY_NAME, null, validStep); + } + + protected Class<E> getStepClass() { + return stepClass; + } + + protected void setStep(E step) { + E oldValue = this.step; + this.step = step; + firePropertyChange(STEP_PROPERTY_NAME, oldValue, step); + // la propriete nextStep peut avoir changee + firePropertyChange(NEXT_STEP_PROPERTY_NAME, null, getNextStep()); + // la propriete previousStep peut avoir changee + firePropertyChange(PREVIOUS_STEP_PROPERTY_NAME, null, getPreviousStep()); + validate(); + } + + protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { + pcs.firePropertyChange(propertyName, oldValue, newValue); + } + + protected void fireIndexedPropertyChange(String propertyName, int index, Object oldValue, Object newValue) { + pcs.fireIndexedPropertyChange(propertyName, index, oldValue, newValue); + } + + protected E[] updateStepUniverse() { + return null; + } + + protected void updateUniverse() { + } +} Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,108 @@ +package jaxx.runtime.swing.wizard; + +import javax.swing.SwingWorker; +import jaxx.runtime.JAXXContext; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * La classe de base a implanter pour definir l'action d'une operation + * dans un wizard. + * + * @author tony + * @param <E> le type d'étapes + * @param <M> le type de modèle + * @since 1.3 + */ +public abstract class WizardOperationAction<E extends WizardOperationStep, M extends WizardOperationModel<E>> extends SwingWorker<WizardOperationState, String> { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + private static final Log log = LogFactory.getLog(WizardOperationAction.class); + E operation; + WizardOperationState operationState; + Exception error; + + public WizardOperationAction(E operation) { + super(); + if (!operation.isOperation()) { + throw new IllegalArgumentException("the step " + operation + " has no operation defined"); + } + this.operation = operation; + } + + public E getOperation() { + return operation; + } + + public Exception getError() { + return error; + } + + public void setError(Exception e) { + error = e; + } + + public void sendMessage(String msg) { + firePropertyChange("message", null, msg); + } + + public abstract void start(JAXXContext context); + + public abstract void beforeAction(JAXXContext context, M model) throws Exception; + + public abstract WizardOperationState doAction(M model) throws Exception; + + public abstract WizardOperationState onError(M model, Exception e); + + public abstract WizardOperationState onCancel(M model, Exception e); + + protected abstract M getModel(); + + public WizardOperationState getOperationState() { + return operationState; + } + + protected abstract JAXXContext getContext(); + + @Override + public String toString() { + return super.toString() + " < operation: " + operation + ", state: " + getState() + " >"; + } + + @Override + protected WizardOperationState doInBackground() throws Exception { + log.trace(this); + WizardOperationState result; + M model = getModel(); + try { + beforeAction(getContext(), model); + result = doAction(model); + } catch (Exception e) { + error = e; + result = onError(model, e); + } + return result; + } + + @Override + protected void done() { + log.trace(this); + WizardOperationState result = null; + try { + if (isCancelled()) { + + result = onCancel(getModel(), error); + } else { + result = get(); + } + } catch (Exception e) { + result = WizardOperationState.FAILED; + error = e; + // ne devrait jamais arrivé ? + log.error(e.getMessage(), e); + } finally { + // on enregistre le resultat de l'opération + this.operationState = result; + } + } +} Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,204 @@ +package jaxx.runtime.swing.wizard; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.Date; +import javax.swing.SwingWorker.StateValue; +import jaxx.runtime.JAXXContext; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Thread qui réalise les opérations. + * + * Pour exécuter une nouvelle opération, on utilise la méthode + * {@link #launchOperation(SynchroActionWorker)}. + * + * Note: Pour bloquer (ou débloquer) le thread, on utilise la méthode {@link #setWaiting(boolean)} + * + * @param <E> le type des etapes + * @param <M> le type de modele + * @param <A> le type d'action d'operation + * + * @author tony + * @since 1.3 + */ +public abstract class WizardOperationActionThread<E extends WizardOperationStep, M extends WizardOperationModel<E>, A extends WizardOperationAction<E, M>> extends Thread implements PropertyChangeListener { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + private static final Log log = LogFactory.getLog(WizardOperationActionThread.class); + /** + * l'état du thread si annulé + */ + private boolean canceled; + protected Class<M> modelClass; + protected A currentAction; + /** + * un lock pour permettre la suspension et la reprise du thread + * lors du mode interactif. + */ + private final Object LOCK = new Object(); + + protected abstract M getModel(); + + protected abstract JAXXContext getContext(); + + public WizardOperationActionThread(Class<M> modelClass) throws IllegalArgumentException { + super(WizardOperationActionThread.class.getSimpleName() + " " + new Date()); + this.modelClass = modelClass; + } + + public void cancel() { + log.info("cancel " + this); + this.canceled = true; + + // on annule le modele + getModel().cancel(); + + // on rend la main au thread + setWaiting(false); + } + + @SuppressWarnings("unchecked") + public A launchOperation(E operation) { + + if (currentAction != null && (!currentAction.isDone() || currentAction.operationState == WizardOperationState.RUNNING)) { + // on ne peut traiter qu'une seule opération à la fois + throw new IllegalStateException("can not add a operation when thread is busy, or has another operation to be done"); + } + currentAction = (A) getModel().getOperationAction(operation); + + // on libere le thread pour qu'il execute l'opération + setWaiting(false); + + return currentAction; + } + + public A getCurrentAction() { + return currentAction; + } + + @Override + public void propertyChange(PropertyChangeEvent evt) { + log.trace(evt.getPropertyName() + " <" + evt.getOldValue() + " - " + evt.getNewValue() + ">"); + if ("state".equals(evt.getPropertyName())) { + StateValue state = (StateValue) evt.getNewValue(); + if (state == StateValue.DONE) { + // on rend la main au thread pour qu'il attende une prochaine operation + setWaiting(false); + } + } + } + + @Override + public void run() { + try { + + // on vérifie que le context contient bien le modèle + if (getModel() == null) { + throw new NullPointerException("could not find model " + modelClass + " for " + this); + } + + while (!canceled) { + + if (canceled) { + // une annulation a été demandé + // donc même si une opération est demandée, on ne la traite + // pas + break; + } + + // en attente qu'une opération + // le block est bloqué jusqu'à arrivée d'une opération + // ou une demande d'annulation + setWaiting(true); + + // le thread a repris la main, donc plus en attente + log.trace("no more waiting " + this); + + if (!canceled) { + // une opération a été demandée + + // le thread écoute les modifications de l'action + currentAction.addPropertyChangeListener(this); + + // l'opération passe en etant en cours + getModel().setOperationState(WizardOperationState.RUNNING); + + // démarrage de l'opération dans un worker + currentAction.start(getContext()); + // le thread est bloqué jusqu'à la fin de l'opération + // ou une demande d'annulation + setWaiting(true); + + // le thread reprend la main des que l'operation + // est terminée ou a été annulée, on passera alors + // dans la méthode onPropertyChanged + + if (canceled) { + getModel().setOperationState(WizardOperationState.CANCELED); + } else { + getModel().setOperationState(currentAction.getOperationState()); + } + + // le thread n'écoute plus l'action car elle est terminée + // ou annulée + currentAction.removePropertyChangeListener(this); + // suppression de l'action + //currentAction = null; + } + + } + + } catch (Exception e) { + throw new RuntimeException(e); + } finally { + unlockThread(); + log.trace(this + " will close..."); + close(); + } + } + + /** + * La méthode pour nettoyer le thread, a la fermeture. + * + */ + protected void close() { + // par defaut, on ne fait rien + log.trace(this); + } + + protected void setWaiting(boolean waiting) { + + if (waiting && !canceled) { + // locking thread + try { + lockThread(); + } catch (InterruptedException ex) { + log.error(ex.getMessage(), ex); + canceled = true; + } + } + + if (!waiting) { + // release lock + unlockThread(); + } + } + + protected void lockThread() throws InterruptedException { + synchronized (LOCK) { + log.trace(this); + // lock + LOCK.wait(); + } + } + + protected void unlockThread() { + synchronized (LOCK) { + log.trace(this); + // unlock + LOCK.notify(); + } + } +} Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,269 @@ +package jaxx.runtime.swing.wizard; + +import java.util.Arrays; +import java.util.EnumMap; +import java.util.EnumSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import javax.swing.SwingWorker.StateValue; + +/** + * Un modèle de wizard avec des opérations. + * + * @param <E> le type des étapes. + * @author tony + * @since 1.3 + */ +public class WizardOperationModel<E extends WizardOperationStep> extends WizardModel<E> { + + public static final String OPERATIONS_PROPERTY_NAME = "operations"; + public static final String OPERATION_STATE_PROPERTY_NAME = "operationState"; + public static final String MODEL_STATE_PROPERTY_NAME = "modelState"; + public static final String WAS_STARTED_PROPERTY_NAME = "wasStarted"; + + /** + * La liste des opérations à effectuer + */ + protected Set<E> operations; + /** + * Pour conserver les états des opérations + */ + protected Map<E, WizardOperationState> operationStates; + protected Map<E, WizardOperationAction> operationActions; + /** + * L'état générale du modèle + */ + protected WizardOperationState modelState; + /** + * un drapeau pour savoir siune opération a été lancée + */ + protected boolean wasStarted; + + @SuppressWarnings("unchecked") + public <T extends Enum<T>> WizardOperationModel(Class<E> stepClass, E... steps) { + super(stepClass, steps); + Class<T> k = (Class) stepClass; + this.operationStates = (Map) new EnumMap(k); + this.operations = (Set<E>) EnumSet.noneOf(k); + this.operationActions = (Map) new EnumMap(k); + } + + public Set<E> getOperations() { + return operations; + } + + public WizardOperationState getModelState() { + return modelState; + } + + public boolean isWasStarted() { + return wasStarted; + } + + @SuppressWarnings("unchecked") + public E getOperation() { + return getStep() != null && getStep().isOperation() ? getStep() : null; + } + + public WizardOperationState getOperationState() { + E operation = getOperation(); + return getOperationState(operation); + } + + public WizardOperationState getOperationState(E operation) { + return operationStates.get(operation); + } + + public WizardOperationAction getOperationAction(E operation) { + WizardOperationAction action = operationActions.get(operation); + if (action == null) { + try { + action = operation.getActionClass().newInstance(); + operationActions.put(operation, action); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + return action; + } + + public void setOperationState(WizardOperationState operationState) { + E operation = getOperation(); + setOperationState(operation, operationState); + } + + public void setOperationState(E operation, WizardOperationState operationState) { + WizardOperationState oldValue = getOperationState(operation); + this.operationStates.put(operation, operationState); + fireIndexedPropertyChange(OPERATION_STATE_PROPERTY_NAME, getSteps().indexOf(operation), oldValue, operationState); + updateModelState(operation, operationState); + validate(); + } + + public boolean[] getAccessibleSteps() { + boolean[] result = new boolean[getSteps().size()]; + int index = getSteps().indexOf(getStep()); + if (index != -1) { + + for (int i = 0, j = steps.size(); i < j; i++) { + if (i <= index) { + // tous les onglets inferieur ou egal au courant sont accessibles + result[i] = true; + continue; + } + // les onglets au dela de l'onglet sélectionné sont accessibles + // uniquement si l'onglet precedent est accessible, valide et son etat est a SUCCESSED + E previousStep = steps.get(i - 1); + result[i] = modelState == WizardOperationState.SUCCESSED || + (result[i - 1] && + validate(previousStep) && + (!previousStep.isOperation() || getOperationState(previousStep) == WizardOperationState.SUCCESSED)); + } + } + //System.out.println("accessibles steps -------- " + java.util.Arrays.toString(result)); + return result; + } + + @Override + public void start() { + super.start(); + updateUniverse(); + //setSteps(steps.toArray((E[]) Array.newInstance(stepClass, steps.size()))); + + // le modèle n'est pas démarré + setModelState(WizardOperationState.PENDING); + } + + public void cancel() { + + for (E op : operations) { + if (getOperationState(op) == WizardOperationState.PENDING) { + // on annule l'opération à venir + setOperationState(op, WizardOperationState.CANCELED); + } + } + setModelState(WizardOperationState.CANCELED); + if (getStep() != null && getStep().isOperation()) { + WizardOperationAction action = getOperationAction(getStep()); + if (action != null) { + if (!action.isCancelled() && !action.isDone() && action.getState() == StateValue.STARTED) { + System.out.println("cancel action " + action); + // on annule l'action + action.cancel(true); + } + } + } + } + + public WizardOperationModel<E> addOperation(E operation) { + operations.add(operation); + // mis a jour de l'univers des etapes et operations + updateUniverse(); + // validation + validate(); + return this; + } + + public void removeOperation(E operation) { + operations.remove(operation); + + // mis a jour de l'univers des etapes et operations + updateUniverse(); + // validation + validate(); + } + + @Override + public void setSteps(E... steps) { + super.setSteps(steps); + // on force la propagation de la nouvelle liste + firePropertyChange(OPERATIONS_PROPERTY_NAME, null, operations); + updateOperationStates(Arrays.asList(steps)); + } + + public void updateOperationStates(List<E> steps) { + int index = 0; + for (E e : steps) { + fireIndexedPropertyChange(OPERATION_STATE_PROPERTY_NAME, index++, null, getOperationState(e)); + } + firePropertyChange(MODEL_STATE_PROPERTY_NAME, null, modelState); + } + + public WizardOperationAction reloadOperation(E operation) { + operationActions.remove(operation); + WizardOperationAction newOp = getOperationAction(operation); + return newOp; + } + + protected void setModelState(WizardOperationState modelState) { + WizardOperationState oldValue = this.modelState; + this.modelState = modelState; + firePropertyChange(MODEL_STATE_PROPERTY_NAME, oldValue, modelState); + if (!wasStarted) { + if ((oldValue == null || oldValue == WizardOperationState.PENDING) && modelState == WizardOperationState.RUNNING) { + this.wasStarted = true; + firePropertyChange(WAS_STARTED_PROPERTY_NAME, false, true); + } + } + } + + protected void updateModelState(E operation, WizardOperationState operationState) { + + switch (operationState) { + case RUNNING: + //le modele est occupé + setModelState(WizardOperationState.RUNNING); + break; + case FAILED: + //le modele est en erreur + setModelState(WizardOperationState.FAILED); + break; + case CANCELED: + //le modele devient annulé + setModelState(WizardOperationState.CANCELED); + return; + case PENDING: + //le modele est en attente + setModelState(WizardOperationState.PENDING); + break; + case NEED_FIX: + //le modele est en attente + setModelState(WizardOperationState.PENDING); + break; + case SUCCESSED: + // on regarde si on peut passer le model a l'état success + boolean valid = true; + for (E o : operations) { + if (getOperationState(o) != WizardOperationState.SUCCESSED) { + valid = false; + break; + } + } + if (valid) { + setModelState(WizardOperationState.SUCCESSED); + } else { + setModelState(WizardOperationState.PENDING); + } + break; + } + updateOperationStates(steps); + } + + @Override + protected void updateUniverse() { + E[] newSteps = updateStepUniverse(); + setSteps(newSteps); + } + + protected int getOperationIndex(E operation) { + int index = 0; + for (E o : operations) { + if (operation == o) { + return index; + } + index++; + } + return -1; + } +} Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,32 @@ +package jaxx.runtime.swing.wizard; + +/** + * Pour caractériser l'état d'une opération. + */ +public enum WizardOperationState { + + /** + * quand l'opération n'a pas encore été réalisée + */ + PENDING, + /** + * quand l'opération est en cours + */ + RUNNING, + /** + * quand l'opération est annulé en cours d'exécution + */ + CANCELED, + /** + * quand une erreur s'est produite pendant l'exécution + */ + FAILED, + /** + * quand l'exécution s'est terminée mais requière des corrections + */ + NEED_FIX, + /** + * quand l'exécution s'est terminée et ne requière pas de correction + */ + SUCCESSED +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,34 @@ +package jaxx.runtime.swing.wizard; + +/** + * + * Le contrat a implanter pour une etapes dans le modèle de wizard avec + * opérations. + * + * @author tony + * @since 1.3 + */ +public interface WizardOperationStep extends WizardStep { + + /** + * @return le label de l'opération + */ + String getOperationLabel(); + + /** + * @return la description de l'opération + */ + String getOperationDescription(); + + /** + * @return le type de l'action associée à l'étape ou <code>null</code> si + * l'étape n'a pas d'opération associée. + */ + Class<? extends WizardOperationAction> getActionClass(); + + /** + * @return <code>true</code> si l'étape a une opération associée, + * <code>false</code> sinon. + */ + boolean isOperation(); +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,20 @@ +package jaxx.runtime.swing.wizard; + +import java.io.Serializable; + +/** + * le contrat d'une étape d'un wizard. + * + * @author tony + * @since 1.3 + */ +public interface WizardStep extends Serializable { + + String name(); + + int ordinal(); + + String getLabel(); + + String getDescription(); +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,14 @@ +package jaxx.runtime.swing.wizard; + +/** + * Le contrat d'une ui d'étape. + * + * @param <E> le type d'étape + * @param <M> le type de modèle + * @author tony + * @since 1.3 + */ +public interface WizardStepUI<E extends WizardStep, M extends WizardModel<E>> { + + E getStep(); +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,94 @@ +package jaxx.runtime.swing.wizard; + +import javax.swing.JTabbedPane; + +/** + * + * Contrat a respecter pour une ui de wizard. + * + * @param <E> le type d'etape + * @param <M> le type de model + * + * @author tony + * @since 1.3 + */ +public interface WizardUI<E extends WizardStep, M extends WizardModel<E>> { + + /** + * @return le modèle de wizard + */ + M getModel(); + + /** + * + * @return l'étape courante + */ + E getSelectedStep(); + + /** + * + * @return l'ui de l'étape courante + */ + WizardStepUI<E, M> getSelectedStepUI(); + + /** + * + * @param step l'étape donnée + * @return l'ui de l'étape donnée + */ + WizardStepUI<E, M> getStepUI(E step); + + /** + * + * @param stepIndex la position de l'étape + * @return l'ui de l'étape donée + */ + WizardStepUI<E, M> getStepUI(int stepIndex); + + /** + * démarre le wizard + */ + void start(); + + /** + * //TODO il faudrait supprimer cette méthode + * @return le conteneur d'ui d'étapes + */ + JTabbedPane getTabs(); + + /** + * Méthode invoqué lorsque la première opération du modèlé a été démarrée. + */ + void onWasStarted(); + + /** + * Méthode invoquée lorsque l'univers des étapes a été modifié dans le + * modèle. + * + * @param steps les nouvelles étapes + */ + void onStepsChanged(E[] steps); + + /** + * Méthode invoquée lorsque l'étape courante a changé dans le modèle. + * + * @param newStep la nouvelle étape courante + */ + void onStepChanged(E newStep); + + /** + * Méthode invoquée lorsque l'état interne du modèle a changé. + * + * @param newState le nouvelle état du modèle de wizard + */ + void onModelStateChanged(WizardOperationState newState); + + /** + * Méthode invoqué lorsque l'état d'une opération a changé. + * + * @param step l'étape dont l'état a changé + * @param newState le nouvel état pour l'étape donné + */ + void onOperationStateChanged(E step,WizardOperationState newState) ; + +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,162 @@ +package jaxx.runtime.swing.wizard; + +import java.awt.Window; +import javax.swing.ImageIcon; +import jaxx.runtime.JAXXContext; +import jaxx.runtime.JAXXInitialContext; +import jaxx.runtime.JAXXObject; +import org.apache.commons.beanutils.ConstructorUtils; + +/** + * + * Une classe pour lancer une ui de wizard. + * + * @param <E> le type des etapes + * @param <M> le type de modele + * @param <UI> le type d'ui + * @author tony + * @since 1.3 + */ +public abstract class WizardUILancher<E extends WizardStep, M extends WizardModel<E>, UI extends WizardUI<E, M>> { + + protected UI ui; + + public WizardUILancher(JAXXContext context, Class<UI> uiClass, Class<M> modelClass, String title, String tip, ImageIcon icon) { + this(context, uiClass, modelClass, null, title, tip, icon); + } + + public WizardUILancher(JAXXContext context, Class<UI> uiClass, Class<M> modelClass, M model, String title, String tip, ImageIcon icon) { + try { + ui = createUI(context, uiClass, modelClass, model, title, tip, icon); + } catch (Exception ex) { + throw new RuntimeException("could not instanciate launcher for reason " + ex.getMessage(), ex); + } + } + + public WizardUILancher(JAXXContext context, Window mainUI, Class<UI> uiClass, Class<M> modelClass, M model) { + try { + ui = createUI(context, mainUI, uiClass, modelClass, model); + } catch (Exception ex) { + throw new RuntimeException("could not instanciate launcher for reason " + ex.getMessage(), ex); + } + } + + public WizardUILancher(JAXXContext context, Window mainUI, Class<UI> uiClass, Class<M> modelClass) { + this(context, mainUI, uiClass, modelClass, null); + } + + public void start() { + init(ui); + start(ui); + } + + protected void start(UI ui) { + ui.start(); + } + + public <T> T getContextValue(Class<T> clazz, String name) { + if (ui == null) { + throw new NullPointerException("ui can not be null"); + } + if (!(ui instanceof JAXXObject)) { + throw new ClassCastException("ui can not be casted to JAXXObject "); + } + + return ((JAXXObject) ui).getContextValue(clazz, name); + } + + public <T> T getContextValue(Class<T> clazz) { + return getContextValue(clazz, null); + } + + protected void init(UI ui) { + } + + protected void doAction(UI ui) { + } + + protected void doCancel(UI ui) { + } + + protected void doClose(UI ui, boolean wasCanceld) { + } + + @SuppressWarnings("unchecked") + protected UI createUI(JAXXContext context, Window mainUI, Class<UI> uiClass, Class<M> modelClass, M model) throws Exception { + JAXXInitialContext uiContext = new JAXXInitialContext(); + uiContext.add(mainUI == null ? context : mainUI); + // parent context model + uiContext.add(modelClass.newInstance()); + if (model != null) { + uiContext.add("incoming", model); + } + // apply action + uiContext.add("apply", new Runnable() { + + @Override + public void run() { + try { + doAction(ui); + } finally { + doClose(ui, false); + } + } + }); + // cancel action + uiContext.add("cancel", new Runnable() { + + @Override + public void run() { + try { + doCancel(ui); + } finally { + doClose(ui, true); + } + } + }); + + // instanciate ui + + UI newUI = (UI) ConstructorUtils.invokeConstructor(uiClass, new Object[]{mainUI, uiContext}, new Class[]{Window.class, JAXXContext.class}); + return newUI; + } + + @SuppressWarnings("unchecked") + protected UI createUI(JAXXContext context, Class<UI> uiClass, Class<M> modelClass, M model, String title, String tip, ImageIcon icon) throws Exception { + JAXXInitialContext uiContext = new JAXXInitialContext(); + uiContext.add(context); + // parent context model + uiContext.add(modelClass.newInstance()); + if (model != null) { + uiContext.add("incoming", model); + } + // apply action + uiContext.add("apply", new Runnable() { + + @Override + public void run() { + try { + doAction(ui); + } finally { + doClose(ui, false); + } + } + }); + // cancel action + uiContext.add("cancel", new Runnable() { + + @Override + public void run() { + try { + doCancel(ui); + } finally { + doClose(ui, true); + } + } + }); + + // instanciate ui + UI newUI = (UI) ConstructorUtils.invokeConstructor(uiClass, new Object[]{uiContext, title, tip, icon}, new Class[]{JAXXContext.class, String.class, String.class, ImageIcon.class}); + return newUI; + } +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,157 @@ +package jaxx.runtime.swing.wizard; + +import java.awt.Component; +import java.beans.IndexedPropertyChangeEvent; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.lang.reflect.Array; +import javax.swing.JTabbedPane; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import static org.nuiton.i18n.I18n._; + +/** + * Classe de méthodes utiles sur les wizard. + * + * @author tony + * @since 1.3 + */ +public class WizardUtil { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private Log log = LogFactory.getLog(WizardUI.class); + + protected WizardUtil() { + } + + public static boolean acceptStates(WizardOperationState state, WizardOperationState... accepted) { + for (WizardOperationState s : accepted) { + if (s == state) { + return true; + } + } + return false; + } + + public static boolean rejectStates(WizardOperationState state, WizardOperationState... rejected) { + for (WizardOperationState s : rejected) { + if (s == state) { + return false; + } + } + return true; + } + + public static void addDebugLogListener(final Log log, WizardModel<?> model) { + if (log.isDebugEnabled()) { + model.addPropertyChangeListener(new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent evt) { + log.debug(evt.getPropertyName() + " <" + evt.getOldValue() + " - " + evt.getNewValue() + ">"); + } + }); + } + } + + public static void addTraceLogListener(final Log log, WizardModel<?> model) { + if (log.isTraceEnabled()) { + model.addPropertyChangeListener(new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent evt) { + log.trace(evt.getPropertyName() + " <" + evt.getOldValue() + " - " + evt.getNewValue() + ">"); + } + }); + } + } + + public static <E extends WizardStep, M extends WizardModel<E>> void installWizardUIListeners(final WizardUI<E, M> ui) { + ui.getModel().addPropertyChangeListener(new PropertyChangeListener() { + + @Override + @SuppressWarnings("unchecked") + public void propertyChange(PropertyChangeEvent evt) { + String propertyName = evt.getPropertyName(); + if (WizardOperationModel.WAS_STARTED_PROPERTY_NAME.equals(propertyName)) { + ui.onWasStarted(); + return; + } + if (WizardModel.STEPS_PROPERTY_NAME.equals(propertyName)) { + java.util.List<E> steps = (java.util.List<E>) evt.getNewValue(); + ui.onStepsChanged(steps.toArray((E[]) Array.newInstance(ui.getModel().stepClass, steps.size()))); + return; + } + if (WizardModel.STEP_PROPERTY_NAME.equals(propertyName)) { + ui.onStepChanged((E) evt.getNewValue()); + return; + } + if (WizardOperationModel.MODEL_STATE_PROPERTY_NAME.equals(propertyName)) { + //TODO should be unicast : only for good stepUI ? + ui.onModelStateChanged((WizardOperationState) evt.getNewValue()); + return; + } + if (WizardOperationModel.OPERATION_STATE_PROPERTY_NAME.equals(propertyName)) { + IndexedPropertyChangeEvent e = (IndexedPropertyChangeEvent) evt; + int stepIndex = e.getIndex(); + E step = ui.getModel().getSteps().get(stepIndex); + ui.onOperationStateChanged(step, (WizardOperationState) evt.getNewValue()); + return; + } + } + }); + } + + /** + * Ajoute un listener sur le modele pour gere la politique d'affichage des + * onglets. + * + * Dans cette implantation, les onglets sont ouverts jusqu'a l'etape courante. + * Lorsque l'on revient en arrière, les onglets d'etapes superieurs sont + * fermes. + * + * @param <E> le type d'un etape de l'assistant + * @param <M> le type du modele de l'assistant + * @param ui l'ui de l'assitant + * @since 1.7.1 + */ + public static <E extends WizardStep, M extends WizardModel<E>> void addTabsDisplayUntilStepListener(final WizardUI<E, M> ui) { + // on écoute les changements d'étapes + ui.getModel().addPropertyChangeListener(WizardModel.STEP_PROPERTY_NAME, new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent evt) { + M model = (M) evt.getSource(); + E oldStep = (E) evt.getOldValue(); + E newStep = (E) evt.getNewValue(); + log.debug("step has changed <old:" + oldStep + ", new:" + newStep + ">"); + int oldStepIndex = oldStep == null ? -1 : model.getStepIndex(oldStep); + int newStepIndex = model.getStepIndex(newStep); + JTabbedPane tabs = ui.getTabs(); + if (oldStepIndex + 1 == newStepIndex) { + // creation d'un nouvel onglet + WizardStepUI<E, M> c = ui.getStepUI(newStep); + String title = _(newStep.getLabel()); + String tip = _(newStep.getDescription()); + tabs.addTab(title, null, (Component) c, tip); + // selection du nouvel onglet + int index = tabs.indexOfComponent((Component) c); + if (index > -1) { + tabs.setSelectedIndex(index); + } + } else if (oldStepIndex > newStepIndex) { + // il s'agit d'un retour en arrière + // on supprime tous les onglets obsoletes + int index = newStepIndex + 1; + while (tabs.getTabCount() > index) { + log.trace("remove tab : " + index); + tabs.remove(index); + } + } else { + throw new IllegalStateException("can not go from " + oldStep + " to " + newStep); + } + } + }); + } +} Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/package.html) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,9 @@ +<html> + <body> + <h1>JAXX - Wizard framework</h1> + + This package contains all the classes of the wizard framework. + + TODO + </body> +</html> \ No newline at end of file Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html ___________________________________________________________________ Added: svn:mergeinfo + Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/validator/BeanValidator.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,6 +1,5 @@ package jaxx.runtime.validator; -import jaxx.runtime.BeanValidatorUtil; import java.beans.EventSetDescriptor; import org.apache.commons.beanutils.ConversionException; import org.apache.commons.beanutils.Converter; Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -17,7 +17,7 @@ String[] messagestoAdd; String[] messagestoDelete; - public BeanValidatorEvent(BeanValidator source, BeanValidatorField<?> field, BeanValidatorScope scope, String[] toAdd, String[] toDelete) { + public BeanValidatorEvent(BeanValidator<?> source, BeanValidatorField<?> field, BeanValidatorScope scope, String[] toAdd, String[] toDelete) { super(source); this.field = field; this.scope = scope; @@ -26,8 +26,8 @@ } @Override - public BeanValidator getSource() { - return (BeanValidator) super.getSource(); + public BeanValidator<?> getSource() { + return (BeanValidator<?>) super.getSource(); } public String getFieldName() { @@ -46,7 +46,7 @@ return scope; } - public BeanValidatorField getField() { + public BeanValidatorField<?> getField() { return field; } } Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorField.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/validator/BeanValidatorField.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorField.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -192,11 +192,11 @@ if (this == o) { return true; } - if (!(o instanceof BeanValidatorField)) { + if (!(o instanceof BeanValidatorField<?>)) { return false; } - BeanValidatorField that = (BeanValidatorField) o; + BeanValidatorField<?> that = (BeanValidatorField<?>) o; return beanClass.equals(that.beanClass) && name.equals(that.name); } Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -8,16 +8,16 @@ * @author chemit * @since 1.3 */ -public class BeanValidatorMessage<E extends BeanValidatorMessage> implements Comparable<E> { +public class BeanValidatorMessage<E extends BeanValidatorMessage<?>> implements Comparable<E> { /** * the validator that produce the message */ - protected BeanValidator validator; + protected BeanValidator<?> validator; /** * the field thatproduce the message */ - protected BeanValidatorField field; + protected BeanValidatorField<?> field; /** * the label of the message (to be displayed somewhere) */ @@ -27,18 +27,18 @@ */ protected BeanValidatorScope scope; - public BeanValidatorMessage(BeanValidator validator, BeanValidatorField field, String message, BeanValidatorScope scope) { + public BeanValidatorMessage(BeanValidator<?> validator, BeanValidatorField<?> field, String message, BeanValidatorScope scope) { this.field = field; this.validator = validator; this.message = message; this.scope = scope; } - public BeanValidator getValidator() { + public BeanValidator<?> getValidator() { return validator; } - public BeanValidatorField getField() { + public BeanValidatorField<?> getField() { return field; } Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/BeanValidatorUtil.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,176 @@ +package jaxx.runtime.validator; + +import jaxx.runtime.*; +import com.opensymphony.xwork2.config.Configuration; +import com.opensymphony.xwork2.config.ConfigurationManager; +import com.opensymphony.xwork2.util.ValueStack; +import com.opensymphony.xwork2.util.ValueStackFactory; +import jaxx.runtime.validator.*; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.beans.BeanInfo; +import java.beans.EventSetDescriptor; +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; + +/** + * The helper class for validation module. + * + * @author chemit + */ +public class BeanValidatorUtil { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private final Log log = LogFactory.getLog(BeanValidatorUtil.class); + /** + * a shared value stack to allow external operations on it (for example + * add some datas in stack to be usedby validators + */ + static private ValueStack sharedValueStack; + + public static synchronized ValueStack getSharedValueStack() { + if (sharedValueStack == null) { + + // init context + ConfigurationManager confManager = new ConfigurationManager(); + Configuration conf = confManager.getConfiguration(); + + sharedValueStack = conf.getContainer().getInstance(ValueStackFactory.class).createValueStack(); + if (log.isDebugEnabled()) { + log.debug("init shared value stack " + sharedValueStack); + } + } + return sharedValueStack; + } + + protected BeanValidatorUtil() { + // no instance + } + + /** + * Convinient method to attach a bean to all validators of an JAXXObject. + * <p/> + * It is possible to exclude some validator to be treated. + * + * @param ui the ui containing the validatros to treate + * @param bean the bean to attach in validators (can be null) + * @param excludeIds the list of validator id to exclude + */ + @SuppressWarnings({"unchecked"}) + public static void setValidatorBean(JAXXObject ui, Object bean, String... excludeIds) { + if (!JAXXValidator.class.isAssignableFrom(ui.getClass())) { + return; + } + JAXXValidator jaxxValidator = (JAXXValidator) ui; + List<String> validatorIds = jaxxValidator.getValidatorIds(); + if (excludeIds.length > 0) { + validatorIds = new ArrayList<String>(validatorIds); + for (String excludeId : excludeIds) { + validatorIds.remove(excludeId); + } + } + for (String validatorId : validatorIds) { + BeanValidator beanValidator = jaxxValidator.getValidator(validatorId); + if (bean == null || beanValidator.getBeanClass().isAssignableFrom(bean.getClass())) { + // touch validator, only if fits the bean type (or bean is null) + beanValidator.setBean(bean); + } + } + } + + /** + * Convinient method to set the changed property to all validators of an JAXXObject. + * <p/> + * It is possible to exclude some validator to be treated. + * + * @param ui the ui containing the validatros to treate + * @param newValue the new value to set in changed validator property + * @param excludeIds the list of validator id to exclude + */ + @SuppressWarnings({"unchecked"}) + public static void setValidatorChanged(JAXXObject ui, boolean newValue, String... excludeIds) { + if (!JAXXValidator.class.isAssignableFrom(ui.getClass())) { + return; + } + JAXXValidator jaxxValidator = (JAXXValidator) ui; + List<String> validatorIds = jaxxValidator.getValidatorIds(); + if (excludeIds.length > 0) { + validatorIds = new ArrayList<String>(validatorIds); + for (String excludeId : excludeIds) { + validatorIds.remove(excludeId); + } + } + for (String validatorId : validatorIds) { + BeanValidator beanValidator = jaxxValidator.getValidator(validatorId); + beanValidator.setChanged(newValue); + } + } + + /** + * Convert a value to a given type and then if was succesffull try to set it in the bean manage by the validator. + * + * @param validator validator to be involved + * @param fieldName the name of the bean property + * @param value the actual value to convert + * @param valueClass the type of the conversion + */ + public static void convert(BeanValidator<?> validator, String fieldName, String value, Class<?> valueClass) { + + Object result = validator.convert(fieldName, value, valueClass); + if (result != null) { + try { + BeanInfo info = Introspector.getBeanInfo(validator.getBean().getClass()); + + for (PropertyDescriptor descriptor : info.getPropertyDescriptors()) { + if (fieldName.equals(descriptor.getName()) && descriptor.getWriteMethod() != null) { + + descriptor.getWriteMethod().invoke(validator.getBean(), result); + break; + } + } + } catch (IntrospectionException e) { + log.error("could not obtain beanInfo for " + valueClass.getClass() + ", reason : " + e.getMessage(), e); + } catch (InvocationTargetException e) { + log.error("could not obtain beanInfo for " + valueClass.getClass() + ", reason : " + e.getMessage(), e); + } catch (IllegalAccessException e) { + log.error("could not obtain beanInfo for " + valueClass.getClass() + ", reason : " + e.getMessage(), e); + } + } else { + //fixme : conversion failed, we should be able to notify ui that values has changed ? + // otherwise, bean value has not changed,... + } + } + + public static EventSetDescriptor getPropertyChangeListenerDescriptor(Class beanClass) { + try { + // check that the bean is listenable, otherwise, can't use + // the validator on it + BeanInfo infos = Introspector.getBeanInfo(beanClass); + EventSetDescriptor[] events = infos.getEventSetDescriptors(); + for (EventSetDescriptor event : events) { + if ("propertyChange".equals(event.getName())) { + + if (event.getAddListenerMethod() == null) { + // no property event listener, so can not use the validator + throw new IllegalStateException("no addPropertyChangeListener method found for " + beanClass); + } + if (event.getRemoveListenerMethod() == null) { + // no property event listener, so can not use the validator + throw new IllegalStateException("no removePropertyChangeListener method found for " + beanClass); + } + return event; + } + } + + // no property event listener, so can not use the validator + throw new IllegalStateException("no PropertyChangeListener access method found for " + beanClass); + } catch (IntrospectionException ex) { + throw new IllegalStateException("could not acquire PropertyChangeListener bean info for " + beanClass + " for reason " + ex.getMessage(), ex); + } + } +} Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -20,7 +20,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import jaxx.runtime.BeanValidatorUtil; /** * @@ -182,10 +181,10 @@ } if (validationContext.hasFieldErrors()) { - Map messages = validationContext.getFieldErrors(); + Map<?,?> messages = validationContext.getFieldErrors(); result = new HashMap<String, List<String>>(messages.size()); for (Object fieldName : messages.keySet()) { - Collection c = (Collection) messages.get(fieldName); + Collection<?> c = (Collection<?>) messages.get(fieldName); List<String> mm = new java.util.ArrayList<String>(c.size()); for (Object message : c) { mm.add(message + ""); @@ -225,7 +224,7 @@ int skip = 0; if (contextName != null && !includeDefaultContext) { // count the number of validator to skip - for (Validator v : validator.getValidators(beanClass, null)) { + for (Validator<?> v : validator.getValidators(beanClass, null)) { // we only work on FieldValidator at the moment if (v instanceof FieldValidator) { skip++; @@ -233,7 +232,7 @@ } } - for (Validator v : validator.getValidators(beanClass, contextName)) { + for (Validator<?> v : validator.getValidators(beanClass, contextName)) { // we only work on FieldValidator at the moment if (v instanceof FieldValidator) { if (skip > 0) { Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidator.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidator.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidator.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -41,6 +41,7 @@ */ public class ExistingDirectoryFieldValidator extends FieldValidatorSupport { + @Override public void validate(Object object) throws ValidationException { String fieldName = getFieldName(); Object value = this.getFieldValue(fieldName, object); Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingFileFieldValidator.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/validator/field/ExistingFileFieldValidator.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingFileFieldValidator.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -41,6 +41,7 @@ */ public class ExistingFileFieldValidator extends FieldValidatorSupport { + @Override public void validate(Object object) throws ValidationException { String fieldName = getFieldName(); Object value = this.getFieldValue(fieldName, object); Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/RequiredFileFieldValidator.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/validator/field/RequiredFileFieldValidator.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/RequiredFileFieldValidator.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -41,6 +41,7 @@ */ public class RequiredFileFieldValidator extends FieldValidatorSupport { + @Override public void validate(Object object) throws ValidationException { String fieldName = getFieldName(); Object value = this.getFieldValue(fieldName, object); Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,279 @@ +package jaxx.runtime.validator.swing; + +import jaxx.runtime.validator.swing.ui.AbstractBeanValidatorUI; +import jaxx.runtime.validator.swing.ui.IconValidationUI; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.jxlayer.JXLayer; + +import javax.swing.JComponent; +import javax.swing.SwingUtilities; +import java.awt.Container; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import jaxx.runtime.validator.BeanValidator; +import jaxx.runtime.validator.BeanValidatorField; + +/** + * La surcharge de {@link jaxx.runtime.validator.BeanValidator} pour les ui swing + * <p/> + * /** + * <p/> + * Permet d'ajouter facilement le support de la validation des champs d'un + * bean et de le relier a une interface graphique. + * Utilise xwork pour la validation et JXLayer pour la visualisation. + * <p/> + * <p/> + * Le mieux pour son integration dans Jaxx est de faire de la generation pour + * force la compilation du code suivant: + * <p/> + * <pre> + * myValidor.getBean().get<field>(); + * </pre> + * <p/> + * et ceci pour chaque field ajoute a la map fieldRepresentation. De cette + * facon meme si le champs field est en texte on a une verification de son + * existance a la compilation. + * <p/> + * <p/> + * La representation en tag pourrait etre + * <pre> + * <validator id="myValidator" beanClass="{Personne.class}" errorList="$list"> + * <field name="name" component="$name"/> + * <field name="firstName" component="$firstName"/> + * <field name="birthDate" component="$birthDate"/> + * </validator> + * <validator beanClass="{Personne.class}" autoField="true" errorList="$list"> + * <fieldRepresentation name="name" component="$lastName"/> + * </validator> + * </pre> + * <p/> + * dans le premier exemple on fait un mapping explicite des champs, mais on voit + * que le nom du composant graphique est le meme que celui du champs. Pour eviter + * de longue saisie, il est possible d'utiliser le flag <b>autoField</b> + * qui pour chaque champs du ayant une methode get du bean recherche un composant + * avec cet Id. Il est aussi possible de surcharge un champs explicitement + * comme ici name, dans le cas ou le composant qui porterait ce nom serait + * utilise pour autre chose. + * <p/> + * <p/> + * Il faut un handler particulier pour ce composant car les attributs + * <b>beanClass</b> et <b>autoField</b> ne sont present que dans le XML jaxx et + * servent a la generation. Il faut aussi prendre en compte les elements + * fieldRepresentation fils du tag validator. + * <p/> + * <p/> + * Voici ce que pourrait etre le code genere par jaxx + * <pre> + * // declaration du bean + * BeanValidator<beanClass> $myValidator; + * // init du bean + * protected void createMyValidator() { + * $myValidator = new BeanValidator<beanClass>(); + * // genere seulement si autoField = true + * for (Method m : beanClass.getMethod()) { + * if (m.getName().startsWith("get")) { + * String fieldName = m.getName().substring(3).toLowerCase(); + * $myValidator.setFieldRepresentation(fieldName, $objectMap.get(fieldName)); + * } + * } + * // pour chaque tag fieldRepresentation + * myValidator.setFieldRepresentation("name", $lastName); + * // si beanClass est specifie et n'est pas Object, on force l'acces au champs + * // pour validation a la compilation + * $myValidator.getBean().getName(); + * $objectMap.put("myValidator", $myValidator); + * } + * </pre> + * + * @param <B> le type de bean a valider + * @author poussin + * @author chemit + * @version 1.0 + */ +public class SwingValidator<B> extends BeanValidator<B> { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private final Log log = LogFactory.getLog(SwingValidator.class); + static private final Class<? extends AbstractBeanValidatorUI> DEFAULT_UI_CLASS = IconValidationUI.class; + /** permet de faire le lien en un champs du bean et l'objet qui permet de l'editer */ + protected Map<String, JComponent> fieldRepresentation; + /** Object servant a contenir la liste des erreurs */ + protected SwingValidatorMessageListModel errorListModel; + /** Object servant a contenir la liste des erreurs */ + protected SwingValidatorMessageTableModel errorTableModel; + /** ui renderer class */ + protected Class<? extends AbstractBeanValidatorUI> uiClass; + + public SwingValidator(Class<B> beanClass, String contextName) { + super(beanClass, contextName); + fieldRepresentation = new HashMap<String, JComponent>(); + } + + /** + * To reload a bean in the validator. + * + * This method is used to reload ui, since some editors + * could not exist when validator is init, so some messages + * should not be attached to an editor. + */ + public void reloadBean() { + B b = getBean(); + if (b != null) { + setBean(null); + setBean(b); + } + } + + public JComponent getFieldRepresentation(String fieldname) { + return fieldRepresentation.get(fieldname); + } + + public Class<? extends AbstractBeanValidatorUI> getUiClass() { + return uiClass; + } + + public void setErrorListModel(SwingValidatorMessageListModel errorListModel) { + this.errorListModel = errorListModel; + if (errorListModel != null) { + // register the validator in the model list + errorListModel.registerValidator(this); + } + } + + public void setErrorTableModel(SwingValidatorMessageTableModel errorTableModel) { + this.errorTableModel = errorTableModel; + if (errorTableModel != null) { + // register the validator in the model table + errorTableModel.registerValidator(this); + } + } + + public void setUiClass(Class<? extends AbstractBeanValidatorUI> uiClass) { + this.uiClass = uiClass; + } + + @Override + public void setContextName(String contextName) { + /*Map<ValidatorField<B>, List<ValidatorErrorListener>> oldListeners = new HashMap<ValidatorField<B>, List<ValidatorErrorListener>>(); + + for (ValidatorField<B> field : fields) { + ValidatorErrorListener[] listeners = field.getValidatorErrorListeners(); + List<ValidatorErrorListener> toReinject = new ArrayList<ValidatorErrorListener>(); + for (ValidatorErrorListener listener : listeners) { + if (listener instanceof AbstractBeanValidatorUI) { + // this listener will be reinject via installUIs method + continue; + } + toReinject.add(listener); + } + oldListeners.put(field, toReinject); + }*/ + super.setContextName(contextName); + // must reinstall ui + installUIs(); + // reinject none ui listeners + /*for (Entry<ValidatorField<B>, List<ValidatorErrorListener>> entry : oldListeners.entrySet()) { + ValidatorField<B> field = getField(entry.getKey().getName()); + for (ValidatorErrorListener listener : entry.getValue()) { + field.addValidatorErrorListener(listener); + } + } + oldListeners.clear();*/ + } + + /** + * Permet d'indiquer le composant graphique responsable de l'affichage + * d'un attribut du bean + * + * @param fieldname the field name in the bean + * @param c the editor component for the field + */ + public void setFieldRepresentation(String fieldname, JComponent c) { + BeanValidatorField<B> field = getField(fieldname); + if (field == null) { + // no field registred in the validator + log.warn("the field '" + fieldname + "' is not defined in validator (no rules on it)"); + return; + } + fieldRepresentation.put(fieldname, c); + } + + public void setFieldRepresentation(Map<String, JComponent> fieldRepresentation) { + for (Map.Entry<String, JComponent> e : fieldRepresentation.entrySet()) { + setFieldRepresentation(e.getKey(), e.getValue()); + } + } + + @Override + public SwingValidator<?> getParentValidator() { + return (SwingValidator<?>) super.getParentValidator(); + } + + public void setParentValidator(SwingValidator<?> parentValidator) { + super.setParentValidator(parentValidator); + } + + /** install ui on required components */ + public void installUIs() { + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + if (uiClass == null) { + // use the default one + uiClass = DEFAULT_UI_CLASS; + } + for (Entry<String, JComponent> entry : fieldRepresentation.entrySet()) { + try { + setMessageRepresentation(entry.getKey(), null, entry.getValue(), uiClass); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + }); + } + + protected void setMessageRepresentation(String fieldname, JComponent old, JComponent c, Class<? extends AbstractBeanValidatorUI> uiClass) + throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException { + if (old == c) { + // same component, nothing to do + return; + } + BeanValidatorField<B> field = getField(fieldname); + + if (field == null) { + // this case should not appear since fieldName has already been check in method addFieldRepresentation + return; + } + if (old != null) { + // suppression du jxlayer sous l'ancien composant + Container container = old.getParent(); + if (container instanceof JXLayer<?>) { + JXLayer<?> jx = (JXLayer<?>) container; + Object ui = jx.getUI(); + if (ui != null && ui instanceof AbstractBeanValidatorUI) { + removeBeanValidatorListener((AbstractBeanValidatorUI) ui); + } + + jx.setUI(null); + } + } + if (c != null) { + // ajout du jxlayer sous ce composant + Container container = c.getParent(); + if (container instanceof JXLayer<?>) { + Constructor<? extends AbstractBeanValidatorUI> cons = uiClass.getConstructor(BeanValidatorField.class); + AbstractBeanValidatorUI ui = cons.newInstance(field); + ui.setEnabled(true); + JXLayer<JComponent> jx = (JXLayer<JComponent>) container; + addBeanValidatorListener(ui); + jx.setUI(ui); + } + } + } +} Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,66 @@ +package jaxx.runtime.validator.swing; + +import javax.swing.JComponent; +import jaxx.runtime.validator.BeanValidatorField; +import jaxx.runtime.validator.BeanValidatorMessage; +import jaxx.runtime.validator.BeanValidatorScope; + +/** + * The object to box a validation message within an u. + * + * @author chemit + * @since 1.3 + * @see BeanValidatorMessage + */ +public class SwingValidatorMessage extends BeanValidatorMessage<SwingValidatorMessage> { + + /** + * the optional field's editor + */ + protected JComponent editor; + protected String fieldName; + + public SwingValidatorMessage(SwingValidator<?> validator, BeanValidatorField<?> field, String message, BeanValidatorScope scope, JComponent editor) { + super(validator, field, message, scope); + this.fieldName = field.getName(); + this.editor = editor; + } + + public SwingValidatorMessage(SwingValidator<?> validator, String fieldName, String message, BeanValidatorScope scope, JComponent editor) { + super(validator, null, message, scope); + this.fieldName = fieldName; + this.editor = editor; + } + + public JComponent getEditor() { + return editor; + } + + public String getFieldName() { + return fieldName; + } + + @Override + public int compareTo(SwingValidatorMessage o) { + // sort on scope + int result = getScope().compareTo(o.getScope()); + if (result == 0) { + // sort on field name + result = fieldName.compareTo(o.getFieldName()); + if (result == 0) { + // sort on message + result = message.compareTo(o.getMessage()); + } + } + return result; + } + + @Override + public String toString() { + String s = scope + " - " + (field == null ? message : field.getI18nError(message)); + if (editor == null) { + return s; + } + return editor.getName() + " : " + s; + } +} Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,142 @@ +package jaxx.runtime.validator.swing; + +import jaxx.runtime.validator.BeanValidatorEvent; + +import javax.swing.JComponent; +import java.util.ArrayList; +import java.util.List; +import jaxx.runtime.validator.BeanValidatorField; +import jaxx.runtime.validator.BeanValidatorScope; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * The model of the list of validation's messages + * + * @author chemit + */ +public class SwingValidatorMessageListModel + extends javax.swing.AbstractListModel + implements jaxx.runtime.validator.BeanValidatorListener { + + private static final long serialVersionUID = 1L; + /** to use log facility, just put in your code: log.info(\"...\"); */ + private static Log log = LogFactory.getLog(SwingValidatorMessageListModel.class); + /** list of registred validators */ + protected transient List<SwingValidator<?>> validators; + /** list of messages actual displayed */ + protected List<SwingValidatorMessage> data; + + public SwingValidatorMessageListModel() { + validators = new ArrayList<SwingValidator<?>>(); + data = new java.util.ArrayList<SwingValidatorMessage>(); + } + + public boolean isEmpty() { + return getSize() == 0; + } + + public void registerValidator(SwingValidator<?> validator) { + if (validators.contains(validator)) { + throw new IllegalArgumentException("the validator " + validator + " is already registred in " + this); + } + validators.add(validator); + validator.addBeanValidatorListener(this); + } + + public void clear() { + int i = data.size(); + if (i > 0) { + data.clear(); + fireIntervalRemoved(this, 0, i - 1); + } + } + + @Override + public int getSize() { + return data.size(); + } + + @Override + public Object getElementAt(int index) { + ensureRowIndex(index); + return data.get(index); + } + + @Override + public void onFieldChanged(BeanValidatorEvent event) { + String[] toDelete = event.getMessagesToDelete(); + String[] toAdd = event.getMessagesToAdd(); + BeanValidatorField<?> field = event.getField(); + BeanValidatorScope scope = event.getScope(); + boolean mustAdd = toAdd != null && toAdd.length > 0; + boolean mustDel = toDelete != null && toDelete.length > 0; + + if (log.isTraceEnabled()) { + log.trace("----------------------------------------------------------"); + log.trace(field + " - (" + getSize() + ") toAdd " + mustAdd); + log.trace(field + " - (" + getSize() + ") toDelete " + mustDel); + } + + SwingValidator<?> validator = (SwingValidator<?>) event.getSource(); + + if (mustDel) { + + // removes datas and notify if no messages to add + removeMessages(validator, field, scope, !mustAdd, toDelete); + } + + if (mustAdd) { + + // add new messages, sort datas and notify + addMessages(validator, field, scope, true, toAdd); + } + } + + protected void ensureRowIndex(int index) throws ArrayIndexOutOfBoundsException { + if (index < -1 || index >= getSize()) { + throw new ArrayIndexOutOfBoundsException("the rowIndex was " + index + ", but should be int [0," + (getSize() - 1) + "]"); + } + } + + protected void addMessages(SwingValidator<?> validator, BeanValidatorField<?> field, BeanValidatorScope scope, boolean sort, String... messages) { + + JComponent editor = validator.getFieldRepresentation(field.getName()); + // add new errors + for (String error : messages) { + SwingValidatorMessage row = new SwingValidatorMessage(validator, field, error, scope, editor); + data.add(row); + if (!sort) { + fireIntervalAdded(this, data.size() - 1, data.size() - 1); + } + } + + if (sort) { + + // resort datas + java.util.Collections.sort(data); + + // notify + fireContentsChanged(this, 0, getSize() - 1); + } + } + + protected void removeMessages(SwingValidator<?> validator, BeanValidatorField<?> field, BeanValidatorScope scope, boolean notify, String... messages) { + + List<String> messagesToDel = new java.util.ArrayList<String>(java.util.Arrays.asList(messages)); + + // do it in reverse mode (only one pass in that way since index + // will stay coherent while removing them) + + for (int i = getSize() - 1; i > -1; i--) { + SwingValidatorMessage error = data.get(i); + if (error.getValidator() == validator && error.getScope() == scope && error.getField() == field && messagesToDel.contains(error.getMessage())) { + // remove the message + data.remove(i); + if (notify) { + fireIntervalRemoved(this, i, i); + } + } + } + } +} Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,60 @@ +package jaxx.runtime.validator.swing; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.swing.JComponent; +import javax.swing.JList; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/** + * A mouse listener to put on a {@link javax.swing.JList} with a {@link SwingValidatorMessageListModel} as a model. + * <p/> + * When a double click occurs, find the selected error in model and then focus to the associated component of error. + * + * @author chemit + */ +public class SwingValidatorMessageListMouseListener extends MouseAdapter { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private Log log = LogFactory.getLog(SwingValidatorMessageListMouseListener.class); + + @Override + public void mouseClicked(MouseEvent e) { + super.mouseClicked(e); + if (e.getClickCount() == 2) { + + SwingValidatorMessage entry = getSelectedMessage(e); + if (entry == null) { + // no entry found + return; + } + JComponent component = entry.getEditor(); + if (component != null) { + component.requestFocus(); + } + } + } + + protected SwingValidatorMessage getSelectedMessage(MouseEvent e) { + JList list = (JList) e.getSource(); + if (!(list.getModel() instanceof SwingValidatorMessageListModel)) { + log.warn("model must be a " + SwingValidatorMessageListModel.class + ", but was " + list.getModel()); + return null; + } + + SwingValidatorMessageListModel model = (SwingValidatorMessageListModel) list.getModel(); + int index = list.getSelectionModel().getMinSelectionIndex(); + if (index == -1) { + // nothing is selected + return null; + } + SwingValidatorMessage entry = (SwingValidatorMessage) model.getElementAt(index); + if (log.isDebugEnabled()) { + log.debug("selected index: " + index + " : error: " + entry); + } + return entry; + } + +} \ No newline at end of file Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,89 @@ +package jaxx.runtime.validator.swing; + +import javax.swing.ImageIcon; +import javax.swing.JLabel; +import javax.swing.JList; +import java.awt.Component; +import javax.swing.DefaultListCellRenderer; +import jaxx.runtime.validator.BeanValidatorScope; +import static org.nuiton.i18n.I18n._; + +/** + * A simple render of a table of validator's messages, says a table that use + * a {@link SwingValidatorMessageTableModel} model. + * + * @author chemit + * @since 1.3 + * @see SwingValidatorMessageTableModel + */ +public class SwingValidatorMessageListRenderer extends DefaultListCellRenderer { + + private static final long serialVersionUID = 1L; + protected String format = "%1$-20s - %2$s"; + protected String formatTip = "%1$-20s - %2$-20s : %3$s"; + + public SwingValidatorMessageListRenderer() { + } + + public SwingValidatorMessageListRenderer(String format) { + this.format = format; + } + + public String getFormat() { + return format; + } + + public void setFormat(String format) { + this.format = format; + } + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + + JLabel rendererComponent = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + + SwingValidatorMessage model = (SwingValidatorMessage) value; + + // scope + ImageIcon icon = SwingValidatorUtil.getIcon(model.getScope()); + + // field name + String fieldName = getFieldName(list, model.getField().getName(), index); + + // message + String message = getMessage(model); + + // text to display + String text = String.format(format, fieldName, message); + + String label = _(model.getScope().getLabel()); + String tmp = _("validator.scope.tip", label); + String tmp2 = _("validator.field.tip", fieldName); + + String tooltTipText = String.format(formatTip, tmp, tmp2, message); + + + rendererComponent.setText(text); + rendererComponent.setToolTipText(tooltTipText); + rendererComponent.setIcon(icon); + + return rendererComponent; + } + + public ImageIcon getIcon(BeanValidatorScope scope) { + ImageIcon icon = SwingValidatorUtil.getIcon(scope); + return icon; + } + + public String getMessage(SwingValidatorMessage model) { + String text = SwingValidatorUtil.getMessage(model); + return text; + } + + public String getFieldName(JList list, String value, int row) { + SwingValidatorMessageListModel tableModel = (SwingValidatorMessageListModel) list.getModel(); + SwingValidatorMessage model = (SwingValidatorMessage) tableModel.getElementAt(row); + String fieldName = SwingValidatorUtil.getFieldName(model, value); + return fieldName; + } +} \ No newline at end of file Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,327 @@ +package jaxx.runtime.validator.swing; + +import jaxx.runtime.validator.BeanValidatorEvent; + +import javax.swing.JComponent; +import java.util.ArrayList; +import java.util.List; +import jaxx.runtime.validator.BeanValidatorField; +import jaxx.runtime.validator.BeanValidatorScope; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * The model of the table of errors. + * + * The model listens validators messages and update his internal model from it. + * + * @author chemit + * @since 1.3 + */ +public class SwingValidatorMessageTableModel + extends javax.swing.table.AbstractTableModel + implements jaxx.runtime.validator.BeanValidatorListener { + + private static final long serialVersionUID = 1L; + /** to use log facility, just put in your code: log.info(\"...\"); */ + private static Log log = LogFactory.getLog(SwingValidatorMessageTableMouseListener.class); + public static final String[] columnNames = {"validator.scope", "validator.field", "validator.message"}; + public static final Class<?>[] columnClasses = {BeanValidatorScope.class, String.class, String.class}; + /** list of registred validators */ + protected transient List<SwingValidator<?>> validators; + /** list of messages actual displayed */ + protected List<SwingValidatorMessage> data; + + public SwingValidatorMessageTableModel() { + super(); + validators = new ArrayList<SwingValidator<?>>(); + data = new java.util.ArrayList<SwingValidatorMessage>(); + } + + /** + * Register a validator for this model. + * + * + * Note: a validator can not be register twice in the same model. + * + * @param validator the validator to register + */ + public void registerValidator(SwingValidator<?> validator) { + if (validators.contains(validator)) { + throw new IllegalArgumentException("the validator " + validator + " is already registred in " + this); + } + validators.add(validator); + validator.addBeanValidatorListener(this); + } + + public void addMessages(SwingValidator<?> validator, String fieldName, BeanValidatorScope scope, String... messages) { + addMessages(validator, fieldName, scope, true, messages); + } + + public void addMessages(JComponent editor, String fieldName, BeanValidatorScope scope, String... messages) { + addMessages(editor, fieldName, scope, true, messages); + } + + public void addMessages(SwingValidator<?> validator, BeanValidatorField<?> field, BeanValidatorScope scope, String... messages) { + addMessages(validator, field, scope, true, messages); + } + + public void removeMessages(JComponent editor, BeanValidatorScope scope) { + + // do it in reverse mode (only one pass in that way since index + // will stay coherent while removing them) + + for (int i = getRowCount() - 1; i > -1; i--) { + SwingValidatorMessage error = data.get(i); + if (error.getEditor() == editor && (scope == null || error.getScope() == scope)) { + // remove the message + data.remove(i); + fireTableRowsDeleted(i, i); + } + } + } + + public void removeMessages(SwingValidator<?> validator, String fieldName, BeanValidatorScope scope, String... messages) { + removeMessages(validator, fieldName, scope, true, messages); + } + + public void removeMessages(JComponent editor, String fieldName, BeanValidatorScope scope) { + removeMessages(editor, fieldName, scope, true); + } + + public void removeMessages(SwingValidator<?> validator, BeanValidatorField<?> field, BeanValidatorScope scope, String... messages) { + removeMessages(validator, field, scope, true, messages); + } + + public void clear() { + int i = data.size(); + if (i > 0) { + data.clear(); + fireTableRowsDeleted(0, i - 1); + } + } + + /** + * Obtain the message for a given row. + * + * @param rowIndex the row index + * @return the message for the given row index + */ + public SwingValidatorMessage getRow(int rowIndex) { + ensureRowIndex(rowIndex); + return data.get(rowIndex); + } + + @Override + public boolean isCellEditable(int row, int column) { + // cells are never editable in this model + return false; + } + + @Override + public Class<?> getColumnClass(int columnIndex) { + ensureColumnIndex(columnIndex); + return columnClasses[columnIndex]; + } + + @Override + public String getColumnName(int column) { + ensureColumnIndex(column); + return columnNames[column]; + } + + @Override + public void onFieldChanged(BeanValidatorEvent event) { + String[] toDelete = event.getMessagesToDelete(); + String[] toAdd = event.getMessagesToAdd(); + BeanValidatorField<?> field = event.getField(); + BeanValidatorScope scope = event.getScope(); + boolean mustAdd = toAdd != null && toAdd.length > 0; + boolean mustDel = toDelete != null && toDelete.length > 0; + + if (log.isTraceEnabled()) { + log.trace("----------------------------------------------------------"); + log.trace(field + " - (" + getRowCount() + ") toAdd " + mustAdd); + log.trace(field + " - (" + getRowCount() + ") toDelete " + mustDel); + } + + SwingValidator<?> validator = (SwingValidator<?>) event.getSource(); + + if (mustDel) { + + // removes datas and notify if no messages to add + removeMessages(validator, field, scope, !mustAdd, toDelete); + } + + if (mustAdd) { + + // add new messages, sort datas and notify + addMessages(validator, field, scope, true, toAdd); + } + } + + @Override + public int getRowCount() { + return data.size(); + } + + @Override + public int getColumnCount() { + return columnNames.length; + } + + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + ensureColumnIndex(columnIndex); + ensureRowIndex(rowIndex); + + SwingValidatorMessage row = data.get(rowIndex); + if (columnIndex == 0) { + // the icon + return row.getScope(); + } + if (columnIndex == 1) { + // the field + return row.getFieldName(); + } + if (columnIndex == 2) { + // the message + return row.getMessage(); + } + + // should never come here + return null; + } + + protected void ensureRowIndex(int rowIndex) throws ArrayIndexOutOfBoundsException { + if (rowIndex < -1 || rowIndex >= getRowCount()) { + throw new ArrayIndexOutOfBoundsException("the rowIndex was " + rowIndex + ", but should be int [0," + (getRowCount() - 1) + "]"); + } + } + + protected void ensureColumnIndex(int index) throws ArrayIndexOutOfBoundsException { + if (index < -1 || index >= getColumnCount()) { + throw new ArrayIndexOutOfBoundsException("the columnIndex was " + index + ", but should be int [0," + (getColumnCount() - 1) + "]"); + } + } + + protected void addMessages(SwingValidator<?> validator, BeanValidatorField<?> field, BeanValidatorScope scope, boolean sort, String... messages) { + + JComponent editor = validator == null ? null : validator.getFieldRepresentation(field.getName()); + // add new errors + for (String error : messages) { + SwingValidatorMessage row = new SwingValidatorMessage(validator, field, error, scope, editor); + data.add(row); + if (!sort) { + fireTableRowsInserted(data.size() - 1, data.size() - 1); + } + } + + if (sort) { + + // resort datas + java.util.Collections.sort(data); + + // notify + fireTableDataChanged(); + } + } + + protected void addMessages(SwingValidator<?> validator, String fieldName, BeanValidatorScope scope, boolean sort, String... messages) { + + JComponent editor = validator == null ? null : validator.getFieldRepresentation(fieldName); + // add new errors + for (String error : messages) { + SwingValidatorMessage row = new SwingValidatorMessage(validator, fieldName, error, scope, editor); + data.add(row); + if (!sort) { + fireTableRowsInserted(data.size() - 1, data.size() - 1); + } + } + + if (sort) { + + // resort datas + java.util.Collections.sort(data); + + // notify + fireTableDataChanged(); + } + } + + protected void addMessages(JComponent editor, String fieldName, BeanValidatorScope scope, boolean sort, String... messages) { + + // add new errors + for (String error : messages) { + SwingValidatorMessage row = new SwingValidatorMessage(null, fieldName, error, scope, editor); + data.add(row); + if (!sort) { + fireTableRowsInserted(data.size() - 1, data.size() - 1); + } + } + + if (sort) { + + // resort datas + java.util.Collections.sort(data); + + // notify + fireTableDataChanged(); + } + } + + protected void removeMessages(SwingValidator<?> validator, BeanValidatorField<?> field, BeanValidatorScope scope, boolean notify, String... messages) { + + List<String> messagesToDel = new java.util.ArrayList<String>(java.util.Arrays.asList(messages)); + + // do it in reverse mode (only one pass in that way since index + // will stay coherent while removing them) + + for (int i = getRowCount() - 1; i > -1; i--) { + SwingValidatorMessage error = data.get(i); + if (error.getValidator() == validator && error.getScope() == scope && error.getFieldName().equals(field.getName()) && messagesToDel.contains(error.getMessage())) { + // remove the message + data.remove(i); + if (notify) { + fireTableRowsDeleted(i, i); + } + } + } + } + + protected void removeMessages(SwingValidator<?> validator, String fieldName, BeanValidatorScope scope, boolean notify, String... messages) { + + List<String> messagesToDel = new java.util.ArrayList<String>(java.util.Arrays.asList(messages)); + + // do it in reverse mode (only one pass in that way since index + // will stay coherent while removing them) + + for (int i = getRowCount() - 1; i > -1; i--) { + SwingValidatorMessage error = data.get(i); + if (error.getValidator() == validator && error.getScope() == scope && error.getFieldName().equals(fieldName) && messagesToDel.contains(error.getMessage())) { + // remove the message + data.remove(i); + if (notify) { + fireTableRowsDeleted(i, i); + } + } + } + } + + protected void removeMessages(JComponent editor, String fieldName, BeanValidatorScope scope, boolean notify) { + + // do it in reverse mode (only one pass in that way since index + // will stay coherent while removing them) + + for (int i = getRowCount() - 1; i > -1; i--) { + SwingValidatorMessage error = data.get(i); + if (error.getEditor() == editor && (scope == null || error.getScope() == scope) && error.getFieldName().equals(fieldName)) { + // remove the message + data.remove(i); + if (notify) { + fireTableRowsDeleted(i, i); + } + } + } + } +} \ No newline at end of file Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,94 @@ +package jaxx.runtime.validator.swing; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.swing.JComponent; +import javax.swing.JTable; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; + +/** + * A mouse listener to put on a {@link javax.swing.JList} with a {@link SwingValidatorMessageTableModel} as a model. + * <p/> + * When a double click occurs, find the selected error in model and then focus to the associated component of error. + * + * @author chemit + */ +public class SwingValidatorMessageTableMouseListener extends MouseAdapter { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + private static Log log = LogFactory.getLog(SwingValidatorMessageTableMouseListener.class); + + public static final String HIGHLIGHT_ERROR_PROPERTY = "highlightError"; + + /** delgate property change support */ + protected PropertyChangeSupport pcs; + + public SwingValidatorMessageTableMouseListener() { + pcs = new PropertyChangeSupport(this); + } + + @Override + public void mouseClicked(MouseEvent e) { + super.mouseClicked(e); + if (e.getClickCount() == 2) { + + SwingValidatorMessage entry = getSelectedMessage(e); + if (entry == null) { + // no entry found + return; + } + JComponent component = entry.getEditor(); + if (component != null) { + pcs.firePropertyChange(HIGHLIGHT_ERROR_PROPERTY, null, entry); + if (component.isVisible()) { + component.requestFocus(); + } + } + } + } + + + protected SwingValidatorMessage getSelectedMessage(MouseEvent e) { + JTable table = (JTable) e.getSource(); + if (!(table.getModel() instanceof SwingValidatorMessageTableModel)) { + log.warn("model must be a " + SwingValidatorMessageTableModel.class + ", but was " + table.getModel()); + return null; + } + + SwingValidatorMessageTableModel model = (SwingValidatorMessageTableModel) table.getModel(); + int index = table.getSelectionModel().getMinSelectionIndex(); + if (index == -1) { + // nothing is selected + return null; + } + if (table.getRowSorter() != null) { + index = table.getRowSorter().convertRowIndexToModel(index); + } + SwingValidatorMessage entry = model.getRow(index); + if (log.isDebugEnabled()) { + log.debug("selected index: " + index + " : error: " + entry); + } + return entry; + } + + public void addPropertyChangeListener(PropertyChangeListener listener) { + pcs.addPropertyChangeListener(listener); + } + + public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { + pcs.addPropertyChangeListener(propertyName, listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + pcs.removePropertyChangeListener(listener); + } + + public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { + pcs.removePropertyChangeListener(propertyName, listener); + } + +} \ No newline at end of file Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,83 @@ +package jaxx.runtime.validator.swing; + +import javax.swing.ImageIcon; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.table.DefaultTableCellRenderer; +import java.awt.Component; +import jaxx.runtime.validator.BeanValidatorScope; +import static org.nuiton.i18n.I18n._; + +/** + * A simple render of a table of validator's messages, says a table that use + * a {@link SwingValidatorMessageTableModel} model. + * + * @author chemit + * @since 1.3 + * @see SwingValidatorMessageTableModel + */ +public class SwingValidatorMessageTableRenderer extends DefaultTableCellRenderer { + + private static final long serialVersionUID = 1L; + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + JLabel rendererComponent = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + + ImageIcon icon = null; + String text = null; + String toolTipText = null; + + column = table.convertColumnIndexToModel(column); + if (table.getRowSorter() != null) { + row = table.getRowSorter().convertRowIndexToModel(row); + } + + + switch (column) { + case 0: + // scope + BeanValidatorScope scope = (BeanValidatorScope) value; + icon = SwingValidatorUtil.getIcon(scope); + String label = _(scope.getLabel()); + toolTipText = _("validator.scope.tip", label); + break; + + case 1: + // field name + text = getFieldName(table, (String) value, row); + toolTipText = _("validator.field.tip", text); + break; + + case 2: + // message + text = getMessage(table, (String) value, row); + toolTipText = _("validator.message.tip", text); + break; + } + + rendererComponent.setText(text); + rendererComponent.setToolTipText(toolTipText); + rendererComponent.setIcon(icon); + return rendererComponent; + } + + public ImageIcon getIcon(BeanValidatorScope scope) { + ImageIcon icon = SwingValidatorUtil.getIcon(scope); + return icon; + } + + public String getMessage(JTable table, String value, int row) { + SwingValidatorMessageTableModel tableModel = (SwingValidatorMessageTableModel) table.getModel(); + SwingValidatorMessage model = tableModel.getRow(row); + String text = SwingValidatorUtil.getMessage(model); + return text; + } + + public String getFieldName(JTable table, String value, int row) { + SwingValidatorMessageTableModel tableModel = (SwingValidatorMessageTableModel) table.getModel(); + SwingValidatorMessage model = tableModel.getRow(row); + String fieldName = SwingValidatorUtil.getFieldName(model, value); + return fieldName; + } +} \ No newline at end of file Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingValidatorUtil.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,201 @@ +package jaxx.runtime.validator.swing; + +import jaxx.runtime.*; +import jaxx.runtime.validator.BeanValidatorUtil; +import jaxx.runtime.validator.*; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.swing.JList; +import javax.swing.JTable; +import java.awt.event.MouseListener; +import javax.swing.ImageIcon; +import javax.swing.JComponent; +import javax.swing.RowSorter; +import javax.swing.SortOrder; +import jaxx.runtime.validator.swing.SwingValidatorMessageTableMouseListener; +import jaxx.runtime.validator.swing.SwingValidatorMessageListMouseListener; +import jaxx.runtime.validator.swing.SwingValidatorMessage; +import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer; +import static org.nuiton.i18n.I18n.n_; + +/** + * The helper class for validation module. + * + * @author chemit + */ +public class SwingValidatorUtil extends BeanValidatorUtil { + + static ImageIcon errorIcon; + static ImageIcon warningIcon; + static ImageIcon infoIcon; + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private final Log log = LogFactory.getLog(SwingValidatorUtil.class); + + public static ImageIcon getErrorIcon() { + if (errorIcon == null) { + errorIcon = jaxx.runtime.Util.createImageIcon("error.png"); + } + return errorIcon; + } + + public static ImageIcon getInfoIcon() { + if (infoIcon == null) { + infoIcon = jaxx.runtime.Util.createImageIcon("info.png"); + } + return infoIcon; + } + + public static ImageIcon getWarningIcon() { + if (warningIcon == null) { + warningIcon = jaxx.runtime.Util.createImageIcon("warning.png"); + } + return warningIcon; + } + + protected SwingValidatorUtil() { + // no instance + } + + /** + * Prepare the ui where to display the validators messages. + * + * @param errorTable the table where to display validators messages + * @param render renderer to use + */ + public static void installUI(JTable errorTable, SwingValidatorMessageTableRenderer render) { + errorTable.setDefaultRenderer(Object.class, render); + errorTable.getRowSorter().setSortKeys(java.util.Arrays.asList(new RowSorter.SortKey(0, SortOrder.ASCENDING))); + SwingUtil.setI18nTableHeaderRenderer(errorTable, + n_("validator.scope.header"), + n_("validator.scope.header.tip"), + n_("validator.field.header"), + n_("validator.field.header.tip"), + n_("validator.message.header"), + n_("validator.message.header.tip")); + // register a single 'goto widget error' mouse listener on errorTable + registerErrorTableMouseListener(errorTable); + SwingUtil.fixTableColumnWidth(errorTable, 0, 25); + } + + /** + * Register for a given validator list ui a validator mouse listener. + * + * Note: there is only one listener registred for a given list model, so + * invoking this method tiwce or more will have no effect. + * + * @param list the validation ui list + * @return the listener instanciate or found + * @see SwingValidatorMessageListMouseListener + */ + public static SwingValidatorMessageListMouseListener registerErrorListMouseListener(JList list) { + SwingValidatorMessageListMouseListener listener = getErrorListMouseListener(list); + + if (listener != null) { + return listener; + } + listener = new SwingValidatorMessageListMouseListener(); + if (log.isDebugEnabled()) { + log.debug(listener.toString()); + } + list.addMouseListener(listener); + return listener; + } + + /** + * Register for a given validator table ui a validator mouse listener + * + * Note: there is onlt one listener registred for a givne table model, so + * invokin this method twice or more will have no effect. + * + * @param table the validator table ui + * @return the listener instanciate or found + * @see SwingValidatorMessageTableMouseListener + */ + public static SwingValidatorMessageTableMouseListener registerErrorTableMouseListener(JTable table) { + SwingValidatorMessageTableMouseListener listener = getErrorTableMouseListener(table); + + if (listener != null) { + return listener; + } + listener = new SwingValidatorMessageTableMouseListener(); + if (log.isDebugEnabled()) { + log.debug(listener.toString()); + } + table.addMouseListener(listener); + return listener; + } + + /** + * @param list the validator list ui + * @return the validator list mouse listener, or <code>null</code> if not found + * @see SwingValidatorMessageListMouseListener + */ + public static SwingValidatorMessageListMouseListener getErrorListMouseListener(JList list) { + if (list != null) { + for (MouseListener listener : list.getMouseListeners()) { + if (listener instanceof SwingValidatorMessageTableMouseListener) { + return (SwingValidatorMessageListMouseListener) listener; + } + } + } + return null; + } + + /** + * @param table the validator table ui + * @return the validator table mouse listener, or <code>null</code> if not found + * @see SwingValidatorMessageTableMouseListener + */ + public static SwingValidatorMessageTableMouseListener getErrorTableMouseListener(JTable table) { + if (table != null) { + for (MouseListener listener : table.getMouseListeners()) { + if (listener instanceof SwingValidatorMessageTableMouseListener) { + return (SwingValidatorMessageTableMouseListener) listener; + } + } + } + return null; + } + + public static String getMessage(SwingValidatorMessage model) { + String text = model.getMessage(); + if (model.getField() != null) { + text = model.getField().getI18nError(text); + } + return text; + } + + public static String getFieldName(SwingValidatorMessage model, String value) { + String text = null; + JComponent editor = model.getEditor(); + if (editor != null) { + text = (String) editor.getClientProperty("validatorLabel"); + /*if (l != null) { + text = I18n._(l); + } else { + // TODO should try the text + }*/ + } + if (text == null) { + text = value; + } + return text; + } + + public static ImageIcon getIcon(BeanValidatorScope scope) { + ImageIcon icon = null; + switch (scope) { + case ERROR: + icon = getErrorIcon(); + break; + case WARNING: + icon = getWarningIcon(); + break; + case INFO: + icon = getInfoIcon(); + break; + } + return icon; + } +} \ No newline at end of file Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,37 @@ +package jaxx.runtime.validator.swing.ui; + +import jaxx.runtime.validator.BeanValidatorEvent; +import jaxx.runtime.validator.BeanValidatorField; +import jaxx.runtime.validator.BeanValidatorListener; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.jxlayer.plaf.AbstractLayerUI; + +/** + * Abstract renderer + * + * @author chemit + */ +public abstract class AbstractBeanValidatorUI extends AbstractLayerUI<javax.swing.JComponent> implements BeanValidatorListener { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + private static final Log log = LogFactory.getLog(AbstractBeanValidatorUI.class); + /** the field to render */ + protected BeanValidatorField<?> field; + + public AbstractBeanValidatorUI(BeanValidatorField<?> field) { + this.field = field; + if (log.isDebugEnabled()) { + log.debug("install " + this + "<field:" + field + ">"); + } + } + + @Override + public void onFieldChanged(BeanValidatorEvent event) { + if (field.equals(event.getField())) { + // ask to repaint the layer + setDirty(true); + } + } + +} Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,86 @@ +package jaxx.runtime.validator.swing.ui; + +import org.jdesktop.jxlayer.JXLayer; + +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.awt.image.BufferedImage; +import jaxx.runtime.validator.BeanValidatorField; +import jaxx.runtime.validator.BeanValidatorScope; + +/** @author chemit */ +public class IconValidationUI extends AbstractBeanValidatorUI { + + // The icon to be shown at the layer's corner + protected static BufferedImage errorIcon; + protected static BufferedImage warningIcon; + protected static BufferedImage infoIcon; + + public IconValidationUI(BeanValidatorField<?> field) { + super(field); + if (errorIcon == null) { + errorIcon = prepareIcon(Color.RED); + } + if (warningIcon == null) { + warningIcon = prepareIcon(Color.ORANGE); + } + if (infoIcon == null) { + infoIcon = prepareIcon(Color.GREEN); + } + } + + @Override + public void installUI(JComponent c) { + super.installUI(c); + c.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 3)); + } + + @Override + public void uninstallUI(JComponent c) { + super.uninstallUI(c); + c.setBorder(null); + } + + @Override + protected void paintLayer(Graphics2D g2, JXLayer<JComponent> l) { + super.paintLayer(g2, l); + // There is no need to take insets into account for this painter + BeanValidatorScope scope = field.getScope(); + if (scope != null) { + BufferedImage icon = null; + switch (scope) { + case ERROR: + icon = errorIcon; + break; + case WARNING: + icon = warningIcon; + break; + case INFO: + icon = infoIcon; + break; + } + if (icon != null) { + g2.drawImage(icon, l.getWidth() - icon.getWidth() - 1, 0, null); + } + } + } + + protected static BufferedImage prepareIcon(Color color) { + int width = 7; + int height = 8; + BufferedImage icon = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); + Graphics2D g2 = (Graphics2D) icon.getGraphics(); + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); + g2.setColor(color); + g2.fillRect(0, 0, width, height); + g2.setColor(Color.WHITE); + g2.drawLine(0, 0, width, height); + g2.drawLine(0, height, width, 0); + g2.dispose(); + return icon; + } +} Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,78 @@ +package jaxx.runtime.validator.swing.ui; + +import org.jdesktop.jxlayer.JXLayer; + +import javax.swing.BorderFactory; +import javax.swing.ImageIcon; +import javax.swing.JComponent; +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.awt.image.BufferedImage; +import jaxx.runtime.validator.BeanValidatorField; +import jaxx.runtime.validator.BeanValidatorScope; + +/** @author chemit */ +public class ImageValidationUI extends AbstractBeanValidatorUI { + + protected static BufferedImage errorIcon; + protected static BufferedImage warningIcon; + protected static BufferedImage infoIcon; + + public ImageValidationUI(BeanValidatorField<?> field) { + super(field); + if (errorIcon == null) { + errorIcon = prepareIcon(jaxx.runtime.Util.createImageIcon("error.png")); + } + if (warningIcon == null) { + warningIcon = prepareIcon(jaxx.runtime.Util.createImageIcon("warning.png")); + } + if (infoIcon == null) { + infoIcon = prepareIcon(jaxx.runtime.Util.createImageIcon("info.png")); + } + } + + protected static BufferedImage prepareIcon(ImageIcon image) { + BufferedImage icon = new BufferedImage(image.getIconWidth(), image.getIconHeight(), BufferedImage.TYPE_INT_ARGB); + Graphics2D g2 = (Graphics2D) icon.getGraphics(); + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); + g2.drawImage(image.getImage(), 0, 0, null); + g2.dispose(); + return icon; + } + + @Override + public void installUI(JComponent c) { + super.installUI(c); + c.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 3)); + } + + @Override + public void uninstallUI(JComponent c) { + super.uninstallUI(c); + c.setBorder(null); + } + + @Override + protected void paintLayer(Graphics2D g2, JXLayer<JComponent> l) { + super.paintLayer(g2, l); + BeanValidatorScope scope = field.getScope(); + if (scope != null) { + BufferedImage icon = null; + switch (scope) { + case ERROR: + icon = errorIcon; + break; + case WARNING: + icon = warningIcon; + break; + case INFO: + icon = infoIcon; + break; + } + if (icon != null) { + g2.drawImage(icon, l.getWidth() - icon.getWidth() - 1, 0, null); + } + } + } +} \ No newline at end of file Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,65 @@ +package jaxx.runtime.validator.swing.ui; + +import jaxx.runtime.validator.BeanValidatorScope; +import org.jdesktop.jxlayer.JXLayer; + +import javax.swing.JComponent; +import java.awt.AlphaComposite; +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Insets; +import java.awt.Rectangle; +import jaxx.runtime.validator.BeanValidatorField; + +/** @author chemit */ +public class TranslucentValidationUI extends AbstractBeanValidatorUI { + + protected Color errorHightlight; + protected Color warningHightlight; + protected Color infoHightlight; + + public TranslucentValidationUI(BeanValidatorField<?> field) { + super(field); + errorHightlight = Color.RED; + warningHightlight = Color.YELLOW; + infoHightlight = Color.GREEN; + } + + @Override + protected void paintLayer(Graphics2D g2, JXLayer<JComponent> l) { + // paints the layer as is + super.paintLayer(g2, l); + + // to be in sync with the view if the layer has a border + Insets layerInsets = l.getInsets(); + g2.translate(layerInsets.left, layerInsets.top); + + JComponent view = l.getView(); + // To prevent painting on view's border + Insets insets = view.getInsets(); + g2.clip(new Rectangle(insets.left, insets.top, + view.getWidth() - insets.left - insets.right, + view.getHeight() - insets.top - insets.bottom)); + + BeanValidatorScope scope = field.getScope(); + + if (scope == null) { + g2.setColor(Color.WHITE); + } else { + switch (scope) { + case ERROR: + g2.setColor(errorHightlight); + break; + case WARNING: + g2.setColor(warningHightlight); + break; + case INFO: + g2.setColor(infoHightlight); + break; + } + } + + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .2f)); + g2.fillRect(0, 0, l.getWidth(), l.getHeight()); + } +} Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-api-en_GB.properties =================================================================== --- branches/jaxx-2.X/jaxx-runtime-api/src/main/resources/i18n/jaxx-runtime-api-en_GB.properties 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-api-en_GB.properties 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +0,0 @@ -validator.scope.error.label=Error -validator.scope.info.label=Information -validator.scope.warning.label=Warning Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-api-fr_FR.properties =================================================================== --- branches/jaxx-2.X/jaxx-runtime-api/src/main/resources/i18n/jaxx-runtime-api-fr_FR.properties 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-api-fr_FR.properties 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +0,0 @@ -validator.scope.error.label=Erreur -validator.scope.info.label=Information -validator.scope.warning.label=Avertissement Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-en_GB.properties (from rev 1558, branches/jaxx-2.X/jaxx-runtime-api/src/main/resources/i18n/jaxx-runtime-api-en_GB.properties) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-en_GB.properties (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-en_GB.properties 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,12 @@ +validator.field.header=Field +validator.field.header.tip=The field involved +validator.field.tip=Property '%1$s' +validator.message.header=Message +validator.message.header.tip=Message +validator.message.tip=Message \: %1$s +validator.scope.error.label=Error +validator.scope.header=... +validator.scope.header.tip=Severity of the message +validator.scope.info.label=Information +validator.scope.tip=Message scope \: '%1$s' +validator.scope.warning.label=Warning Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-fr_FR.properties (from rev 1558, branches/jaxx-2.X/jaxx-runtime-api/src/main/resources/i18n/jaxx-runtime-api-fr_FR.properties) =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-fr_FR.properties (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-fr_FR.properties 2009-10-05 19:15:44 UTC (rev 1559) @@ -0,0 +1,12 @@ +validator.field.header=Champ +validator.field.header.tip=Le champ surquel intervient le message +validator.field.tip=Propri\u00E9t\u00E9 '%1$s' +validator.message.header=Message +validator.message.header.tip=Le texte du message +validator.message.tip=Message \: %1$s +validator.scope.error.label=Erreur +validator.scope.header=... +validator.scope.header.tip=Le de type de message +validator.scope.info.label=Information +validator.scope.tip=Type de message \: '%1$s' +validator.scope.warning.label=Avertissement Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-delete.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-delete.png) =================================================================== (Binary files differ) Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-delete.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-config-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-config-16.png) =================================================================== (Binary files differ) Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-config-16.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-config.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-config.png) =================================================================== (Binary files differ) Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-config.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-message-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-message-16.png) =================================================================== (Binary files differ) Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-message-16.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-message.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-message.png) =================================================================== (Binary files differ) Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-message.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-next-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-next-16.png) =================================================================== (Binary files differ) Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-next-16.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-next.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-next.png) =================================================================== (Binary files differ) Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-next.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-pause-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-pause-16.png) =================================================================== (Binary files differ) Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-pause-16.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-pause.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-pause.png) =================================================================== (Binary files differ) Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-pause.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-previous-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-previous-16.png) =================================================================== (Binary files differ) Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-previous-16.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-previous.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-previous.png) =================================================================== (Binary files differ) Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-previous.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-refresh-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-refresh-16.png) =================================================================== (Binary files differ) Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-refresh-16.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-refresh.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-refresh.png) =================================================================== (Binary files differ) Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-refresh.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-start-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-start-16.png) =================================================================== (Binary files differ) Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-start-16.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-start.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-start.png) =================================================================== (Binary files differ) Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-start.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-canceled-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-canceled-16.png) =================================================================== (Binary files differ) Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-canceled-16.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-canceled.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-canceled.png) =================================================================== (Binary files differ) Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-canceled.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-failed-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-failed-16.png) =================================================================== (Binary files differ) Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-failed-16.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-failed.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-failed.png) =================================================================== (Binary files differ) Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-failed.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-need_fix-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-need_fix-16.png) =================================================================== (Binary files differ) Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-need_fix-16.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-need_fix.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-need_fix.png) =================================================================== (Binary files differ) Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-need_fix.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-pending-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-pending-16.png) =================================================================== (Binary files differ) Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-pending-16.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-pending.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-pending.png) =================================================================== (Binary files differ) Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-pending.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-running-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-running-16.png) =================================================================== (Binary files differ) Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-running-16.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-running.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-running.png) =================================================================== (Binary files differ) Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-running.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-successed-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-successed-16.png) =================================================================== (Binary files differ) Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-successed-16.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-successed.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-successed.png) =================================================================== (Binary files differ) Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-successed.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:mergeinfo + Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/error.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/error.png) =================================================================== (Binary files differ) Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/info.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/info.png) =================================================================== (Binary files differ) Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/warning.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/warning.png) =================================================================== (Binary files differ) Deleted: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/JXPathDecoratorTest.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime-api/src/test/java/jaxx/runtime/JXPathDecoratorTest.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/JXPathDecoratorTest.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,163 +0,0 @@ -package jaxx.runtime; - -import jaxx.runtime.JXPathDecorator.Context; -import org.junit.After; -import static org.junit.Assert.assertEquals; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -/** @author chemit */ -public class JXPathDecoratorTest { - - - protected JXPathDecorator<?> decorator; - protected String expected; - protected String result; - - @After - public void after() { - decorator = null; - } - - @Test(expected = NullPointerException.class) - public void testNullInternalClass() throws Exception { - decorator = JXPathDecorator.newDecorator(null, "hello"); - } - - @Test(expected = IllegalArgumentException.class) - public void testMissingRightBrace() throws Exception { - decorator = JXPathDecorator.newDecorator(Object.class, "${haha"); - } - - @Test(expected = IllegalArgumentException.class) - public void testMissingRightBrace2() throws Exception { - decorator = JXPathDecorator.newDecorator(Object.class, "${haha${hum}"); - } - - @Test - public void testNullBean() throws Exception { - decorator = JXPathDecorator.newDecorator(Object.class, "hello"); - expected = "hello"; - assertEquals(expected, decorator.getExpression()); - assertEquals(0, decorator.nbToken); - assertEquals(0, decorator.getTokens().length); - - result = decorator.toString(null); - assertEquals(null, result); - } - - @Test - public void testNoJXPath() throws Exception { - decorator = JXPathDecorator.newDecorator(Object.class, "hello"); - expected = "hello"; - assertEquals(expected, decorator.getExpression()); - assertEquals(0, decorator.nbToken); - assertEquals(0, decorator.getTokens().length); - - result = decorator.toString(this); - assertEquals(expected, result); - } - - @Test - public void testDecorator() throws Exception { - - decorator = JXPathDecorator.newDecorator(JXPathDecorator.class, "${expression}$s - ${nbToken}$d"); - assertEquals("%1$s - %2$d", decorator.getExpression()); - assertDecoratorInternal(); - - decorator = JXPathDecorator.newDecorator(JXPathDecorator.class, "${expression}${nbToken}"); - assertEquals("%1%2", decorator.getExpression()); - assertDecoratorInternal(); - - decorator = JXPathDecorator.newDecorator(JXPathDecorator.class, "before ${expression}$s - ${nbToken}$d after"); - assertEquals("before %1$s - %2$d after", decorator.getExpression()); - assertDecoratorInternal(); - - decorator = JXPathDecorator.newDecorator(JXPathDecorator.class, "before${expression}$s-${nbToken}$dafter"); - assertEquals("before%1$s-%2$dafter", decorator.getExpression()); - assertDecoratorInternal(); - } - - public static class Data { - int pos; - String name; - - protected static List<Data> generate(int nb) { - List<Data> datas = new ArrayList<Data>(nb); - for (int i = 0; i < nb; i++) { - datas.add(new Data(i, "name_" + (nb - i))); - } - return datas; - } - - Data(int pos, String name) { - this.pos = pos; - this.name = name; - } - - public int getPos() { - return pos; - } - - public String getName() { - return name; - } - - @Override - public String toString() { - return "Data{pos=" + pos + ", name='" + name + '\'' + '}'; - } - } - - @Test - public void testSort() throws Exception { - - List<Data> datas = Data.generate(10); - JXPathDecorator<Data> decorator = JXPathDecorator.newDecorator(Data.class, "${pos}$d ${name}$s"); - - List<Data> sortData = new ArrayList<Data>(datas); - JXPathDecorator.sort(decorator, sortData, 0); - for (int i = 0; i < datas.size(); i++) { - Data data = datas.get(i); - Data sData = sortData.get(i); - assertEquals(data, sData); - } - Collections.sort(datas, new Comparator<Data>() { - @Override - public int compare(Data o1, Data o2) { - return o1.name.compareTo(o2.name); - } - }); - Context<Data> context = decorator.context; - context.setComparator(null); - JXPathDecorator.sort(decorator, sortData, 1); - for (int i = 0; i < datas.size(); i++) { - Data data = datas.get(i); - Data sData = sortData.get(i); - assertEquals(data, sData); - } - } - - - public void assertDecoratorInternal(String... tokens) { - assertTokens(tokens); - expected = String.format(decorator.getExpression(), decorator.getExpression(), decorator.getNbToken()); - result = decorator.toString(decorator); - assertEquals(expected, result); - } - - private void assertTokens(String... tokens) { - if (tokens.length == 0) { - tokens = new String[]{"expression", "nbToken"}; - } - assertEquals(2, decorator.nbToken); - assertEquals(2, decorator.getTokens().length); - assertEquals(tokens[0], decorator.getTokens()[0]); - assertEquals(tokens[1], decorator.getTokens()[1]); - } - -} Deleted: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/MultiJXPathDecoratorTest.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime-api/src/test/java/jaxx/runtime/MultiJXPathDecoratorTest.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/MultiJXPathDecoratorTest.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,184 +0,0 @@ -package jaxx.runtime; - -import jaxx.runtime.JXPathDecoratorTest.Data; -import org.junit.After; -import static org.junit.Assert.assertEquals; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -/** @author chemit */ -public class MultiJXPathDecoratorTest { - - - protected MultiJXPathDecorator<?> decorator; - protected String expected; - protected String result; - - @After - public void after() { - decorator = null; - } - - @Test(expected = NullPointerException.class) - public void testNullInternalClass() throws Exception { - decorator = MultiJXPathDecorator.newDecorator(null, "hello", "#"); - } - - @Test(expected = IllegalArgumentException.class) - public void testMissingRightBrace() throws Exception { - decorator = MultiJXPathDecorator.newDecorator(Object.class, "${haha", "#"); - } - - @Test(expected = IllegalArgumentException.class) - public void testMissingRightBrace2() throws Exception { - decorator = MultiJXPathDecorator.newDecorator(Object.class, "${haha${hum}", "#"); - } - - @Test - public void testNullBean() throws Exception { - decorator = MultiJXPathDecorator.newDecorator(Object.class, "hello", ""); - expected = "hello"; - assertEquals(expected, decorator.getExpression()); - assertEquals(0, decorator.nbToken); - assertEquals(0, decorator.getTokens().length); - - result = decorator.toString(null); - assertEquals(null, result); - } - - @Test - public void testMultiDecorator() throws Exception { - - decorator = MultiJXPathDecorator.newDecorator(JXPathDecorator.class, "${expression}$s#${nbToken}$d", "#", " - "); - assertEquals("%1$s - %2$d", decorator.getExpression()); - assertDecoratorInternal(); - assertEquals(2, decorator.contexts.length); - decorator.setContextIndex(1); - assertEquals("%1$d - %2$s", decorator.getExpression()); - assertTokens("nbToken", "expression"); - expected = String.format(decorator.getExpression(), decorator.getNbToken(), decorator.getExpression()); - result = decorator.toString(decorator); - assertEquals(expected, result); - - decorator = MultiJXPathDecorator.newDecorator(JXPathDecorator.class, "${expression}$s ## ${nbToken}$d", " ## ", " - "); - assertEquals("%1$s - %2$d", decorator.getExpression()); - assertDecoratorInternal(); - assertEquals(2, decorator.contexts.length); - decorator.setContextIndex(1); - assertEquals("%1$d - %2$s", decorator.getExpression()); - assertTokens("nbToken", "expression"); - expected = String.format(decorator.getExpression(), decorator.getNbToken(), decorator.getExpression()); - result = decorator.toString(decorator); - assertEquals(expected, result); - } - - @Test - public void testMultiDecorator2() throws Exception { - - decorator = MultiJXPathDecorator.newDecorator(JXPathDecorator.class, "${expression}$s#${nbToken}$d#${separator}$s", "#", " - "); - - assertEquals("%1$s - %2$d - %3$s", decorator.getExpression()); - assertTokens("expression", "nbToken", "separator"); - assertEquals(3, decorator.contexts.length); - - expected = String.format(decorator.getExpression(), decorator.getExpression(), decorator.getNbToken(), decorator.getSeparator()); - result = decorator.toString(decorator); - assertEquals(expected, result); - - decorator.setContextIndex(1); - assertEquals("%1$d - %2$s - %3$s", decorator.getExpression()); - assertTokens("nbToken", "separator", "expression"); - expected = String.format(decorator.getExpression(), decorator.getNbToken(), decorator.getSeparator(), decorator.getExpression()); - result = decorator.toString(decorator); - assertEquals(expected, result); - - decorator.setContextIndex(2); - assertEquals("%1$s - %2$s - %3$d", decorator.getExpression()); - assertTokens("separator", "expression", "nbToken"); - - expected = String.format(decorator.getExpression(), decorator.getSeparator(), decorator.getExpression(), decorator.getNbToken()); - result = decorator.toString(decorator); - assertEquals(expected, result); - } - - @Test - public void testMultiDecoratorWithMultiRef() throws Exception { - - decorator = MultiJXPathDecorator.newDecorator(JXPathDecorator.class, "${expression}$s#${nbToken}$d#${separator}$s %3$s", "#", " - "); - - assertEquals("%1$s - %2$d - %3$s %3$s", decorator.getExpression()); - assertTokens("expression", "nbToken", "separator"); - assertEquals(3, decorator.contexts.length); - - expected = String.format(decorator.getExpression(), decorator.getExpression(), decorator.getNbToken(), decorator.getSeparator()); - result = decorator.toString(decorator); - assertEquals(expected, result); - - decorator.setContextIndex(1); - assertEquals("%1$d - %2$s %3$s - %3$s", decorator.getExpression()); - assertTokens("nbToken", "separator", "expression"); - expected = String.format(decorator.getExpression(), decorator.getNbToken(), decorator.getSeparator(), decorator.getExpression()); - result = decorator.toString(decorator); - assertEquals(expected, result); - - decorator.setContextIndex(2); - assertEquals("%1$s %3$s - %2$s - %3$d", decorator.getExpression()); - assertTokens("separator", "expression", "nbToken"); - - expected = String.format(decorator.getExpression(), decorator.getSeparator(), decorator.getExpression(), decorator.getNbToken()); - result = decorator.toString(decorator); - assertEquals(expected, result); - } - - @Test - public void testSort() throws Exception { - - List<Data> datas = Data.generate(10); - - MultiJXPathDecorator<Data> decorator = MultiJXPathDecorator.newDecorator(Data.class, "${pos}$d-${name}$s", "-"); - - List<Data> sortData = new ArrayList<Data>(datas); - JXPathDecorator.sort(decorator, sortData, 0); - for (int i = 0; i < datas.size(); i++) { - Data data = datas.get(i); - Data sData = sortData.get(i); - assertEquals(data, sData); - } - Collections.sort(datas, new Comparator<Data>() { - @Override - public int compare(Data o1, Data o2) { - return o1.name.compareTo(o2.name); - } - }); - decorator.setContextIndex(1); - JXPathDecorator.sort(decorator, sortData, 1); - for (int i = 0; i < datas.size(); i++) { - Data data = datas.get(i); - Data sData = sortData.get(i); - assertEquals(data, sData); - } - } - - public void assertDecoratorInternal(String... tokens) { - assertTokens(tokens); - expected = String.format(decorator.getExpression(), decorator.getExpression(), decorator.getNbToken()); - result = decorator.toString(decorator); - assertEquals(expected, result); - } - - private void assertTokens(String... tokens) { - if (tokens.length == 0) { - tokens = new String[]{"expression", "nbToken"}; - } - assertEquals(tokens.length, decorator.nbToken); - assertEquals(tokens.length, decorator.getTokens().length); - for (int i = 0; i < tokens.length; i++) { - assertEquals(tokens[i], decorator.getTokens()[i]); - } - } - -} \ No newline at end of file Modified: branches/jaxx-2.X/jaxx-runtime/src/test/resources/log4j.properties =================================================================== --- branches/jaxx-2.X/jaxx-runtime-api/src/test/resources/log4j.properties 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-runtime/src/test/resources/log4j.properties 2009-10-05 19:15:44 UTC (rev 1559) @@ -5,4 +5,4 @@ log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n -log4j.logger.jaxx=DEBUG +log4j.logger.jaxx=INFO Modified: branches/jaxx-2.X/jaxx-swing-action/pom.xml =================================================================== --- branches/jaxx-2.X/jaxx-swing-action/pom.xml 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-swing-action/pom.xml 2009-10-05 19:15:44 UTC (rev 1559) @@ -11,7 +11,7 @@ <parent> <groupId>org.nuiton</groupId> <artifactId>jaxx</artifactId> - <version>1.7.2-SNAPSHOT</version> + <version>2.0.0-SNAPSHOT</version> </parent> <groupId>org.nuiton.jaxx</groupId> @@ -21,7 +21,7 @@ <dependency> <groupId>${project.groupId}</groupId> - <artifactId>jaxx-runtime-swing</artifactId> + <artifactId>jaxx-runtime</artifactId> <version>${project.version}</version> </dependency> @@ -42,8 +42,8 @@ <!-- *** Project Information ************************************* --> <!-- ************************************************************* --> - <name>${project.artifactId}</name> - <description>Jaxx lutin library swing extension (tabs and actions)</description> + <name>JAXX Action</name> + <description>JAXX Action framework</description> <!-- ************************************************************* --> <!-- *** Build Settings ****************************************** --> Modified: branches/jaxx-2.X/jaxx-widgets/pom.xml =================================================================== --- branches/jaxx-2.X/jaxx-runtime-swing-widget/pom.xml 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-widgets/pom.xml 2009-10-05 19:15:44 UTC (rev 1559) @@ -10,11 +10,11 @@ <parent> <groupId>org.nuiton</groupId> <artifactId>jaxx</artifactId> - <version>1.7.2-SNAPSHOT</version> + <version>2.0.0-SNAPSHOT</version> </parent> <groupId>org.nuiton.jaxx</groupId> - <artifactId>jaxx-runtime-swing-widget</artifactId> + <artifactId>jaxx-widgets</artifactId> <dependencies> @@ -22,7 +22,7 @@ <dependency> <groupId>${project.groupId}</groupId> - <artifactId>jaxx-runtime-swing</artifactId> + <artifactId>jaxx-runtime</artifactId> <version>${project.version}</version> </dependency> @@ -47,8 +47,8 @@ <!-- *** Project Information ************************************* --> <!-- ************************************************************* --> - <name>${project.artifactId}</name> - <description>Jaxx runtime swing widgets</description> + <name>JAXX Widgets</name> + <description>Collection of swing widgets wrote with JAXX</description> <!-- ************************************************************* --> <!-- *** Build Settings ****************************************** --> @@ -97,13 +97,9 @@ <groupId>org.nuiton.i18n</groupId> <artifactId>maven-i18n-plugin</artifactId> <configuration> - <silent>true</silent> <entries> <entry> - <basedir>${maven.gen.dir}/java/</basedir> - <includes> - <param>**\/**.java</param> - </includes> + <basedir>${maven.gen.dir}/java</basedir> </entry> </entries> </configuration> Modified: branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -76,6 +76,7 @@ <script><![CDATA[ import static org.nuiton.i18n.I18n.n_; +import jaxx.runtime.decorator.JXPathDecorator; public static final String DEFAULT_POPUP_LABEL = n_("entitycombobox.popup.label"); @@ -83,7 +84,7 @@ public static final String DEFAULT_NOT_SELECTED_TOOLTIP = n_("entitycombobox.sort.off"); -public <O> void init(jaxx.runtime.JXPathDecorator<O> decorator, java.util.List<O> data) { +public <O> void init(JXPathDecorator<O> decorator, java.util.List<O> data) { handler.init(decorator, data); } Modified: branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -19,9 +19,6 @@ package jaxx.runtime.swing; import java.awt.Component; -import jaxx.runtime.JXPathDecorator; -import jaxx.runtime.MultiJXPathDecorator; -import jaxx.runtime.Util; import jaxx.runtime.SwingUtil; import org.apache.commons.beanutils.PropertyUtils; import org.apache.commons.logging.Log; @@ -46,7 +43,11 @@ import java.lang.reflect.Method; import java.util.List; import javax.swing.JComboBox; -import jaxx.runtime.Decorator; +import jaxx.runtime.decorator.Decorator; +import jaxx.runtime.decorator.JXPathDecorator; +import jaxx.runtime.decorator.MultiJXPathDecorator; +import jaxx.runtime.decorator.swing.DecoratorListCellRenderer; +import jaxx.runtime.decorator.DecoratorUtils; import org.jdesktop.swingx.autocomplete.AutoCompletePropertyChangeListener; /** @@ -119,12 +120,12 @@ // should clone decorator ? d = (MultiJXPathDecorator<O>) decorator; } else { - d = MultiJXPathDecorator.newDecorator(decorator.getInternalClass(), decorator.getInitialExpression(), " - "); + d = DecoratorUtils.newMultiJXPathDecorator(decorator.getInternalClass(), decorator.getInitialExpression(), " - "); } this.decorator = d; // init combobox renderer base on given decorator - ui.getCombobox().setRenderer(Util.newDecoratedListCellRenderer(d)); + ui.getCombobox().setRenderer(new DecoratorListCellRenderer(d)); this.convertor = newDecoratedObjectToStringConverter(d); @@ -233,7 +234,7 @@ try { // Sort data with the decorator jxpath tokens. - JXPathDecorator.sort(decorator, ui.getData(), newValue); + DecoratorUtils.sort(decorator, ui.getData(), newValue); } catch (Exception e) { log.warn(e.getMessage(), e); //System.out.println("newValue :: "+decorator+" : "+newValue); Modified: branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties =================================================================== --- branches/jaxx-2.X/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties 2009-10-05 19:15:44 UTC (rev 1559) @@ -2,8 +2,7 @@ aboutframe.license=License aboutframe.ok=OK aboutframe.thirdparty=Third party -columnselection.action.tip= -columnselector.action.tip= +columnselector.action.tip=Select the columns config.action.quit=Quit config.action.quit.tip=Quit the configuration editor config.action.reset=Cancel Modified: branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties =================================================================== --- branches/jaxx-2.X/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties 2009-10-05 19:15:44 UTC (rev 1559) @@ -2,8 +2,7 @@ aboutframe.license=Licence aboutframe.ok=OK aboutframe.thirdparty=Tierce partie -columnselection.action.tip= -columnselector.action.tip= +columnselector.action.tip=S\u00E9lectionner les colonnes config.action.quit=Quitter config.action.quit.tip=Quitter l'\u00E9diteur de configuration config.action.reset=Annuler Modified: branches/jaxx-2.X/maven-jaxx-plugin/pom.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/pom.xml 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/maven-jaxx-plugin/pom.xml 2009-10-05 19:15:44 UTC (rev 1559) @@ -10,7 +10,7 @@ <parent> <groupId>org.nuiton</groupId> <artifactId>jaxx</artifactId> - <version>1.7.2-SNAPSHOT</version> + <version>2.0.0-SNAPSHOT</version> </parent> <groupId>org.nuiton.jaxx</groupId> @@ -22,6 +22,12 @@ <dependency> <groupId>${project.groupId}</groupId> + <artifactId>jaxx-runtime</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>${project.groupId}</groupId> <artifactId>jaxx-compiler</artifactId> <version>${project.version}</version> </dependency> @@ -108,10 +114,9 @@ <!-- *** Project Information ************************************* --> <!-- ************************************************************* --> - <name>${project.artifactId}</name> + <name>JAXX Maven plugin</name> <description> - Maven 2 plugin to generate java source from ui interface definitions - in jaxx format. + Maven 2 plugin to generate java sources from JAXX files. </description> <!-- ************************************************************* --> @@ -135,6 +140,188 @@ </plugin> </plugins> + + <pluginManagement> + <plugins> + <plugin> + <artifactId>maven-javadoc-plugin</artifactId> + <version>${javadoc.version}</version> + <configuration> + <taglets> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoAggregatorTypeTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoComponentFieldTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoConfiguratorTypeTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoExecuteTypeTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoExecutionStrategyTypeTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoGoalTypeTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoInheritByDefaultTypeTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoInstantiationStrategyTypeTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoParameterFieldTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoPhaseTypeTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoReadOnlyFieldTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiredFieldTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresDependencyResolutionTypeTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresDirectInvocationTypeTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresOnLineTypeTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresProjectTypeTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresReportsTypeTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + + <taglet> + <tagletClass>org.codehaus.plexus.javadoc.PlexusComponentTaglet</tagletClass> + <tagletArtifact> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-javadoc</artifactId> + <version>1.0</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.codehaus.plexus.javadoc.PlexusConfigurationTaglet</tagletClass> + <tagletArtifact> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-javadoc</artifactId> + <version>1.0</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.codehaus.plexus.javadoc.PlexusRequirementTaglet</tagletClass> + <tagletArtifact> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-javadoc</artifactId> + <version>1.0</version> + </tagletArtifact> + </taglet> + </taglets> + </configuration> + <executions> + <execution> + <id>attach-javadocs</id> + <goals> + <goal>jar</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </pluginManagement> </build> <reporting> @@ -142,6 +329,175 @@ <plugin> <artifactId>maven-plugin-plugin</artifactId> </plugin> + <plugin> + <artifactId>maven-javadoc-plugin</artifactId> + <version>${javadoc.version}</version> + <configuration> + <taglets> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoAggregatorTypeTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoComponentFieldTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoConfiguratorTypeTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoExecuteTypeTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoExecutionStrategyTypeTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoGoalTypeTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoInheritByDefaultTypeTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoInstantiationStrategyTypeTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoParameterFieldTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoPhaseTypeTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoReadOnlyFieldTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiredFieldTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresDependencyResolutionTypeTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresDirectInvocationTypeTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresOnLineTypeTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresProjectTypeTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresReportsTypeTaglet</tagletClass> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>2.4.2</version> + </tagletArtifact> + </taglet> + + <taglet> + <tagletClass>org.codehaus.plexus.javadoc.PlexusComponentTaglet</tagletClass> + <tagletArtifact> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-javadoc</artifactId> + <version>1.0</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.codehaus.plexus.javadoc.PlexusConfigurationTaglet</tagletClass> + <tagletArtifact> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-javadoc</artifactId> + <version>1.0</version> + </tagletArtifact> + </taglet> + <taglet> + <tagletClass>org.codehaus.plexus.javadoc.PlexusRequirementTaglet</tagletClass> + <tagletArtifact> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-javadoc</artifactId> + <version>1.0</version> + </tagletArtifact> + </taglet> + </taglets> + </configuration> + </plugin> </plugins> </reporting> Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -124,46 +124,6 @@ protected boolean checkPackaging() { return project != null && !"pom".equals(project.getPackaging()) && !"site".equals(project.getPackaging()); } -// @Override -// public void execute() throws MojoExecutionException, MojoFailureException { -// -// try { -// init(); -// } catch (Exception e) { -// if (e instanceof MojoFailureException) { -// throw (MojoFailureException) e; -// } -// if (e instanceof MojoExecutionException) { -// throw (MojoExecutionException) e; -// } -// throw new MojoExecutionException("error in init : " + e.getMessage(), e); -// } -// -// if (skip) { -// if (verbose) { -// getLog().info("jaxx - skip!"); -// } -// return; -// } -// -// try { -// -// doAction(); -// -// } catch (Exception e) { -// //getLog().error(e); -// Throwable e2 = e; -// while (e2.getCause() != null) { -// e2 = e.getCause(); -// } -// getLog().error(e2); -// -// throw new MojoExecutionException(e2.getMessage(), e2); -// } finally { -// System.gc(); -// } -// -// } @Override public MavenProject getProject() { Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java 2009-10-05 19:15:44 UTC (rev 1559) @@ -182,9 +182,9 @@ */ protected String jaxxContextImplementorClass; /** - * extra path to be added in {@link java.beans.Introspector#setBeanInfoSearchPath(String[])}. + * extra path to be added in {@link java.beans.Introspector#setBeanInfoSearchPath(java.lang.String[])}. * <p/> - * add beanInfoSearchPath to be registred by {@link BeanInfoUtil#addJaxxBeanInfoPath(String[])} + * add beanInfoSearchPath to be registred by {@link BeanInfoUtil#addJaxxBeanInfoPath(java.lang.String[])} * <p/> * and then will be use by {@link jaxx.tags.swing.SwingInitializer#initialize()}. * <p/> @@ -215,7 +215,8 @@ * If not given, will use the one defined in validator * * @parameter expression="${jaxx.defaultErrorUIFQN}" - * @see jaxx.runtime.validator.swing.SwingValidator#DEFAULT_UI_CLASS + * + * @see jaxx.runtime.validator.swing.SwingValidator */ protected String defaultErrorUIFQN; /** @@ -284,13 +285,6 @@ if (skip) { return true; } -// -// if (project != null && ("pom".equals(project.getPackaging()) || "site".equals(project.getPackaging()))) { -// // nothing to be done for this type of packaging -// skip = true; -// getLog().info("skip generate goal for packaging " + project.getPackaging()); -// return true; -// } if (generateHelp) { // check there is some bundle @@ -475,14 +469,7 @@ return result; } - //TODO use the AbstractPublig method protected void fixCompileSourceRoots() { -// //fixme should remove this silly test when we will make real maven plugin tests :) -// if (project != null) { -// if (!project.getCompileSourceRoots().contains(outJava.getPath())) { -// project.addCompileSourceRoot(outJava.getPath()); -// } -// } if (project == null) { // no project defined, can not fix anything // this case could appears if we wanted to do some tests of the plugin @@ -525,13 +512,6 @@ getLog().warn("??? : " + e.getMessage(), e); } } - - //fixme should remove this silly test when we will make real maven plugin tests :) - if (getPluginContext() != null) { - for (Object e : getPluginContext().keySet()) { - getLog().info("pluginContext " + e + " : " + getPluginContext().get(e)); - } - } } protected void checkJaxxContextImplementorClass() { Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JComboBoxTest1.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JComboBoxTest1.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JComboBoxTest1.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +1,3 @@ -<JComboBox> +<JAXXComboBox> <item value='Working' selected='true'/> -</JComboBox> \ No newline at end of file +</JAXXComboBox> \ No newline at end of file Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JComboBoxTest2.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JComboBoxTest2.jaxx 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JComboBoxTest2.jaxx 2009-10-05 19:15:44 UTC (rev 1559) @@ -1,3 +1,3 @@ -<JComboBox> +<JAXXComboBox> <item value='Failed!'/> -</JComboBox> \ No newline at end of file +</JAXXComboBox> \ No newline at end of file Modified: branches/jaxx-2.X/pom.xml =================================================================== --- branches/jaxx-2.X/pom.xml 2009-10-05 13:18:45 UTC (rev 1558) +++ branches/jaxx-2.X/pom.xml 2009-10-05 19:15:44 UTC (rev 1559) @@ -14,18 +14,17 @@ </parent> <artifactId>jaxx</artifactId> - <version>1.7.2-SNAPSHOT</version> + <version>2.0.0-SNAPSHOT</version> <modules> - <module>jaxx-runtime-api</module> - <module>jaxx-runtime-swing</module> + <module>jaxx-runtime</module> <module>jaxx-compiler</module> <module>jaxx-swing-action</module> <module>maven-jaxx-plugin</module> - <module>jaxx-runtime-swing-widget</module> + <module>jaxx-widgets</module> <!-- deprecated since 1.7.2, will be removed before 2.0.0 <module>jaxx-example</module--> @@ -256,7 +255,7 @@ <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> - <version>1.2.9</version> + <version>1.2.14</version> </dependency> <dependency> @@ -308,8 +307,8 @@ <!-- *** Project Information ************************************* --> <!-- ************************************************************* --> - <name>${project.artifactId}</name> - <description>Jaxx library parent pom</description> + <name>JAXX Project</name> + <description>JAXX Project</description> <inceptionYear>2008</inceptionYear> <url>http://maven-site.nuiton.org/jaxx</url> @@ -325,7 +324,7 @@ <projectId>jaxx</projectId> <lutinutil.version>1.1.0</lutinutil.version> - <i18n.version>1.0.1-SNAPSHOT</i18n.version> + <i18n.version>1.0.2-SNAPSHOT</i18n.version> <jxlayer.version>3.0.3</jxlayer.version>
participants (1)
-
tchemit@users.nuiton.org