r1673 - in trunk: . jaxx-compiler jaxx-compiler/src/main/java/jaxx jaxx-compiler/src/main/java/jaxx/compiler jaxx-compiler/src/main/java/jaxx/compiler/beans jaxx-compiler/src/main/java/jaxx/compiler/binding jaxx-compiler/src/main/java/jaxx/compiler/css jaxx-compiler/src/main/java/jaxx/compiler/css/parser jaxx-compiler/src/main/java/jaxx/compiler/decorators jaxx-compiler/src/main/java/jaxx/compiler/finalizers jaxx-compiler/src/main/java/jaxx/compiler/java jaxx-compiler/src/main/java/jaxx/compi
Author: tchemit Date: 2009-12-02 14:59:28 +0100 (Wed, 02 Dec 2009) New Revision: 1673 Added: trunk/jaxx-compiler/src/main/java/jaxx/compiler/ClassMap.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/CompilerException.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/IDHelper.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompilerFinalizer.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXEngine.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedAttributeException.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedTagException.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/ trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/BeanInfoUtil.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanDescriptor.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanInfo.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXEventSetDescriptor.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXFeatureDescriptor.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXIntrospector.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXPropertyDescriptor.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/ trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataBinding.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataBindingHelper.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataSource.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/PseudoClassDataBinding.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/StylesheetHelper.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSS.jj trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSS.jjt trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParser.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParserConstants.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParserTokenManager.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParserTreeConstants.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/JJTCSSParserState.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/Node.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/ParseException.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/SimpleCharStream.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/SimpleNode.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/Token.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/TokenMgrError.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/decorators/ trunk/jaxx-compiler/src/main/java/jaxx/compiler/decorators/BoxedCompiledObjectDecorator.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/decorators/DefaultCompiledObjectDecorator.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/ trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/DefaultFinalizer.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/SwingFinalizer.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/ValidatorFinalizer.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaArgument.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaElement.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaField.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaFile.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaFileGenerator.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaMethod.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JJTJavaParserState.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Java1.5.jj trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Java1.5.jjt trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaCharStream.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParser.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParserConstants.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParserTokenManager.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParserTreeConstants.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Node.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/ParseException.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/SimpleNode.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Token.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/TokenMgrError.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptor.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptorLoader.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/FieldDescriptor.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/JavaFileParser.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MemberDescriptor.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MethodDescriptor.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/script/ trunk/jaxx-compiler/src/main/java/jaxx/compiler/script/ScriptInitializer.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/script/ScriptManager.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/spi/ trunk/jaxx-compiler/src/main/java/jaxx/compiler/spi/DefaultInitializer.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/spi/Initializer.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultComponentHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/ScriptHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/StyleHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagManager.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ApplicationHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CellHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CompiledItemContainer.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ItemHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXComboBoxHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXListHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTabHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTreeHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JCheckBoxHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JComboBoxHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JInternalFrameHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JListHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JMenuHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPasswordFieldHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPopupMenuHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JProgressBarHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JRadioButtonHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JScrollPaneHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSliderHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSpinnerHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSplitPaneHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTabbedPaneHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTextComponentHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JToolBarHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTreeHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JWindowHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/RowHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TableHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/BeanValidatorHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/ExcludeFieldValidatorHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/FieldValidatorHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/PrintTagInfo.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/AbstractContextNode.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/CapturedObject.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ContextNode.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/JAXXCapture.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/LiteralNode.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/MethodNode.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/PropertyNode.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ValueNode.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/JTabbedPaneHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/ObjectHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/TableHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/ trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/ColorConverter.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/GridBagConstraintsConverter.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/InsetsConverter.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/KeyStrokeConverter.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/PrimitiveConverter.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeConverter.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeManager.java trunk/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.CompiledObjectDecorator trunk/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.JAXXCompilerFinalizer trunk/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.spi.Initializer trunk/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.types.TypeConverter trunk/jaxx-compiler/src/test/java/jaxx/compiler/ trunk/jaxx-compiler/src/test/java/jaxx/compiler/JavaFileParserTest.java trunk/jaxx-compiler/src/test/java/jaxx/compiler/JavaMethodTest.java trunk/jaxx-compiler/src/test/java/jaxx/compiler/beans/ trunk/jaxx-compiler/src/test/java/jaxx/compiler/beans/BeanIntoUtilTest.java trunk/jaxx-compiler/src/test/java/jaxx/compiler/reflect/ trunk/jaxx-compiler/src/test/java/jaxx/compiler/reflect/ClassDescriptorTest.java trunk/jaxx-compiler/src/test/java/jaxx/compiler/tags/ trunk/jaxx-compiler/src/test/java/jaxx/compiler/tags/TagManagerTest.java trunk/jaxx-compiler/src/test/java/jaxx/compiler/types/ trunk/jaxx-compiler/src/test/java/jaxx/compiler/types/ColorConverterTest.java trunk/jaxx-compiler/src/test/java/jaxx/compiler/types/InsetsConverterTest.java trunk/jaxx-compiler/src/test/java/jaxx/compiler/types/PrimitiveConverterTest.java trunk/jaxx-compiler/src/test/java/jaxx/compiler/types/TypeManagerTest.java trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeDemo.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeHelper.java trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeModelBuilder.java trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/Movie.java trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/People.java trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorContentUI.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorsContentUI.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ContentUI.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ContentUIHandler.java trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MovieContentUI.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MoviesContentUI.jaxx trunk/jaxx-runtime/ trunk/jaxx-runtime/LICENSE.txt trunk/jaxx-runtime/README.txt trunk/jaxx-runtime/changelog.txt trunk/jaxx-runtime/pom.xml trunk/jaxx-runtime/src/ trunk/jaxx-runtime/src/main/ trunk/jaxx-runtime/src/main/java/ trunk/jaxx-runtime/src/main/java/jaxx/ trunk/jaxx-runtime/src/main/java/jaxx/runtime/ trunk/jaxx-runtime/src/main/java/jaxx/runtime/Base64Coder.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/ComponentDescriptor.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingListener.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingUpdateListener.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXAction.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXBinding.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObjectDescriptor.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXValidator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/Util.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/ trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/ trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/DataBinding.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/Pseudoclasses.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/Rule.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/Selector.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/Stylesheet.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/ trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/Decorator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorProvider.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/JXPathDecorator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/MultiJXPathDecorator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/PropertyDecorator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/Application.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/GBC.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBox.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxBeanInfo.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxLayout.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/Item.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXButtonGroup.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXComboBox.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXList.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTab.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXToggleButton.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTree.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/OneClicListSelectionModel.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/Spacer.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/Table.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBox.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxBeanInfo.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxLayout.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/ClassCellEditor.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/EnumEditor.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/LocaleEditor.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/MyDefaultCellEditor.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpBroker.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUI.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUIHandler.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationCardPanel.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationPanel.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemTreeNavigationAdapter.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationContentUI.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRenderer.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererDecoratorImpl.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererI18nImpl.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/package.html trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/BooleanCellRenderer.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorListCellRenderer.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorProviderListCellRenderer.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorProviderTableCellRenderer.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorTableCellRenderer.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EmptyNumberTableCellRenderer.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EnumTableCellRenderer.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/I18nTableCellRenderer.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/LocaleListCellRenderer.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/MultiDecoratorListCellRenderer.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/MultiDecoratorTableCelleRenderer.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorDetector.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorField.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorScope.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/CollectionFieldExpressionValidator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingFileFieldValidator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/FieldExpressionWithParamsValidator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/NotExistingDirectoryFieldValidator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/NotExistingFileFieldValidator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/RequiredFileFieldValidator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java trunk/jaxx-runtime/src/main/resources/ trunk/jaxx-runtime/src/main/resources/i18n/ trunk/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-en_GB.properties trunk/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-fr_FR.properties trunk/jaxx-runtime/src/main/resources/icons/ trunk/jaxx-runtime/src/main/resources/icons/action-delete.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-config-16.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-config.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-message-16.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-message.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-next-16.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-next.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-pause-16.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-pause.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-previous-16.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-previous.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-refresh-16.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-refresh.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-start-16.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-start.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-canceled-16.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-canceled.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-failed-16.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-failed.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-need_fix-16.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-need_fix.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-pending-16.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-pending.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-running-16.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-running.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-successed-16.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-successed.png trunk/jaxx-runtime/src/main/resources/icons/error.png trunk/jaxx-runtime/src/main/resources/icons/info.png trunk/jaxx-runtime/src/main/resources/icons/warning.png trunk/jaxx-runtime/src/main/resources/validators.xml trunk/jaxx-runtime/src/site/ trunk/jaxx-runtime/src/site/rst/ trunk/jaxx-runtime/src/site/site.xml trunk/jaxx-runtime/src/test/ trunk/jaxx-runtime/src/test/java/ trunk/jaxx-runtime/src/test/java/jaxx/ trunk/jaxx-runtime/src/test/java/jaxx/runtime/ trunk/jaxx-runtime/src/test/java/jaxx/runtime/UtilTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/ trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultApplicationContextTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/decorator/ trunk/jaxx-runtime/src/test/java/jaxx/runtime/decorator/Data.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/decorator/DecoratorProviderTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/decorator/JXPathDecoratorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/decorator/MultiJXPathDecoratorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/swing/ trunk/jaxx-runtime/src/test/java/jaxx/runtime/swing/navigation/ trunk/jaxx-runtime/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/AbstractBeanValidatorDetectorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/BeanValidatorDetectorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/BeanValidatorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/SimpleBean.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/XWorkBeanValidatorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/AbstractFieldValidatorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/AbstractValidatorBeanFieldValidatorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/CollectionFieldExpressionValidatorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidatorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidatorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/ExistingFileFieldValidatorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/FieldExpressionBean.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/FieldExpressionWithParamsValidatorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/NotExistingDirectoryFieldValidatorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/NotExistingFileFieldValidatorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/RequiredFileFieldValidatorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/ValidatorBean.java trunk/jaxx-runtime/src/test/resources/ trunk/jaxx-runtime/src/test/resources/jaxx/ trunk/jaxx-runtime/src/test/resources/jaxx/runtime/ trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/ trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-error-validation.xml trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-info-validation.xml trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-simple-validation.xml trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-warning-validation.xml trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/field/ trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/field/FieldExpressionBean-error-validation.xml trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/field/ValidatorBean-error-validation.xml trunk/jaxx-runtime/src/test/resources/log4j.properties trunk/jaxx-runtime/src/test/resources/validators.xml trunk/jaxx-widgets/ trunk/jaxx-widgets/LICENSE.txt trunk/jaxx-widgets/README.txt trunk/jaxx-widgets/changelog.txt trunk/jaxx-widgets/pom.xml trunk/jaxx-widgets/src/ trunk/jaxx-widgets/src/main/ trunk/jaxx-widgets/src/main/java/ trunk/jaxx-widgets/src/main/java/jaxx/ trunk/jaxx-widgets/src/main/java/jaxx/runtime/ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/AboutPanel.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ClockWidget.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ErrorDialogUI.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/HidorButton.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ListSelectorUI.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/MemoryStatusWidget.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/StatusMessagePanel.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/StatusMessagePanelHandler.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/ColumnSelector.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/I18nEditor.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditor.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorPopup.css trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/TimeEditor.css trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/TimeEditor.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/TimeEditorHandler.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.css trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableEditor.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableRenderer.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.css trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigTableModel.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java trunk/jaxx-widgets/src/main/resources/ trunk/jaxx-widgets/src/main/resources/i18n/ trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties trunk/jaxx-widgets/src/main/resources/icons/ trunk/jaxx-widgets/src/main/resources/icons/action-add.png trunk/jaxx-widgets/src/main/resources/icons/action-collapse.png trunk/jaxx-widgets/src/main/resources/icons/action-config-quit.png trunk/jaxx-widgets/src/main/resources/icons/action-config-reset.png trunk/jaxx-widgets/src/main/resources/icons/action-config-save.png trunk/jaxx-widgets/src/main/resources/icons/action-expand.png trunk/jaxx-widgets/src/main/resources/icons/action-i18n-be.png trunk/jaxx-widgets/src/main/resources/icons/action-i18n-ca.png trunk/jaxx-widgets/src/main/resources/icons/action-i18n-ch.png trunk/jaxx-widgets/src/main/resources/icons/action-i18n-de.png trunk/jaxx-widgets/src/main/resources/icons/action-i18n-dk.png trunk/jaxx-widgets/src/main/resources/icons/action-i18n-es.png trunk/jaxx-widgets/src/main/resources/icons/action-i18n-fi.png trunk/jaxx-widgets/src/main/resources/icons/action-i18n-fr.png trunk/jaxx-widgets/src/main/resources/icons/action-i18n-gb.png trunk/jaxx-widgets/src/main/resources/icons/action-i18n-it.png trunk/jaxx-widgets/src/main/resources/icons/action-i18n-nl.png trunk/jaxx-widgets/src/main/resources/icons/action-i18n-no.png trunk/jaxx-widgets/src/main/resources/icons/action-i18n-se.png trunk/jaxx-widgets/src/main/resources/icons/action-i18n-us.png trunk/jaxx-widgets/src/main/resources/icons/action-numbereditor-calculator.png trunk/jaxx-widgets/src/main/resources/icons/action-numbereditor-reset.png trunk/jaxx-widgets/src/main/resources/icons/action-numbereditor-validate.png trunk/jaxx-widgets/src/main/resources/icons/action-remove.png trunk/jaxx-widgets/src/site/ trunk/jaxx-widgets/src/site/rst/ trunk/jaxx-widgets/src/site/rst/images/ trunk/jaxx-widgets/src/site/rst/images/Components-screenshot.gif trunk/jaxx-widgets/src/site/rst/images/webstart.gif trunk/jaxx-widgets/src/site/rst/index.rst trunk/jaxx-widgets/src/site/site.xml trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/XmlHelper.java trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBinding/ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBinding/Bean.java trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBinding/BeanImpl.java trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBindingTest.java trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Evolution74Test.java trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerTest/ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerTest/classReferences/ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerTest/classReferences/JavaTaist.java trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Identity.java trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Model.java trunk/maven-jaxx-plugin/src/test/resources/log4j.properties trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1722Test/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1722Test/Bug_1722.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1722Test/DemoPanel.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1722Test/JButtonDemo.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1750Test/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1750Test/Bug_1750.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1750Test/ComboBox.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Bug_1751.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Test1.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Test2.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Test3.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClientProperty.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ErrorJaxxContextImplementorClass.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Errors.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Force.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Icon.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Initializers.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/InnerClasses.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/NoLog.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/OverridingDataBindings.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Script.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/WithLog.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/CSSTests.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Child.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Child2.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/GrandChild.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/GrandChildButton.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Pseudoclasses.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/SimpleCSS.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/ClassReferences.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/ConstructorReferenceTest.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/JAXXReferenceTest.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/JAXXTest.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/StaticMethodTest.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/TypeReference.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/clientProperty/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/clientProperty/TestOne.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/AmbiguousName.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/BadTypeConversions.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/CellOutsideOfRow.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ChildrenInNonContainer.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ClassNotFound.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ConflictingPackages.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ConstraintsParseError.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/DataBindingParseError.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/DuplicateIDs.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/EventHandlerParseError.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/InvalidID.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/InvalidRootTag.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/InvalidXML.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ItemDuplicateValues.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ItemNoValue.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/MixedContent.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/RowOutsideOfTable.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/RowWrongChild.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ScriptNotFound.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ScriptParseError.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ScriptSourceAndInline.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/StyleNotFound.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/StyleParseError.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/StyleSourceAndInline.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TabOutsideOfTabbedPane.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TabbedPaneWrongChild.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TableWrongChild.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManyCellChildren.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManyScrollPaneChildren.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManySplitPaneChildren.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManyTabChildren.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/UnsupportedAttribute.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/UnsupportedEvent.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/UnsupportedPseudoclass.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/dependencies/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/dependencies/test.css trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/dependencies/test.script trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/force/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/force/JButton.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/icon/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/icon/Test1.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/initializers/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/initializers/Initializers.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/innerClasses/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/innerClasses/InnerClasses.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/nolog/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/nolog/NoLog.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/nolog/NoLogSon.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/withlog/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/withlog/NoLog.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/withlog/WithLog.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/CurrentTime.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/OverriddenCurrentTime.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/OverridingDataBindings.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/script/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/script/JScriptInitializer.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JComboBoxTest1.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JComboBoxTest2.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JListTest1.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JListTest2.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JTreeTest1.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JTreeTest2.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/SpecialSubclassing.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/ValidatorErrors.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/ValidatorOk.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/AutoFieldComponentNotFound.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedBean.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedBean2.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedErrorListModel.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedErrorTableModel.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedFieldInSameValidator.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldBeanPropertyNotFound.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldComponentDuplicated.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldComponentNotFound.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldComponentNotFound2.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldNoName.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldNoName2.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/Model.java trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/NoBean.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundBean.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorList.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorListModel.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorTable.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorTableModel.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundParentValidator.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Validation.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/ValidationBeanClass.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/dataBindingTest/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/dataBindingTest/First.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/dataBindingTest/simpleBinding.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/decoratorTest/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/decoratorTest/BoxedDecorator.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/decoratorTest/Decorator.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error/swingcombo.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error/swinglist.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error/swingtree.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxcombo.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxlist.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxtree.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/swingcombo.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/swinglist.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/swingtree.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/I18nText.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/I18nTitle.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/I18nToolTipText.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/text/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/text/JButton.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/title/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/title/JDialog.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/title/JTabbedPane.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/title/JTabbedPane2.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JButton.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JTabbedPane.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JTabbedPane2.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JTabbedPane3.jaxx trunk/src/site/rst/migration.rst Removed: trunk/jaxx-compiler/src/main/java/jaxx/ClassMap.java trunk/jaxx-compiler/src/main/java/jaxx/CompilerException.java trunk/jaxx-compiler/src/main/java/jaxx/DefaultInitializer.java trunk/jaxx-compiler/src/main/java/jaxx/PrintTagInfo.java trunk/jaxx-compiler/src/main/java/jaxx/ScriptException.java trunk/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java trunk/jaxx-compiler/src/main/java/jaxx/UnsupportedAttributeException.java trunk/jaxx-compiler/src/main/java/jaxx/UnsupportedTagException.java trunk/jaxx-compiler/src/main/java/jaxx/beaninfos/ trunk/jaxx-compiler/src/main/java/jaxx/compiler/BoxedCompiledObjectDecorator.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/CompilerOptions.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/DataBinding.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/DataSource.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompiledObjectDecorator.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/Generator.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/HelpRootCompiledObjectDecorator.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompilerLaunchor.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXObjectGenerator.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/JavaArgument.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/JavaField.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/JavaFile.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/JavaMethod.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/ScriptInitializer.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/ScriptManager.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/SwingCompiler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/SwingGenerator.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/ValidatorGenerator.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/BeanInfoUtil.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanDescriptor.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanInfo.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXEventSetDescriptor.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXFeatureDescriptor.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXIntrospector.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXPropertyDescriptor.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataBinding.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataBindingHelper.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataSource.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/PseudoClassDataBinding.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/StylesheetHelper.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSS.jj trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSS.jjt trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParser.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParserConstants.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParserTokenManager.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParserTreeConstants.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/JJTCSSParserState.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/Node.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/ParseException.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/SimpleCharStream.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/SimpleNode.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/Token.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/TokenMgrError.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/decorators/BoxedCompiledObjectDecorator.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/decorators/DefaultCompiledObjectDecorator.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/DefaultFinalizer.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/SwingFinalizer.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/ValidatorFinalizer.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaArgument.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaElement.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaField.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaFile.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaFileGenerator.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaMethod.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JJTJavaParserState.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Java1.5.jj trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Java1.5.jjt trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaCharStream.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParser.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParserConstants.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParserTokenManager.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParserTreeConstants.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Node.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/ParseException.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/SimpleNode.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Token.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/TokenMgrError.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptor.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptorLoader.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/FieldDescriptor.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/JavaFileParser.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MemberDescriptor.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MethodDescriptor.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/script/ScriptInitializer.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/script/ScriptManager.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/spi/DefaultInitializer.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/spi/Initializer.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultComponentHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/ScriptHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/StyleHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagManager.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ApplicationHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CellHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CompiledItemContainer.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ItemHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXComboBoxHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXListHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTabHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTreeHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JCheckBoxHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JComboBoxHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JInternalFrameHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JListHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JMenuHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPasswordFieldHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPopupMenuHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JProgressBarHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JRadioButtonHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JScrollPaneHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSliderHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSpinnerHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSplitPaneHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTabbedPaneHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTextComponentHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JToolBarHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTreeHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JWindowHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/RowHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TableHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/BeanValidatorHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/ExcludeFieldValidatorHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/FieldValidatorHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/PrintTagInfo.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/AbstractContextNode.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/CapturedObject.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ContextNode.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/JAXXCapture.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/LiteralNode.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/MethodNode.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/PropertyNode.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ValueNode.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/JTabbedPaneHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/ObjectHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/TableHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/ColorConverter.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/GridBagConstraintsConverter.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/InsetsConverter.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/KeyStrokeConverter.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/PrimitiveConverter.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeConverter.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeManager.java trunk/jaxx-compiler/src/main/java/jaxx/css/ trunk/jaxx-compiler/src/main/java/jaxx/introspection/ trunk/jaxx-compiler/src/main/java/jaxx/parser/ trunk/jaxx-compiler/src/main/java/jaxx/reflect/ trunk/jaxx-compiler/src/main/java/jaxx/spi/ trunk/jaxx-compiler/src/main/java/jaxx/tags/ trunk/jaxx-compiler/src/main/java/jaxx/tools/ trunk/jaxx-compiler/src/main/java/jaxx/types/ trunk/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.Generator trunk/jaxx-compiler/src/main/resources/META-INF/services/jaxx.spi.Initializer trunk/jaxx-compiler/src/test/java/jaxx/beaninfos/ trunk/jaxx-compiler/src/test/java/jaxx/compiler/JavaFileParserTest.java trunk/jaxx-compiler/src/test/java/jaxx/compiler/JavaMethodTest.java trunk/jaxx-compiler/src/test/java/jaxx/compiler/beans/ trunk/jaxx-compiler/src/test/java/jaxx/compiler/beans/BeanIntoUtilTest.java trunk/jaxx-compiler/src/test/java/jaxx/compiler/reflect/ trunk/jaxx-compiler/src/test/java/jaxx/compiler/reflect/ClassDescriptorTest.java trunk/jaxx-compiler/src/test/java/jaxx/compiler/tags/ trunk/jaxx-compiler/src/test/java/jaxx/compiler/tags/TagManagerTest.java trunk/jaxx-compiler/src/test/java/jaxx/compiler/types/ trunk/jaxx-compiler/src/test/java/jaxx/compiler/types/ColorConverterTest.java trunk/jaxx-compiler/src/test/java/jaxx/compiler/types/InsetsConverterTest.java trunk/jaxx-compiler/src/test/java/jaxx/compiler/types/PrimitiveConverterTest.java trunk/jaxx-compiler/src/test/java/jaxx/compiler/types/TypeManagerTest.java trunk/jaxx-compiler/src/test/java/jaxx/junit/ trunk/jaxx-compiler/src/test/java/jaxx/runtime/ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorContentUI.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorsContentUI.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ContentUI.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ContentUIHandler.java trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MovieContentUI.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MoviesContentUI.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/ trunk/jaxx-example/ trunk/jaxx-runtime-api/ trunk/jaxx-runtime-swing-widget/ trunk/jaxx-runtime-swing/ trunk/jaxx-runtime/LICENSE.txt trunk/jaxx-runtime/README.txt trunk/jaxx-runtime/changelog.txt trunk/jaxx-runtime/pom.xml trunk/jaxx-runtime/src/ trunk/jaxx-runtime/src/main/ trunk/jaxx-runtime/src/main/java/ trunk/jaxx-runtime/src/main/java/jaxx/ trunk/jaxx-runtime/src/main/java/jaxx/runtime/ trunk/jaxx-runtime/src/main/java/jaxx/runtime/Base64Coder.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/ComponentDescriptor.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingListener.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingUpdateListener.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXAction.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXBinding.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObjectDescriptor.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXValidator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/Util.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/ trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/ trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/DataBinding.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/Pseudoclasses.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/Rule.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/Selector.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/Stylesheet.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/ trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/Decorator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorProvider.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/JXPathDecorator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/MultiJXPathDecorator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/PropertyDecorator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/Application.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/GBC.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBox.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxBeanInfo.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxLayout.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/Item.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXButtonGroup.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXComboBox.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXList.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTab.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXToggleButton.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTree.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/OneClicListSelectionModel.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/Spacer.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/Table.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBox.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxBeanInfo.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxLayout.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/ClassCellEditor.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/EnumEditor.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/LocaleEditor.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/MyDefaultCellEditor.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpBroker.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUI.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUIHandler.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationCardPanel.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationPanel.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemTreeNavigationAdapter.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationContentUI.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRenderer.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererDecoratorImpl.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererI18nImpl.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/package.html trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/BooleanCellRenderer.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorListCellRenderer.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorProviderListCellRenderer.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorProviderTableCellRenderer.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorTableCellRenderer.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EmptyNumberTableCellRenderer.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EnumTableCellRenderer.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/I18nTableCellRenderer.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/LocaleListCellRenderer.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/MultiDecoratorListCellRenderer.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/MultiDecoratorTableCelleRenderer.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorDetector.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorField.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorScope.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/CollectionFieldExpressionValidator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingFileFieldValidator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/FieldExpressionWithParamsValidator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/NotExistingDirectoryFieldValidator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/NotExistingFileFieldValidator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/RequiredFileFieldValidator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java trunk/jaxx-runtime/src/main/resources/ trunk/jaxx-runtime/src/main/resources/i18n/ trunk/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-en_GB.properties trunk/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-fr_FR.properties trunk/jaxx-runtime/src/main/resources/icons/ trunk/jaxx-runtime/src/main/resources/icons/action-delete.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-config-16.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-config.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-message-16.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-message.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-next-16.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-next.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-pause-16.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-pause.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-previous-16.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-previous.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-refresh-16.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-refresh.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-start-16.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-start.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-canceled-16.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-canceled.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-failed-16.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-failed.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-need_fix-16.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-need_fix.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-pending-16.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-pending.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-running-16.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-running.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-successed-16.png trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-successed.png trunk/jaxx-runtime/src/main/resources/icons/error.png trunk/jaxx-runtime/src/main/resources/icons/info.png trunk/jaxx-runtime/src/main/resources/icons/warning.png trunk/jaxx-runtime/src/main/resources/validators.xml trunk/jaxx-runtime/src/site/ trunk/jaxx-runtime/src/site/rst/ trunk/jaxx-runtime/src/site/site.xml trunk/jaxx-runtime/src/test/ trunk/jaxx-runtime/src/test/java/ trunk/jaxx-runtime/src/test/java/jaxx/ trunk/jaxx-runtime/src/test/java/jaxx/runtime/ trunk/jaxx-runtime/src/test/java/jaxx/runtime/UtilTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/ trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultApplicationContextTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/decorator/ trunk/jaxx-runtime/src/test/java/jaxx/runtime/decorator/Data.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/decorator/DecoratorProviderTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/decorator/JXPathDecoratorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/decorator/MultiJXPathDecoratorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/swing/ trunk/jaxx-runtime/src/test/java/jaxx/runtime/swing/navigation/ trunk/jaxx-runtime/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/AbstractBeanValidatorDetectorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/BeanValidatorDetectorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/BeanValidatorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/SimpleBean.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/XWorkBeanValidatorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/AbstractFieldValidatorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/AbstractValidatorBeanFieldValidatorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/CollectionFieldExpressionValidatorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidatorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidatorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/ExistingFileFieldValidatorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/FieldExpressionBean.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/FieldExpressionWithParamsValidatorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/NotExistingDirectoryFieldValidatorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/NotExistingFileFieldValidatorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/RequiredFileFieldValidatorTest.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/ValidatorBean.java trunk/jaxx-runtime/src/test/resources/ trunk/jaxx-runtime/src/test/resources/jaxx/ trunk/jaxx-runtime/src/test/resources/jaxx/runtime/ trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/ trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-error-validation.xml trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-info-validation.xml trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-simple-validation.xml trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-warning-validation.xml trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/field/ trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/field/FieldExpressionBean-error-validation.xml trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/field/ValidatorBean-error-validation.xml trunk/jaxx-runtime/src/test/resources/log4j.properties trunk/jaxx-runtime/src/test/resources/validators.xml trunk/jaxx-widgets/LICENSE.txt trunk/jaxx-widgets/README.txt trunk/jaxx-widgets/changelog.txt trunk/jaxx-widgets/pom.xml trunk/jaxx-widgets/src/ trunk/jaxx-widgets/src/main/ trunk/jaxx-widgets/src/main/java/ trunk/jaxx-widgets/src/main/java/jaxx/ trunk/jaxx-widgets/src/main/java/jaxx/runtime/ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/AboutPanel.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ClockWidget.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ErrorDialogUI.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/HidorButton.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ListSelectorUI.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/MemoryStatusWidget.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/StatusMessagePanel.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/StatusMessagePanelHandler.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/ColumnSelector.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/I18nEditor.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditor.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorPopup.css trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/TimeEditor.css trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/TimeEditor.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/TimeEditorHandler.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.css trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableEditor.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableRenderer.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.css trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigTableModel.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java trunk/jaxx-widgets/src/main/resources/ trunk/jaxx-widgets/src/main/resources/i18n/ trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties trunk/jaxx-widgets/src/main/resources/icons/ trunk/jaxx-widgets/src/main/resources/icons/action-add.png trunk/jaxx-widgets/src/main/resources/icons/action-collapse.png trunk/jaxx-widgets/src/main/resources/icons/action-config-quit.png trunk/jaxx-widgets/src/main/resources/icons/action-config-reset.png trunk/jaxx-widgets/src/main/resources/icons/action-config-save.png trunk/jaxx-widgets/src/main/resources/icons/action-expand.png trunk/jaxx-widgets/src/main/resources/icons/action-i18n-be.png trunk/jaxx-widgets/src/main/resources/icons/action-i18n-ca.png trunk/jaxx-widgets/src/main/resources/icons/action-i18n-ch.png trunk/jaxx-widgets/src/main/resources/icons/action-i18n-de.png trunk/jaxx-widgets/src/main/resources/icons/action-i18n-dk.png trunk/jaxx-widgets/src/main/resources/icons/action-i18n-es.png trunk/jaxx-widgets/src/main/resources/icons/action-i18n-fi.png trunk/jaxx-widgets/src/main/resources/icons/action-i18n-fr.png trunk/jaxx-widgets/src/main/resources/icons/action-i18n-gb.png trunk/jaxx-widgets/src/main/resources/icons/action-i18n-it.png trunk/jaxx-widgets/src/main/resources/icons/action-i18n-nl.png trunk/jaxx-widgets/src/main/resources/icons/action-i18n-no.png trunk/jaxx-widgets/src/main/resources/icons/action-i18n-se.png trunk/jaxx-widgets/src/main/resources/icons/action-i18n-us.png trunk/jaxx-widgets/src/main/resources/icons/action-numbereditor-calculator.png trunk/jaxx-widgets/src/main/resources/icons/action-numbereditor-reset.png trunk/jaxx-widgets/src/main/resources/icons/action-numbereditor-validate.png trunk/jaxx-widgets/src/main/resources/icons/action-remove.png trunk/jaxx-widgets/src/site/ trunk/jaxx-widgets/src/site/rst/ trunk/jaxx-widgets/src/site/rst/images/ trunk/jaxx-widgets/src/site/rst/images/Components-screenshot.gif trunk/jaxx-widgets/src/site/rst/images/webstart.gif trunk/jaxx-widgets/src/site/rst/index.rst trunk/jaxx-widgets/src/site/site.xml trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxHelpGeneratorMojo.java trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/TemplateGenerator.java trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBinding/Bean.java trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBinding/BeanImpl.java trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerTest/classReferences/ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerTest/classReferences/JavaTaist.java trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Identity.java trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Model.java trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1722Test/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1750Test/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1751Test/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerValidatorTest/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/DecoratorTest/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1722Test/Bug_1722.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1722Test/DemoPanel.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1722Test/JButtonDemo.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1750Test/Bug_1750.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1750Test/ComboBox.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Bug_1751.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Test1.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Test2.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Test3.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClientProperty.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ErrorJaxxContextImplementorClass.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Errors.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Force.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Icon.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Initializers.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/InnerClasses.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/NoLog.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/OverridingDataBindings.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Script.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/WithLog.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/CSSTests.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Child.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Child2.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/GrandChild.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/GrandChildButton.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Pseudoclasses.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/SimpleCSS.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/ClassReferences.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/ConstructorReferenceTest.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/JAXXReferenceTest.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/JAXXTest.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/StaticMethodTest.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/TypeReference.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/clientProperty/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/clientProperty/TestOne.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/AmbiguousName.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/BadTypeConversions.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/CellOutsideOfRow.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ChildrenInNonContainer.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ClassNotFound.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ConflictingPackages.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ConstraintsParseError.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/DataBindingParseError.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/DuplicateIDs.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/EventHandlerParseError.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/InvalidID.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/InvalidRootTag.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/InvalidXML.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ItemDuplicateValues.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ItemNoValue.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/MixedContent.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/RowOutsideOfTable.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/RowWrongChild.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ScriptNotFound.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ScriptParseError.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ScriptSourceAndInline.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/StyleNotFound.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/StyleParseError.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/StyleSourceAndInline.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TabOutsideOfTabbedPane.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TabbedPaneWrongChild.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TableWrongChild.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManyCellChildren.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManyScrollPaneChildren.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManySplitPaneChildren.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManyTabChildren.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/UnsupportedAttribute.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/UnsupportedEvent.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/UnsupportedPseudoclass.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/dependencies/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/dependencies/test.css trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/dependencies/test.script trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/force/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/force/JButton.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/icon/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/icon/Test1.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/initializers/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/initializers/Initializers.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/innerClasses/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/innerClasses/InnerClasses.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/nolog/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/nolog/NoLog.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/nolog/NoLogSon.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/withlog/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/withlog/NoLog.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/withlog/WithLog.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/CurrentTime.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/OverriddenCurrentTime.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/OverridingDataBindings.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/script/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/script/JScriptInitializer.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JComboBoxTest1.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JComboBoxTest2.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JListTest1.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JListTest2.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JTreeTest1.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JTreeTest2.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/SpecialSubclassing.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/ValidatorErrors.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/ValidatorOk.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/AutoFieldComponentNotFound.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedBean.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedBean2.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedErrorListModel.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedErrorTableModel.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedFieldInSameValidator.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldBeanPropertyNotFound.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldComponentDuplicated.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldComponentNotFound.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldComponentNotFound2.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldNoName.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldNoName2.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/Model.java trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/NoBean.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundBean.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorList.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorListModel.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorTable.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorTableModel.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundParentValidator.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Validation.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/ValidationBeanClass.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/dataBindingTest/First.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/dataBindingTest/simpleBinding.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/decoratorTest/BoxedDecorator.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/decoratorTest/Decorator.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error/swingcombo.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error/swinglist.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error/swingtree.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxcombo.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxlist.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxtree.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/swingcombo.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/swinglist.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/swingtree.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/I18nText.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/I18nTitle.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/I18nToolTipText.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/text/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/text/JButton.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/title/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/title/JDialog.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/title/JTabbedPane.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/title/JTabbedPane2.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JButton.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JTabbedPane.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JTabbedPane2.jaxx trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JTabbedPane3.jaxx Modified: trunk/ trunk/jaxx-compiler/ trunk/jaxx-compiler/pom.xml trunk/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObject.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObjectDecorator.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/EventHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/I18nHelper.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXProfile.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/SymbolTable.java trunk/jaxx-compiler/src/site/rst/JAXXContext.rst trunk/jaxx-compiler/src/test/resources/log4j.properties trunk/jaxx-demo/ trunk/jaxx-demo/pom.xml trunk/jaxx-demo/src/main/filters/jaxx-demo.properties trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.css trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java trunk/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/BoxedDecoratorDemo.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/StatusMessagePanelDemo.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/ComboEditorDemo.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/I18nEditorDemo.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemoModel.java trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ExempleItemTreeNavigationAdapter.java trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JButtonDemo.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxDemo.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxMenuItemDemo.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JComboBoxDemo.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JDialogDemo.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JListDemo.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JMenuItemDemo.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JPasswordFieldDemo.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JProgressBarDemo.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonDemo.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonMenuItemDemo.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSliderDemo.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSpinnerDemo.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSplitPaneDemo.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextAreaDemo.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextFieldDemo.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JToggleButtonDemo.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BaseBeanDataBinding.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BeanDataBindingDemo.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Identity.java trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Model.java trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/fun/Calculator.css trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorDemo.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorEngine.java trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CounterDemo.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyle.css trunk/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyleDemo.jaxx trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties trunk/jaxx-demo/src/main/resources/log4j.properties trunk/jaxx-demo/src/site/rst/index.rst trunk/jaxx-demo/src/test/java/jaxx/demo/BeanValidatorDetectorTest.java trunk/jaxx-swing-action/ trunk/jaxx-swing-action/pom.xml trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/AbstractActionConfigurationResolver.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionAnnotationProcessing.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionConfig.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionConfigConfigurationResolver.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionConfigurationResolver.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionFactory.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionFactoryFromProvider.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionNameProvider.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionProvider.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionProviderAnnotation.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionProviderFromProperties.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/MyAbstractAction.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/SelectActionConfig.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/SelectActionConfigConfigurationResolver.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ToggleActionConfig.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ToggleActionConfigConfigurationResolver.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/tab/TabContentConfig.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/tab/TabFactory.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/tab/TabModel.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/AbstractUIAction.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/DialogUI.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/DialogUIDef.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/DialogUIHandler.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/DialogUIModel.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/FactoryWindowListener.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/FormElement.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/ShowUIAction.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/UIFactory.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/UIHelper.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/UIProvider.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/config/CancelAction.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/config/DialogConfigUI.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/config/DialogConfigUIHandler.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/config/DialogConfigUIModel.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/config/ResetAction.java trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/config/SaveAction.java trunk/maven-jaxx-plugin/ trunk/maven-jaxx-plugin/pom.xml trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/NodeItem.java trunk/maven-jaxx-plugin/src/main/resources/defaultContent.html.vm trunk/maven-jaxx-plugin/src/main/resources/defaultHelpSet.hs.vm trunk/maven-jaxx-plugin/src/main/resources/log4j.properties trunk/maven-jaxx-plugin/src/site/rst/index.rst trunk/maven-jaxx-plugin/src/site/site.xml trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1722Test.java trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1750Test.java trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1751Test.java trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerTest.java trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerValidatorTest.java trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DecoratorTest.java trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/I18nTest.java trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/JaxxBaseTest.java trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/NodeItemTest.java trunk/pom.xml trunk/src/site/rst/JAXXContext.rst trunk/src/site/rst/index.rst trunk/src/site/site.xml Log: JAXX 2.x is back on trunk Property changes on: trunk ___________________________________________________________________ Deleted: svn:mergeinfo - Added: svn.ignore + target *.iml *.ipr *.iws Property changes on: trunk/jaxx-compiler ___________________________________________________________________ Modified: svn:ignore - target *.log *.iml + target *.log *.iml *.ipr *.iws Modified: trunk/jaxx-compiler/pom.xml =================================================================== --- trunk/jaxx-compiler/pom.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/pom.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -10,7 +10,7 @@ <parent> <groupId>org.nuiton</groupId> <artifactId>jaxx</artifactId> - <version>1.7.2-SNAPSHOT</version> + <version>2.0.0-beta-3-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 ****************************************** --> Deleted: trunk/jaxx-compiler/src/main/java/jaxx/ClassMap.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/ClassMap.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/ClassMap.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,96 +0,0 @@ -/* - * Copyright 2006 Ethan Nicholas. All rights reserved. - * Use is subject to license terms. - */ -package jaxx; - -import jaxx.reflect.ClassDescriptor; -import jaxx.reflect.ClassDescriptorLoader; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; - -/** - * A Map implementation which uses Classes as keys. <code>ClassMap</code> differs from typical maps - * in that it takes subclasses into account; mapping a class to a value also maps all subclasses of - * that class to the value. - * <p/> - * A <code>get</code> operation will return the value associated with the class itself, or failing - * that, with its nearest ancestor for which there exists a mapping. - * @param <T> type of the class - */ -public class ClassMap<T> extends HashMap<ClassDescriptor, T> { - /** log */ - protected static final Log log = LogFactory.getLog(ClassMap.class); - - /** - * Keeps track of automatically-added Classes so we can distinguish them from user-added - * Classes. Unknown Classes are automatically added to the map during <code>get</code> - * calls to speed up subsequent requests, but they must be updated when the mappings - * for their superclasses are modified. - */ - private List<ClassDescriptor> autoKeys = new ArrayList<ClassDescriptor>(); - private static final long serialVersionUID = 5149779660675529037L; - - - /** - * Returns the value associated with the key <code>Class</code>. If the class itself does not have - * a mapping, its superclass will be checked, and so on until an ancestor class with a mapping is - * located. If none of the class' ancestors have a mapping, <code>null</code> is returned. - * - * @param key the class to check - * @return the mapping for the class - */ - @Override - public T get(Object key) { - T result = null; - ClassDescriptor c = (ClassDescriptor) key; - while (c != null) { - result = super.get(c); - if (result != null) { - break; - } - c = c.getSuperclass(); - } - - if (result == null && ((ClassDescriptor) key).isInterface()) { - result = get(ClassDescriptorLoader.getClassDescriptor(Object.class)); - } - - if (c != key && result != null) { // no mapping for the class itself, but found one for a superclass - put((ClassDescriptor) key, result); - autoKeys.add((ClassDescriptor) key); - } - return result; - } - - - /** - * Associates a value with a class and all of its descendents. - * - * @param key the class to map - * @param value the value to map to the class - * @return the old value associated with the class - */ - @Override - public T put(ClassDescriptor key, T value) { - //if (!(key instanceof ClassDescriptor)) { - // throw new IllegalArgumentException("expected ClassDescriptor, got " + key); - //} - if (autoKeys.size() > 0) { // remove all automatic keys which descend from the class being modified - Iterator<ClassDescriptor> i = autoKeys.iterator(); - while (i.hasNext()) { - ClassDescriptor auto = i.next(); - if (key.isAssignableFrom(auto)) { - i.remove(); - remove(auto); - } - } - } - return super.put(key, value); - } -} \ No newline at end of file Deleted: trunk/jaxx-compiler/src/main/java/jaxx/CompilerException.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/CompilerException.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/CompilerException.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,52 +0,0 @@ -/* - * Copyright 2006 Ethan Nicholas. All rights reserved. - * Use is subject to license terms. - */ -package jaxx; - -/** Thrown by the compiler when an error occurs. */ -public class CompilerException extends RuntimeException { - private static final long serialVersionUID = -9099889519671482440L; - - /** Creates a new <code>ParseException</code>. */ - public CompilerException() { - } - - - /** - * Creates a new <code>ParseException</code> with the specified detail message. - * - * @param msg the exception's detail message - */ - public CompilerException(String msg) { - super(msg); - } - - - /** - * Creates a new <code>ParseException</code> with the specified cause. - * - * @param initCause the exception's initCause - */ - public CompilerException(Throwable initCause) { - super(initCause); - } - - - /** - * Creates a new <code>ParseException</code> with the specified detail message and cause. - * - * @param msg the exception's detail message - * @param initCause the exception's initCause - */ - public CompilerException(String msg, Throwable initCause) { - super(msg, initCause); - } - - - public void printStackTrace() { - super.printStackTrace(); - System.err.println("CompilerException printed from:"); - Thread.dumpStack(); - } -} \ No newline at end of file Deleted: trunk/jaxx-compiler/src/main/java/jaxx/DefaultInitializer.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/DefaultInitializer.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/DefaultInitializer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,52 +0,0 @@ -/* - * Copyright 2006 Ethan Nicholas. All rights reserved. - * Use is subject to license terms. - */ -package jaxx; - -import jaxx.compiler.JAXXCompiler; -import jaxx.reflect.ClassDescriptorLoader; -import jaxx.tags.DefaultComponentHandler; -import jaxx.tags.DefaultObjectHandler; -import jaxx.tags.ScriptHandler; -import jaxx.tags.StyleHandler; -import jaxx.tags.TagManager; -import jaxx.types.PrimitiveConverter; -import jaxx.types.TypeManager; - -import java.awt.Component; -import jaxx.compiler.CompiledObjectDecorator; -import jaxx.compiler.DefaultCompiledObjectDecorator; - -/** Initializes support for java. */ -public class DefaultInitializer implements jaxx.spi.Initializer { - - @Override - public void initialize() { - TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(Object.class), DefaultObjectHandler.class); - TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(Component.class), DefaultComponentHandler.class); - TagManager.registerTag(JAXXCompiler.JAXX_NAMESPACE, "script", new ScriptHandler()); - TagManager.registerTag(JAXXCompiler.JAXX_NAMESPACE, "style", new StyleHandler()); - - PrimitiveConverter primitiveConverter = new PrimitiveConverter(); - TypeManager.registerTypeConverter(boolean.class, primitiveConverter); - TypeManager.registerTypeConverter(Boolean.class, primitiveConverter); - TypeManager.registerTypeConverter(byte.class, primitiveConverter); - TypeManager.registerTypeConverter(Byte.class, primitiveConverter); - TypeManager.registerTypeConverter(short.class, primitiveConverter); - TypeManager.registerTypeConverter(Short.class, primitiveConverter); - TypeManager.registerTypeConverter(int.class, primitiveConverter); - TypeManager.registerTypeConverter(Integer.class, primitiveConverter); - TypeManager.registerTypeConverter(long.class, primitiveConverter); - TypeManager.registerTypeConverter(Long.class, primitiveConverter); - TypeManager.registerTypeConverter(float.class, primitiveConverter); - TypeManager.registerTypeConverter(Float.class, primitiveConverter); - TypeManager.registerTypeConverter(double.class, primitiveConverter); - TypeManager.registerTypeConverter(Double.class, primitiveConverter); - TypeManager.registerTypeConverter(char.class, primitiveConverter); - TypeManager.registerTypeConverter(Character.class, primitiveConverter); - TypeManager.registerTypeConverter(String.class, primitiveConverter); - - CompiledObjectDecorator.registerDecorator("default", DefaultCompiledObjectDecorator.class); - } -} \ No newline at end of file Deleted: trunk/jaxx-compiler/src/main/java/jaxx/PrintTagInfo.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/PrintTagInfo.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/PrintTagInfo.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,118 +0,0 @@ -package jaxx; - -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.JAXXCompilerLaunchor; -import jaxx.introspection.JAXXPropertyDescriptor; -import jaxx.reflect.ClassDescriptor; -import jaxx.reflect.ClassDescriptorLoader; -import jaxx.reflect.MethodDescriptor; -import jaxx.tags.DefaultObjectHandler; -import jaxx.tags.TagManager; - -import java.io.BufferedWriter; -import java.io.FileWriter; -import java.io.IOException; -import java.io.OutputStreamWriter; - -/** Generates information about a tag for use on the jaxxframework.org web site. */ -public class PrintTagInfo { - /** - * Displays information about the class name in arg[0]. - * - * @param arg command-line arguments - * @throws Exception if an error occurs - */ - public static void main(String[] arg) throws Exception { - if (arg.length < 1) { - throw new IllegalArgumentException("programm needs at least two parameters : the file where to put the result, and at least one fqn class to treate"); - } - String firstarg = arg[0]; - boolean toFile = false; - BufferedWriter w; - if (firstarg.startsWith("file:")) { - w = new BufferedWriter(new FileWriter(firstarg.substring(5))); - toFile = true; - } else { - w = new BufferedWriter(new OutputStreamWriter(System.out)); - } - - try { - JAXXCompilerLaunchor.loadLibraries(false); - for (int i = toFile ? 1 : 0; i < arg.length; i++) { - String className = arg[i]; - treateClass(w, className); - } - } finally { - w.flush(); - w.close(); - } - - } - - protected static void treateClass(BufferedWriter w, String className) throws ClassNotFoundException, IOException { - - ClassDescriptor beanClass = ClassDescriptorLoader.getClassDescriptor(className); - DefaultObjectHandler handler = TagManager.getTagHandler(beanClass); - - DefaultObjectHandler superHandler = TagManager.getTagHandler(beanClass.getSuperclass()); - - // dump all bean properties - w.append("Properties in ").append(String.valueOf(beanClass)); - w.newLine(); - JAXXPropertyDescriptor[] properties = handler.getJAXXBeanInfo().getJAXXPropertyDescriptors(); - JAXXPropertyDescriptor[] superProperties = superHandler.getJAXXBeanInfo().getJAXXPropertyDescriptors(); - for (JAXXPropertyDescriptor property : properties) { - if (property.getWriteMethodDescriptor() == null) { - continue; - } - - boolean found = false; - String name = property.getName(); - for (JAXXPropertyDescriptor superProperty : superProperties) { - if (superProperty.getName().equals(name)) { - found = true; - break; - } - } - if (!found) { - if (property.getPropertyType() == null) { - System.err.println(name + " has null type"); - } else { - w.append("{{EquivalentAttribute|"); - w.append(name); - w.append("|"); - w.append(className.replace('.', '/')); - w.append("|set"); - w.append(org.apache.commons.lang.StringUtils.capitalize(name)); - w.append("|"); - w.append(JAXXCompiler.getCanonicalName(property.getPropertyType())); - w.append("}}"); - w.append("|-"); - w.newLine(); - } - } - } - - w.newLine(); - w.newLine(); - - // dump all bound methods - dumpMethods(w, beanClass, handler); - } - - protected static void dumpMethods(BufferedWriter w, ClassDescriptor beanClass, DefaultObjectHandler handler) throws IOException { - MethodDescriptor[] methods = beanClass.getMethodDescriptors(); - w.append("Bound methods in ").append(String.valueOf(beanClass)); - w.newLine(); - for (MethodDescriptor method : methods) { - try { - if (handler.isMemberBound(method.getName())) { - w.append("* <tt>").append(method.getName()).append("()</tt>"); - w.newLine(); - } - } catch (Throwable e) { - // ignore ? - } - } - } -} \ No newline at end of file Deleted: trunk/jaxx-compiler/src/main/java/jaxx/ScriptException.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/ScriptException.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/ScriptException.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,45 +0,0 @@ -/* - * Copyright 2006 Ethan Nicholas. All rights reserved. - * Use is subject to license terms. - */ -package jaxx; - -/** Thrown by the runtime engine when a script error occurs. */ -public class ScriptException extends RuntimeException { - private static final long serialVersionUID = 5687529939397610336L; - - /** Creates a new <code>ScriptException</code>. */ - public ScriptException() { - } - - - /** - * Creates a new <code>ScriptException</code> with the specified detail message. - * - * @param msg the exception's detail message - */ - public ScriptException(String msg) { - super(msg); - } - - - /** - * Creates a new <code>ScriptException</code> with the specified cause. - * - * @param initCause the exception's initCause - */ - public ScriptException(Throwable initCause) { - super(initCause); - } - - - /** - * Creates a new <code>ScriptException</code> with the specified detail message and cause. - * - * @param msg the exception's detail message - * @param initCause the exception's initCause - */ - public ScriptException(String msg, Throwable initCause) { - super(msg, initCause); - } -} \ No newline at end of file Deleted: trunk/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,127 +0,0 @@ -/* - * Copyright 2006 Ethan Nicholas. All rights reserved. - * Use is subject to license terms. - */ -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.BoxedCompiledObjectDecorator; -import jaxx.compiler.CompiledObjectDecorator; -import jaxx.compiler.HelpRootCompiledObjectDecorator; -import jaxx.runtime.swing.editor.EnumEditor; -import jaxx.runtime.swing.editor.LocaleEditor; - -public class SwingInitializer implements Initializer { - - @Override - public void initialize() { - - BeanInfoUtil.addJaxxBeanInfoPath("jaxx.beaninfos"); - - 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))); - TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JDialog.class), JWindowHandler.class); - TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JFrame.class), JWindowHandler.class); - TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JInternalFrame.class), JInternalFrameHandler.class); - TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXList.class), JListHandler.class); - TagManager.registerTag("javax.swing.*", "JList", new JListHandler(ClassDescriptorLoader.getClassDescriptor(JAXXList.class))); - TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JMenu.class), JMenuHandler.class); - TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JPasswordField.class), JPasswordFieldHandler.class); - TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JPopupMenu.class), JPopupMenuHandler.class); - TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JProgressBar.class), JProgressBarHandler.class); - TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JRadioButton.class), JRadioButtonHandler.class); - TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JRadioButtonMenuItem.class), JRadioButtonHandler.class); - TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JScrollPane.class), JScrollPaneHandler.class); - TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JSlider.class), JSliderHandler.class); - TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JSpinner.class), JSpinnerHandler.class); - TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JSplitPane.class), JSplitPaneHandler.class); - TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JTabbedPane.class), JTabbedPaneHandler.class); - TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JTextComponent.class), JTextComponentHandler.class); - TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JToggleButton.class), JRadioButtonHandler.class); - TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JToolBar.class), JToolBarHandler.class); - TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXTree.class), JTreeHandler.class); - TagManager.registerTag("javax.swing.*", "JTree", new JTreeHandler(ClassDescriptorLoader.getClassDescriptor(JAXXTree.class))); - TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JWindow.class), JWindowHandler.class); - - TagManager.registerDefaultNamespace("JEditorPane", "javax.swing.*"); - TagManager.registerDefaultNamespace("JFormattedTextField", "javax.swing.*"); - TagManager.registerDefaultNamespace("JPasswordField", "javax.swing.*"); - TagManager.registerDefaultNamespace("JTextArea", "javax.swing.*"); - TagManager.registerDefaultNamespace("JTextField", "javax.swing.*"); - TagManager.registerDefaultNamespace("JTextPane", "javax.swing.*"); - - TagManager.registerTag(JAXXCompiler.JAXX_NAMESPACE, "tab", new TabHandler()); - TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(Table.class), TableHandler.class); - TagManager.registerTag(JAXXCompiler.JAXX_NAMESPACE, "row", new RowHandler()); - TagManager.registerTag(JAXXCompiler.JAXX_NAMESPACE, "cell", new CellHandler()); - TagManager.registerTag(JAXXCompiler.JAXX_NAMESPACE, "item", new ItemHandler()); - - TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXTab.class), JAXXTabHandler.class); - - TypeManager.registerTypeConverter(Color.class, new ColorConverter()); - TypeManager.registerTypeConverter(GridBagConstraints.class, new GridBagConstraintsConverter()); - TypeManager.registerTypeConverter(Insets.class, new InsetsConverter()); - TypeManager.registerTypeConverter(KeyStroke.class, new KeyStrokeConverter()); - - CompiledObjectDecorator.registerDecorator("boxed", BoxedCompiledObjectDecorator.class); - CompiledObjectDecorator.registerDecorator("help", HelpRootCompiledObjectDecorator.class); - } -} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/UnsupportedAttributeException.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/UnsupportedAttributeException.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/UnsupportedAttributeException.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,49 +0,0 @@ -/* - * Copyright 2006 Ethan Nicholas. All rights reserved. - * Use is subject to license terms. - */ -package jaxx; - -/** - * Thrown by <code>TagHandler</code> when an unsupported attribute is encountered. - * - * @see jaxx.tags.TagHandler - */ -public class UnsupportedAttributeException extends CompilerException { - private static final long serialVersionUID = -6919583037172920343L; - - /** Creates a new <code>UnsupportedAttributeException</code>. */ - public UnsupportedAttributeException() { - } - - - /** - * Creates a new <code>UnsupportedAttributeException</code> with the specified detail message. - * - * @param msg the exception's detail message - */ - public UnsupportedAttributeException(String msg) { - super(msg); - } - - - /** - * Creates a new <code>UnsupportedAttributeException</code> with the specified cause. - * - * @param initCause the exception's initCause - */ - public UnsupportedAttributeException(Throwable initCause) { - super(initCause); - } - - - /** - * Creates a new <code>UnsupportedAttributeException</code> with the specified detail message and cause. - * - * @param msg the exception's detail message - * @param initCause the exception's initCause - */ - public UnsupportedAttributeException(String msg, Throwable initCause) { - super(msg, initCause); - } -} \ No newline at end of file Deleted: trunk/jaxx-compiler/src/main/java/jaxx/UnsupportedTagException.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/UnsupportedTagException.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/UnsupportedTagException.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,45 +0,0 @@ -/* - * Copyright 2006 Ethan Nicholas. All rights reserved. - * Use is subject to license terms. - */ -package jaxx; - -/** Thrown by the compiler when an unregistered tag is encountered. */ -public class UnsupportedTagException extends CompilerException { - private static final long serialVersionUID = 3199732135804426699L; - - /** Creates a new <code>UnsupportedTagException</code>. */ - public UnsupportedTagException() { - } - - - /** - * Creates a new <code>UnsupportedTagException</code> with the specified detail message. - * - * @param msg the exception's detail message - */ - public UnsupportedTagException(String msg) { - super(msg); - } - - - /** - * Creates a new <code>UnsupportedTagException</code> with the specified cause. - * - * @param initCause the exception's initCause - */ - public UnsupportedTagException(Throwable initCause) { - super(initCause); - } - - - /** - * Creates a new <code>UnsupportedTagException</code> with the specified detail message and cause. - * - * @param msg the exception's detail message - * @param initCause the exception's initCause - */ - public UnsupportedTagException(String msg, Throwable initCause) { - super(msg, initCause); - } -} \ No newline at end of file Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/BoxedCompiledObjectDecorator.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/BoxedCompiledObjectDecorator.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/BoxedCompiledObjectDecorator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,27 +0,0 @@ -package jaxx.compiler; - -import jaxx.compiler.CompiledObject.ChildRef; -import jaxx.runtime.SwingUtil; - -/** - * A decorator to surround a compiled object (should be a component at least) - * with a JXLayer. - * - * @author tony - * @since 1.2 - */ -public class BoxedCompiledObjectDecorator extends DefaultCompiledObjectDecorator { - - @Override - public void finalizeCompiler(JAXXCompiler compiler, CompiledObject root, CompiledObject object, JavaFile javaFile, String packageName, String className, String fullClassName) { - CompiledObject parent = object.getParent(); - for (ChildRef child : parent.getChilds()) { - if (child.getChild() == object) { - String javaCode = child.getChildJavaCode(); - child.setChildJavaCode(SwingUtil.class.getName()+".boxComponentWithJxLayer(" + javaCode + ")"); - break; - } - } - super.finalizeCompiler(compiler, root, object, javaFile, packageName, className, fullClassName); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/ClassMap.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ClassMap.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/ClassMap.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/ClassMap.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,112 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler; + +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; + +/** + * A Map implementation which uses Classes as keys. <code>ClassMap</code> differs from typical maps + * in that it takes subclasses into account; mapping a class to a value also maps all subclasses of + * that class to the value. + * <p/> + * A <code>get</code> operation will return the value associated with the class itself, or failing + * that, with its nearest ancestor for which there exists a mapping. + * @param <T> type of the class + */ +public class ClassMap<T> extends HashMap<ClassDescriptor, T> { + + private static final long serialVersionUID = 5149779660675529037L; + /** + * Logger + */ + protected static final Log log = LogFactory.getLog(ClassMap.class); + /** + * Keeps track of automatically-added Classes so we can distinguish them from user-added + * Classes. Unknown Classes are automatically added to the map during <code>get</code> + * calls to speed up subsequent requests, but they must be updated when the mappings + * for their superclasses are modified. + */ + private List<ClassDescriptor> autoKeys = new ArrayList<ClassDescriptor>(); + + /** + * Returns the value associated with the key <code>Class</code>. If the class itself does not have + * a mapping, its superclass will be checked, and so on until an ancestor class with a mapping is + * located. If none of the class' ancestors have a mapping, <code>null</code> is returned. + * + * @param key the class to check + * @return the mapping for the class + */ + @Override + public T get(Object key) { + T result = null; + ClassDescriptor c = (ClassDescriptor) key; + while (c != null) { + result = super.get(c); + if (result != null) { + break; + } + c = c.getSuperclass(); + } + + if (result == null && ((ClassDescriptor) key).isInterface()) { + result = get(ClassDescriptorLoader.getClassDescriptor(Object.class)); + } + + if (c != key && result != null) { // no mapping for the class itself, but found one for a superclass + put((ClassDescriptor) key, result); + autoKeys.add((ClassDescriptor) key); + } + return result; + } + + /** + * Associates a value with a class and all of its descendents. + * + * @param key the class to map + * @param value the value to map to the class + * @return the old value associated with the class + */ + @Override + public T put(ClassDescriptor key, T value) { + //if (!(key instanceof ClassDescriptor)) { + // throw new IllegalArgumentException("expected ClassDescriptor, got " + key); + //} + if (autoKeys.size() > 0) { // remove all automatic keys which descend from the class being modified + Iterator<ClassDescriptor> i = autoKeys.iterator(); + while (i.hasNext()) { + ClassDescriptor auto = i.next(); + if (key.isAssignableFrom(auto)) { + i.remove(); + remove(auto); + } + } + } + return super.put(key, value); + } +} Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObject.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObject.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObject.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,638 +1,716 @@ -/* - * Copyright 2006 Ethan Nicholas. All rights reserved. - * Use is subject to license terms. - */ -package jaxx.compiler; - -import jaxx.CompilerException; -import jaxx.reflect.ClassDescriptor; -import jaxx.reflect.ClassDescriptorLoader; -import jaxx.reflect.MethodDescriptor; -import jaxx.tags.DefaultComponentHandler; -import jaxx.tags.TagHandler; -import jaxx.tags.TagManager; -import jaxx.types.TypeManager; - -import java.awt.Container; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Represents an object in the <code>.java</code> file being generated during compilation. There is - * a <code>CompiledObject</code> for each class tag encountered, and certain tags may generate - * additional objects for various reasons. - */ -public class CompiledObject { - - /** The object's id. */ - private String id; - /** Java code referring to the object. */ - private String javaCode; - /** The object's class. */ - private ClassDescriptor objectClass; - /** The style class. */ - private String styleClass; - /** The container containing this CompiledObject. */ - private CompiledObject parent; - /** true if this object overrides an object of the same id in a superclass of the object being compiled */ - private boolean override; - /** - * Comma-separated Java code snippets representing the parameters that should be passed to the object's - * constructor. - */ - private String constructorParams; - /** - * Java code snippet which performs basic initialization of the object (after it has already been constructed). - * Because CompiledObject initialization order cannot be guaranteed, it is not safe to refer to other - * CompiledObjects from initializationCode -- you must refer to them from additionCode instead. - */ - private StringBuffer initializationCode = new StringBuffer(); - /** - * Java code snippet which completes setup by adding any child objects, or otherwise manipulates any refererenced - * objects. Because CompiledObject initialization order cannot be guaranteed, it is not safe to refer to other - * CompiledObjects from initializationCode -- you must refer to them from additionCode instead. - */ - private StringBuffer additionCode = new StringBuffer(); - /** List of all registered event handlers. */ - private List<EventHandler> eventHandlers = new ArrayList<EventHandler>(); - /** All properties that have been applied to this CompiledObject. */ - private Map<String, String> properties = new HashMap<String, String>(); - /** generic types of the compiled object */ - private String[] genericTypes; - /** a flag to indicate if javaBean full support must be support for this object by root object */ - private boolean javaBean; - /** code to initialize the bean (can be null) */ - private String javaBeanInitCode; - /** the type of the override object (can be null if no oveeride) */ - private ClassDescriptor overrideType; - /** - * the decorator (if null will use {@link DefaultCompiledObjectDecorator}). - */ - private CompiledObjectDecorator decorator; - /** - * client properties - */ - private Map<String,String> clientProperties; - - public class ChildRef { - - CompiledObject child; - String constraints; - String childJavaCode; - String delegateCode; - - public ChildRef(CompiledObject child, String constraints, String childJavaCode, String delegateCode) { - this.child = child; - this.constraints = constraints; - this.childJavaCode = childJavaCode; - this.delegateCode = delegateCode; - } - - public CompiledObject getChild() { - return child; - } - - public void setChild(CompiledObject child) { - this.child = child; - } - - public String getConstraints() { - return constraints; - } - - public void setConstraints(String constraints) { - this.constraints = constraints; - } - - public String getChildJavaCode() { - return childJavaCode; - } - - public void setChildJavaCode(String childJavaCode) { - this.childJavaCode = childJavaCode; - } - - public String getDelegateCode() { - return delegateCode; - } - - public void setDelegateCode(String delegateCode) { - this.delegateCode = delegateCode; - } - - public void addToAdditionCode(StringBuffer buffer) { - if (constraints != null) { - buffer.append(javaCode).append(delegateCode).append(".add(").append(childJavaCode).append(", ").append(constraints).append(");"); - } else { - buffer.append(javaCode).append(delegateCode).append(".add(").append(childJavaCode).append(");"); - } - buffer.append(JAXXCompiler.getLineSeparator()); - } - } - private List<ChildRef> childs; - - /** - * Creates a new <code>CompiledObject</code>. To be useful, the object should be registered with a - * <code>JAXXCompiler</code> using {@link JAXXCompiler#registerCompiledObject registerCompiledObject}. - * - * @param id the object's id - * @param objectClass the object's class - * @param compiler the current <code>JAXXCompiler</code> - * @throws NullPointerException if id or class is null - */ - public CompiledObject(String id, ClassDescriptor objectClass, JAXXCompiler compiler) { - this(id, objectClass, compiler, false); - } - - /** - * Creates a new <code>CompiledObject</code>. To be useful, the object should be registered with a - * <code>JAXXCompiler</code> using {@link JAXXCompiler#registerCompiledObject registerCompiledObject}. - * - * @param id the object's id - * @param objectClass the object's class - * @param compiler the current <code>JAXXCompiler</code> - * @param force <code>true</code> to force acceptance of invalid ids - * @throws NullPointerException if id or class is null - */ - public CompiledObject(String id, ClassDescriptor objectClass, JAXXCompiler compiler, boolean force) { - this(id, id, objectClass, compiler, force); - } - - /** - * Creates a new <code>CompiledObject</code>. To be useful, the object should be registered with a - * <code>JAXXCompiler</code> using {@link JAXXCompiler#registerCompiledObject registerCompiledObject}. - * - * @param id the object's id - * @param javaCode Java code referring to the object - * @param objectClass the object's class - * @param force <code>true</code> to force acceptance of invalid ids - * @param compiler the current <code>JAXXCompiler</code> - * @throws CompilerException if the id is not a valid Java identifier - * @throws NullPointerException if id or class is null - */ - public CompiledObject(String id, String javaCode, ClassDescriptor objectClass, JAXXCompiler compiler, boolean force) throws CompilerException { - if (!force) { - if (!isValidID(id)) { - compiler.reportError("the id '" + id + "' is not a valid Java identifier"); - } - } - this.id = id; - this.javaCode = javaCode; - - if (objectClass == null) { - throw new NullPointerException(); - } - this.objectClass = objectClass; - this.childs = new ArrayList<ChildRef>(); - } - - public static boolean isValidID(String id) { - boolean valid = true; - if (id.length() == 0) { - valid = false; - } - if (valid) { - if (!Character.isJavaIdentifierStart(id.charAt(0))) { - valid = false; - } - if (valid) { - for (int i = 1; i < id.length(); i++) { - if (!Character.isJavaIdentifierPart(id.charAt(i))) { - valid = false; - break; - } - } - } - } - return valid; - } - - /** - * True if this object overrides an object in the superclass of the class being compiled. For this to be true, the - * class currently being compiled must be a subclass of another <code>JAXXObject</code> which has an - * identically-named object. - * - * @return <code>true</code> if this object is an override - * @see #setOverride - */ - public boolean isOverride() { - return override; - } - - /** - * Sets whether this class overrides an identically-named object in the parent class. - * - * @param override <code>true</code> if this object is an override - * @see #isOverride - */ - public void setOverride(boolean override) { - this.override = override; - } - - /** - * Returns this object's CSS style class. - * - * @return the value of the <code>styleClass</code> attribute - */ - public String getStyleClass() { - return styleClass; - } - - /** - * Sets this object's CSS style class. - * - * @param styleClass the new style class - */ - public void setStyleClass(String styleClass) { - this.styleClass = styleClass; - } - - /** - * Returns this object's parent container. Non-visual components (and the root container) return <code>null</code>. - * - * @return the object's parent container - */ - public CompiledObject getParent() { - return parent; - } - - /** - * Sets this object's parent container. - * - * @param parent the parent container - */ - public void setParent(CompiledObject parent) { - if (!ClassDescriptorLoader.getClassDescriptor(Container.class).isAssignableFrom(parent.getObjectClass())) { - throw new IllegalArgumentException("parent must descend from java.awt.Container"); - } - this.parent = parent; - } - - /** - * Returns the name of the method that should be generated in the compiled <code>.java</code> file - * in order to create this object. This is just a suggestion and may be ignored. - * - * @return the suggested name of the method which initializes this object - */ - public String getCreationMethodName() { - return "create" + org.apache.commons.lang.StringUtils.capitalize(getId()); - } - - /** - * Returns the name of the method that should be generated in the compiled <code>.java</code> file - * in order to add children to this object. This is just a suggestion and may be ignored. - * - * @return the suggested name of the method which completes this object's setup - */ - public String getAdditionMethodName() { - return "addChildrenTo" + org.apache.commons.lang.StringUtils.capitalize(getId()); - } - - /** - * Returns the type of this object. - * - * @return the class this <code>CompiledObject</code> represents - */ - public ClassDescriptor getObjectClass() { - return objectClass; - } - - /** - * Returns this object's id. Generally, a field with this name will be created in the compiled <code>.java</code> - * file in order to represent this object. - * - * @return the id used to refer to this object - */ - public String getId() { - return id; - } - - /** - * Returns Java code used to refer to this object in the compiled Java file. This is usually the same as its - * id. - * - * @return the Java code for this object - */ - public String getJavaCode() { - String result = javaCode; - if (isOverride()) { - // handle cases where object is overridden to be a different class - result = "((" + JAXXCompiler.getCanonicalName(getObjectClass()) + ") " + javaCode + ")"; - } - return result; - } - - public String getJavaCodeForProperty(String property) { - if (!override) { - return javaCode; - } - String result = "((" + JAXXCompiler.getCanonicalName(getObjectClass()) + ") " + javaCode + ")"; - - String methodName = org.apache.commons.lang.StringUtils.capitalize(property); - try { - MethodDescriptor methodDescriptor = overrideType.getMethodDescriptor("get" + methodName); - if (methodDescriptor != null) { - if (overrideType.getMethodDescriptor("set" + methodName, methodDescriptor.getReturnType()) != null) { - // handle cases where object is overridden to be a different class - result = javaCode; - } - } - } catch (NoSuchMethodException e) { - // lazy error, do nothing - } - return result; - } - - /** - * Returns a list of comma-separated Java code snippets that represent the parameters to pass to this - * object's constructor. - * - * @return the raw constructor params - * @see #setConstructorParams - */ - public String getConstructorParams() { - return constructorParams; - } - - /** - * Sets the parameters to pass to this object's constructor. - * - * @param constructorParams comma-separated Java code snippets representing constructor params - * @see #getConstructorParams - */ - public void setConstructorParams(String constructorParams) { - this.constructorParams = constructorParams; - } - - /** - * Returns the code that performs basic initialization of this object, after it has already been constructed. - * This basic code should not reference any other <code>CompiledObjects</code> as they may not have - * been created yet. - * - * @param compiler compiler to use - * @return the code which initializes this object - */ - public String getInitializationCode(JAXXCompiler compiler) { - StringBuffer result = new StringBuffer(initializationCode.toString()); - for (Object eventHandler : eventHandlers) { - EventHandler handler = (EventHandler) eventHandler; - result.append(getInitializationCode(handler, compiler)); - } - return result.toString(); - } - - protected String getInitializationCode(EventHandler handler, JAXXCompiler compiler) { - MethodDescriptor addMethod = handler.getAddMethod(); - ClassDescriptor listenerClass = addMethod.getParameterTypes()[0]; - return getJavaCode() + '.' + addMethod.getName() + "((" + JAXXCompiler.getCanonicalName(listenerClass) + - ") jaxx.runtime.Util.getEventListener(" + JAXXCompiler.getCanonicalName(listenerClass) + ".class, " + - TypeManager.getJavaCode(handler.getListenerMethod().getName()) + ", " + compiler.getRootObject().getJavaCode() + ", " + - TypeManager.getJavaCode(compiler.getEventHandlerMethodName(handler)) + "));" + JAXXCompiler.getLineSeparator(); - } - - /** - * Returns Java code to complete final setup on this object. This code may reference other - * <code>CompiledObjects</code>, as they are guaranteed to have all been created by this point. - * - * @return code which adds children and performs final setup - */ - public String getAdditionCode() { - return additionCode.toString(); - } - - /** - * Appends code to the initialization code block. A line separator is automatically appended to the end. - * - * @param code the code to add to the initialization block - * @see #getInitializationCode - */ - public void appendInitializationCode(String code) { - this.initializationCode.append(code); - this.initializationCode.append(JAXXCompiler.getLineSeparator()); - } - - /** - * Appends code to the addition code block. A line separator is automatically appended to the end. - * - * @param code the code to add to the addition block - * @see #getAdditionCode - */ - public void appendAdditionCode(String code) { - this.additionCode.append(code); - this.additionCode.append(JAXXCompiler.getLineSeparator()); - } - - /** - * Stores a property for this object. The only effect of calling this method is that the property will - * be returned by <code>getProperties()</code>. - * - * @param property the name of the property - * @param value the property's value - * @see #getProperties - */ - public void addProperty(String property, String value) { - properties.put(property, value); - } - - public boolean hasClientProperties() { - return clientProperties != null && !clientProperties.isEmpty(); - } - - public void addClientProperty(String property, String value) { - getClientProperties().put(property, value); - } - - public String getClientProperty(String key) { - if (!hasClientProperties()) { - return null; - } - return clientProperties.get(key); - } - - public Map<String, String> getClientProperties() { - if (clientProperties == null) { - clientProperties = new HashMap<String, String>(); - } - return clientProperties; - } - - - /** - * Returns all properties which have been set for this object. - * - * @return a <code>Map</code> containing all properties defined for this object - * @see #addProperty - */ - public Map/*<String, String>*/ getProperties() { - return properties; - } - - // TODO: remove this temporary method and complete switchover to MethodDescriptors - public void addEventHandler(String eventId, Method addMethod, Method listenerMethod, String code, JAXXCompiler compiler) { - try { - ClassDescriptor descriptor = ClassDescriptorLoader.getClassDescriptor(getObjectClass().getName()); - String listenerClassName = addMethod.getParameterTypes()[0].getName(); - ClassDescriptor listenerDescriptor = ClassDescriptorLoader.getClassDescriptor(listenerClassName); - MethodDescriptor addMethodDescriptor = descriptor.getMethodDescriptor(addMethod.getName(), listenerDescriptor); - MethodDescriptor listenerMethodDescriptor = listenerDescriptor.getMethodDescriptor(listenerMethod.getName(), ClassDescriptorLoader.getClassDescriptor(listenerMethod.getParameterTypes()[0].getName())); - addEventHandler(eventId, addMethodDescriptor, listenerMethodDescriptor, code, compiler); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - /** - * Adds an event listener to this object. The generated code will appear in the initialization block. - * - * @param eventId unique (per CompiledObject) identifier for the event handler - * @param addMethod the method which adds the event listener - * @param listenerMethod the method (in the listener class) which is called when the event is fired - * @param code the Java code for the listenerMethod's body - * @param compiler the current <code>JAXXCompiler</code> - * @see #getInitializationCode - */ - public void addEventHandler(String eventId, MethodDescriptor addMethod, MethodDescriptor listenerMethod, String code, JAXXCompiler compiler) { - EventHandler handler = new EventHandler(getId() + "." + eventId, getJavaCode(), addMethod, addMethod.getParameterTypes()[0], listenerMethod, code); - compiler.registerEventHandler(handler); - eventHandlers.add(handler); - - if (getJavaCode().indexOf(".") != -1) { // object lives in another JAXX file and consequently its initialization code won't be output - compiler.appendInitializerCode(getInitializationCode(handler, compiler)); - } - } - - /** - * Adds a child component to this container. The child is added without layout constraints. - * - * @param child the component to add - * @param compiler the current <code>JAXXCompiler</code> - * @throws CompilerException if this object is not a container - * @see #addChild(CompiledObject, String, JAXXCompiler) - */ - public void addChild(CompiledObject child, JAXXCompiler compiler) throws CompilerException { - addChild(child, null, compiler); - } - - /** - * Adds a child component to this container. This variant allows the Java code for a layout constraints - * object to be specified. - * - * @param child the component to add - * @param constraints Java code for the layout constraints object - * @param compiler the current <code>JAXXCompiler</code> - * @throws CompilerException if this object is not a container - * @see #addChild(CompiledObject, JAXXCompiler) - */ - public void addChild(CompiledObject child, String constraints, JAXXCompiler compiler) throws CompilerException { - try { - if (constraints != null) { - constraints = compiler.checkJavaCode(constraints); - } - } catch (CompilerException e) { - compiler.reportError("While parsing 'constraints' attribute: " + e.getMessage()); - } - - if (!child.isOverride()) { - TagHandler tagHandler = TagManager.getTagHandler(getObjectClass()); - if (tagHandler instanceof DefaultComponentHandler && !((DefaultComponentHandler) tagHandler).isContainer()) { - compiler.reportError("component " + this + " may not have children"); - } - - String containerDelegate = ((DefaultComponentHandler) tagHandler).getContainerDelegate(); - String delegateCode = containerDelegate != null ? "." + containerDelegate + "()" : ""; - - child.setParent(this); - - childs.add(new ChildRef(child, constraints, child.getJavaCode(), delegateCode)); - } - } - - @Override - public String toString() { - return getObjectClass().getName() + "[id='" + id + "']"; - } - - public void registerDataBinding(String src, String property, String assignment, JAXXCompiler compiler) throws CompilerException { - compiler.registerDataBinding(src, getId() + "." + property, assignment); - } - public String getGenericTypes() { - if (getGenericTypesLength() == 0) { - // not using it - return ""; - } - String result = ""; - for (int i = 0, j = getGenericTypesLength(); i < j; i++) { - result += ", " + genericTypes[i]; - } - return "< " + result.substring(2) + " >"; - } - - public void setGenericTypes(String[] genericTypes) { - if (genericTypes == null) { - this.genericTypes = null; - return; - } - this.genericTypes = new String[genericTypes.length]; - for (int i = 0, j = genericTypes.length; i < j; i++) { - this.genericTypes[i] = genericTypes[i].trim(); - } - } - - public boolean isJavaBean() { - return javaBean; - } - - public void setJavaBean(boolean javaBean) { - this.javaBean = javaBean; - } - - public ClassDescriptor getOverrideType() { - return overrideType; - } - - public void setOverrideType(ClassDescriptor overrideType) { - this.overrideType = overrideType; - } - - public String getJavaBeanInitCode() { - return javaBeanInitCode; - } - - public void setJavaBeanInitCode(String javaBeanInitCode) { - this.javaBeanInitCode = javaBeanInitCode; - } - - public List<ChildRef> getChilds() { - return childs; - } - - public CompiledObjectDecorator getDecorator() { - return decorator; - } - - public void setDecorator(CompiledObjectDecorator decorator) { - this.decorator = decorator; - } - - public void finalizeCompiler() { - StringBuffer buffer = new StringBuffer(); - - List<CompiledObject.ChildRef> refList = getChilds(); - if (refList == null || refList.isEmpty()) { - return; - } - - for (ChildRef childRef : refList) { - childRef.addToAdditionCode(buffer); - } - - additionCode = buffer.append(additionCode); - } - - public int getGenericTypesLength() { - return genericTypes == null ? 0 : genericTypes.length; - } -} \ No newline at end of file +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler; + +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.reflect.MethodDescriptor; +import jaxx.compiler.tags.DefaultComponentHandler; +import jaxx.compiler.tags.TagHandler; +import jaxx.compiler.tags.TagManager; + +import java.awt.Container; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import jaxx.compiler.types.TypeManager; +import org.apache.commons.lang.StringUtils; + +/** + * Represents an object in the <code>.java</code> file being generated during compilation. There is + * a <code>CompiledObject</code> for each class tag encountered, and certain tags may generate + * additional objects for various reasons. + */ +public class CompiledObject { + + /** + * The object's id. + */ + private String id; + /** + * Java code referring to the object. + */ + private String javaCode; + /** + * The object's class. + */ + private ClassDescriptor objectClass; + /** + * The style class. + */ + private String styleClass; + /** + * The container containing this CompiledObject. + */ + private CompiledObject parent; + /** + * true if this object overrides an object of the same id in a superclass + * of the object being compiled + */ + private boolean override; + /** + * Comma-separated Java code snippets representing the parameters that + * should be passed to the object's constructor. + */ + private String constructorParams; + /** + * Java code snippet which performs basic initialization of the object (after it has already been constructed). + * Because CompiledObject initialization order cannot be guaranteed, it is not safe to refer to other + * CompiledObjects from initializationCode -- you must refer to them from additionCode instead. + */ + private StringBuffer initializationCode = new StringBuffer(); + /** + * Java code snippet which completes setup by adding any child objects, or otherwise manipulates any refererenced + * objects. Because CompiledObject initialization order cannot be guaranteed, it is not safe to refer to other + * CompiledObjects from initializationCode -- you must refer to them from additionCode instead. + */ + private StringBuffer additionCode = new StringBuffer(); + /** + * List of all registered event handlers. + */ + private List<EventHandler> eventHandlers = new ArrayList<EventHandler>(); + /** + * All properties that have been applied to this CompiledObject. + */ + private Map<String, String> properties = new HashMap<String, String>(); + /** + * generic types of the compiled object + */ + private String[] genericTypes; + /** + * a flag to indicate if javaBean full support must be support for this + * object by root object + */ + private boolean javaBean; + /** + * code to initialize the bean (can be null) + */ + private String javaBeanInitCode; + /** + * the type of the override object (can be null if no overide) + */ + private ClassDescriptor overrideType; + /** + * the decorator + */ + private CompiledObjectDecorator decorator; + /** + * client properties + */ + private Map<String, String> clientProperties; + /** + * initializer of the object + */ + private String initializer; + + public class ChildRef { + + CompiledObject child; + String constraints; + String childJavaCode; + private String delegateCode; + + public ChildRef(CompiledObject child, String constraints, String childJavaCode, String delegateCode) { + this.child = child; + this.constraints = constraints; + this.childJavaCode = childJavaCode; + this.delegateCode = delegateCode; + } + + public CompiledObject getChild() { + return child; + } + +// public void setChild(CompiledObject child) { +// this.child = child; +// } +// +// public String getConstraints() { +// return constraints; +// } +// +// public void setConstraints(String constraints) { +// this.constraints = constraints; +// } + + public String getChildJavaCode() { + return childJavaCode; + } + + public void setChildJavaCode(String childJavaCode) { + this.childJavaCode = childJavaCode; + } + +// public String getDelegateCode() { +// return delegateCode; +// } +// +// public void setDelegateCode(String delegateCode) { +// this.delegateCode = delegateCode; +// } + + public void addToAdditionCode(StringBuffer buffer, boolean isRootObject) { + //TC-20091026 do not prefix if on root object + String prefix; + if (isRootObject) { + prefix = ""; + } else { + prefix = javaCode + delegateCode + "."; + } + if (constraints != null) { + buffer.append(prefix).append("add(").append(childJavaCode).append(", ").append(constraints).append(");"); + } else { + buffer.append(prefix).append("add(").append(childJavaCode).append(");"); + } + buffer.append(JAXXCompiler.getLineSeparator()); + } + } + private List<ChildRef> childs; + + /** + * Creates a new <code>CompiledObject</code>. To be useful, the object should be registered with a + * <code>JAXXCompiler</code> using {@link JAXXCompiler#registerCompiledObject registerCompiledObject}. + * + * @param id the object's id + * @param objectClass the object's class + * @param compiler the current <code>JAXXCompiler</code> + * @throws NullPointerException if id or class is null + */ + public CompiledObject(String id, ClassDescriptor objectClass, JAXXCompiler compiler) { + this(id, objectClass, compiler, false); + } + + /** + * Creates a new <code>CompiledObject</code>. To be useful, the object should be registered with a + * <code>JAXXCompiler</code> using {@link JAXXCompiler#registerCompiledObject registerCompiledObject}. + * + * @param id the object's id + * @param objectClass the object's class + * @param compiler the current <code>JAXXCompiler</code> + * @param force <code>true</code> to force acceptance of invalid ids + * @throws NullPointerException if id or class is null + */ + public CompiledObject(String id, ClassDescriptor objectClass, JAXXCompiler compiler, boolean force) { + this(id, id, objectClass, compiler, force); + } + + /** + * Creates a new <code>CompiledObject</code>. To be useful, the object should be registered with a + * <code>JAXXCompiler</code> using {@link JAXXCompiler#registerCompiledObject registerCompiledObject}. + * + * @param id the object's id + * @param javaCode Java code referring to the object + * @param objectClass the object's class + * @param force <code>true</code> to force acceptance of invalid ids + * @param compiler the current <code>JAXXCompiler</code> + * @throws CompilerException if the id is not a valid Java identifier + * @throws NullPointerException if id or class is null + */ + public CompiledObject(String id, String javaCode, ClassDescriptor objectClass, JAXXCompiler compiler, boolean force) throws CompilerException { + if (!force) { + if (!isValidID(id)) { + compiler.reportError("the id '" + id + "' is not a valid Java identifier"); + } + } + this.id = id; + this.javaCode = javaCode; + + if (objectClass == null) { + throw new NullPointerException(); + } + this.objectClass = objectClass; + this.childs = new ArrayList<ChildRef>(); + } + + public static boolean isValidID(String id) { + boolean valid = true; + if (id.length() == 0) { + valid = false; + } + if (valid) { + if (!Character.isJavaIdentifierStart(id.charAt(0))) { + valid = false; + } + if (valid) { + for (int i = 1; i < id.length(); i++) { + if (!Character.isJavaIdentifierPart(id.charAt(i))) { + valid = false; + break; + } + } + } + } + return valid; + } + + /** + * True if this object overrides an object in the superclass of the class + * being compiled. For this to be true, the class currently being compiled + * must be a subclass of another <code>JAXXObject</code> which has an + * identically-named object. + * + * @return <code>true</code> if this object is an override + * @see #setOverride + */ + public boolean isOverride() { + return override; + } + + /** + * Sets whether this class overrides an identically-named object in the + * parent class. + * + * @param override <code>true</code> if this object is an override + * @see #isOverride + */ + public void setOverride(boolean override) { + this.override = override; + } + + /** + * Returns this object's CSS style class. + * + * @return the value of the <code>styleClass</code> attribute + */ + public String getStyleClass() { + return styleClass; + } + + /** + * Sets this object's CSS style class. + * + * @param styleClass the new style class + */ + public void setStyleClass(String styleClass) { + this.styleClass = styleClass; + } + + /** + * Returns this object's parent container. Non-visual components (and + * the root container) return <code>null</code>. + * + * @return the object's parent container + */ + public CompiledObject getParent() { + return parent; + } + + /** + * Sets this object's parent container. + * + * @param parent the parent container + * @throws IllegalArgumentException if parent is not a {@link Container} + */ + public void setParent(CompiledObject parent) throws IllegalArgumentException { + if (!ClassDescriptorLoader.getClassDescriptor(Container.class).isAssignableFrom(parent.getObjectClass())) { + throw new IllegalArgumentException("parent must descend from java.awt.Container"); + } + this.parent = parent; + } + + /** + * Returns the name of the method that should be generated in the compiled + * <code>.java</code> file + * in order to create this object. This is just a suggestion and may be + * ignored. + * + * @return the suggested name of the method which initializes this object + */ + public String getCreationMethodName() { + return "create" + StringUtils.capitalize(getId()); + } + + /** + * Returns the name of the method that should be generated in the compiled + * <code>.java</code> file in order to add children to this object. This + * is just a suggestion and may be ignored. + * + * @return the suggested name of the method which completes this object's setup + */ + public String getAdditionMethodName() { + return "addChildrenTo" + StringUtils.capitalize(getId()); + } + + /** + * Returns the type of this object. + * + * @return the class this <code>CompiledObject</code> represents + */ + public ClassDescriptor getObjectClass() { + return objectClass; + } + + /** + * Returns this object's id. Generally, a field with this name will be + * created in the compiled <code>.java</code> + * file in order to represent this object. + * + * @return the id used to refer to this object + */ + public String getId() { + return id; + } + + /** + * Returns Java code used to refer to this object in the compiled Java file. + * This is usually the same as its id. + * + * @return the Java code for this object + */ + public String getJavaCode() { + String result = javaCode; + if (isOverride()) { + // handle cases where object is overridden to be a different class + result = "((" + JAXXCompiler.getCanonicalName(getObjectClass()) + ") " + javaCode + ")"; + } + return result; + } + + public String getJavaCodeForProperty(String property) { + if (!override) { + return javaCode; + } + String result = "((" + JAXXCompiler.getCanonicalName(getObjectClass()) + ") " + javaCode + ")"; + + String methodName = StringUtils.capitalize(property); + try { + MethodDescriptor methodDescriptor = overrideType.getMethodDescriptor("get" + methodName); + if (methodDescriptor != null) { + if (overrideType.getMethodDescriptor("set" + methodName, methodDescriptor.getReturnType()) != null) { + // handle cases where object is overridden to be a different class + result = javaCode; + } + } + } catch (NoSuchMethodException e) { + // lazy error, do nothing + } + return result; + } + + /** + * Returns a list of comma-separated Java code snippets that represent the + * parameters to pass to this object's constructor. + * + * @return the raw constructor params + * @see #setConstructorParams + */ + public String getConstructorParams() { + return constructorParams; + } + + /** + * Sets the parameters to pass to this object's constructor. + * + * @param constructorParams comma-separated Java code snippets representing + * constructor params + * @see #getConstructorParams + */ + public void setConstructorParams(String constructorParams) { + this.constructorParams = constructorParams; + } + + public String getInitializer() { + return initializer; + } + + public void setInitializer(String initializer) { + this.initializer = initializer; + } + + /** + * Returns the code that performs basic initialization of this object, + * after it has already been constructed. + * This basic code should not reference any other + * <code>CompiledObjects</code> as they may not have been created yet. + * + * @param compiler compiler to use + * @return the code which initializes this object + */ + public String getInitializationCode(JAXXCompiler compiler) { + StringBuffer result = new StringBuffer(initializationCode.toString()); + for (Object eventHandler : eventHandlers) { + EventHandler handler = (EventHandler) eventHandler; + result.append(getInitializationCode(handler, compiler)); + } + return result.toString(); + } + + protected String getInitializationCode(EventHandler handler, JAXXCompiler compiler) { + MethodDescriptor addMethod = handler.getAddMethod(); + ClassDescriptor listenerClass = addMethod.getParameterTypes()[0]; + //TC-20091026 use 'this' instead of root object javaCode + //TC-20091105 Util.getEventListener is generic, no more need cast and use simple name + return getJavaCode() + '.' + addMethod.getName() + "(Util.getEventListener(" + listenerClass.getSimpleName() + ".class, " + + TypeManager.getJavaCode(handler.getListenerMethod().getName()) + ", this, " + + TypeManager.getJavaCode(compiler.getEventHandlerMethodName(handler)) + "));" + JAXXCompiler.getLineSeparator(); + } + + /** + * Returns Java code to complete final setup on this object. This code may + * reference other <code>CompiledObjects</code>, as they are guaranteed to + * have all been created by this point. + * + * @return code which adds children and performs final setup + */ + public String getAdditionCode() { + return additionCode.toString(); + } + + /** + * Appends code to the initialization code block. A line separator is + * automatically appended to the end. + * + * @param code the code to add to the initialization block + * @see #getInitializationCode + */ + public void appendInitializationCode(String code) { + if (!code.isEmpty()) { + this.initializationCode.append(code); + this.initializationCode.append(JAXXCompiler.getLineSeparator()); + } + } + + /** + * Appends code to the addition code block. A line separator is + * automatically appended to the end. + * + * @param code the code to add to the addition block + * @see #getAdditionCode + */ + public void appendAdditionCode(String code) { + if (!code.isEmpty()) { + this.additionCode.append(code); + this.additionCode.append(JAXXCompiler.getLineSeparator()); + } + } + + /** + * Stores a property for this object. The only effect of calling this + * method is that the property will be returned by {@code getProperties()}. + * + * @param property the name of the property + * @param value the property's value + * @see #getProperties + */ + public void addProperty(String property, String value) { + properties.put(property, value); + } + + public boolean hasClientProperties() { + return clientProperties != null && !clientProperties.isEmpty(); + } + + public void addClientProperty(String property, String value) { + getClientProperties().put(property, value); + } + + public String getClientProperty(String key) { + if (!hasClientProperties()) { + return null; + } + return clientProperties.get(key); + } + + public Map<String, String> getClientProperties() { + if (clientProperties == null) { + clientProperties = new HashMap<String, String>(); + } + return clientProperties; + } + + /** + * Returns all properties which have been set for this object. + * + * @return a <code>Map</code> containing all properties defined for this object + * @see #addProperty + */ + public Map<?, ?>/*<String, String>*/ getProperties() { + return properties; + } + + // TODO: remove this temporary method and complete switchover to MethodDescriptors + public void addEventHandler(String eventId, Method addMethod, Method listenerMethod, String code, JAXXCompiler compiler) { + try { + ClassDescriptor descriptor = ClassDescriptorLoader.getClassDescriptor(getObjectClass().getName()); + String listenerClassName = addMethod.getParameterTypes()[0].getName(); + ClassDescriptor listenerDescriptor = ClassDescriptorLoader.getClassDescriptor(listenerClassName); + MethodDescriptor addMethodDescriptor = descriptor.getMethodDescriptor(addMethod.getName(), listenerDescriptor); + MethodDescriptor listenerMethodDescriptor = listenerDescriptor.getMethodDescriptor(listenerMethod.getName(), ClassDescriptorLoader.getClassDescriptor(listenerMethod.getParameterTypes()[0].getName())); + addEventHandler(eventId, addMethodDescriptor, listenerMethodDescriptor, code, compiler); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * Adds an event listener to this object. The generated code will appear + * in the initialization block. + * + * @param eventId unique (per CompiledObject) identifier for the event handler + * @param addMethod the method which adds the event listener + * @param listenerMethod the method (in the listener class) which is called when the event is fired + * @param code the Java code for the listenerMethod's body + * @param compiler the current <code>JAXXCompiler</code> + * @see #getInitializationCode + */ + public void addEventHandler(String eventId, MethodDescriptor addMethod, MethodDescriptor listenerMethod, String code, JAXXCompiler compiler) { + EventHandler handler = new EventHandler(getId() + "." + eventId, getJavaCode(), addMethod, addMethod.getParameterTypes()[0], listenerMethod, code); + compiler.registerEventHandler(handler); + eventHandlers.add(handler); + + if (getJavaCode().indexOf(".") != -1) { + // object lives in another JAXX file and consequently its initialization code won't be output + compiler.appendInitializerCode(getInitializationCode(handler, compiler)); + } + } + + /** + * Adds a child component to this container. The child is added without + * layout constraints. + * + * @param child the component to add + * @param compiler the current <code>JAXXCompiler</code> + * @throws CompilerException if this object is not a container + * @see #addChild(CompiledObject, String, JAXXCompiler) + */ + public void addChild(CompiledObject child, JAXXCompiler compiler) throws CompilerException { + addChild(child, null, compiler); + } + + /** + * Adds a child component to this container. This variant allows the Java + * code for a layout constraints object to be specified. + * + * @param child the component to add + * @param constraints Java code for the layout constraints object + * @param compiler the current <code>JAXXCompiler</code> + * @throws CompilerException if this object is not a container + * @see #addChild(CompiledObject, JAXXCompiler) + */ + public void addChild(CompiledObject child, String constraints, JAXXCompiler compiler) throws CompilerException { + try { + if (constraints != null) { + constraints = compiler.checkJavaCode(constraints); + } + } catch (CompilerException e) { + compiler.reportError("While parsing 'constraints' attribute: " + e.getMessage()); + } + + if (!child.isOverride()) { + TagHandler tagHandler = TagManager.getTagHandler(getObjectClass()); + if (tagHandler instanceof DefaultComponentHandler && + !((DefaultComponentHandler) tagHandler).isContainer()) { + compiler.reportError("component " + this + " may not have children"); + } + + String containerDelegate = ((DefaultComponentHandler) tagHandler).getContainerDelegate(); + String delegateCode = containerDelegate != null ? "." + containerDelegate + "()" : ""; + + child.setParent(this); + + childs.add(new ChildRef(child, constraints, child.getJavaCode(), delegateCode)); + } + } + + @Override + public String toString() { + return getObjectClass().getName() + "[id='" + id + "']"; + } + + public String getGenericTypes() { + if (getGenericTypesLength() == 0) { + // not using it + return ""; + } + String result = ""; + for (int i = 0, j = getGenericTypesLength(); i < j; i++) { + result += ", " + genericTypes[i]; + } + return "< " + result.substring(2) + " >"; + } + + public void setGenericTypes(String[] genericTypes) { + if (genericTypes == null) { + this.genericTypes = null; + return; + } + this.genericTypes = new String[genericTypes.length]; + for (int i = 0, j = genericTypes.length; i < j; i++) { + this.genericTypes[i] = genericTypes[i].trim(); + } + } + + public boolean isJavaBean() { + return javaBean; + } + + public void setJavaBean(boolean javaBean) { + this.javaBean = javaBean; + } + + public ClassDescriptor getOverrideType() { + return overrideType; + } + + public void setOverrideType(ClassDescriptor overrideType) { + this.overrideType = overrideType; + } + + public String getJavaBeanInitCode() { + return javaBeanInitCode; + } + + public void setJavaBeanInitCode(String javaBeanInitCode) { + this.javaBeanInitCode = javaBeanInitCode; + } + + public List<ChildRef> getChilds() { + return childs; + } + + public CompiledObjectDecorator getDecorator() { + return decorator; + } + + public void setDecorator(CompiledObjectDecorator decorator) { + this.decorator = decorator; + } + + public void finalizeCompiler(JAXXCompiler compiler) { + + List<CompiledObject.ChildRef> refList = getChilds(); + if (refList != null && !refList.isEmpty()) { + // compute additionCode for all childs + StringBuffer buffer = new StringBuffer(); + for (ChildRef childRef : refList) { + childRef.addToAdditionCode(buffer, compiler.getRootObject() == this); + } + additionCode = buffer.append(additionCode); + } + } + + public int getGenericTypesLength() { + return genericTypes == null ? 0 : genericTypes.length; + } +} Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObjectDecorator.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObjectDecorator.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObjectDecorator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,76 +1,87 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ package jaxx.compiler; -import java.util.Map; -import java.util.TreeMap; -import jaxx.CompilerException; +import jaxx.compiler.java.JavaFile; /** + * Contract of compiled object decorator at generation time. + * <p/> + * Note : The implementation of this class must be stateless. * - * A class to decorate a compiled object at generation time. - * - * Contains also a cache of decorator in a dictonnary indexed by fqn of decorator. - * - * Use the {@link #getDecorator(java.lang.String)} to obtain the cached decorator. - * - * Note : The implementation of this class must be stateless. - * * @author tony * @since 1.2 */ -public abstract class CompiledObjectDecorator { +public interface CompiledObjectDecorator { - protected static Map<String, CompiledObjectDecorator> cache; + /** + * @return the name of the decorator (match the content of a decorator + * attribute value in a JAXX file) + */ + String getName(); - public static void registerDecorator(String key, Class<? extends CompiledObjectDecorator> klass) { - synchronized (getCache()) { - if (getCache().containsKey(key)) { - throw new IllegalArgumentException("the decorator with key [" + key + "] is already registred! use another key name"); - } - try { - getCache().put(key, klass.newInstance()); - } catch (InstantiationException ex) { - throw new IllegalArgumentException("could not create decorator " + klass + " for reason " + ex.getMessage(), ex); - } catch (IllegalAccessException ex) { - throw new IllegalArgumentException("could not create decorator " + klass + " for reason " + ex.getMessage(), ex); - } - } - } + /** + * Obtain the setup code of the given {@code object} from the {@code compiler} to be inject in the generated + * method {@code $completeSetup}. + * + * @param compiler the compiler to use + * @param object the compiled object to treate + * @param javaFile the file to treate + * @return the code to inject in $completeSetup method in file + */ + String createCompleteSetupMethod(JAXXCompiler compiler, CompiledObject object, JavaFile javaFile); - public static CompiledObjectDecorator getDecorator(String name) { - CompiledObjectDecorator decorator = getCache().get(name); - if (decorator == null) { - throw new IllegalArgumentException("could not find decorator with key " + name + " (known decorators : " + getCache().keySet()); - } - return decorator; - } + /** + * Create the initializer code for the given compiled {@code object} and inject it in the {@code code}. + * + * @param compiler the compiler to use + * @param root the root compiled object of the jaxx file + * @param object the compiled object to treate + * @param code where to store code to inject + * @param lastWasMethodCall {@code true} if last instruction call was a method call + * @return {@code true} if the last instruction was a method call + */ + boolean createInitializer(JAXXCompiler compiler, CompiledObject root, CompiledObject object, StringBuffer code, boolean lastWasMethodCall); - public static CompiledObjectDecorator getDecorator(Class<?> type) { - for (CompiledObjectDecorator decorator : getCache().values()) { - if (type == decorator.getClass()) { - return decorator; - } - } - return null; - } + /** + * Finalize the given compiled object before any generation in the {@code file}. + * + * @param compiler the compiler to use + * @param root the root compiled object of the jaxx file + * @param object the compiled object to treate + * @param javaFile the file to treate + * @param packageName the package name + * @param className the (simple ?) class name + * @param fullClassName the fully class name + */ + void finalizeCompiler(JAXXCompiler compiler, CompiledObject root, CompiledObject object, JavaFile javaFile, String packageName, String className, String fullClassName); - protected static synchronized Map<String, CompiledObjectDecorator> getCache() { - if (cache == null) { - cache = new TreeMap<String, CompiledObjectDecorator>(); - } - return cache; - } - - public static void reset() { - if (cache != null) { - cache.clear(); - } - } - - public abstract void finalizeCompiler(JAXXCompiler compiler, CompiledObject root, CompiledObject object, JavaFile javaFile, String packageName, String className, String fullClassName); - - public abstract String getCreationCode(JAXXCompiler compiler, CompiledObject object) throws CompilerException; - - public abstract boolean createInitializer(JAXXCompiler compiler, CompiledObject root, CompiledObject object, StringBuffer code, boolean lastWasMethodCall); - - public abstract String createCompleteSetupMethod(JAXXCompiler compiler, CompiledObject object, JavaFile javaFile, StringBuffer initDataBindings); + /** + * Obtain the creation code of the given {@code object} from the {@code compiler} to inject in generate method + * {@code $initialize} or {@code createXXX} in not inline. + * + * @param compiler the compiler to use + * @param object the compiled object to treate + * @return the code to inject in $initialize (or in the createXXX in not inline) method to create the given object + * @throws CompilerException if any pb + */ + String getCreationCode(JAXXCompiler compiler, CompiledObject object) throws CompilerException; } Property changes on: trunk/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObjectDecorator.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL Added: svn:mergeinfo + Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,150 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler; + +import java.io.File; +import jaxx.runtime.JAXXContext; + +/** + * TODO javadoc. + * + * @author chemit + * @since 2.0.0 + */ +public interface CompilerConfiguration { + + /** + * + * @return the class loader used by compilers + */ + ClassLoader getClassLoader(); + + /** + * + * @return the type of compiler to use + */ + Class<? extends JAXXCompiler> getCompilerClass(); + + /** + * + * @return the type of default decorator to use if none specified + */ + Class<? extends CompiledObjectDecorator> getDefaultDecoratorClass(); + + /** + * + * @return the type of the default error UI to use for validation + */ + Class<?> getDefaultErrorUI(); + + /** + * + * @return extra imports to add on all generated jaxx object + */ + String[] getExtraImports(); + + /** + * + * @return the FQN of the help broker (can not directly a type since + * the help broker should (may?) be inside the sources. + */ + String getHelpBrokerFQN(); + + /** + * + * @return the type of context to use in each generated jaxx object + */ + Class<? extends JAXXContext> getJaxxContextClass(); + + /** + * Returns whether or not optimization should be performed. + * + * @return whether or not optimizations should be performed + */ + boolean getOptimize(); + + /** + * Returns the target directory. + * + * @return the target directory + */ + File getTargetDirectory(); + + /** + * + * @return the type of validator to use + */ + Class<?> getValidatorClass(); + + /** + * + * @return {@code true} if a logger must add on each generated jaxx object + */ + boolean isAddLogger(); + + /** + * + * @return {@code true} if we are generating help + */ + boolean isGenerateHelp(); + + /** + * + * @return {@code true} if we use the i18n system + */ + boolean isI18nable(); + + /** + * + * @return {@code true} to generate optimized code + */ + boolean isOptimize(); + + /** + * + * @return {@code true} if a profile pass must be done + */ + boolean isProfile(); + + /** + * + * @return {@code true} if states must be reset after the compilation + */ + boolean isResetAfterCompile(); + + /** + * + * @return {@code true} if UIManager is used to retrieve icons + */ + boolean isUseUIManagerForIcon(); + + /** + * + * @return {@code true} if compiler is verbose + */ + boolean isVerbose(); + + /** + * + * @return the encoding to use to write files + */ + String getEncoding(); +} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/CompilerException.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerException.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/CompilerException.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/CompilerException.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,66 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler; + +/** Thrown by the compiler when an error occurs. */ +public class CompilerException extends RuntimeException { + + private static final long serialVersionUID = -9099889519671482440L; + + /** Creates a new <code>ParseException</code>. */ + public CompilerException() { + } + + /** + * Creates a new <code>ParseException</code> with the specified detail message. + * + * @param msg the exception's detail message + */ + public CompilerException(String msg) { + super(msg); + } + + /** + * Creates a new <code>ParseException</code> with the specified cause. + * + * @param initCause the exception's initCause + */ + public CompilerException(Throwable initCause) { + super(initCause); + } + + /** + * Creates a new <code>ParseException</code> with the specified detail message and cause. + * + * @param msg the exception's detail message + * @param initCause the exception's initCause + */ + public CompilerException(String msg, Throwable initCause) { + super(msg, initCause); + } + + @Override + public void printStackTrace() { + super.printStackTrace(); + System.err.println("CompilerException printed from:"); + Thread.dumpStack(); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/CompilerOptions.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/CompilerOptions.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/CompilerOptions.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,406 +0,0 @@ -package jaxx.compiler; - -import org.apache.commons.lang.builder.ToStringBuilder; - -import java.io.File; - -/** - * Stores options which affect the jaxxc tool's operation. These options are generally specified by the - * user on the command line. - */ -public class CompilerOptions { - private File targetDirectory; - private File javacTargetDirectory; - private String classPath; - private String javacOpts; - private boolean keepJavaFiles; - private boolean optimize; - private boolean verbose; - private boolean profile; - /** a flag to enable or disable i18n generation */ - private boolean i18nable; - - /** a flag to add or not logger on generated jaxx files */ - private boolean addLogger; - - /** a flag to not reset compiler after a compile */ - private boolean resetAfterCompile; - - /** the name of implementation of {@link jaxx.runtime.JAXXContext} to be used on {@link jaxx.runtime.JAXXObject}. */ - protected String jaxxContextImplementorClass; - - /** list of fqn of class toimport for all generated jaxx files */ - protected String[] extraImports; - - /** default error ui */ - private Class<?> defaultErrorUI; - - private ClassLoader classLoader; - - private Class<? extends JAXXCompiler> compilerClass; - - /** - * @deprecated prefer use {@link #validatorClass} - */ - @Deprecated - private String validatorFQN; - /** - * the validator class to use. - * - * @since 1.6.0 - */ - private Class<?> validatorClass; - - /** a flag to use {@link javax.swing.UIManager} to retreave icons. */ - private boolean useUIManagerForIcon; - - /** a flag to generate javax help for any */ - private boolean generateHelp; - - private String helpBrokerFQN; - /** - * The prefix to add to i18n key for any help i18n key. - * - * @since 1.3 - */ - protected String helpsetI18nPrefix; - /** - * The suffix to add to i18n key for an help Id. - * - * @since 1.3 - */ - protected String helpsetTitleI18nSuffix; - /** - * The suffix to add to i18n key for an toc Id. - * - * @since 1.3 - */ - protected String helpsetTocI18nSuffix; - /** - * The suffix to add to i18n key for an toc Id. - * - * @since 1.3 - */ - protected String helpsetIndexI18nSuffix; - /** - * The helpset name - * - * @since 1.3 - */ - protected String helpSetName; - /** the default compiled object decorator to use if none specifed via decorator attribute */ - private Class<? extends CompiledObjectDecorator> defaultDecoratorClass; - - /** - * Returns the target directory, generally specified with the "-d" option on the command line. - * - * @return the target directory - * @see #setTargetDirectory - */ - public File getJavacTargetDirectory() { - if (javacTargetDirectory == null) { - // to use the old way : if javacTargetDirectory not specified, - // use same directory as targetDirectory (says where the java sources - // are generated) - return targetDirectory; - } - return javacTargetDirectory; - } - - /** - * Returns the target directory, generally specified with the "-d" option on the command line. - * - * @return the target directory - * @see #setTargetDirectory - */ - public File getTargetDirectory() { - return targetDirectory; - } - - - /** - * Sets the target directory into which compiled classes will be placed. - * - * @param targetDirectory the target directory - * @see #getTargetDirectory - */ - public void setTargetDirectory(File targetDirectory) { - this.targetDirectory = targetDirectory; - } - - public void setJavacTargetDirectory(File javacTargetDirectory) { - this.javacTargetDirectory = javacTargetDirectory; - } - - /** - * Returns the class path to be used during compilation. - * - * @return the class path to be used during compilation - * @see #setClassPath - */ - public String getClassPath() { - return classPath; - } - - /** - * Sets the class path to be used during compilation. - * - * @param classPath the compilation class path - * @see #getClassPath - */ - public void setClassPath(String classPath) { - this.classPath = classPath; - } - - - /** - * Returns the options to be passed into <code>javac</code>. - * - * @return options to be passed into <code>javac</code> - * @see #setJavacOpts - */ - public String getJavacOpts() { - return javacOpts; - } - - - /** - * Sets options to be passed into <code>javac</code>. - * - * @param javacOpts options to be passed into <code>javac</code> - * @see #getJavacOpts - */ - public void setJavacOpts(String javacOpts) { - this.javacOpts = javacOpts; - } - - - /** - * Returns whether or not generated Java files should be preserved after compilation. - * - * @return <code>true</code> if generated Java files should be preserved, <code>false</code> to delete - * @see #setKeepJavaFiles - */ - public boolean getKeepJavaFiles() { - return keepJavaFiles; - } - - - /** - * Sets whether or not generated Java files should be preserved after compilation. - * - * @param keepJavaFiles <code>true</code> if generated Java files should be preserved, <code>false</code> to delete - * @see #getKeepJavaFiles - */ - public void setKeepJavaFiles(boolean keepJavaFiles) { - this.keepJavaFiles = keepJavaFiles; - } - - - /** - * Returns whether or not optimization should be performed. - * - * @return whether or not optimizations should be performed - */ - public boolean getOptimize() { - return optimize; - } - - - /** - * Sets whether or not optimizations should be performed. - * - * @param optimize <code>true</code> to perform optimizations during compilation - * @see #getOptimize - */ - public void setOptimize(boolean optimize) { - this.optimize = optimize; - } - - public boolean isVerbose() { - return verbose; - } - - public void setVerbose(boolean verbose) { - this.verbose = verbose; - } - - public boolean isI18nable() { - return i18nable; - } - - public boolean isUseUIManagerForIcon() { - return useUIManagerForIcon; - } - - public void setI18nable(boolean i18nable) { - this.i18nable = i18nable; - } - - public boolean isAddLogger() { - return addLogger; - } - - public void setAddLogger(boolean addLogger) { - this.addLogger = addLogger; - } - - public String getJaxxContextImplementorClass() { - return jaxxContextImplementorClass; - } - - public void setJaxxContextImplementorClass(String jaxxContextImplementorClass) { - this.jaxxContextImplementorClass = jaxxContextImplementorClass; - } - - public String[] getExtraImports() { - return extraImports; - } - - public void setExtraImports(String[] extraImports) { - this.extraImports = extraImports; - } - - public boolean isResetAfterCompile() { - return resetAfterCompile; - } - - public void setResetAfterCompile(boolean resetAfterCompile) { - this.resetAfterCompile = resetAfterCompile; - } - - public void setUseUIManagerForIcon(boolean useUIManagerForIcon) { - this.useUIManagerForIcon = useUIManagerForIcon; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this); - } - - - public void setDefaultErrorUI(Class<?> defaultErrorUI) { - this.defaultErrorUI = defaultErrorUI; - } - - public boolean isKeepJavaFiles() { - return keepJavaFiles; - } - - public boolean isOptimize() { - return optimize; - } - - public Class<?> getDefaultErrorUI() { - return defaultErrorUI; - } - - public ClassLoader getClassLoader() { - return classLoader; - } - - public void setClassLoader(ClassLoader classLoader) { - this.classLoader = classLoader; - } - - public Class<? extends JAXXCompiler> getCompilerClass() { - return compilerClass; - } - - public void setCompilerClass(Class<? extends JAXXCompiler> compilerClass) { - this.compilerClass = compilerClass; - } - - @Deprecated - public String getValidatorFQN() { - return validatorClass.getName(); - } - - @Deprecated - public void setValidatorFQN(String validatorFQN) { - this.validatorFQN = validatorFQN; - } - - public Class<? extends CompiledObjectDecorator> getDefaultDecoratorClass() { - return defaultDecoratorClass; - } - - public void setDefaultDecoratorClass(Class<? extends CompiledObjectDecorator> defaultDecoratorClass) { - this.defaultDecoratorClass = defaultDecoratorClass; - } - - public boolean isProfile() { - return profile; - } - - public void setProfile(boolean profile) { - this.profile = profile; - } - - public boolean isGenerateHelp() { - return generateHelp; - } - - public void setGenerateHelp(boolean generateHelp) { - this.generateHelp = generateHelp; - } - - public String getHelpBrokerFQN() { - return helpBrokerFQN; - } - - public void setHelpBrokerFQN(String helpBrokerFQN) { - this.helpBrokerFQN = helpBrokerFQN; - } - - public String getHelpsetIndexI18nSuffix() { - return helpsetIndexI18nSuffix; - } - - public void setHelpsetIndexI18nSuffix(String helpsetIndexI18nSuffix) { - this.helpsetIndexI18nSuffix = helpsetIndexI18nSuffix; - } - - public String getHelpsetTitleI18nSuffix() { - return helpsetTitleI18nSuffix; - } - - public void setHelpsetTitleI18nSuffix(String helpsetTitleI18nSuffix) { - this.helpsetTitleI18nSuffix = helpsetTitleI18nSuffix; - } - - public String getHelpsetTocI18nSuffix() { - return helpsetTocI18nSuffix; - } - - public void setHelpsetTocI18nSuffix(String helpsetTocI18nSuffix) { - this.helpsetTocI18nSuffix = helpsetTocI18nSuffix; - } - - public String getHelpSetName() { - return helpSetName; - } - - public void setHelpSetName(String helpSetName) { - this.helpSetName = helpSetName; - } - - public String getHelpsetI18nPrefix() { - return helpsetI18nPrefix; - } - - public void setHelpsetI18nPrefix(String helpsetI18nPrefix) { - this.helpsetI18nPrefix = helpsetI18nPrefix; - } - - public Class<?> getValidatorClass() { - return validatorClass; - } - - public void setValidatorClass(Class<?> validatorClass) { - this.validatorClass = validatorClass; - } - - - -} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/DataBinding.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/DataBinding.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/DataBinding.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,92 +0,0 @@ -/* - * Copyright 2006 Ethan Nicholas. All rights reserved. - * Use is subject to license terms. - */ -package jaxx.compiler; - -import jaxx.CompilerException; -import jaxx.types.TypeManager; - -/** - * Represents a data binding in a JAXX file. <code>DataBinding</code> uses {@link DataSource} to - * track changes to a source expression and update the destination. - */ -public class DataBinding { - private String id; - - /** The DatSource which tracks source expression changes. */ - private DataSource dataSource; - - /** The data binding destination in the form <code><id>.<propertyName></code>. */ - private String dest; - - /** - * A Java snippet which will cause the destination property to be updated with the current value of - * the binding. - */ - private String assignment; - - /** The current <code>JAXXCompiler</code>. */ - private JAXXCompiler compiler; - - - /** - * Creates a new data binding. - * - * @param source the Java source code for the data binding expression - * @param dest the data binding destination in the form <code><id>.<propertyName></code> - * @param assignment Java snippet which will cause the destination property to be updated with the current value of the binding - * @param compiler the current <code>JAXXCompiler</code> - */ - public DataBinding(String source, String dest, String assignment, JAXXCompiler compiler) { - this.id = dest; - this.dataSource = new DataSource(id, source, compiler); - this.dest = dest; - this.assignment = assignment; - this.compiler = compiler; - } - - - public String getId() { - return id; - } - - - /** - * Compiles the data binding expression. This method calls methods in <code>JAXXCompiler</code> - * to add the Java code that performs the data binding setup. - * - * @param quickNoDependencies true to optimize bindings with no dependencies by simply running them at startup time - * @return <code>true</code> if the expression has dependencies, <code>false</code> otherwise - * @throws CompilerException if a compilation error occurs - */ - public boolean compile(boolean quickNoDependencies) throws CompilerException { - // DataSource.compile handles all of the listener additions - boolean result = dataSource.compile("new jaxx.runtime.DataBindingListener(" + compiler.getRootObject().getJavaCode() + ", " + TypeManager.getJavaCode(id) + ")"); - - if (!result && quickNoDependencies) { - if (!dest.endsWith(".layout")) // layout is specially handled early in the chain - { - compiler.appendInitDataBindings(assignment + JAXXCompiler.getLineSeparator()); - } - return false; // no dependencies, just a static expression - } - if (compiler.haveProcessDataBinding()) { - compiler.appendProcessDataBinding(" else "); - } else { - compiler.appendProcessDataBinding(" "); - } - compiler.appendProcessDataBinding("if (" + TypeManager.getJavaCode(id) + ".equals($dest)) {" + JAXXCompiler.getLineSeparator()); - String objectCode = dataSource.getObjectCode(); - if (objectCode != null) { - compiler.appendProcessDataBinding(" if (" + objectCode + " != null) {" + JAXXCompiler.getLineSeparator()); - compiler.appendProcessDataBinding(" "); - } - compiler.appendProcessDataBinding(" " + assignment.trim()); - if (objectCode != null) { - compiler.appendProcessDataBinding(JAXXCompiler.getLineSeparator() + " }"); - } - compiler.appendProcessDataBinding(JAXXCompiler.getLineSeparator() + " }"); - return true; - } -} \ No newline at end of file Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/DataSource.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/DataSource.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/DataSource.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,454 +0,0 @@ -/* - * Copyright 2006 Ethan Nicholas. All rights reserved. - * Use is subject to license terms. - */ -package jaxx.compiler; - -import jaxx.CompilerException; -import jaxx.UnsupportedAttributeException; -import jaxx.parser.JavaParser; -import jaxx.parser.JavaParserConstants; -import jaxx.parser.JavaParserTreeConstants; -import jaxx.parser.SimpleNode; -import jaxx.reflect.ClassDescriptor; -import jaxx.reflect.ClassDescriptorLoader; -import jaxx.reflect.FieldDescriptor; -import jaxx.reflect.MethodDescriptor; -import jaxx.tags.DefaultObjectHandler; -import jaxx.tags.TagManager; -import jaxx.types.TypeManager; - -import java.beans.Introspector; -import java.beans.PropertyChangeListener; -import java.io.StringReader; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -/** - * Represents a Java expression which fires a <code>PropertyChangeEvent</code> when it can be - * determined that its value may have changed. Events are fired on a "best effort" basis, and events - * may either be fired too often (the value has not actually changed) or not often enough (the value - * changed but no event was fired). - */ -public class DataSource { - private class NULL { - } // type attached to "null" constants in parsed expressions - - private String id; - - /** The Java source code for the expression. */ - private String source; - - /** The current <code>JAXXCompiler</code>. */ - private JAXXCompiler compiler; - - /** List of symbols which this data source expression depends on. */ - private List<String> dependencySymbols = new ArrayList<String>(); - - private StringBuffer addListenerCode = new StringBuffer(); - private StringBuffer removeListenerCode = new StringBuffer(); - private boolean compiled; - - /** the delegate of property to be required */ - private String objectCode; - - /** - * Creates a new data source. After creating a <code>DataSource</code>, use {@link #compile} - * to cause it to function at runtime. - * - * @param id the DataSource's id - * @param source the Java source code for the data source expression - * @param compiler the current <code>JAXXCompiler</code> - */ - public DataSource(String id, String source, JAXXCompiler compiler) { - this.id = id; - this.source = source; - this.compiler = compiler; - } - - - public String getId() { - return id; - } - - public String getSource() { - return source; - } - - public String getObjectCode() { - return objectCode; - } - - /** - * Compiles the data source expression and listener. This method calls methods in <code>JAXXCompiler</code> - * to add the Java code that performs the data source setup. Adding listeners to <code>DataSource</code> is - * slightly more complicated than with ordinary classes, because <code>DataSource</code> only exists at compile - * time. You must pass in a Java expression which evaluates to a <code>PropertyChangeListener</code>; this - * expression will be compiled and evaluated at runtime to yield the <code>DataSource's</code> listener. - * - * @param propertyChangeListenerCode Java code snippet which evaluates to a <code>PropertyChangeListener</code> - * @return <code>true</code> if the expression has dependencies, <code>false</code> otherwise - * @throws CompilerException if a compilation error occurs - */ - public boolean compile(String propertyChangeListenerCode) throws CompilerException { - if (compiled) { - throw new IllegalStateException(this + " has already been compiled"); - } - String id = compiler.getAutoId(ClassDescriptorLoader.getClassDescriptor(getClass())); - JavaParser p = new JavaParser(new StringReader(source + ";")); - while (!p.Line()) { - SimpleNode node = p.popNode(); - scanNode(node, id); - } - - if (dependencySymbols.size() > 0) { - //TC 20081108 prefer add a real JavaField instead of raw code - //compiler.appendBodyCode("private PropertyChangeListener " + id + " = " + propertyChangeListenerCode + ";\n"); - compiler.addSimpleField(new JavaField(Modifier.PRIVATE, PropertyChangeListener.class.getName(), id, propertyChangeListenerCode)); - } - - compileListeners(); - compiled = true; - - return dependencySymbols.size() > 0; - } - - /** @return a list of symbols on which this data source depends. */ - public Collection<String> getDependencies() { - return Collections.unmodifiableList(dependencySymbols); - } - - /** - * Examines a node to identify any dependencies it contains. - * - * @param node node to scan - * @param listenerId id of listener - * @throws jaxx.CompilerException ? - */ - private void scanNode(SimpleNode node, String listenerId) throws CompilerException { - switch (node.getId()) { - case JavaParserTreeConstants.JJTMETHODDECLARATION: - break; - case JavaParserTreeConstants.JJTFIELDDECLARATION: - break; - - default: - int count = node.jjtGetNumChildren(); - for (int i = 0; i < count; i++) { - scanNode(node.getChild(i), listenerId); - } - determineNodeType(node, listenerId); - } - } - - private ClassDescriptor determineLiteralType(SimpleNode node) { - assert node.getId() == JavaParserTreeConstants.JJTLITERAL; - if (node.jjtGetNumChildren() == 1) { - int id = node.getChild(0).getId(); - if (id == JavaParserTreeConstants.JJTBOOLEANLITERAL) { - return ClassDescriptorLoader.getClassDescriptor(boolean.class); - } - if (id == JavaParserTreeConstants.JJTNULLLITERAL) { - return ClassDescriptorLoader.getClassDescriptor(NULL.class); - } - throw new RuntimeException("Expected BooleanLiteral or NullLiteral, found " + JavaParserTreeConstants.jjtNodeName[id]); - } - int id = node.firstToken.kind; - switch (id) { - case JavaParserConstants.INTEGER_LITERAL: - if (node.firstToken.image.toLowerCase().endsWith("l")) { - return ClassDescriptorLoader.getClassDescriptor(long.class); - } - return ClassDescriptorLoader.getClassDescriptor(int.class); - case JavaParserConstants.CHARACTER_LITERAL: - return ClassDescriptorLoader.getClassDescriptor(char.class); - case JavaParserConstants.FLOATING_POINT_LITERAL: - if (node.firstToken.image.toLowerCase().endsWith("f")) { - return ClassDescriptorLoader.getClassDescriptor(float.class); - } - return ClassDescriptorLoader.getClassDescriptor(double.class); - case JavaParserConstants.STRING_LITERAL: - return ClassDescriptorLoader.getClassDescriptor(String.class); - default: - throw new RuntimeException("Expected literal token, found " + JavaParserConstants.tokenImage[id]); - } - } - - /** - * Scans through a compound symbol (foo.bar.baz) to identify and track all trackable pieces of it. - * - * @param symbol symbol to scan - * @param contextClass current class context - * @param isMethod flag to search a method - * @param listenerId id of the listener - * @return the type of the symbol (or null if it could not be determined). - */ - private ClassDescriptor scanCompoundSymbol(String symbol, ClassDescriptor contextClass, boolean isMethod, String listenerId) { - String[] tokens = symbol.split("\\s*\\.\\s*"); - StringBuffer currentSymbol = new StringBuffer(); - StringBuffer tokensSeenSoFar = new StringBuffer(); - boolean accepted; // if this ends up false, it means we weren't able to figure out - // which object the method is being invoked on - boolean recognizeClassNames = true; - for (int j = 0; j < tokens.length - (isMethod ? 1 : 0); j++) { - accepted = false; - - if (tokensSeenSoFar.length() > 0) { - tokensSeenSoFar.append('.'); - } - tokensSeenSoFar.append(tokens[j]); - if (currentSymbol.length() > 0) { - currentSymbol.append('.'); - } - currentSymbol.append(tokens[j]); - - if (currentSymbol.indexOf(".") == -1) { - String memberName = currentSymbol.toString(); - CompiledObject object = compiler.getCompiledObject(memberName); - if (object != null) { - contextClass = object.getObjectClass(); - currentSymbol.setLength(0); - accepted = true; - recognizeClassNames = false; - } else { - try { - FieldDescriptor field = contextClass.getFieldDescriptor(memberName); - trackMemberIfPossible(tokensSeenSoFar.toString(), contextClass, field.getName(), false, listenerId); - contextClass = field.getType(); - currentSymbol.setLength(0); - accepted = true; - recognizeClassNames = false; - } - catch (NoSuchFieldException e) { - if (j == 0 || j == 1 && tokens[0].equals(compiler.getRootObject().getId())) { // still in root context - FieldDescriptor[] newFields = compiler.getScriptFields(); - for (FieldDescriptor newField : newFields) { - if (newField.getName().equals(memberName)) { - addListener(tokensSeenSoFar.toString(), - null, - "addPropertyChangeListener(\"" + memberName + "\", " + listenerId + ");" + JAXXCompiler.getLineSeparator(), - "removePropertyChangeListener(\"" + memberName + "\", " + listenerId + ");" + JAXXCompiler.getLineSeparator()); - contextClass = newField.getType(); - assert contextClass != null : "script field '" + memberName + "' is defined, but has type null"; - currentSymbol.setLength(0); - accepted = true; - recognizeClassNames = false; - break; - } - } - } - } - } - } - if (currentSymbol.length() > 0 && recognizeClassNames) { - contextClass = TagManager.resolveClass(currentSymbol.toString(), compiler); - if (contextClass != null) { - currentSymbol.setLength(0); - //accepted = true; - //recognizeClassNames = false; - // TODO: for now we don't handle statics - return null; - } - } - if (!accepted) { - return null; - } - } - - return contextClass; - } - - /** - * Adds type information to nodes where possible, and as a side effect adds event listeners to nodes which - * can be tracked. - * - * @param expression the node to scan - * @param listenerId id of the listener - * @return the class descriptor of the return type or null - */ - private ClassDescriptor determineExpressionType(SimpleNode expression, String listenerId) { - assert expression.getId() == JavaParserTreeConstants.JJTPRIMARYEXPRESSION; - SimpleNode prefix = expression.getChild(0); - if (prefix.jjtGetNumChildren() == 1) { - int type = prefix.getChild(0).getId(); - if (type == JavaParserTreeConstants.JJTLITERAL || type == JavaParserTreeConstants.JJTEXPRESSION) { - prefix.setJavaType(prefix.getChild(0).getJavaType()); - } else if (type == JavaParserTreeConstants.JJTNAME && expression.jjtGetNumChildren() == 1) // name with no arguments after it - { - prefix.setJavaType(scanCompoundSymbol(prefix.getText().trim(), compiler.getRootObject().getObjectClass(), false, listenerId)); - } - } - - if (expression.jjtGetNumChildren() == 1) { - return prefix.getJavaType(); - } - - ClassDescriptor contextClass = prefix.getJavaType(); - if (contextClass == null) { - contextClass = compiler.getRootObject().getObjectClass(); - } - String lastNode = prefix.getText().trim(); - - for (int i = 1; i < expression.jjtGetNumChildren(); i++) { - SimpleNode suffix = expression.getChild(i); - if (suffix.jjtGetNumChildren() == 1 && suffix.getChild(0).getId() == JavaParserTreeConstants.JJTARGUMENTS) { - if (suffix.getChild(0).jjtGetNumChildren() == 0) { // at the moment only no-argument methods are trackable - contextClass = scanCompoundSymbol(lastNode, contextClass, true, listenerId); - if (contextClass == null) { - return null; - } - int dotPos = lastNode.lastIndexOf("."); - String objectCode = dotPos == -1 ? "" : lastNode.substring(0, dotPos); - for (int j = i - 2; j >= 0; j--) { - objectCode = expression.getChild(j).getText() + objectCode; - } - if (objectCode.length() == 0) { - objectCode = compiler.getRootObject().getJavaCode(); - } - String methodName = lastNode.substring(dotPos + 1).trim(); - try { - MethodDescriptor method = contextClass.getMethodDescriptor(methodName); - trackMemberIfPossible(objectCode, contextClass, method.getName(), true, listenerId); - return method.getReturnType(); - } - catch (NoSuchMethodException e) { - // happens for methods defined in the current JAXX file via scripts - String propertyName = null; - if (methodName.startsWith("is")) { - propertyName = Introspector.decapitalize(methodName.substring("is".length())); - } else if (methodName.startsWith("get")) { - propertyName = Introspector.decapitalize(methodName.substring("get".length())); - } - if (propertyName != null) { - MethodDescriptor[] newMethods = compiler.getScriptMethods(); - for (MethodDescriptor newMethod : newMethods) { - if (newMethod.getName().equals(methodName)) { - addListener(compiler.getRootObject().getId(), - null, - "addPropertyChangeListener(\"" + propertyName + "\", " + listenerId + ");" + JAXXCompiler.getLineSeparator(), - "removePropertyChangeListener(\"" + propertyName + "\", " + listenerId + ");" + JAXXCompiler.getLineSeparator()); - contextClass = newMethod.getReturnType(); - break; - } - } - } - } - } - } - lastNode = suffix.getText().trim(); - if (lastNode.startsWith(".")) { - lastNode = lastNode.substring(1); - } - } - - return null; - } - - private void trackMemberIfPossible(String objectCode, ClassDescriptor objectClass, String memberName, boolean method, String listenerId) { - if (objectClass.isInterface()) // might be technically possible to track in some cases, but for now - { - return; // we can't create a DefaultObjectHandler for interfaces - } - - DefaultObjectHandler handler = TagManager.getTagHandler(objectClass); - try { - if (handler.isMemberBound(memberName)) { - addListener(objectCode + "." + memberName + (method ? "()" : ""), - objectCode, - handler.getAddMemberListenerCode(objectCode, id, memberName, listenerId, compiler), - handler.getRemoveMemberListenerCode(objectCode, id, memberName, listenerId, compiler)); - } - } - catch (UnsupportedAttributeException e) { - // ignore -- this is thrown for methods like toString(), for which there is no tracking and - // no setting support - } - } - - /** - * Adds type information to nodes where possible, and as a side effect adds event listeners to nodes which - * can be tracked. - * - * @param node node to scan - * @param listenerId the listener id - */ - private void determineNodeType(SimpleNode node, String listenerId) { - ClassDescriptor type = null; - if (node.jjtGetNumChildren() == 1) { - type = node.getChild(0).getJavaType(); - } - switch (node.getId()) { - case JavaParserTreeConstants.JJTCLASSORINTERFACETYPE: - type = ClassDescriptorLoader.getClassDescriptor(Class.class); - break; - case JavaParserTreeConstants.JJTPRIMARYEXPRESSION: - type = determineExpressionType(node, listenerId); - break; - case JavaParserTreeConstants.JJTLITERAL: - type = determineLiteralType(node); - break; - case JavaParserTreeConstants.JJTCASTEXPRESSION: - type = TagManager.resolveClass(node.getChild(0).getText(), compiler); - break; - } - node.setJavaType(type); - } - - private void addListener(String dependencySymbol, String objectCode, String addCode, String removeCode) { - this.objectCode = objectCode; - if (!dependencySymbols.contains(dependencySymbol)) { - dependencySymbols.add(dependencySymbol); - if (objectCode != null) { - addListenerCode.append("if (").append(objectCode).append(" != null) {").append(JAXXCompiler.getLineSeparator()); - addListenerCode.append(" "); - } - addListenerCode.append(" ").append(addCode); - if (objectCode != null) { - addListenerCode.append(" ").append("}"); - } - - if (objectCode != null) { - removeListenerCode.append("if (").append(objectCode).append(" != null) {").append(JAXXCompiler.getLineSeparator()); - removeListenerCode.append(" "); - } - removeListenerCode.append(" ").append(removeCode); - if (objectCode != null) { - removeListenerCode.append(" }"); - } - } - } - - private void compileListeners() { - String javaCodeId = TypeManager.getJavaCode(id); - if (addListenerCode.length() > 0) { - if (compiler.haveApplyDataBinding()) { - compiler.appendApplyDataBinding(" else "); - } - compiler.appendApplyDataBinding("if (" + javaCodeId + ".equals($binding)) {" + JAXXCompiler.getLineSeparator()); - compiler.appendApplyDataBinding(" " + addListenerCode + JAXXCompiler.getLineSeparator()); - compiler.appendApplyDataBinding("}"); - //if (compiler.applyDataBinding.length() > 0) - // compiler.applyDataBinding.append("else "); - //compiler.applyDataBinding.append("if ($binding.equals(").append(TypeManager.getJavaCode(id)).append(")) {").append(JAXXCompiler.getLineSeparator()); - //compiler.applyDataBinding.append(" ").append(addListenerCode).append(JAXXCompiler.getLineSeparator()); - //compiler.applyDataBinding.append("}").append(JAXXCompiler.getLineSeparator()); - } - - if (removeListenerCode.length() > 0) { - if (compiler.haveRemoveDataBinding()) { - compiler.appendRemoveDataBinding(" else "); - } - compiler.appendRemoveDataBinding("if (" + javaCodeId + ".equals($binding)) {" + JAXXCompiler.getLineSeparator()); - compiler.appendRemoveDataBinding(" " + removeListenerCode + JAXXCompiler.getLineSeparator()); - compiler.appendRemoveDataBinding("}"); - //if (compiler.removeDataBinding.length() > 0) - // compiler.removeDataBinding.append("else "); - //compiler.removeDataBinding.append("if ($binding.equals(").append(TypeManager.getJavaCode(id)).append(")) {").append(JAXXCompiler.getLineSeparator()); - //compiler.removeDataBinding.append(" ").append(removeListenerCode).append(JAXXCompiler.getLineSeparator()); - //compiler.removeDataBinding.append("}").append(JAXXCompiler.getLineSeparator()); - } - } -} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompiledObjectDecorator.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompiledObjectDecorator.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompiledObjectDecorator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,128 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package jaxx.compiler; - -import java.lang.reflect.Modifier; -import java.util.Map.Entry; -import jaxx.CompilerException; -import jaxx.types.TypeManager; - -/** - * The default compiledObjectDecorator. - * - * @author tony - * @since 1.2 - */ -public class DefaultCompiledObjectDecorator extends CompiledObjectDecorator { - - @Override - public void finalizeCompiler(JAXXCompiler compiler, CompiledObject root, CompiledObject object, JavaFile javaFile, String packageName, String className, String fullClassName) { - - if (!object.isOverride() && !(object instanceof ScriptInitializer)) { - String id = object.getId(); - int access = id.startsWith("$") ? Modifier.PRIVATE : Modifier.PROTECTED; - if (object == root) { - javaFile.addField(new JavaField(access, fullClassName, id, "this")); - } else { - //TC -20081017 can have generic on compiled Object - javaFile.addField(JavaField.newField(access, JAXXCompiler.getCanonicalName(object), id), object.isJavaBean()); - } - } - - if (!compiler.inlineCreation(object) && object != root) { - javaFile.addMethod(JavaMethod.newMethod(Modifier.PROTECTED, "void", object.getCreationMethodName(), getCreationCode(compiler, object))); - } - } - - @Override - public String getCreationCode(JAXXCompiler compiler, CompiledObject object) throws CompilerException { - if (object instanceof ScriptInitializer) { - return object.getInitializationCode(compiler); - } - StringBuffer result = new StringBuffer(); - if (object.isOverride() && object.getOverrideType()==object.getObjectClass()) { - //TC-20090309 on utilise le super code quand l'objet est de meme type - result.append("super.").append(object.getCreationMethodName()).append("();"); - } else { - result.append(object.getId()); - result.append(" = "); - if (object.isJavaBean() && object.getJavaBeanInitCode() != null) { - result.append(object.getJavaBeanInitCode()).append(";"); - } else { - String constructorParams = object.getConstructorParams(); - if (constructorParams != null) { - //TC - 20081017 compiledObject can have generics - result.append(" new ").append(JAXXCompiler.getCanonicalName(object)).append("(").append(constructorParams).append(");"); - //result.append("(").append(getCanonicalName(object.getObjectClass())).append(") new ").append(getCanonicalName(object.getObjectClass())).append("(").append(constructorParams).append(");"); - } else { - //TC - 20081017 compiledObject can have generics - result.append("new ").append(JAXXCompiler.getCanonicalName(object)).append("();"); - } - } - result.append(JAXXCompiler.getLineSeparator()); - result.append("$objectMap.put(").append(TypeManager.getJavaCode(object.getId())).append(", ").append(object.getId()).append(");"); - } - result.append(JAXXCompiler.getLineSeparator()); - String initCode = object.getInitializationCode(compiler); - if (initCode != null && initCode.length() > 0) { - result.append(initCode); - } - - return result.toString(); - } - - @Override - public String createCompleteSetupMethod(JAXXCompiler compiler, CompiledObject object, JavaFile javaFile, StringBuffer initDataBindings) { - StringBuffer code = new StringBuffer(); - //TC-20090327 generate client properties - if (object.hasClientProperties()) { - // generate putClientProperty invocations - for (Entry<String,String> entry : object.getClientProperties().entrySet()) { - object.appendAdditionCode(object.getJavaCode() + ".putClientProperty(\"" + entry.getKey() + "\", " + entry.getValue() + ");"); - } - - } - //TC - 20081017 only generate the method if not empty ? - if (object.getId().startsWith("$")) { - code.append(object.getAdditionCode()).append(JAXXCompiler.getLineSeparator()); - } else { - String additionCode = object.getAdditionCode(); - if (additionCode.length() > 0) { - code.append(object.getAdditionMethodName()).append("();").append(JAXXCompiler.getLineSeparator()); - additionCode = "if (!allComponentsCreated) {" + JAXXCompiler.getLineSeparator() + " return;" + JAXXCompiler.getLineSeparator() + "}" + JAXXCompiler.getLineSeparator() + additionCode; - javaFile.addMethod(JavaMethod.newMethod(Modifier.PROTECTED, "void", object.getAdditionMethodName(), additionCode)); - } - } - //code.append(getLineSeparator()); - return code.toString(); - } - - @Override - public boolean createInitializer(JAXXCompiler compiler, CompiledObject root, CompiledObject object, StringBuffer code, boolean lastWasMethodCall) { - if (object == root) { - String rootCode = root.getInitializationCode(compiler); - if (rootCode != null && rootCode.length() > 0) { - code.append(rootCode); - code.append(JAXXCompiler.getLineSeparator()); - } - } else { - if (!object.isOverride()) { - if (compiler.inlineCreation(object)) { - if (lastWasMethodCall) { - lastWasMethodCall = false; - code.append(JAXXCompiler.getLineSeparator()); - } - code.append(getCreationCode(compiler, object)); - code.append(JAXXCompiler.getLineSeparator()); - } else { - code.append(object.getCreationMethodName()).append("();"); - code.append(JAXXCompiler.getLineSeparator()); - lastWasMethodCall = true; - } - } - } - return lastWasMethodCall; - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,216 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler; + +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + +import java.io.File; +import jaxx.runtime.JAXXContext; + +/** + * Options of the {@link JAXXCompiler} and {@link JAXXCompilerLaunchor}. + * + */ +public class DefaultCompilerConfiguration implements CompilerConfiguration { + + /** + * where to generate + */ + private File targetDirectory; + /** + * flag to optimize generated code + */ + private boolean optimize; + /** + * verbose flag + */ + private boolean verbose; + /** + * to do a profile pass after generation + */ + private boolean profile; + /** + * a flag to enable or disable i18n generation + */ + private boolean i18nable; + /** + * a flag to add or not logger on generated jaxx files + */ + private boolean addLogger; + /** + * a flag to not reset compiler after a compile + */ + private boolean resetAfterCompile; + /** + * the name of implementation of {@link jaxx.runtime.JAXXContext} + * to be used on {@link jaxx.runtime.JAXXObject}. + */ + protected Class<? extends JAXXContext> jaxxContextClass; + /** + * list of fqn of class to import for all generated jaxx files + */ + protected String[] extraImports; + /** + * default error ui + */ + private Class<?> defaultErrorUI; + /** + * class loader to use in compiler + */ + private ClassLoader classLoader; + /** + * the compiler class to use + */ + private Class<? extends JAXXCompiler> compilerClass; + /** + * the validator class to use. + * + * @since 1.6.0 + */ + private Class<?> validatorClass; + /** + * the default compiled object decorator to use if none specifed via + * decorator attribute + */ + private Class<? extends CompiledObjectDecorator> defaultDecoratorClass; + /** + * a flag to use {@link javax.swing.UIManager} to retreave icons. + */ + private boolean useUIManagerForIcon; + /** + * a flag to generate javax help for any + */ + private boolean generateHelp; + /** + * Fully qualified name of help broker, can not use a class here + * since this class should be in sources (so not yet compiled) + */ + private String helpBrokerFQN; + /** + * Encoding to use to write files + */ + private String encoding; + + @Override + public File getTargetDirectory() { + return targetDirectory; + } + + @Override + public boolean getOptimize() { + return optimize; + } + + @Override + public boolean isVerbose() { + return verbose; + } + + public void setVerbose(boolean verbose) { + this.verbose = verbose; + } + + @Override + public boolean isI18nable() { + return i18nable; + } + + @Override + public boolean isUseUIManagerForIcon() { + return useUIManagerForIcon; + } + + @Override + public boolean isAddLogger() { + return addLogger; + } + + @Override + public Class<? extends JAXXContext> getJaxxContextClass() { + return jaxxContextClass; + } + + @Override + public String[] getExtraImports() { + return extraImports; + } + + @Override + public boolean isResetAfterCompile() { + return resetAfterCompile; + } + + @Override + public boolean isOptimize() { + return optimize; + } + + @Override + public Class<?> getDefaultErrorUI() { + return defaultErrorUI; + } + + @Override + public ClassLoader getClassLoader() { + return classLoader; + } + + @Override + public Class<? extends JAXXCompiler> getCompilerClass() { + return compilerClass; + } + + @Override + public Class<? extends CompiledObjectDecorator> getDefaultDecoratorClass() { + return defaultDecoratorClass; + } + + @Override + public boolean isProfile() { + return profile; + } + + @Override + public boolean isGenerateHelp() { + return generateHelp; + } + + @Override + public String getHelpBrokerFQN() { + return helpBrokerFQN; + } + + @Override + public Class<?> getValidatorClass() { + return validatorClass; + } + + @Override + public String getEncoding() { + return encoding; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); + } +} Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/EventHandler.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/EventHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/EventHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,61 +1,72 @@ -/* - * Copyright 2006 Ethan Nicholas. All rights reserved. - * Use is subject to license terms. - */ -package jaxx.compiler; - -import jaxx.reflect.ClassDescriptor; -import jaxx.reflect.MethodDescriptor; - -public class EventHandler { - private String eventId; - private String objectCode; - private ClassDescriptor listenerClass; - private MethodDescriptor addMethod; - private MethodDescriptor listenerMethod; - private String javaCode; - - public EventHandler(String eventId, String objectCode, MethodDescriptor addMethod, ClassDescriptor listenerClass, MethodDescriptor listenerMethod, String javaCode) { - this.eventId = eventId; - this.objectCode = objectCode; - this.addMethod = addMethod; - this.listenerClass = listenerClass; - this.listenerMethod = listenerMethod; - this.javaCode = javaCode; - } - - - public String getEventId() { - return eventId; - } - - - public String getObjectCode() { - return objectCode; - } - - - public MethodDescriptor getAddMethod() { - return addMethod; - } - - - public ClassDescriptor getListenerClass() { - return listenerClass; - } - - - public MethodDescriptor getListenerMethod() { - return listenerMethod; - } - - - public String getJavaCode() { - return javaCode; - } - - - public String toString() { - return "EventHandler[" + eventId + ", " + listenerClass.getName() + ", " + objectCode + ", " + javaCode + "]"; - } -} \ No newline at end of file +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler; + +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.MethodDescriptor; + +public class EventHandler { + + private String eventId; + private String objectCode; + private ClassDescriptor listenerClass; + private MethodDescriptor addMethod; + private MethodDescriptor listenerMethod; + private String javaCode; + + public EventHandler(String eventId, String objectCode, MethodDescriptor addMethod, ClassDescriptor listenerClass, MethodDescriptor listenerMethod, String javaCode) { + this.eventId = eventId; + this.objectCode = objectCode; + this.addMethod = addMethod; + this.listenerClass = listenerClass; + this.listenerMethod = listenerMethod; + this.javaCode = javaCode; + } + + public String getEventId() { + return eventId; + } + + public String getObjectCode() { + return objectCode; + } + + public MethodDescriptor getAddMethod() { + return addMethod; + } + + public ClassDescriptor getListenerClass() { + return listenerClass; + } + + public MethodDescriptor getListenerMethod() { + return listenerMethod; + } + + public String getJavaCode() { + return javaCode; + } + + @Override + public String toString() { + return "EventHandler[" + eventId + ", " + listenerClass.getName() + ", " + objectCode + ", " + javaCode + "]"; + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/Generator.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/Generator.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/Generator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,14 +0,0 @@ -package jaxx.compiler; - -/** - * TODO javadoc! - * - * @author chemit - */ -public interface Generator { - - void finalizeCompiler(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className); - - void prepareJavaFile(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) throws ClassNotFoundException; - -} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/HelpRootCompiledObjectDecorator.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/HelpRootCompiledObjectDecorator.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/HelpRootCompiledObjectDecorator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,93 +0,0 @@ -package jaxx.compiler; - -import java.lang.reflect.Modifier; -import java.util.Iterator; -import java.util.Set; - -/** - * A decorator to place on a root compiled object to process javaHelp on the file. - * - * @author tony - * @since 1.2 - */ -public class HelpRootCompiledObjectDecorator extends DefaultCompiledObjectDecorator { - - /** - * the list of discovered helpId - */ - protected static Set<String> helpIds = new java.util.HashSet<String>(); - - protected String getBrokerFQN(JAXXCompiler compiler) { - String helpBrokerFQN = compiler.getOptions().getHelpBrokerFQN(); - return helpBrokerFQN; - } - - protected String getHelpId(CompiledObject o) { - String helpID = null; - if (o.hasClientProperties()) { - helpID = o.getClientProperty("help"); - } - return helpID; - } - - @Override - public void finalizeCompiler(JAXXCompiler compiler, CompiledObject root, CompiledObject object, JavaFile javaFile, String packageName, String className, String fullClassName) { - super.finalizeCompiler(compiler, root, object, javaFile, packageName, className, fullClassName); - CompilerOptions options = compiler.getOptions(); - - if (options.isGenerateHelp()) { - - // add JaxxHelpUI interface - Class<?> validatorInterface = jaxx.runtime.JaxxHelpUI.class; - String helpBrokerFQN = getBrokerFQN(compiler); - javaFile.addInterface(JAXXCompiler.getCanonicalName(validatorInterface) + "<" + helpBrokerFQN + ">"); - - javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC, "void", "registerHelpId", - "broker.installUI(component, helpId);", - new JavaArgument(helpBrokerFQN, "broker"), - new JavaArgument("Component", "component"), - new JavaArgument("String", "helpId"))); - - javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC, "void", "showHelp", - "getBroker().showHelp(this, helpId);", - new JavaArgument("String", "helpId"))); - - StringBuilder buffer = new StringBuilder(); - - String lineSeparator = JAXXCompiler.getLineSeparator(); - - if (options.isGenerateHelp()) { - - // add code to init javax help system - Iterator<CompiledObject> itr = compiler.getObjectCreationOrder(); - - for (; itr.hasNext();) { - CompiledObject o = itr.next(); - String helpID = getHelpId(o); - if (helpID != null) { - buffer.append(lineSeparator); - // detects a helpId to register - buffer.append("registerHelpId(_broker, " + o.getJavaCode() + ", " + helpID + ");"); - //keep the helpID for helpSet generation - helpIds.add(helpID); - } - } - } - if (buffer.length() > 0) { - - StringBuilder extraCode = new StringBuilder(helpBrokerFQN).append(" _broker = getBroker();"); - - buffer.append(lineSeparator).append("_broker.prepareUI(this);"); - buffer.append(lineSeparator); - - // add the calls - compiler.appendLateInitializer(extraCode.toString()); - compiler.appendLateInitializer(buffer.toString()); - } - } - } - - public static Set<String> getHelpIds() { - return helpIds; - } -} Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/I18nHelper.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/I18nHelper.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/I18nHelper.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,6 +1,25 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ package jaxx.compiler; -import jaxx.tags.DefaultComponentHandler; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -8,16 +27,15 @@ import java.util.List; /** - * I18n methods to add {@link org.nuiton.i18n.I18n#_(String, Object[])} method on some attributes. + * I18n methods to add {@link org.nuiton.i18n.I18n#_(java.lang.String, java.lang.Object[])} method on some attributes. * <p/> - * Make sure to set an i18nable compiler to have his {@link CompilerOptions#isI18nable()} returning true. + * Make sure to set an i18nable compiler to have his {@link CompilerConfiguration#isI18nable()} returning true. * * @author chemit */ public class I18nHelper { - protected static final Log log = LogFactory.getLog(DefaultComponentHandler.class); - + protected static final Log log = LogFactory.getLog(I18nHelper.class); public static final List<String> I18N_ATTRIBUTES = Arrays.asList("text", "title", "toolTipText"); /** @@ -28,7 +46,7 @@ * @return <code>true</code> if wa have an active i18n attribute, <code>false</code> otherwise. */ public static boolean isI18nableAttribute(String attributeName, JAXXCompiler compiler) { - return compiler.getOptions().isI18nable() && isI18nAttribute(attributeName); + return compiler.getConfiguration().isI18nable() && isI18nAttribute(attributeName); } /** @@ -40,6 +58,7 @@ public static boolean isI18nAttribute(String attributeName) { return I18N_ATTRIBUTES.contains(attributeName); } + /** * Add the i18n on a attribute. * <p/> @@ -60,7 +79,7 @@ log.debug(" try i18n support for [" + widgetId + ":" + attributeName + "] : " + attributeValueCode); } if (attributeValueCode.contains("_(") && attributeValueCode.contains(")")) { - compiler.reportWarning("\n\tjaxx supports i18n, no need to add explicit call to I18n._ for attribute '" + attributeName + "' in component '" + widgetId + "' : ["+attributeValueCode+"]"); + compiler.reportWarning("\n\tjaxx supports i18n, no need to add explicit call to I18n._ for attribute '" + attributeName + "' in component '" + widgetId + "' : [" + attributeValueCode + "]"); } else { attributeValueCode = "_(" + attributeValueCode + ")"; } Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/IDHelper.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/IDHelper.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/IDHelper.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/IDHelper.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,96 @@ +package jaxx.compiler; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.util.HashMap; +import java.util.Map; +import java.util.TreeMap; + +/** + * A usefull class to generate Ids. + * <p/> + * Created: 27 nov. 2009 + * + * @author Tony Chemit <chemit@codelutin.com> Copyright Code Lutin + * @version $Revision$ + * <p/> + * Mise a jour: $Date$ par : + * $Author: tchemit $ + */ +public class IDHelper { + /** + * Logger + */ + protected static final Log log = LogFactory.getLog(IDHelper.class); + /** + * Counter by type + */ + protected final Map<String, Integer> autoGenIds = new TreeMap<String, Integer>(); + /** + * Maps of uniqued id for objects used in compiler + */ + protected final Map<Object, String> uniqueIds = new HashMap<Object, String>(); + /** + * Optimized Counter + */ + protected int optimizedAutogenId = 0; + + /** + * Flag to use optimized id + */ + protected final boolean optimize; + + public IDHelper(boolean optimize) { + this.optimize = optimize; + } + + public String nextId(String name) { + + if (optimize) { + return "$" + Integer.toString(optimizedAutogenId++, 36); + } + + Integer integer = autoGenIds.get(name); + + if (integer == null) { + integer = 0; + } + name = name.substring(name.lastIndexOf(".") + 1); + String result = "$" + name + integer; + autoGenIds.put(name, ++integer); + if (log.isTraceEnabled()) { + log.trace("new id = " + result); + } + return result; + } + + public void revertId(String name) { + if (optimize) { + optimizedAutogenId--; + } else { + name = name.substring(name.lastIndexOf(".") + 1); + Integer integer = autoGenIds.get(name); + if (integer != null) { + autoGenIds.put(name, --integer); + } + } + } + + public String getUniqueId(Object object) { + String result = uniqueIds.get(object); + if (result == null) { + result = "$u" + uniqueIds.size(); + uniqueIds.put(object, result); + } + if (log.isTraceEnabled()) { + log.trace("new uniqueid = " + result); + } + return result; + } + + public void clear() { + autoGenIds.clear(); + uniqueIds.clear(); + } +} Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,286 +1,301 @@ /* - * Copyright 2006 Ethan Nicholas. All rights reserved. - * Use is subject to license terms. + * *##% + * JAXX Compiler + * 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>. + * ##%* */ package jaxx.compiler; -import jaxx.CompilerException; -import jaxx.UnsupportedAttributeException; -import jaxx.UnsupportedTagException; -import jaxx.css.Rule; -import jaxx.css.Stylesheet; -import jaxx.css.StylesheetHelper; -import jaxx.parser.ParseException; -import jaxx.reflect.ClassDescriptor; -import jaxx.reflect.ClassDescriptorLoader; -import jaxx.reflect.FieldDescriptor; -import jaxx.reflect.MethodDescriptor; +import jaxx.compiler.binding.DataBindingHelper; +import jaxx.compiler.css.StylesheetHelper; +import jaxx.compiler.java.JavaField; +import jaxx.compiler.java.JavaFile; +import jaxx.compiler.java.JavaFileGenerator; +import jaxx.compiler.java.JavaMethod; +import jaxx.compiler.java.parser.ParseException; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.reflect.FieldDescriptor; +import jaxx.compiler.reflect.MethodDescriptor; +import jaxx.compiler.script.ScriptManager; +import jaxx.compiler.tags.DefaultObjectHandler; +import jaxx.compiler.tags.TagHandler; +import jaxx.compiler.tags.TagManager; import jaxx.runtime.ComponentDescriptor; import jaxx.runtime.JAXXObjectDescriptor; -import jaxx.tags.DefaultObjectHandler; -import jaxx.tags.TagHandler; -import jaxx.tags.TagManager; +import jaxx.runtime.css.Rule; +import jaxx.runtime.css.Stylesheet; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; -import org.xml.sax.Attributes; -import org.xml.sax.InputSource; -import org.xml.sax.Locator; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; +import org.xml.sax.*; import org.xml.sax.helpers.AttributesImpl; import org.xml.sax.helpers.XMLFilterImpl; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; -import javax.xml.transform.ErrorListener; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; +import javax.xml.transform.*; import javax.xml.transform.dom.DOMResult; import javax.xml.transform.sax.SAXSource; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.PrintWriter; -import java.io.UnsupportedEncodingException; +import java.io.*; import java.lang.reflect.Modifier; -import java.net.MalformedURLException; import java.net.URL; -import java.net.URLClassLoader; import java.net.URLDecoder; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Stack; -import java.util.regex.Matcher; -import java.util.regex.Pattern; +import java.util.*; /** * Compiles JAXX files into Java classes. * <p/> - * use {@link Generator} ... todo finish javadoc + * use {@link JAXXCompilerFinalizer} ... todo finish javadoc */ public class JAXXCompiler { - /** log */ + /** + * Logger + */ protected static final Log log = LogFactory.getLog(JAXXCompiler.class); - /** * True to throw exceptions when we encounter unresolvable classes, false to ignore. * This is currently set to false until JAXX has full support for inner classes * (including enumerations), because currently they don't always resolve (but will - * generally compile without error anyway). + * generally run without error anyway). */ public static final boolean STRICT_CHECKS = false; + /** + * + */ public static final String JAXX_NAMESPACE = "http://www.jaxxframework.org/"; + /** + * + */ public static final String JAXX_INTERNAL_NAMESPACE = "http://www.jaxxframework.org/internal"; - - /** Maximum length of an inlinable creation method. */ + /** + * Maximum length of an inlinable creation method. + */ public static final int INLINE_THRESHOLD = 300; - + /** + * Line separator cached value + */ + protected static String lineSeparator = System.getProperty("line.separator", "\n"); + /** + * The unique object handler used in first pass + */ protected final DefaultObjectHandler firstPassClassTagHandler; - protected List<String> staticImports = new ArrayList<String>(); - - /*---------------------------------------------------------------------------------*/ - /*-- compiler fields --------------------------------------------------------------*/ - /*---------------------------------------------------------------------------------*/ - - /** flag to detec if an error occurs while compiling jaxx file */ + /*------------------------------------------------------------------------*/ + /*-- compiler fields -----------------------------------------------------*/ + /*------------------------------------------------------------------------*/ + /** + * flag to detect if an error occurs while compiling jaxx file + */ protected boolean failed; - - /** Object corresponding to the root tag in the document. */ + /** + * Object corresponding to the root tag in the document. + */ protected CompiledObject root; - - /** Contains strings of the form "javax.swing." */ + /** + * Contains strings of the form "javax.swing." + */ protected Set<String> importedPackages = new HashSet<String>(); - - /** Contains strings of the form "javax.swing.Timer" */ + /** + * Contains strings of the form "javax.swing.Timer" + */ protected Set<String> importedClasses = new HashSet<String>(); - - /** Keeps track of open components (components still having children added). */ + /** + * Keeps track of open components (components still having children added). + */ protected Stack<CompiledObject> openComponents = new Stack<CompiledObject>(); - - /** Sequence number used to create automatic variable names. */ - protected int autogenID = 0; - - protected List<DataBinding> dataBindings = new ArrayList<DataBinding>(); - + /** + * to generate ids + */ + protected final IDHelper idHelper; + /** + * Binding Util + */ + protected final DataBindingHelper bindingHelper; + /** + * table of symbols for this compiler + */ protected SymbolTable symbolTable = new SymbolTable(); - - /** Base directory used for path resolution (normally the directory in which the .jaxx file resides). */ + /** + * Base directory used for path resolution (normally the directory in + * which the .jaxx file resides). + */ protected File baseDir; - - /** .jaxx file being compiled. */ + /** + * jaxx file being compiled. + */ protected File src; - - /** Parsed XML of src file. */ + /** + * Parsed XML of src file. + */ protected Document document; - - /** Name of class being compiled. */ + /** + * Name of class being compiled. + */ protected String outputClassName; - + /** + * + */ protected ScriptManager scriptManager = new ScriptManager(this); - - /** Combination of all stylesheets registered using {@link #registerStylesheet}. */ + /** + * Combination of all stylesheets registered using + * {@link #registerStylesheet}. + */ protected Stylesheet stylesheet; - - /** Contains all attributes defined inline on class tags. */ + /** + * Contains all attributes defined inline on class tags. + */ protected List<Rule> inlineStyles = new ArrayList<Rule>(); - /** * Maps objects (expressed in Java code) to event listener classes (e.g. MouseListener) to Lists of EventHandlers. The final list * contains all event handlers of a particular type attached to a particular object (again, as represented by a Java expression). */ protected Map<String, Map<ClassDescriptor, List<EventHandler>>> eventHandlers = new HashMap<String, Map<ClassDescriptor, List<EventHandler>>>(); - - /** Maps of uniqued id for objects used in compiler */ - protected Map<Object, String> uniqueIds = new HashMap<Object, String>(); - - /** Map of event handler method names used in compiler */ + /** + * Map of event handler method names used in compiler + */ protected Map<EventHandler, String> eventHandlerMethodNames = new HashMap<EventHandler, String>(); - - /** ClassLoader which searches the user-specified class path in addition to the normal class path */ + /** + * ClassLoader which searches the user-specified class path in addition to the normal class path + */ protected ClassLoader classLoader; - /** * A list of Runnables which will be run after the first compilation pass. This is primarily used * to trigger the creation of CompiledObjects, which cannot be created during the first pass and must be * created in document order. */ protected List<Runnable> initializers = new ArrayList<Runnable>(); - - /** left brace matcher */ - protected Matcher leftBraceMatcher = Pattern.compile("^(\\{)|[^\\\\](\\{)").matcher(""); - - /** right brace matcher */ - protected Matcher rightBraceMatcher = Pattern.compile("^(\\})|[^\\\\](\\})").matcher(""); - - /** extra interfaces which can by passed to root object via the 'implements' attribute */ + /** + * extra interfaces which can by passed to root object via the 'implements' attribute + */ private String[] extraInterfaces; - - /** a flag to generate a abstract class */ + /** + * a flag to generate a abstract class + */ private boolean abstractClass; - - /** the possible generic type of the class */ + /** + * the possible generic type of the class + */ private String genericType; - - /** thepossible generic type of the super class */ + /** + * the possible generic type of the super class + */ private String superGenericType; - - /** Extra code to be added to the instance initializer. */ + /** + * Extra code to be added to the instance initializer. + */ protected StringBuffer initializer = new StringBuffer(); - - /** Extra code to be added at the end of the instance initializer. */ + /** + * Extra code to be added at the end of the instance initializer. + */ protected StringBuffer lateInitializer = new StringBuffer(); - - /** Extra code to be added to the class body. */ + /** + * Extra code to be added to the class body. + */ protected StringBuffer bodyCode = new StringBuffer(); - - /** Code to initialize data bindings. */ - protected StringBuffer initDataBindings = new StringBuffer(); - - /** Body of the applyDataBinding method. */ - protected StringBuffer applyDataBinding = new StringBuffer(); - - /** Body of the removeDataBinding method. */ - protected StringBuffer removeDataBinding = new StringBuffer(); - - /** Body of the processDataBinding method. */ - protected StringBuffer processDataBinding = new StringBuffer(); - - /** true if a main() method has been declared in a script */ + /** + * true if a main() method has been declared in a script + */ protected boolean mainDeclared; - - /** the file to be generated */ + /** + * the file to be generated + */ protected JavaFile javaFile; - - - protected CompilerOptions options; - - /** Used for error reporting purposes, so we can report the right line number. */ + /** + * configuration of the compiler + */ + protected CompilerConfiguration configuration; + /** + * Used for error reporting purposes, so we can report the right line number. + */ protected Stack<Element> tagsBeingCompiled = new Stack<Element>(); - - /** Used for error reporting purposes, so we can report the right source file. */ + /** + * Used for error reporting purposes, so we can report the right source file. + */ protected Stack<File> sourceFiles = new Stack<File>(); - - /** Maps object ID strings to the objects themselves. These are created during the second compilation pass. */ + /** + * Maps object ID strings to the objects themselves. These are created during the second compilation pass. + */ protected Map<String, CompiledObject> objects = new LinkedHashMap<String, CompiledObject>(); - - /** Maps objects to their ID strings. These are created during the second compilation pass. */ + /** + * Maps objects to their ID strings. These are created during the second compilation pass. + */ protected Map<CompiledObject, String> ids = new LinkedHashMap<CompiledObject, String>(); - + /** + * default decodator to use if none specified + */ protected CompiledObjectDecorator defaultDecorator; - - /*---------------------------------------------------------------------------------*/ - /*-- Constructor methods ----------------------------------------------------------*/ - /*---------------------------------------------------------------------------------*/ + /** + * engine which references this compiler (can be null if compiler is standalone) + */ + protected final JAXXEngine engine; - protected JAXXCompiler(ClassLoader classLoader, DefaultObjectHandler firstPassClassTagHandler, String... staticImports) { - this.firstPassClassTagHandler = firstPassClassTagHandler; - this.options = new CompilerOptions(); - this.classLoader = classLoader; - if (staticImports == null || staticImports.length == 0) { - staticImports = new String[0]; - } - this.staticImports = Arrays.asList(staticImports); - addImport("java.lang.*"); - } - /** * Creates a new JAXXCompiler. * - * @param baseDir classpath location - * @param src location of file to compile - * @param outputClassName the out file name - * @param options options to pass to javac - * @param firstPassClassTagHandler handler to use for first pass - * @param staticImports statics imports + * @param engine engine which use the compiler (could be null if not attach to any engine) + * @param baseDir classpath location + * @param src location of file to run + * @param outputClassName the out file name + * @param configuration configuration to pass to javac + * @param defaultImports list of default imports to add to java files */ - protected JAXXCompiler(File baseDir, File src, String outputClassName, CompilerOptions options, DefaultObjectHandler firstPassClassTagHandler, String... staticImports) { + public JAXXCompiler(JAXXEngine engine, File baseDir, File src, String outputClassName, CompilerConfiguration configuration, List<String> defaultImports) { + this.engine = engine; this.baseDir = baseDir; this.src = src; - this.firstPassClassTagHandler = firstPassClassTagHandler; - this.staticImports = Arrays.asList(staticImports); + this.firstPassClassTagHandler = new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(Object.class)); sourceFiles.push(src); this.outputClassName = outputClassName; - this.options = options; - addImport(outputClassName.substring(0, outputClassName.lastIndexOf(".") + 1) + "*"); - if (staticImports == null || staticImports.length == 0) { - staticImports = new String[]{"java.lang.*"}; + this.configuration = configuration; + if (outputClassName != null) { + addImport(outputClassName.substring(0, outputClassName.lastIndexOf(".") + 1) + "*"); } - for (Object staticImport : staticImports) { - addImport((String) staticImport); + if (defaultImports != null) { + for (Object staticImport : defaultImports) { + addImport((String) staticImport); + } } - // add extra imports from options - if (options.getExtraImports() != null) { - for (String extraImport : options.getExtraImports()) { - addImport(extraImport); + if (configuration != null) { + // add extra imports from configuration + if (configuration.getExtraImports() != null) { + for (String extraImport : configuration.getExtraImports()) { + addImport(extraImport); + } } + defaultDecorator = engine.getDecorator(configuration.getDefaultDecoratorClass()); + if (defaultDecorator == null) { + log.error("could not find default decorator : " + configuration.getDefaultDecoratorClass()); + throw new IllegalArgumentException("could not find default decorator : " + configuration.getDefaultDecoratorClass()); + } + idHelper = new IDHelper(configuration.isOptimize()); + } else { + idHelper = new IDHelper(false); } - defaultDecorator = CompiledObjectDecorator.getDecorator(options.getDefaultDecoratorClass()); - if (defaultDecorator == null) { - log.error("could not find default decorator : "+options.getDefaultDecoratorClass()); - throw new IllegalArgumentException("could not find default decorator : " + options.getDefaultDecoratorClass()); - } + bindingHelper = new DataBindingHelper(this); } - /*---------------------------------------------------------------------------------*/ - /*-- Initializer methods -----------------------------------------------------------*/ - /*---------------------------------------------------------------------------------*/ - + /*------------------------------------------------------------------------*/ + /*-- Initializer methods -------------------------------------------------*/ + /*------------------------------------------------------------------------*/ public void runInitializers() { for (Runnable runnable : initializers) { if (log.isDebugEnabled()) { @@ -297,7 +312,6 @@ initializers.clear(); } - /** * Registers a <code>Runnable</code> which will be executed after the first * compilation pass is complete. @@ -308,10 +322,9 @@ initializers.add(r); } - /*---------------------------------------------------------------------------------*/ - /*-- Compile methods --------------------------------------------------------------*/ - /*---------------------------------------------------------------------------------*/ - + /*------------------------------------------------------------------------*/ + /*-- Compile methods -----------------------------------------------------*/ + /*------------------------------------------------------------------------*/ public void compileFirstPass(final Element tag) throws IOException { tagsBeingCompiled.push(tag); @@ -322,13 +335,14 @@ // resolve class tags into fully-qualified class name if (namespace != null && namespace.endsWith("*")) { String packageName = namespace.substring(0, namespace.length() - 1); - if (localName.startsWith(packageName)) // class name is fully-qualified already - { + if (localName.startsWith(packageName)) { + // class name is fully-qualified already fullClassName = TagManager.resolveClassName(localName, this); - } else { // namespace not included in class name, probably need the namespace to resolve + } else { + // namespace not included in class name, probably need the namespace to resolve fullClassName = TagManager.resolveClassName(packageName + localName, this); - if (fullClassName == null && !namespacePrefix) // it was just a default namespace, try again without using the namespace - { + if (fullClassName == null && !namespacePrefix) { + // it was just a default namespace, try again without using the namespace fullClassName = TagManager.resolveClassName(localName, this); } } @@ -336,18 +350,19 @@ fullClassName = TagManager.resolveClassName(localName, this); } - if (fullClassName != null) { // we are definitely dealing with a class tag + if (fullClassName != null) { + // we are definitely dealing with a class tag addDependencyClass(fullClassName); namespace = fullClassName.substring(0, fullClassName.lastIndexOf(".") + 1) + "*"; if (symbolTable.getSuperclassName() == null) { symbolTable.setSuperclassName(fullClassName); } - String id = tag.getAttribute("id"); + String id = tag.getAttribute(DefaultObjectHandler.ID_ATTRIBUTE); if (id.length() > 0) { symbolTable.getClassTagIds().put(id, fullClassName); - if (tag.getAttributeNode("javaBean") != null) { + if (tag.getAttributeNode(DefaultObjectHandler.JAVA_BEAN_ATTRIBUTE) != null) { // add java bean support for this property - String capitalizeName = org.apache.commons.lang.StringUtils.capitalize(id); + String capitalizeName = StringUtils.capitalize(id); // add method symbolTable.getScriptMethods().add(new MethodDescriptor("get" + capitalizeName, Modifier.PUBLIC, fullClassName, new String[0], classLoader)); if (Boolean.class.getName().equals(fullClassName)) { @@ -369,8 +384,10 @@ } if (handler == firstPassClassTagHandler) { final String finalClassName = fullClassName; - registerInitializer(new Runnable() { // register an initializer which will create the CompiledObject after pass 1 + 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) { @@ -380,16 +397,15 @@ } }); } - if (handler != null) { + if (handler == null) { + reportError("Could not find a Java class corresponding to: <" + tag.getTagName() + ">"); + failed = true; + } else { try { handler.compileFirstPass(tag, this); - } - catch (CompilerException e) { + } catch (CompilerException e) { reportError(e); } - } else { - reportError("Could not find a Java class corresponding to: <" + tag.getTagName() + ">"); - failed = true; } Element finished = tagsBeingCompiled.pop(); @@ -398,24 +414,21 @@ } } - public void compileSecondPass(Element tag) throws IOException { tagsBeingCompiled.push(tag); TagHandler handler = TagManager.getTagHandler(tag.getNamespaceURI(), tag.getLocalName(), tag.getPrefix() != null, this); - if (handler != null) { - handler.compileSecondPass(tag, this); - } else { + if (handler == null) { reportError("Could not find a Java class corresponding to: <" + tag.getTagName() + ">"); - assert false : "can't-happen error: error should have been reported during the fast pass and caused an abort"; failed = true; + } else { + handler.compileSecondPass(tag, this); } Element finished = tagsBeingCompiled.pop(); if (finished != tag) { throw new RuntimeException("internal error: just finished compiling " + tag + ", but top of tagsBeingCompiled stack is " + finished); } - } protected void compileFirstPass() throws IOException { @@ -424,11 +437,9 @@ document = parseDocument(in); in.close(); compileFirstPass(document.getDocumentElement()); - } - catch (SAXParseException e) { + } catch (SAXParseException e) { reportError(e.getLineNumber(), "Invalid XML: " + e.getMessage()); - } - catch (SAXException e) { + } catch (SAXException e) { reportError(null, "Error parsing XML document: " + e); } } @@ -440,10 +451,9 @@ compileSecondPass(document.getDocumentElement()); } - /*---------------------------------------------------------------------------------*/ - /*-- CompiledObject methods -------------------------------------------------------*/ - /*---------------------------------------------------------------------------------*/ - + /*------------------------------------------------------------------------*/ + /*-- CompiledObject methods ----------------------------------------------*/ + /*------------------------------------------------------------------------*/ public void openComponent(CompiledObject component) throws CompilerException { openComponent(component, null); } @@ -477,7 +487,7 @@ } public void registerCompiledObject(CompiledObject object) { - assert JAXXCompilerLaunchor.get().symbolTables.values().contains(symbolTable) : "attempting to register CompiledObject before pass 1 is complete"; + assert engine.symbolTables.values().contains(symbolTable) : "attempting to register CompiledObject before pass 1 is complete"; if (root == null) { root = object; } @@ -492,18 +502,17 @@ objects.put(id, object); ids.put(object, id); if (object.getDecorator() == null) { - // use compiler decorator + // use default decorator object.setDecorator(defaultDecorator); } } public CompiledObject getCompiledObject(String id) { runInitializers(); - assert JAXXCompilerLaunchor.get().symbolTables.values().contains(symbolTable) : "attempting to retrieve CompiledObject before pass 1 is complete"; + assert engine.symbolTables.values().contains(symbolTable) : "attempting to retrieve CompiledObject before pass 1 is complete"; return objects.get(id); } - public boolean inlineCreation(CompiledObject object) { return object.getId().startsWith("$") && object.getInitializationCode(this).length() < INLINE_THRESHOLD; } @@ -525,87 +534,20 @@ object.setOverride(true); object.setOverrideType(f.getType()); break; - } - catch (NoSuchFieldException e) { + } catch (NoSuchFieldException e) { ancestor = ancestor.getSuperclass(); } } } - /*---------------------------------------------------------------------------------*/ - /*-- DataBinding methods ----------------------------------------------------------*/ - /*---------------------------------------------------------------------------------*/ + /*------------------------------------------------------------------------*/ + /*-- DataBinding methods -------------------------------------------------*/ + /*------------------------------------------------------------------------*/ - /** - * Examine an attribute value for data binding expressions. Returns a 'cooked' expression which - * can be used to determine the resulting value. It is expected that this expression will be used - * as the source expression in a call to {@link #registerDataBinding}. - * If the attribute value does not invoke data binding, this method returns <code>null</code> - * - * @param stringValue the string value of the property from the XML - * @param type the type of the property, from the <code>JAXXPropertyDescriptor</code> - * @return a processed version of the expression - * @throws jaxx.CompilerException ? - */ - public String processDataBindings(String stringValue, ClassDescriptor type) throws CompilerException { - int pos = getNextLeftBrace(stringValue, 0); - if (pos != -1) { - StringBuffer expression = new StringBuffer(); - int lastPos = 0; - while (pos != -1 && pos < stringValue.length()) { - if (pos > lastPos) { - if (expression.length() > 0) { - expression.append(" + "); - } - expression.append('"'); - expression.append(escapeJavaString(stringValue.substring(lastPos, pos))); - expression.append('"'); - } - - if (expression.length() > 0) { - expression.append(" + "); - } - expression.append('('); - int pos2 = getNextRightBrace(stringValue, pos + 1); - if (pos2 == -1) { - reportError("unmatched '{' in expression: " + stringValue); - return ""; - } - expression.append(stringValue.substring(pos + 1, pos2)); - expression.append(')'); - pos2++; - if (pos2 < stringValue.length()) { - pos = getNextLeftBrace(stringValue, pos2); - lastPos = pos2; - } else { - pos = stringValue.length(); - lastPos = pos; - } - } - if (lastPos < stringValue.length()) { - if (expression.length() > 0) { - expression.append(" + "); - } - expression.append('"'); - expression.append(escapeJavaString(stringValue.substring(lastPos))); - expression.append('"'); - } - return type == ClassDescriptorLoader.getClassDescriptor(String.class) ? "String.valueOf(" + expression + ")" : expression.toString(); - } - return null; + public DataBindingHelper getBindingHelper() { + return bindingHelper; } - - public void registerDataBinding(String src, String dest, String assignment) { - try { - src = checkJavaCode(src); - dataBindings.add(new DataBinding(src, dest, assignment, this)); - } - catch (CompilerException e) { - reportError("While parsing data binding for '" + dest.substring(dest.lastIndexOf(".") + 1) + "': " + e.getMessage()); - } - } - public void registerEventHandler(EventHandler handler) { String objectCode = handler.getObjectCode(); Map<ClassDescriptor, List<EventHandler>> listeners = eventHandlers.get(objectCode); @@ -625,25 +567,34 @@ public String getEventHandlerMethodName(EventHandler handler) { String result = eventHandlerMethodNames.get(handler); if (result == null) { - if (getOptions().isOptimize()) { + if (getConfiguration().isOptimize()) { result = "$ev" + eventHandlerMethodNames.size(); } else { //TC-20090309 must get the goal property from the event id // to make possible inheritance - String id = handler.getEventId().substring(0,handler.getEventId().indexOf(".")); - - result = "do" + org.apache.commons.lang.StringUtils.capitalize(handler.getListenerMethod().getName()) + "__on__" + id; - //result = "do" + org.apache.commons.lang.StringUtils.capitalize(handler.getListenerMethod().getName()) + "__on__" + handler.getObjectCode(); + String id = handler.getEventId().substring(0, handler.getEventId().indexOf(".")); + + result = "do" + StringUtils.capitalize(handler.getListenerMethod().getName()) + "__on__" + id; + //TC-20091105 : check the method name is available + // using css can have multi methods with result name (see priority) + if (eventHandlerMethodNames.containsValue(result)) { + int index = 0; + String result2; + do { + result2 = result + "_" + (index++); + + } while (eventHandlerMethodNames.containsValue(result2)); + result = result2; + } } eventHandlerMethodNames.put(handler, result); } return result; } - /*---------------------------------------------------------------------------------*/ - /*-- Script methods ---------------------------------------------------------------*/ - /*---------------------------------------------------------------------------------*/ - + /*------------------------------------------------------------------------*/ + /*-- Script methods ------------------------------------------------------*/ + /*------------------------------------------------------------------------*/ public void addScriptField(FieldDescriptor field) { symbolTable.getScriptFields().add(field); } @@ -681,10 +632,9 @@ return scriptManager.preprocessScript(script); } - /*---------------------------------------------------------------------------------*/ - /*-- StyleSheet methods -----------------------------------------------------------*/ - /*---------------------------------------------------------------------------------*/ - + /*------------------------------------------------------------------------*/ + /*-- StyleSheet methods --------------------------------------------------*/ + /*------------------------------------------------------------------------*/ public void applyStylesheets() { for (Object o : new ArrayList<CompiledObject>(objects.values())) { CompiledObject object = (CompiledObject) o; @@ -704,10 +654,9 @@ inlineStyles.add(StylesheetHelper.inlineAttribute(object, propertyName, dataBinding)); } - /*---------------------------------------------------------------------------------*/ - /*-- Report methods ---------------------------------------------------------------*/ - /*---------------------------------------------------------------------------------*/ - + /*------------------------------------------------------------------------*/ + /*-- Report methods ------------------------------------------------------*/ + /*------------------------------------------------------------------------*/ public void reportWarning(String warning) { Element currentTag = null; if (!tagsBeingCompiled.isEmpty()) { @@ -716,7 +665,6 @@ reportWarning(currentTag, warning, 0); } - public void reportWarning(Element tag, String warning, int lineOffset) { String lineNumber = null; if (tag != null) { @@ -725,23 +673,25 @@ lineNumber = lineAttr; } } - File src = sourceFiles.peek(); + File srcFile = sourceFiles.peek(); try { - src = src.getCanonicalFile(); - } - catch (IOException e) { + srcFile = srcFile.getCanonicalFile(); + } catch (IOException e) { // ignore ? } - - System.err.print(src); + StringBuilder buffer = new StringBuilder(); + buffer.append(srcFile); if (lineNumber != null) { - System.err.print(":" + ((sourceFiles.size() == 1) ? Integer.parseInt(lineNumber) + lineOffset : lineOffset + 1)); + buffer.append(":").append((sourceFiles.size() == 1) ? Integer.parseInt(lineNumber) + lineOffset : lineOffset + 1); } - System.err.println(": Warning: " + warning); - JAXXCompilerLaunchor.get().warningCount++; + buffer.append(getLineSeparator()).append(warning.trim()); + if (engine != null) { + engine.addWarning(buffer.toString()); + } else { + System.err.println(buffer.toString()); + } } - public void reportError(String error) { Element currentTag = null; if (!tagsBeingCompiled.isEmpty()) { @@ -789,47 +739,41 @@ } 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) { + } catch (IOException e) { // ignore ? } - - System.err.print(src != null ? src.getPath() : "<unknown source>"); + StringBuilder buffer = new StringBuilder(); + buffer.append(errorFile != null ? errorFile.getPath() : "<unknown source>"); if (lineNumber > 0) { - System.err.print(":" + lineNumber); + buffer.append(":").append(lineNumber); } - System.err.println(": " + error); - JAXXCompilerLaunchor.get().errorCount++; + buffer.append(getLineSeparator()).append(": ").append(error); + if (engine != null) { + engine.addError(buffer.toString()); + } else { + System.err.println(buffer.toString()); + } failed = true; } - /*---------------------------------------------------------------------------------*/ - /*-- Getter methods ---------------------------------------------------------------*/ - /*---------------------------------------------------------------------------------*/ - + /*------------------------------------------------------------------------*/ + /*-- Getter methods ------------------------------------------------------*/ + /*------------------------------------------------------------------------*/ public Map<String, CompiledObject> getObjects() { return objects; } - public List<DataBinding> getDataBindings() { - return dataBindings; - } - - /*public List<CompiledBeanValidator> getValidators() { - return validators; - }*/ - public Map<String, Map<ClassDescriptor, List<EventHandler>>> getEventHandlers() { return eventHandlers; } - public CompilerOptions getOptions() { - return options; + public CompilerConfiguration getConfiguration() { + return configuration; } public String getOutputClassName() { @@ -882,16 +826,25 @@ return scriptFields.toArray(new FieldDescriptor[scriptFields.size()]); } + public FieldDescriptor getScriptField(String fieldName) { + for (FieldDescriptor f : symbolTable.getScriptFields()) { + if (fieldName.equals(f.getName())) { + return f; + } + } + return null; + } + public MethodDescriptor[] getScriptMethods() { List<MethodDescriptor> scriptMethods = symbolTable.getScriptMethods(); return scriptMethods.toArray(new MethodDescriptor[scriptMethods.size()]); } public MethodDescriptor getScriptMethod(String methodName) { - for (MethodDescriptor m :symbolTable.getScriptMethods()) { - if (methodName.equals(m.getName())) { - return m; - } + for (MethodDescriptor m : symbolTable.getScriptMethods()) { + if (methodName.equals(m.getName())) { + return m; + } } return null; } @@ -900,6 +853,10 @@ return failed; } + public IDHelper getIdHelper() { + return idHelper; + } + /** * Returns a <code>ClassLoader</code> which searches the user-specified class path in addition * to the normal system class path. @@ -908,24 +865,10 @@ */ public ClassLoader getClassLoader() { if (classLoader == null) { - if (options.getClassLoader() != null) { - classLoader = options.getClassLoader(); + if (configuration.getClassLoader() != null) { + classLoader = configuration.getClassLoader(); } else { - String classPath = options.getClassPath(); - if (classPath == null) { - classPath = "."; - } - String[] paths = classPath.split(File.pathSeparator); - URL[] urls = new URL[paths.length]; - for (int i = 0; i < paths.length; i++) { - try { - urls[i] = new File(paths[i]).toURI().toURL(); - } - catch (MalformedURLException e) { - throw new RuntimeException(e); - } - } - classLoader = new URLClassLoader(urls, getClass().getClassLoader()); + throw new NullPointerException("compiler configuration requires a classLoader! :\n" + configuration); } } @@ -944,7 +887,8 @@ CompiledObject parent = components[i].getParent(); while (parent != null) { boolean found = false; - for (int j = i + 1; j < components.length; j++) { // found parent after component, swap them + for (int j = i + 1; j < components.length; j++) { + // found parent after component, swap them if (components[j] == parent) { components[j] = components[i]; components[i] = parent; @@ -966,30 +910,22 @@ } } } - descriptors[i] = new ComponentDescriptor(components[i].getId(), components[i] == root ? outputClassName : components[i].getObjectClass().getName(), + descriptors[i] = new ComponentDescriptor( + components[i].getId(), components[i] == root ? outputClassName : components[i].getObjectClass().getName(), 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); } - /*---------------------------------------------------------------------------------*/ - /*-- Setter methods ---------------------------------------------------------------*/ - /*---------------------------------------------------------------------------------*/ - - public void setFailed(boolean failed) { - this.failed = failed; - } - - /*---------------------------------------------------------------------------------*/ - /*-- Buffer ------------------------------------*/ - /*---------------------------------------------------------------------------------*/ - + /*------------------------------------------------------------------------*/ + /*-- Buffer --------------------------------------------------------------*/ + /*------------------------------------------------------------------------*/ public StringBuffer getInitializer() { return initializer; } @@ -1002,22 +938,7 @@ return bodyCode; } - public StringBuffer getInitDataBindings() { - return initDataBindings; - } - public StringBuffer getApplyDataBinding() { - return applyDataBinding; - } - - public StringBuffer getRemoveDataBinding() { - return removeDataBinding; - } - - public StringBuffer getProcessDataBinding() { - return processDataBinding; - } - public boolean isMainDeclared() { return mainDeclared; } @@ -1027,52 +948,19 @@ } public void appendInitializerCode(String code) { - getInitializer().append(code); + initializer.append(code); } public void appendBodyCode(String code) { - getBodyCode().append(code); + bodyCode.append(code); } - public void appendInitDataBindings(String code) { - getInitDataBindings().append(code); - } - - public void appendProcessDataBinding(String code) { - getProcessDataBinding().append(code); - } - - public void appendApplyDataBinding(String code) { - getApplyDataBinding().append(code); - } - - public void appendRemoveDataBinding(String code) { - getRemoveDataBinding().append(code); - } - public void appendLateInitializer(String code) { - getLateInitializer().append(code); + lateInitializer.append(code); } - public boolean haveProcessDataBinding() { - return getProcessDataBinding().length() > 0; - } - - public boolean haveApplyDataBinding() { - return getApplyDataBinding().length() > 0; - } - - public boolean haveRemoveDataBinding() { - return getRemoveDataBinding().length() > 0; - } - - public void addMethodToJavaFile(JavaMethod method) { - getJavaFile().addMethod(method); - } - public boolean hasMethod(String methodName) { - JavaMethod[] methods = getJavaFile().getMethods(); - for (JavaMethod method : methods) { + for (JavaMethod method : getJavaFile().getMethods()) { if (methodName.equals(method.getName())) { return true; } @@ -1080,10 +968,9 @@ return false; } - /*---------------------------------------------------------------------------------*/ - /*-- Other methods ----------------------------------------------------------------*/ - /*---------------------------------------------------------------------------------*/ - + /*------------------------------------------------------------------------*/ + /*-- Other methods -------------------------------------------------------*/ + /*------------------------------------------------------------------------*/ public void addImport(String text) { if (text.endsWith("*")) { importedPackages.add(text.substring(0, text.length() - 1)); @@ -1097,7 +984,8 @@ } public void addDependencyClass(String className) { - if (!JAXXCompilerLaunchor.get().jaxxFileClassNames.contains(className)) { + + if (!engine.containsJaxxFileClassName(className)) { URL jaxxURL = getClassLoader().getResource(className.replace('.', '/') + ".jaxx"); URL classURL = getClassLoader().getResource(className.replace('.', '/') + ".class"); if (jaxxURL != null && classURL != null) { @@ -1107,8 +995,7 @@ if (classFile.lastModified() > jaxxFile.lastModified()) { return; // class file is newer, no need to recompile } - } - catch (Exception e) { + } catch (Exception e) { // do nothing } } @@ -1117,18 +1004,17 @@ File jaxxFile = URLtoFile(jaxxURL); try { jaxxFile = jaxxFile.getCanonicalFile(); - } - catch (IOException ex) { + } catch (IOException ex) { // ignore ? } assert jaxxFile.getName().equalsIgnoreCase(className.substring(className.lastIndexOf(".") + 1) + ".jaxx") : "expecting file name to match " + className + ", but found " + jaxxFile.getName(); if (jaxxFile.getName().equals(className.substring(className.lastIndexOf(".") + 1) + ".jaxx")) { // check case match - if (JAXXCompilerLaunchor.get().currentPass != JAXXCompilerLaunchor.LifeCycle.compile_first_pass) { + if (engine.getCurrentPass() != JAXXEngine.LifeCycle.compile_first_pass) { throw new AssertionError("Internal error: adding dependency class " + className + " during second compilation pass"); } - JAXXCompilerLaunchor.get().jaxxFileClassNames.add(className); - JAXXCompilerLaunchor.get().jaxxFiles.add(jaxxFile); + engine.addJaxxFileClassName(className); + engine.addJaxxFile(jaxxFile); } } } @@ -1140,7 +1026,7 @@ * * @param javaCode the Java code snippet to test * @return a "cooked" version of the string which has enclosing curly braces removed. - * @throws jaxx.CompilerException if the code cannot be parsed + * @throws CompilerException if the code cannot be parsed */ public String checkJavaCode(String javaCode) { javaCode = scriptManager.trimScript(javaCode); @@ -1174,113 +1060,43 @@ return true; } - protected int getNextLeftBrace(String string, int pos) { - leftBraceMatcher.reset(string); - return leftBraceMatcher.find(pos) ? Math.max(leftBraceMatcher.start(1), leftBraceMatcher.start(2)) : -1; - } +// public String getAutoId(ClassDescriptor objectClass) { +// String name = objectClass.getName(); +// name = name.substring(name.lastIndexOf(".") + 1); +// return getAutoId(name); +//// if (configuration.getOptimize()) { +//// return "$" + Integer.toString(autogenID++, 36); +//// } else { +//// String name = objectClass.getName(); +//// name = name.substring(name.lastIndexOf(".") + 1); +//// return "$" + name + autogenID++; +//// } +// } - protected int getNextRightBrace(String string, int pos) { - leftBraceMatcher.reset(string); - rightBraceMatcher.reset(string); - int openCount = 1; - int rightPos; - while (openCount > 0) { - pos++; - int leftPos = leftBraceMatcher.find(pos) ? Math.max(leftBraceMatcher.start(1), leftBraceMatcher.start(2)) : -1; - rightPos = rightBraceMatcher.find(pos) ? Math.max(rightBraceMatcher.start(1), rightBraceMatcher.start(2)) : -1; - assert leftPos == -1 || leftPos >= pos; - assert rightPos == -1 || rightPos >= pos; - if (leftPos != -1 && leftPos < rightPos) { - pos = leftPos; - openCount++; - } else if (rightPos != -1) { - pos = rightPos; - openCount--; - } else { - openCount = 0; - } - } - return pos; + public String getAutoId(String name) { + return idHelper.nextId(name); +// if (configuration.getOptimize()) { +// return "$" + Integer.toString(autogenID++, 36); +// } else { +// name = name.substring(name.lastIndexOf(".") + 1); +// return "$" + name + autogenID++; +// } } - public String[] parseParameterList(String parameters) throws CompilerException { - List<String> result = new ArrayList<String>(); - StringBuffer current = new StringBuffer(); - int state = 0; // normal - for (int i = 0; i < parameters.length(); i++) { - char c = parameters.charAt(i); - switch (state) { - case 0: // normal - switch (c) { - case '"': - current.append(c); - state = 1; - break; // in quoted string - case '\\': - current.append(c); - state = 2; - break; // immediately after backslash - case ',': - if (current.length() > 0) { - result.add(current.toString()); - current.setLength(0); - break; - } else { - reportError("error parsing parameter list: " + parameters); - } - default: - current.append(c); - } - break; - case 1: // in quoted string - switch (c) { - case '"': - current.append(c); - state = 0; - break; // normal - case '\\': - current.append(c); - state = 3; - break; // immediate after backslash in quoted string - default: - current.append(c); - } - break; - case 2: // immediately after backslash - current.append(c); - state = 0; // normal - break; - case 3: // immediately after backslash in quoted string - current.append(c); - state = 1; // in quoted string - break; - } - } - if (current.length() > 0) { - result.add(current.toString()); - } - return result.toArray(new String[result.size()]); + public String getUniqueId(Object object) { + return idHelper.getUniqueId(object); +// String result = uniqueIds.get(object); +// if (result == null) { +// result = "$u" + uniqueIds.size(); +// uniqueIds.put(object, result); +// } +// return result; } - public String getAutoId(ClassDescriptor objectClass) { - if (options.getOptimize()) { - return "$" + Integer.toString(autogenID++, 36); - } else { - String name = objectClass.getName(); - name = name.substring(name.lastIndexOf(".") + 1); - return "$" + name + autogenID++; - } + public void revertId(String name) { + idHelper.revertId(name); } - public String getUniqueId(Object object) { - String result = uniqueIds.get(object); - if (result == null) { - result = "$u" + uniqueIds.size(); - uniqueIds.put(object, result); - } - return result; - } - public void setExtraInterfaces(String[] extraInterfaces) { this.extraInterfaces = extraInterfaces; } @@ -1324,53 +1140,52 @@ return javaFile; } - public void generateCode(Iterable<Generator> generatorIterator) throws IOException { + public void finalizeCompiler(Iterable<JAXXCompilerFinalizer> finalizers) throws Exception { + + int dotPos = getOutputClassName().lastIndexOf("."); + String packageName = dotPos != -1 ? getOutputClassName().substring(0, dotPos) : null; + String simpleClassName = getOutputClassName().substring(dotPos + 1); + CompiledObject compiledObject = getRootObject(); + for (JAXXCompilerFinalizer finalizer : finalizers) { + finalizer.finalizeCompiler(compiledObject, this, javaFile, packageName, simpleClassName); + } + + for (CompiledObject object : getObjects().values()) { + object.finalizeCompiler(this); + } + + for (JAXXCompilerFinalizer finalizer : finalizers) { + finalizer.prepareJavaFile(compiledObject, this, javaFile, packageName, simpleClassName); + } + } + + public void generate(JavaFileGenerator generator) throws IOException { File dest; - if (getOptions().getTargetDirectory() != null) { - dest = new File(getOptions().getTargetDirectory(), getOutputClassName().replace('.', File.separatorChar) + ".java"); + if (getConfiguration().getTargetDirectory() != null) { + dest = new File(getConfiguration().getTargetDirectory(), getOutputClassName().replace('.', File.separatorChar) + ".java"); } else { dest = new File(getBaseDir(), getOutputClassName().substring(getOutputClassName().lastIndexOf(".") + 1) + ".java"); } if (dest.exists() && !dest.setLastModified(System.currentTimeMillis())) { log.warn("could not touch file " + dest); } + PrintWriter out = null; try { - PrintWriter out = new PrintWriter(new FileWriter(dest)); - int dotPos = getOutputClassName().lastIndexOf("."); - String packageName = dotPos != -1 ? getOutputClassName().substring(0, dotPos) : null; - String simpleClassName = getOutputClassName().substring(dotPos + 1); - CompiledObject compiledObject = getRootObject(); - for (Generator generator : generatorIterator) { - generator.finalizeCompiler(compiledObject, this, javaFile, packageName, simpleClassName); - } - - for (CompiledObject object : getObjects().values()) { - object.finalizeCompiler(); - } - - for (Generator generator : generatorIterator) { - generator.prepareJavaFile(compiledObject, this, javaFile, packageName, simpleClassName); - } - out.println(javaFile.toString(getLineSeparator())); - out.close(); - } catch (RuntimeException e) { + out = new PrintWriter(new FileWriter(dest)); + generator.generateFile(javaFile, out); + } catch (IOException e) { // file could not be generated, so delete it... if (!dest.delete()) { log.warn("could not delete file " + dest); } throw e; - } catch (ClassNotFoundException e) { - // file could not be generated, so delete it... - if (!dest.delete()) { - log.warn("could not delete file " + dest); + } finally { + if (out != null) { + out.close(); } - throw new CompilerException(e); } } - /** line separator cached value */ - protected static String lineSeparator = System.getProperty("line.separator", "\n"); - /** * Returns the system line separator string. * @@ -1381,7 +1196,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) { @@ -1469,8 +1284,7 @@ } try { return new File(URLDecoder.decode(urlString.replace('/', File.separatorChar), "utf-8")); - } - catch (UnsupportedEncodingException e) { + } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } } @@ -1482,11 +1296,9 @@ SAXParser parser; parser = factory.newSAXParser(); return parser; - } - catch (SAXException e) { + } catch (SAXException e) { throw new RuntimeException(e); - } - catch (ParserConfigurationException e) { + } catch (ParserConfigurationException e) { throw new RuntimeException(e); } } @@ -1496,14 +1308,18 @@ 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; } @@ -1511,6 +1327,7 @@ DOMResult result = new DOMResult(); transformer.transform(new SAXSource(new XMLFilterImpl(getSAXParser().getXMLReader()) { + Locator locator; @Override @@ -1526,11 +1343,9 @@ } }, new InputSource(in)), result); return (Document) result.getNode(); - } - catch (TransformerConfigurationException e) { + } catch (TransformerConfigurationException e) { throw new RuntimeException(e); - } - catch (TransformerException e) { + } catch (TransformerException e) { Throwable ex = e; while (ex.getCause() != null) { ex = ex.getCause(); @@ -1547,4 +1362,298 @@ throw new RuntimeException(ex); } } + + public JAXXEngine getEngine() { + return engine; + } + + public void clear() { + idHelper.clear(); + bindingHelper.clear(); + objects.clear(); + ids.clear(); + } + +// /*------------------------------------------------------------------------*/ +// /*-- REMOVE CODE (Goto to idHelper and DataBindingHelper) ----------------*/ +// /*------------------------------------------------------------------------*/ +// /** +// * Sequence number used to create automatic variable names. +// */ +// protected int autogenID = 0; +// /** +// * data bindings detected +// */ +// protected List<DataBinding> dataBindings = new ArrayList<DataBinding>(); +// /** +// * Maps of uniqued id for objects used in compiler +// */ +// protected Map<Object, String> uniqueIds = new HashMap<Object, String>(); +// /** +// * left brace matcher +// */ +// protected Matcher leftBraceMatcher = Pattern.compile("^(\\{)|[^\\\\](\\{)").matcher(""); +// /** +// * right brace matcher +// */ +// protected Matcher rightBraceMatcher = Pattern.compile("^(\\})|[^\\\\](\\})").matcher(""); +// /** +// * Code to initialize data bindings. +// */ +// protected StringBuffer initDataBindings = new StringBuffer(); +// /** +// * Body of the applyDataBinding method. +// */ +// protected StringBuffer applyDataBinding = new StringBuffer(); +// /** +// * Body of the removeDataBinding method. +// */ +// protected StringBuffer removeDataBinding = new StringBuffer(); +// /** +// * Body of the processDataBinding method. +// */ +// protected StringBuffer processDataBinding = new StringBuffer(); +// public String getJavaCode(Object object) { +// String result = TypeManager.getJavaCode(object); +// return result; +// } +// public Object convertFromString(String string, Class<?> type) { +// Object result = TypeManager.convertFromString(string, type); +// return result; +// } +// public List<DataBinding> getDataBindings() { +// return dataBindings; +// } +// /** +// * Examine an attribute value for data binding expressions. Returns a 'cooked' expression which +// * can be used to determine the resulting value. It is expected that this expression will be used +// * as the source expression in a call to {@link #registerDataBinding}. +// * If the attribute value does not invoke data binding, this method returns <code>null</code> +// * +// * @param stringValue the string value of the property from the XML +// * @return a processed version of the expression +// * @throws CompilerException ? +// */ +// public String processDataBindings(String stringValue) throws CompilerException { +// int pos = getNextLeftBrace(stringValue, 0); +// if (pos != -1) { +// StringBuffer expression = new StringBuffer(); +// int lastPos = 0; +// while (pos != -1 && pos < stringValue.length()) { +// if (pos > lastPos) { +// if (expression.length() > 0) { +// expression.append(" + "); +// } +// expression.append('"'); +// expression.append(escapeJavaString(stringValue.substring(lastPos, pos))); +// expression.append('"'); +// } +// boolean multi = expression.length() > 0; +// if (multi) { +// expression.append(" + "); +// expression.append('('); +// } +// int pos2 = getNextRightBrace(stringValue, pos + 1); +// if (pos2 == -1) { +// reportError("unmatched '{' in expression: " + stringValue); +// return ""; +// } +// expression.append(stringValue.substring(pos + 1, pos2)); +// if (multi) { +// expression.append(')'); +// } +// pos2++; +// if (pos2 < stringValue.length()) { +// pos = getNextLeftBrace(stringValue, pos2); +// lastPos = pos2; +// } else { +// pos = stringValue.length(); +// lastPos = pos; +// } +// } +// if (lastPos < stringValue.length()) { +// if (expression.length() > 0) { +// expression.append(" + "); +// } +// expression.append('"'); +// expression.append(escapeJavaString(stringValue.substring(lastPos))); +// expression.append('"'); +// } +// //TC-20091027 : developper must write extact databinding +// // the fact of adding the String boxed for String type binding is not +// // a good thing, since it add one more call to process in binding +// // and add nothing special more ? +//// return type == ClassDescriptorLoader.getClassDescriptor(String.class) ? "String.valueOf(" + expression + ")" : expression.toString(); +// return expression.toString(); +// } +// return null; +// } +// public void registerDataBinding(String src, String dest, String assignment) { +// try { +// src = checkJavaCode(src); +//// if (log.isDebugEnabled()) { +//// log.info(getRootObject().getId() + " src=" + src + ", dst=" + dest.trim()); +//// } +// dataBindings.add(new DataBinding(src, dest, assignment)); +//// dataBindings.add(new DataBinding(src, dest, assignment, this)); +// } catch (CompilerException e) { +// reportError("While parsing data binding for '" + dest.substring(dest.lastIndexOf(".") + 1) + "': " + e.getMessage()); +// } +// } +// public void setFailed(boolean failed) { +// this.failed = failed; +// } +// public StringBuffer getInitDataBindings() { +// return initDataBindings; +// } +// public StringBuffer getApplyDataBinding() { +// return applyDataBinding; +// } +// public StringBuffer getRemoveDataBinding() { +// return removeDataBinding; +// } +// public StringBuffer getProcessDataBinding() { +// return processDataBinding; +// } +// public void appendInitDataBindings(String code) { +// initDataBindings.append(code); +// } + +// public void appendProcessDataBinding(String code) { +// processDataBinding.append(code); +// } + +// public void appendApplyDataBinding(String code) { +// applyDataBinding.append(code); +// } + +// public void appendRemoveDataBinding(String code) { +// removeDataBinding.append(code); +// } + +// public boolean hasProcessDataBinding() { +// return processDataBinding.length() > 0; +// } + +// public boolean hasApplyDataBinding() { +// return applyDataBinding.length() > 0; +// } + + // public boolean hasRemoveDataBinding() { +// return removeDataBinding.length() > 0; +// } +// public int getNextLeftBrace(String string, int pos) { +// leftBraceMatcher.reset(string); +// return leftBraceMatcher.find(pos) ? Math.max(leftBraceMatcher.start(1), leftBraceMatcher.start(2)) : -1; +// } +// +// public int getNextRightBrace(String string, int pos) { +// leftBraceMatcher.reset(string); +// rightBraceMatcher.reset(string); +// int openCount = 1; +// int rightPos; +// while (openCount > 0) { +// pos++; +// int leftPos = leftBraceMatcher.find(pos) ? Math.max(leftBraceMatcher.start(1), leftBraceMatcher.start(2)) : -1; +// rightPos = rightBraceMatcher.find(pos) ? Math.max(rightBraceMatcher.start(1), rightBraceMatcher.start(2)) : -1; +// assert leftPos == -1 || leftPos >= pos; +// assert rightPos == -1 || rightPos >= pos; +// if (leftPos != -1 && leftPos < rightPos) { +// pos = leftPos; +// openCount++; +// } else if (rightPos != -1) { +// pos = rightPos; +// openCount--; +// } else { +// openCount = 0; +// } +// } +// return pos; +// } +// +// public String[] parseParameterList(String parameters) throws CompilerException { +// List<String> result = new ArrayList<String>(); +// StringBuffer current = new StringBuffer(); +// int state = 0; // normal +// for (int i = 0; i < parameters.length(); i++) { +// char c = parameters.charAt(i); +// switch (state) { +// case 0: // normal +// switch (c) { +// case '"': +// current.append(c); +// state = 1; +// break; // in quoted string +// case '\\': +// current.append(c); +// state = 2; +// break; // immediately after backslash +// case ',': +// if (current.length() > 0) { +// result.add(current.toString()); +// current.setLength(0); +// break; +// } else { +// reportError("error parsing parameter list: " + parameters); +// break; +// } +// default: +// current.append(c); +// } +// break; +// case 1: // in quoted string +// switch (c) { +// case '"': +// current.append(c); +// state = 0; +// break; // normal +// case '\\': +// current.append(c); +// state = 3; +// break; // immediate after backslash in quoted string +// default: +// current.append(c); +// } +// break; +// case 2: // immediately after backslash +// current.append(c); +// state = 0; // normal +// break; +// case 3: // immediately after backslash in quoted string +// current.append(c); +// state = 1; // in quoted string +// break; +// } +// } +// if (current.length() > 0) { +// result.add(current.toString()); +// } +// return result.toArray(new String[result.size()]); +// } +// /** +// * Convertit un nom de variable en nom de constante. +// * +// * @param variableName le nom de variable a convertir +// * @return le nom de la constante à partir du nom de la variable +// */ +// public static String convertVariableNameToConstantName(String variableName) { +// StringBuilder buffer = new StringBuilder(); +// boolean lastCarIsUp = false; +// for (int i = 0, j = variableName.length(); i < j; i++) { +// char c = variableName.charAt(i); +// boolean carIsUp = Character.isUpperCase(c); +// if (i > 0 && !lastCarIsUp && carIsUp) { +// // ajout d'un _ +// buffer.append('_'); +// } +// if (carIsUp) { +// buffer.append(c); +// } else { +// buffer.append(Character.toUpperCase(c)); +// } +// lastCarIsUp = carIsUp; +// } +// return buffer.toString(); +// } + } Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompilerFinalizer.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompilerFinalizer.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompilerFinalizer.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompilerFinalizer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,59 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler; + +import jaxx.compiler.java.JavaFile; + +/** + * Contract of any object to interact with a {@link JAXXCompiler} before the + * generation pass. + * + * @author chemit + * @since 2.0.0 + */ +public interface JAXXCompilerFinalizer { + + /** + * Finalize compiler for a given compiler on the finalizer pass before any + * generation. + * + * @param root the root object + * @param compiler the current compiler + * @param javaFile the java file to generate + * @param packageName the package name of the file to generate + * @param className the class name of the file to generate + * @throws Exception + */ + void finalizeCompiler(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) throws Exception; + + /** + * Prepare java file after any compiler finalizer pass, says the last + * action before generation. + * + * @param root the root object + * @param compiler the current compiler + * @param javaFile the java file to generate + * @param packageName the package name of the file to generate + * @param className the class name of the file to generate + * @throws Exception + */ + void prepareJavaFile(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) throws Exception; +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompilerLaunchor.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompilerLaunchor.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompilerLaunchor.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,451 +0,0 @@ -package jaxx.compiler; - -import jaxx.CompilerException; -import jaxx.reflect.ClassDescriptorLoader; -import jaxx.spi.Initializer; -import jaxx.tags.DefaultObjectHandler; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.io.File; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.ServiceLoader; - -/** @author chemit */ -public class JAXXCompilerLaunchor { - - /** log */ - protected static final Log log = LogFactory.getLog(JAXXCompilerLaunchor.class); - - protected enum LifeCycle { - - init,// state before compilation - compile_first_pass, // state when first pass of compilation - compile_second_pass, // state when second pass of compilation - stylesheet_pass, // state when applygin stylesheet phase after compilation - generate_pass, // state when generation phase - profile_pass // state when profile - } - /** shared instance of unique launchor at a givne time. */ - protected static JAXXCompilerLaunchor singleton; - - /** - * Create a new empty launchor and set it as current launchor accessible via method {@link #get()} - * - * @return the new instanciated launchor - */ - public static synchronized JAXXCompilerLaunchor newLaunchor() { - return newLaunchor((File[]) null, null, null); - } - - /** - * Create a new launchor and set it as current launchor accessible via method {@link #get()}. - * <p/> - * The launchor will be prepared to compile a set of files, expressed as paths relative to a base directory. - * The class names of the compiled files are derived from the relative path strings - * (e.g. "example/Foo.jaxx" compiles into a class named "example.Foo"). - * - * @param base the directory against which to resolve relative paths - * @param relativePaths a list of relative paths to .jaxx files being compiled - * @param options the compiler options to use - * @return the new instanciated launchor - */ - public static synchronized JAXXCompilerLaunchor newLaunchor(File base, String[] relativePaths, CompilerOptions options) { - File[] files = new File[relativePaths.length]; - String[] classNames = new String[relativePaths.length]; - for (int i = 0; i < files.length; i++) { - files[i] = new File(base, relativePaths[i]); - classNames[i] = relativePaths[i].substring(0, relativePaths[i].lastIndexOf(".")); - classNames[i] = classNames[i].replace(File.separatorChar, '.'); - classNames[i] = classNames[i].replace('/', '.'); - classNames[i] = classNames[i].replace('\\', '.'); - classNames[i] = classNames[i].replace(':', '.'); - } - return newLaunchor(files, classNames, options); - } - - /** - * Create a new launchor and set it as current launchor accessible via method {@link #get()}. - * <p/> - * The launchor will be prepared to compile a set of files, with the class names specified explicitly. - * The class compiled from files[i] will be named classNames[i]. - * - * @param files the .jaxx files to compile - * @param classNames the names of the classes being compiled - * @param options the compiler options to use - * @return the new instanciated launchor - */ - public static synchronized JAXXCompilerLaunchor newLaunchor(File[] files, String[] classNames, CompilerOptions options) { - if (singleton != null) { - singleton.reset(); - } - singleton = new JAXXCompilerLaunchor(files, classNames, options); - return singleton; - } - - /** - * @return the current launchor - * @throws NullPointerException if no launchor was registred via a <code>newLaunchor-like</code> method. - */ - public static JAXXCompilerLaunchor get() throws NullPointerException { - if (singleton == null) { - throw new NullPointerException("no launchor was registred via newLaunchor method"); - } - return singleton; - } - - /** @return <code> if there is a launchor registred, <code>false</code> otherwise. */ - public static boolean isRegistred() { - return singleton != null; - } - - /** - * Load the {@link jaxx.spi.Initializer} services found via the{@link ServiceLoader} mecanism. - * - * @param verbose <ocde>true</code> to print initializers - */ - public static void loadLibraries(boolean verbose) { - //BeanInfoUtil.reset(); - ClassLoader classloader = Thread.currentThread().getContextClassLoader(); - if (verbose) { - log.info("with cl " + classloader); - } - ServiceLoader<Initializer> loader = ServiceLoader.load(Initializer.class, classloader); - for (Initializer initializer : loader) { - if (verbose) { - log.info("load initializer " + initializer); - } - initializer.initialize(); - } - } - /** options of the launchor and underlines compilers */ - protected CompilerOptions options; - /** original list of files to compile */ - protected final File[] files; - /** original list of classes to compile */ - protected final String[] classNames; - /** Files to be treated while compilation. */ - protected List<File> jaxxFiles = new ArrayList<File>(); - /** Class names corresponding to the files in the jaxxFiles list. */ - protected List<String> jaxxFileClassNames = new ArrayList<String>(); - /** Maps the names of classes being compiled to the compiler instance handling the compilation. */ - protected Map<String, JAXXCompiler> compilers = new HashMap<String, JAXXCompiler>(); - /** Maps the names of classes being compiled to their symbol tables (created after the first compiler pass). */ - protected Map<File, SymbolTable> symbolTables = new HashMap<File, SymbolTable>(); - protected LifeCycle currentPass; - protected int errorCount; - protected int warningCount; - protected int compilerCount; - protected JAXXProfile profiler; - - protected JAXXCompilerLaunchor(File[] files, String[] classNames, CompilerOptions options) { - this.options = options == null ? new CompilerOptions() : options; - this.files = files; - this.classNames = classNames; - if (this.options.isVerbose()) { - log.info("files : " + Arrays.toString(files)); - } - if (this.options.isProfile()) { - profiler = new JAXXProfile(); - } - } - - public void init() { - // forces static initializer to run if it hasn't yet - } - - /** Resets all state in preparation for a new compilation session. */ - protected void reset() { - errorCount = warningCount = 0; - jaxxFiles.clear(); - jaxxFileClassNames.clear(); - symbolTables.clear(); - compilers.clear(); - if (profiler != null) { - profiler.clear(); - } - } - - public String getVersion() { - return "1.0.4"; - } - - /** - * Creates a dummy Compiler for use in unit testing. - * - * @return the compiler - */ - public static JAXXCompiler createDummyCompiler() { - return createDummyCompiler(JAXXCompiler.class.getClassLoader()); - } - - /** - * Creates a dummy Compiler for use in unit testing. - * - * @param classLoader class loader to use - * @return the compiler - */ - public static JAXXCompiler createDummyCompiler(ClassLoader classLoader) { - return new JAXXCompiler(classLoader, new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(Object.class))) { - }; - } - - /** - * @param className the name of the class to use - * @return the compiler instance which is processing the specified JAXX class. Each class is compiled by a - * different compiler instance. - */ - public JAXXCompiler getJAXXCompiler(String className) { - return compilers != null ? compilers.get(className) : null; - } - - /** - * @param className the name of the class to use - * @return the symbol table for the specified JAXX class. Must be called during the second compiler pass. - * Returns <code>null</code> if no such symbol table could be found. - */ - public SymbolTable getSymbolTable(String className) { - JAXXCompiler compiler = getJAXXCompiler(className); - if (compiler == null) { - return null; - } - return compiler.getSymbolTable(); - } - - /** - * Returns the system line separator string. - * - * @return the string used to separate lines - */ - public String getLineSeparator() { - return System.getProperty("line.separator", "\n"); - } - - /** - * Compiled a set of files. - * - * @return <code>true</code> if compilation succeeds, <code>false</code> otherwise - */ - public synchronized boolean compile() { - //reset(); // just to be safe... - compilerCount = 0; - jaxxFiles.addAll(Arrays.asList(files)); - jaxxFileClassNames.addAll(Arrays.asList(classNames)); - try { - boolean success = true; - - // pass 1 - if (!nextStep(LifeCycle.compile_first_pass, success)) { - return false; - } - boolean compiled; - do { - compiled = false; - assert jaxxFiles.size() == jaxxFileClassNames.size(); - java.util.Iterator<File> filesIterator = new ArrayList<File>(jaxxFiles).iterator(); // clone it so it can safely be modified while we're iterating - java.util.Iterator<String> classNamesIterator = new ArrayList<String>(jaxxFileClassNames).iterator(); - while (filesIterator.hasNext()) { - File file = filesIterator.next(); - String className = classNamesIterator.next(); - if (log.isDebugEnabled()) { - log.debug("compile first pass for " + className); - } - if (symbolTables.get(file) == null) { - compiled = true; - if (compilers.containsKey(className)) { - throw new CompilerException("Internal error: " + className + " is already being compiled, attempting to compile it again"); - } - - File destDir = options.getTargetDirectory(); - if (destDir != null) { - int dotPos = className.lastIndexOf("."); - if (dotPos != -1) { - destDir = new File(destDir, className.substring(0, dotPos).replace('.', File.separatorChar)); - } - if (!destDir.exists() && !destDir.mkdirs()) { - log.warn("could not create directory " + destDir); - continue; - } - } else { - //destDir = file.getParentFile(); - } - JAXXCompiler compiler = newCompiler(file.getParentFile(), file, className); - addProfileTime(compiler, currentPass.name() + "_start"); - compilers.put(className, compiler); - compiler.compileFirstPass(); - addProfileTime(compiler, currentPass.name() + "_end"); - assert !symbolTables.values().contains(compiler.getSymbolTable()) : "symbolTable is already registered"; - symbolTables.put(file, compiler.getSymbolTable()); - if (compiler.isFailed()) { - success = false; - } - } - } - - } while (compiled); - - // pass 2 - if (!nextStep(LifeCycle.compile_second_pass, success)) { - return false; - } - - assert jaxxFiles.size() == jaxxFileClassNames.size(); - List<File> jaxxFilesClone = new ArrayList<File>(jaxxFiles); - for (String className : jaxxFileClassNames) { - JAXXCompiler compiler = getCompiler(className, "Internal error: could not find compiler for " + className + " during second pass"); - addProfileTime(compiler, currentPass.name() + "_start"); - if (log.isDebugEnabled()) { - log.debug("runInitializers for " + className); - } - if (!compiler.isFailed()) { - compiler.runInitializers(); - } - if (log.isDebugEnabled()) { - log.debug("compile second pass for " + className); - } - compiler.compileSecondPass(); - addProfileTime(compiler, currentPass.name() + "_end"); - if (log.isDebugEnabled()) { - log.debug("done with result [" + !compiler.isFailed() + "] for " + className); - } - if (compiler.isFailed()) { - success = false; - } - } - if (!jaxxFilesClone.equals(jaxxFiles)) { - throw new AssertionError("Internal error: compilation set altered during pass 2 (was " + jaxxFilesClone + ", modified to " + jaxxFiles + ")"); - } - - // stylesheet application - if (!nextStep(LifeCycle.stylesheet_pass, success)) { - return false; - } - assert jaxxFiles.size() == jaxxFileClassNames.size(); - for (String className : jaxxFileClassNames) { - JAXXCompiler compiler = getCompiler(className, "Internal error: could not find compiler for " + className + " during stylesheet application"); - addProfileTime(compiler, currentPass.name() + "_start"); - compiler.applyStylesheets(); - addProfileTime(compiler, currentPass.name() + "_end"); - if (compiler.isFailed()) { - success = false; - } - } - - // code generation - if (!nextStep(LifeCycle.generate_pass, success)) { - return false; - } - assert jaxxFiles.size() == jaxxFileClassNames.size(); - List<Generator> generators = new ArrayList<Generator>(); - for (Generator generator : ServiceLoader.load(Generator.class)) { - generators.add(generator); - } - for (String className : jaxxFileClassNames) { - JAXXCompiler compiler = getCompiler(className, "Internal error: could not find compiler for " + className + " during code generation"); - addProfileTime(compiler, currentPass.name() + "_start"); - compiler.generateCode(generators); - addProfileTime(compiler, currentPass.name() + "_end"); - //compiler.generateCode(); - if (compiler.isFailed()) { - success = false; - } - } - - if (options.isProfile()) { - // profile pass (only if succes compile) - if (!nextStep(LifeCycle.profile_pass, success)) { - return false; - } - StringBuilder buffer = profiler.computeProfileReport(); - log.info(buffer.toString()); - } - - return report(success); - - //FIXME : deal better the exception treatment... - } catch (CompilerException e) { - System.err.println(e.getMessage()); - e.printStackTrace(); - return false; - } catch (Throwable e) { - e.printStackTrace(); - return false; - } finally { - compilerCount = compilers.size(); - //TC - 20081018 only reset when no error was detected - if (options.isResetAfterCompile() && errorCount == 0) { - reset(); - } - } - } - - public int getCompilerCount() { - return compilerCount; - } - - protected JAXXCompiler getCompiler(String className, String message) { - JAXXCompiler compiler = compilers.get(className); - if (compiler == null) { - throw new CompilerException(message); - } - return compiler; - } - - protected boolean nextStep(LifeCycle nextCycle, boolean success) { - if (!success) { - return report(false); - } - currentPass = nextCycle; - return true; - } - - protected boolean report(boolean success) { - if (warningCount == 1) { - System.err.println("1 warning"); - } else if (warningCount > 0) { - System.err.println(warningCount + " warnings"); - } - if (errorCount == 1) { - System.err.println("1 error"); - } else if (errorCount > 0) { - System.err.println(errorCount + " errors"); - } - return success; - } - - protected JAXXCompiler newCompiler(File parentFile, File file, String className) throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException { - Constructor<? extends JAXXCompiler> cons = options.getCompilerClass().getConstructor(File.class, File.class, String.class, CompilerOptions.class); - return cons.newInstance(parentFile, file, className, options); - } - - public static void addProfileTime(JAXXCompiler compiler, String key) { - JAXXProfile p = JAXXCompilerLaunchor.get().profiler; - if (p != null) { - p.addTime(compiler, key); - } - } - - protected static void showUsage() { - System.out.println("Usage: jaxxc <options> <source files>"); - System.out.println(); - System.out.println("Source files must end in extension .jaxx"); - System.out.println("Use JAXX_OPTS environment variable to pass arguments to Java runtime"); - System.out.println(); - System.out.println("Supported options include:"); - System.out.println(" -classpath <paths> paths to search for user classes"); - System.out.println(" -cp <paths> same as -classpath"); - System.out.println(" -d <directory> target directory for generated class files"); - System.out.println(" -java or -j produce .java files, but do not compile them"); - System.out.println(" -keep or -k preserve generated .java files after compilation"); - System.out.println(" -optimize or -o optimize during compilation"); - System.out.println(" -version display version information"); - System.out.println(); - System.out.println("See http://www.jaxxframework.org/ for full documentation."); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXEngine.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXEngine.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXEngine.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXEngine.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,680 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler; + +import jaxx.compiler.java.JavaFileGenerator; +import jaxx.compiler.spi.Initializer; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.io.File; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.ServiceLoader; +import java.util.TreeMap; + +/** + * @author chemit + * @since 2.0.0 was previously JAXXCompilerLaunchor + */ +public class JAXXEngine { + + /** + * Logger + */ + protected static final Log log = LogFactory.getLog(JAXXEngine.class); + + public void addJaxxFileClassName(String className) { + jaxxFileClassNames.add(className); + } + + public void addJaxxFile(File jaxxFile) { + jaxxFiles.add(jaxxFile); + } + + public boolean containsJaxxFileClassName(String className) { + return jaxxFileClassNames.contains(className); + } + + public LifeCycle getCurrentPass() { + return currentPass; + } + /** shared instance of unique launchor at a givne time. */ + protected static JAXXEngine singleton; + + /** + * Create a new empty launchor and set it as current launchor accessible via method {@link #get()} + * + * @return the new instanciated launchor + */ + public static synchronized JAXXEngine newLaunchor() { + return newLaunchor((File[]) null, null, null); + } + + /** + * Create a new launchor and set it as current launchor accessible via method {@link #get()}. + * <p/> + * The launchor will be prepared to run a set of files, expressed as paths relative to a base directory. + * The class names of the compiled files are derived from the relative path strings + * (e.g. "example/Foo.jaxx" compiles into a class named "example.Foo"). + * + * @param base the directory against which to resolve relative paths + * @param relativePaths a list of relative paths to .jaxx files being compiled + * @param configuration the compiler configuration to use + * @return the new instanciated launchor + */ + public static synchronized JAXXEngine newLaunchor(File base, String[] relativePaths, CompilerConfiguration configuration) { + File[] files = new File[relativePaths.length]; + String[] classNames = new String[relativePaths.length]; + for (int i = 0; i < files.length; i++) { + files[i] = new File(base, relativePaths[i]); + classNames[i] = relativePaths[i].substring(0, relativePaths[i].lastIndexOf(".")); + classNames[i] = classNames[i].replace(File.separatorChar, '.'); + classNames[i] = classNames[i].replace('/', '.'); + classNames[i] = classNames[i].replace('\\', '.'); + classNames[i] = classNames[i].replace(':', '.'); + } + return newLaunchor(files, classNames, configuration); + } + + /** + * Create a new launchor and set it as current launchor accessible via method {@link #get()}. + * <p/> + * The launchor will be prepared to run a set of files, with the class names specified explicitly. + * The class compiled from files[i] will be named classNames[i]. + * + * @param files the .jaxx files to run + * @param classNames the names of the classes being compiled + * @param configuration the compiler configuration to use + * @return the new instanciated launchor + */ + public static synchronized JAXXEngine newLaunchor(File[] files, String[] classNames, CompilerConfiguration configuration) { + if (singleton != null) { + singleton.reset(); + } + singleton = new JAXXEngine(files, classNames, configuration); + return singleton; + } + + /** + * @return the current launchor + * @throws NullPointerException if no launchor was registred via a <code>newLaunchor-like</code> method. + */ + public static JAXXEngine get() throws NullPointerException { + if (singleton == null) { + throw new NullPointerException("no launchor was registred via newLaunchor method"); + } + return singleton; + } + + /** @return <code> if there is a launchor registred, <code>false</code> otherwise. */ + public static boolean isRegistred() { + return singleton != null; + } + + /** + * Load the {@link Initializer} services found via the{@link ServiceLoader} mecanism. + * + * @param verbose <ocde>true</code> to print initializers + */ + public static void loadLibraries(boolean verbose) { + //BeanInfoUtil.reset(); + ClassLoader classloader = Thread.currentThread().getContextClassLoader(); + if (verbose) { + log.info("with cl " + classloader); + } + ServiceLoader<Initializer> loader = ServiceLoader.load(Initializer.class, classloader); + for (Initializer initializer : loader) { + if (verbose) { + log.info("load initializer " + initializer); + } + initializer.initialize(); + } + } + /** + * configuration of the launchor and underlines compilers + */ + protected CompilerConfiguration configuration; + /** + * original list of files to run + */ + protected final File[] files; + /** + * original list of classes to run + */ + protected final String[] classNames; + /** + * Files to be treated while compilation. + */ + private List<File> jaxxFiles = new ArrayList<File>(); + /** + * Class names corresponding to the files in the jaxxFiles list. + */ + private List<String> jaxxFileClassNames = new ArrayList<String>(); + /** + * Maps the names of classes being compiled to the compiler instance handling the compilation. + */ + protected Map<String, JAXXCompiler> compilers = new HashMap<String, JAXXCompiler>(); + /** + * Maps the names of classes being compiled to their symbol tables (created after the first compiler pass). + */ + protected Map<File, SymbolTable> symbolTables = new HashMap<File, SymbolTable>(); + /** + * current pass of the engine + */ + private LifeCycle currentPass; + /** + * Warnings detected while running. + */ + protected List<String> warnings = new ArrayList<String>(); + /** + * Errors detected while running. + */ + protected List<String> errors = new ArrayList<String>(); + /** + * profile attached to the engine (can be null) + */ + protected JAXXProfile profiler; + /** + * decorators available in engine + */ + protected Map<String, CompiledObjectDecorator> decorators; + /** + * finalizers available in engine + */ + protected List<JAXXCompilerFinalizer> finalizers; + + /** + * Different passes of the engine. + * + * Each pass defines the {@link #run(JAXXEngine)} method which implements + * the logic of the pass. + */ + protected enum LifeCycle { + + /** + * state before compilation + */ + init { + + @Override + public boolean run(JAXXEngine engine) { + boolean success = true; + engine.warnings.clear(); + engine.errors.clear(); + // init decorators + if (engine.decorators == null) { + engine.decorators = new TreeMap<String, CompiledObjectDecorator>(); + // load decorators + for (CompiledObjectDecorator decorator : ServiceLoader.load(CompiledObjectDecorator.class)) { + engine.decorators.put(decorator.getName(), decorator); + } + } + // init finalizers + engine.finalizers = new ArrayList<JAXXCompilerFinalizer>(); + for (JAXXCompilerFinalizer finalizer : ServiceLoader.load(JAXXCompilerFinalizer.class)) { + engine.finalizers.add(finalizer); + } + + engine.jaxxFiles.addAll(Arrays.asList(engine.files)); + engine.jaxxFileClassNames.addAll(Arrays.asList(engine.classNames)); + return success; + } + }, + /** + * first pass of compilation + */ + compile_first_pass { + + @Override + public boolean run(JAXXEngine engine) throws Exception { + boolean success = true; + boolean compiled; + do { + compiled = false; + assert engine.jaxxFiles.size() == engine.jaxxFileClassNames.size(); + java.util.Iterator<File> filesIterator = new ArrayList<File>(engine.jaxxFiles).iterator(); // clone it so it can safely be modified while we're iterating + java.util.Iterator<String> classNamesIterator = new ArrayList<String>(engine.jaxxFileClassNames).iterator(); + while (filesIterator.hasNext()) { + File file = filesIterator.next(); + String className = classNamesIterator.next(); + if (log.isDebugEnabled()) { + log.debug("compile first pass for " + className); + } + if (engine.symbolTables.get(file) == null) { + compiled = true; + if (engine.compilers.containsKey(className)) { + throw new CompilerException("Internal error: " + className + " is already being compiled, attempting to compile it again"); + } + + File destDir = engine.configuration.getTargetDirectory(); + if (destDir != null) { + int dotPos = className.lastIndexOf("."); + if (dotPos != -1) { + destDir = new File(destDir, className.substring(0, dotPos).replace('.', File.separatorChar)); + } + if (!destDir.exists() && !destDir.mkdirs()) { + log.warn("could not create directory " + destDir); + continue; + } + } + JAXXCompiler compiler = engine.newCompiler(file.getParentFile(), file, className); + addStartProfileTime(engine, compiler); + engine.compilers.put(className, compiler); + compiler.compileFirstPass(); + addEndProfileTime(engine, compiler); + assert !engine.symbolTables.values().contains(compiler.getSymbolTable()) : "symbolTable is already registered"; + engine.symbolTables.put(file, compiler.getSymbolTable()); + if (compiler.isFailed()) { + success = false; + } + } + } + + } while (compiled); + return success; + } + }, + /** + * second pass of compilation + */ + compile_second_pass { + + @Override + public boolean run(JAXXEngine engine) throws Exception { + boolean success = true; + List<File> jaxxFilesClone = new ArrayList<File>(engine.jaxxFiles); + for (String className : engine.jaxxFileClassNames) { + JAXXCompiler compiler = engine.getCompiler(className, "Internal error: could not find compiler for " + className + " during second pass"); + addStartProfileTime(engine, compiler); + if (log.isDebugEnabled()) { + log.debug("runInitializers for " + className); + } + if (!compiler.isFailed()) { + compiler.runInitializers(); + } + if (log.isDebugEnabled()) { + log.debug("compile second pass for " + className); + } + compiler.compileSecondPass(); + addEndProfileTime(engine, compiler); + if (log.isDebugEnabled()) { + log.debug("done with result [" + !compiler.isFailed() + "] for " + className); + } + if (compiler.isFailed()) { + success = false; + } + } + if (!jaxxFilesClone.equals(engine.jaxxFiles)) { + throw new AssertionError("Internal error: compilation set altered during pass 2 (was " + jaxxFilesClone + ", modified to " + engine.jaxxFiles + ")"); + } + return success; + } + }, + /** + * applying stylesheet + */ + stylesheet_pass { + + @Override + public boolean run(JAXXEngine engine) throws Exception { + boolean success = true; + for (String className : engine.jaxxFileClassNames) { + JAXXCompiler compiler = engine.getCompiler(className, "Internal error: could not find compiler for " + className + " during stylesheet application"); + addStartProfileTime(engine, compiler); + compiler.applyStylesheets(); + addEndProfileTime(engine, compiler); + if (compiler.isFailed()) { + success = false; + } + } + return success; + } + }, + /** + * finalize compiler + */ + finalize_compiler { + + @Override + public boolean run(JAXXEngine engine) throws Exception { + boolean success = true; + for (String className : engine.jaxxFileClassNames) { + JAXXCompiler compiler = engine.getCompiler(className, "Internal error: could not find compiler for " + className + " during code generation"); + addStartProfileTime(engine, compiler); + compiler.finalizeCompiler(engine.finalizers); + addEndProfileTime(engine, compiler); + if (compiler.isFailed()) { + success = false; + } + } + return success; + } + }, + /** + * generate java file + */ + generate_pass { + + @Override + public boolean run(JAXXEngine engine) throws Exception { + boolean success = true; + JavaFileGenerator generator = new JavaFileGenerator(JAXXCompiler.getLineSeparator(), engine.configuration.isVerbose()); + + for (String className : engine.jaxxFileClassNames) { + JAXXCompiler compiler = engine.getCompiler(className, "Internal error: could not find compiler for " + className + " during code generation"); + addStartProfileTime(engine, compiler); + compiler.generate(generator); + addEndProfileTime(engine, compiler); + if (compiler.isFailed()) { + success = false; + } + } + return success; + } + }, + /** + * display profile results + */ + profile_pass { + + @Override + public boolean run(JAXXEngine engine) throws Exception { + boolean success = true; + if (engine.configuration.isProfile()) { + StringBuilder buffer = engine.profiler.computeProfileReport(); + log.info(buffer.toString()); + } + return success; + } + }; + + /** + * Run the pass. + * + * @param engine the engine to use + * @return {@code true} if pass was ok, {@code false} otherwise + * @throws Exception if any pb + */ + public abstract boolean run(JAXXEngine engine) throws Exception; + + void addStartProfileTime(JAXXEngine engine, JAXXCompiler compiler) { + engine.addProfileTime(compiler, name() + "_start"); + } + + void addEndProfileTime(JAXXEngine engine, JAXXCompiler compiler) { + engine.addProfileTime(compiler, name() + "_end"); + } + } + + protected JAXXEngine(File[] files, String[] classNames, CompilerConfiguration options) { + this.configuration = options == null ? new DefaultCompilerConfiguration() : options; + this.files = files; + this.classNames = classNames; + if (log.isDebugEnabled()) { + log.debug("files : " + Arrays.toString(files)); + } + if (this.configuration.isProfile()) { + profiler = new JAXXProfile(); + } + } + + /** + * Resets all state in preparation for a new compilation session. + */ + protected void reset() { + jaxxFiles.clear(); + jaxxFileClassNames.clear(); + symbolTables.clear(); + for (JAXXCompiler jaxxCompiler : compilers.values()) { + jaxxCompiler.clear(); + } + compilers.clear(); + if (profiler != null) { + profiler.clear(); + profiler = null; + } + if (decorators != null) { + decorators.clear(); + decorators = null; + } + if (finalizers != null) { + finalizers.clear(); + finalizers = null; + } + } + + public String getVersion() { + return "2.0.0"; + } + + /** + * Creates a dummy Compiler for use in unit testing or dettached use of an + * engine. + * + * @param classLoader class loader to use + * @return the compiler + */ + public static JAXXCompiler createDummyCompiler(final ClassLoader classLoader) { + JAXXCompiler compiler = new JAXXCompiler(null, null, null, null, null, null); + compiler.classLoader = classLoader; + return compiler; + } + + /** + * Obtain the jaxx compiler of the given class name. + * + * @param className the name of the class to use + * @return the compiler instance which is processing the specified JAXX class. Each class is compiled by a + * different compiler instance. + */ + public JAXXCompiler getJAXXCompiler(String className) { + return compilers == null ? null : compilers.get(className); + } + + /** + * Obtain the symbo table for the given class name. + * + * @param className the name of the class to use + * @return the symbol table for the specified JAXX class. Must be called during the second compiler pass. + * Returns <code>null</code> if no such symbol table could be found. + */ + public SymbolTable getSymbolTable(String className) { + JAXXCompiler compiler = getJAXXCompiler(className); + if (compiler == null) { + return null; + } + return compiler.getSymbolTable(); + } + + /** + * Obtain the decorator of the given name. + * + * @param name the name of the decorator + * @return the decorator found. + * @throws IllegalArgumentException if decorator not found for the given name. + */ + public CompiledObjectDecorator getDecorator(String name) throws IllegalArgumentException { + CompiledObjectDecorator decorator = decorators.get(name); + if (decorator == null) { + throw new IllegalArgumentException("could not find decorator with key " + name + " (known decorators : " + decorators.keySet() + ")"); + } + return decorator; + } + + /** + * Obtain the decorator of the given type. + * + * @param type the type of the decorator (syas his fqn) + * @return the decorator found + */ + public CompiledObjectDecorator getDecorator(Class<?> type) { + for (CompiledObjectDecorator decorator : decorators.values()) { + if (type == decorator.getClass()) { + return decorator; + } + } + return null; + } + + /** + * Add a warning to the engine. + * + * @param warning the warning to add + */ + public void addWarning(String warning) { + warnings.add(warning); + } + + /** + * Add an error to the engine. + * + * @param error the error to add + */ + public void addError(String error) { + errors.add(error); + } + + /** + * @return the errors of the engine + */ + public List<String> getErrors() { + return errors; + } + + /** + * @return the warnings of the engine + */ + public List<String> getWarnings() { + return warnings; + } + + /** + * Compiled a set of files. + * + * @return {@code -1} if errors appears, the number of generated files + * otherwise. + */ + public synchronized int run() { + try { + boolean success = true; + + for (LifeCycle state : LifeCycle.values()) { + if (!success) { + // stop as soon as a engine phase failed + break; + } + currentPass = state; + if (configuration.isVerbose()) { + log.info("'" + state + "' on " + jaxxFiles.size() + " file(s)"); + } + success = state.run(this); + } + return success ? compilers.size() : -1; + + //FIXME : deal better the exception treatment... + } catch (CompilerException e) { + log.error(e.getMessage()); +// System.err.println(e.getMessage()); +// e.printStackTrace(); + return -1; + } catch (Throwable e) { + log.error(e.getMessage()); +// e.printStackTrace(); + return -1; + } finally { + //TC - 20081018 only reset when no error was detected + if (configuration.isResetAfterCompile() && errors.isEmpty()) { + reset(); + } + } + } + + /** + * Obtain the compiler for the given class name. + * + * @param className the class name of the searched compiler + * @param message the message to throw if compiler not found + * @return the compiler found + * @throws CompilerException if compiler not found + */ + protected JAXXCompiler getCompiler(String className, String message) throws CompilerException { + JAXXCompiler compiler = compilers.get(className); + if (compiler == null) { + throw new CompilerException(message); + } + return compiler; + } + + /** + * Create a new compiler. + * + * @param parentFile the directory where to generate the java file + * @param file the path of file to generate + * @param className name of the class to generate in the file + * @return the new compiler + * @throws InvocationTargetException introspection error + * @throws IllegalAccessException introspection error + * @throws InstantiationException introspection error + * @throws NoSuchMethodException introspection error + */ + protected JAXXCompiler newCompiler(File parentFile, File file, String className) throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException { + Constructor<? extends JAXXCompiler> cons = configuration.getCompilerClass().getConstructor(JAXXEngine.class, File.class, File.class, String.class, CompilerConfiguration.class, List.class); + return cons.newInstance(this, parentFile, file, className, configuration, + Arrays.asList("java.awt.*", + "java.awt.event.*", +// "java.beans.*", + "java.io.*", + "java.lang.*", + "java.util.*", + "javax.swing.*", + "javax.swing.border.*", + "javax.swing.event.*", + "jaxx.runtime.swing.JAXXButtonGroup", + "jaxx.runtime.swing.HBox", + "jaxx.runtime.swing.VBox", + "jaxx.runtime.swing.Table", + "jaxx.runtime.Util", + "jaxx.runtime.SwingUtil", + "static org.nuiton.i18n.I18n._", + "static jaxx.runtime.SwingUtil.createImageIcon") + ); + } + + /** + * Add a profile time for the given compiler and key. + * + * Note: if {@link #profiler} is {@code null}, do nothing + * + * @param compiler the compiler to profile + * @param key the key of profiling + */ + public void addProfileTime(JAXXCompiler compiler, String key) { + if (profiler != null) { + profiler.addTime(compiler, key); + } + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXObjectGenerator.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXObjectGenerator.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXObjectGenerator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,598 +0,0 @@ -package jaxx.compiler; - -import jaxx.Base64Coder; -import jaxx.CompilerException; -import jaxx.reflect.ClassDescriptor; -import jaxx.reflect.ClassDescriptorLoader; -import jaxx.reflect.FieldDescriptor; -import jaxx.reflect.MethodDescriptor; -import jaxx.runtime.JAXXContext; -import jaxx.runtime.JAXXObject; -import jaxx.runtime.JAXXObjectDescriptor; -import jaxx.types.TypeManager; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.io.IOException; -import java.lang.reflect.Modifier; -import static java.lang.reflect.Modifier.FINAL; -import static java.lang.reflect.Modifier.PROTECTED; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -/** - * This class is a refactoring of the {@link jaxx.compiler.JAXXCompiler}. - * <p/> - * We delegate now the generation of a {@link jaxx.runtime.JAXXObject} to this class, the - * {@link jaxx.compiler.JAXXCompiler} now only deals with the compilation of files. - * - * @author chemit - */ -public class JAXXObjectGenerator implements Generator { - - /** log */ - protected static final Log log = LogFactory.getLog(JAXXObjectGenerator.class); - protected static final JavaField ACTIVE_BINDINGS_FIELD = JavaField.newField(PROTECTED, - "java.util.List<Object>", "$activeBindings", "new ArrayList<Object>()"); - protected static final JavaField BINDING_SOURCES_FIELD = JavaField.newField(PROTECTED, - "java.util.Map<String,Object>", "$bindingSources", "new HashMap<String,Object>()"); - protected static final JavaField OBJECT_MAP_FIELD = JavaField.newField(PROTECTED, - "Map<String,Object>", "$objectMap", "new HashMap<String,Object>()"); - protected static final JavaField ALL_COMPONENTS_CREATED_FIELD = JavaField.newField(java.lang.reflect.Modifier.PRIVATE, - "boolean", "allComponentsCreated"); - protected static final JavaField CONTEXT_INITIALIZED = JavaField.newField(java.lang.reflect.Modifier.PRIVATE, - "boolean", "contextInitialized", "true"); - protected static final JavaField PREVIOUS_VALUES_FIELD = JavaField.newField(0, - "java.util.Map", "$previousValues", "new java.util.HashMap()"); - protected static final JavaField DELEGATE_CONTEXT_FIELD = JavaField.newField(PROTECTED, - "jaxx.runtime.JAXXContext", "delegateContext"); - protected static final JavaField PROPERTY_CHANGE_SUPPORT_FIELD = JavaField.newField(0, - "java.beans.PropertyChangeSupport", "$propertyChangeSupport"); - protected static final JavaMethod GET_CONTEXT_VALUE_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<T> T", "getContextValue", - "return delegateContext.getContextValue(clazz, null);", - new JavaArgument("Class<T>", "clazz")); - protected static final JavaMethod GET_CONTEXT_VALUE_NAMED_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<T> T", "getContextValue", - "return delegateContext.getContextValue(clazz, name);", - new JavaArgument("Class<T>", "clazz"), new JavaArgument("String", "name")); - protected static final JavaMethod SET_CONTEXT_VALUE_NAMED_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<T> void", "setContextValue", - "delegateContext.setContextValue(o, name);", - new JavaArgument("T", "o"), new JavaArgument("String", "name")); - protected static final JavaMethod SET_CONTEXT_VALUE_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<T> void", "setContextValue", - "delegateContext.setContextValue(o, null);", - new JavaArgument("T", "o")); - protected static final JavaMethod REMOVE_CONTEXT_VALUE_NAMED_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<T> void", "removeContextValue", - "delegateContext.removeContextValue(clazz, name);", - new JavaArgument("Class<T>", "clazz"), new JavaArgument("String", "name")); - protected static final JavaMethod REMOVE_CONTEXT_VALUE_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<T> void", "removeContextValue", - "delegateContext.removeContextValue(clazz, null);", - new JavaArgument("Class<T>", "clazz")); - protected static final JavaMethod GET_PARENT_CONTAINER_MORE_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<O extends Container> O", "getParentContainer", - "return delegateContext.getParentContainer(source, clazz);", - new JavaArgument("Object", "source"), new JavaArgument("Class<O>", "clazz")); - protected static final JavaMethod GET_PARENT_CONTAINER_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<O extends Container> O", "getParentContainer", - "return delegateContext.getParentContainer(clazz);", - new JavaArgument("Class<O>", "clazz")); - protected static final JavaMethod GET_OBJECT_BY_ID_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "java.lang.Object", "getObjectById", - "return $objectMap.get(id);", - new JavaArgument("String", "id")); - protected static final JavaMethod GET_JAXX_OBJECT_DESCRIPTOR_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC | java.lang.reflect.Modifier.STATIC, "jaxx.runtime.JAXXObjectDescriptor", "$getJAXXObjectDescriptor", - "return jaxx.runtime.Util.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);"); - protected static final JavaMethod PROCESS_DATA_BINDING_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "processDataBinding", - "processDataBinding(dest, false);", - new JavaArgument("String", "dest")); - protected static final JavaMethod FIRE_PROPERTY_CHANGE_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "firePropertyChange", - "super.firePropertyChange(propertyName, oldValue, newValue);", - new JavaArgument("String", "propertyName"), new JavaArgument("Object", "oldValue"), new JavaArgument("Object", "newValue")); - protected static final JavaMethod FIRE_PROPERTY_CHANGE_NAMED_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "firePropertyChange", - "$getPropertyChangeSupport().firePropertyChange(propertyName, oldValue, newValue);", - new JavaArgument("String", "propertyName"), new JavaArgument("Object", "oldValue"), new JavaArgument("Object", "newValue")); - protected static final JavaMethod GET_PROPERTY_CHANGE_SUPPORT_METHOD = JavaMethod.newMethod(0, "java.beans.PropertyChangeSupport", "$getPropertyChangeSupport", - "if ($propertyChangeSupport == null)\n" + - " $propertyChangeSupport = new PropertyChangeSupport(this);\n" + - "return $propertyChangeSupport;"); - protected static final JavaMethod ADD_PROPERTY_CHANGE_SUPPORT_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "addPropertyChangeListener", - "$getPropertyChangeSupport().addPropertyChangeListener(listener);", - new JavaArgument("java.beans.PropertyChangeListener", "listener")); - protected static final JavaMethod ADD_PROPERTY_CHANGE_SUPPORT_NAMED_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "addPropertyChangeListener", - "$getPropertyChangeSupport().addPropertyChangeListener(property, listener);", - new JavaArgument("String", "property"), new JavaArgument("java.beans.PropertyChangeListener", "listener")); - protected static final JavaMethod REMOVE_PROPERTY_CHANGE_SUPPORT_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "removePropertyChangeListener", - "$getPropertyChangeSupport().removePropertyChangeListener(listener);", - new JavaArgument("java.beans.PropertyChangeListener", "listener")); - protected static final JavaMethod REMOVE_PROPERTY_CHANGE_SUPPORT_NAMED_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "removePropertyChangeListener", - "$getPropertyChangeSupport().removePropertyChangeListener(property, listener);", - new JavaArgument("String", "property"), new JavaArgument("java.beans.PropertyChangeListener", "listener")); - - @Override - public void finalizeCompiler(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) { - - String fullClassName = packageName != null ? packageName + "." + className : className; - if (root == null) { - throw new CompilerException("root tag must be a class tag"); - } - //Map<String, CompiledObject> objects = compiler.getObjects(); - ClassDescriptor superclass = root.getObjectClass(); - boolean superclassIsJAXXObject = ClassDescriptorLoader.getClassDescriptor(JAXXObject.class).isAssignableFrom(superclass); - javaFile.setModifiers(Modifier.PUBLIC); - javaFile.setClassName(fullClassName); - javaFile.setSuperClass(JAXXCompiler.getCanonicalName(superclass)); - javaFile.setSuperclassIsJAXXObject(superclassIsJAXXObject); - - javaFile.addInterfaces(compiler.getExtraInterfaces()); - javaFile.setAbstractClass(compiler.isAbstractClass()); - javaFile.setGenericType(compiler.getGenericType()); - javaFile.setSuperGenericType(compiler.getSuperGenericType()); - - for (CompiledObject object : compiler.getObjects().values()) { - CompiledObjectDecorator decorator = object.getDecorator(); - decorator.finalizeCompiler(compiler, root, object, javaFile, packageName, className, fullClassName); - - /*if (!object.isOverride() && !(object instanceof ScriptInitializer)) { - String id = object.getId(); - int access = id.startsWith("$") ? Modifier.PRIVATE : Modifier.PROTECTED; - if (object == root) { - javaFile.addField(new JavaField(access, fullClassName, id, "this")); - } else { - //TC -20081017 can have generic on compiled Object - javaFile.addField(JavaField.newField(access, JAXXCompiler.getCanonicalName(object), id), object.isJavaBean()); - } - } - - if (!compiler.inlineCreation(object) && object != root) { - javaFile.addMethod(JavaMethod.newMethod(Modifier.PROTECTED, "void", object.getCreationMethodName(), getCreationCode(compiler, object))); - }*/ - } - - // DataBinding - for (DataBinding dataBinding : compiler.getDataBindings()) { - if (dataBinding.compile(true)) { - compiler.getInitDataBindings().append("applyDataBinding(").append(TypeManager.getJavaCode(dataBinding.getId())).append(");").append(JAXXCompiler.getLineSeparator()); - } - } - - if (superclassIsJAXXObject) { - boolean hasBind = compiler.getApplyDataBinding().length() > 0; - if (hasBind) { - compiler.appendApplyDataBinding(" else {"); - compiler.appendApplyDataBinding(JAXXCompiler.getLineSeparator()); - compiler.appendApplyDataBinding(" "); - } - compiler.appendApplyDataBinding("super.applyDataBinding($binding);"); - compiler.appendApplyDataBinding(JAXXCompiler.getLineSeparator()); - - if (hasBind) { - compiler.appendApplyDataBinding(" return;"); - compiler.appendApplyDataBinding(JAXXCompiler.getLineSeparator()); - compiler.appendApplyDataBinding("}"); - } - - - hasBind = compiler.getRemoveDataBinding().length() > 0; - if (hasBind) { - compiler.appendRemoveDataBinding(" else {"); - compiler.appendRemoveDataBinding(JAXXCompiler.getLineSeparator()); - compiler.appendRemoveDataBinding(" "); - } - compiler.appendRemoveDataBinding("super.removeDataBinding($binding);"); - compiler.appendRemoveDataBinding(JAXXCompiler.getLineSeparator()); - - if (hasBind) { - compiler.appendRemoveDataBinding("}"); - } - } else { - javaFile.addInterface(JAXXCompiler.getCanonicalName(JAXXObject.class)); - } - } - - @Override - public void prepareJavaFile(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) throws ClassNotFoundException { - - String fullClassName = javaFile.getClassName(); - - String jaxxContextImplementorClass = compiler.getOptions().getJaxxContextImplementorClass(); - boolean superclassIsJAXXObject = javaFile.isSuperclassIsJAXXObject(); - if (!superclassIsJAXXObject) { - // add logger - if (compiler.getOptions().isAddLogger()) { - javaFile.addImport(Log.class); - javaFile.addImport(LogFactory.class); - javaFile.addField(JavaField.newField(Modifier.PUBLIC + Modifier.STATIC + FINAL, "Log", "log", "LogFactory.getLog(" + fullClassName + ".class)")); - } - - // JAXXObject - javaFile.addField(OBJECT_MAP_FIELD); - javaFile.addMethod(GET_OBJECT_BY_ID_METHOD); - javaFile.addField(BINDING_SOURCES_FIELD); - javaFile.addField(ACTIVE_BINDINGS_FIELD); - - // JAXXContext - javaFile.addField(JavaField.newField(PROTECTED | FINAL, JAXXContext.class.getName(), "delegateContext", "new " + jaxxContextImplementorClass + "(this);")); - javaFile.addMethod(SET_CONTEXT_VALUE_METHOD); - javaFile.addMethod(SET_CONTEXT_VALUE_NAMED_METHOD); - javaFile.addMethod(GET_CONTEXT_VALUE_METHOD); - javaFile.addMethod(GET_CONTEXT_VALUE_NAMED_METHOD); - javaFile.addMethod(REMOVE_CONTEXT_VALUE_METHOD); - javaFile.addMethod(REMOVE_CONTEXT_VALUE_NAMED_METHOD); - javaFile.addMethod(GET_PARENT_CONTAINER_METHOD); - javaFile.addMethod(GET_PARENT_CONTAINER_MORE_METHOD); - - // PropertyChangeSupport - addPropertyChangeSupport(root, javaFile); - - // DataBinding - javaFile.addMethod(PROCESS_DATA_BINDING_METHOD); - } - - javaFile.addField(ALL_COMPONENTS_CREATED_FIELD); - boolean overrideContextInitialized = false; - FieldDescriptor[] scriptFields = compiler.getScriptFields(); - for (FieldDescriptor f : scriptFields) { - if ("contextInitialized".equals(f.getName())) { - overrideContextInitialized = true; - break; - } - } - if (!overrideContextInitialized) { - javaFile.addField(CONTEXT_INITIALIZED); - } - javaFile.addField(createJAXXObjectDescriptorField(compiler, javaFile)); - - if (compiler.getStylesheet() != null) { - javaFile.addField(PREVIOUS_VALUES_FIELD); - } - /*for (CompiledObject object : compiler.getObjects().values()) { - List<CompiledObject.ChildRef> refList = object.getChilds(); - if (refList==null || refList.isEmpty()) { - continue; - } - for (ChildRef childRef : refList) { - childRef.addToAdditionCode(buffer); - } - }*/ - //TC 20090228 - only generate constructors if not done in scripts - boolean constructorDetected = false; - MethodDescriptor[] methods = compiler.getScriptMethods(); - for (MethodDescriptor m : methods) { - try { - m.getReturnType(); - if (className.equals(m.getName())) { - constructorDetected = true; - break; - } - } catch (Exception e) { - log.warn("could not find return type " + m); - } - } - if (!constructorDetected) { - javaFile.addMethod(createConstructor(compiler, className, superclassIsJAXXObject)); - javaFile.addMethod(createConstructorWithInitialContext(compiler, className, superclassIsJAXXObject)); - } - - javaFile.addMethod(createInitializer(compiler)); - javaFile.addMethod(GET_JAXX_OBJECT_DESCRIPTOR_METHOD); - - javaFile.addBodyCode(compiler.getBodyCode().toString()); - - javaFile.addMethod(createCompleteSetupMethod(compiler, javaFile, compiler.getInitDataBindings())); - - - javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC, "void", "applyDataBinding", - compiler.getApplyDataBinding().toString() + JAXXCompiler.getLineSeparator() + "processDataBinding($binding);", - new JavaArgument("String", "$binding"))); - - javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC, "void", "removeDataBinding", - compiler.getRemoveDataBinding().toString(), new JavaArgument("String", "$binding"))); - - javaFile.addMethod(createProcessDataBindingMethod(compiler, superclassIsJAXXObject)); - - addEventHandlers(compiler, javaFile); - - } - - - /*---------------------------------------------------------------------------------*/ - /*-- Create fields ----------------------------------------------------------------*/ - /*---------------------------------------------------------------------------------*/ - protected JavaField createJAXXObjectDescriptorField(JAXXCompiler compiler, JavaFile javaFile) { - try { - JAXXObjectDescriptor descriptor = compiler.getJAXXObjectDescriptor(); - String data = Base64Coder.serialize(descriptor, true); - /*ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - ObjectOutputStream out = new ObjectOutputStream(new GZIPOutputStream(buffer)); - out.writeObject(descriptor); - out.close(); - // the use of the weird deprecated constructor is deliberate -- we need to store the data as a String - // in the compiled class file, since byte array initialization is horribly inefficient compared to - // String initialization. So we store the bytes in the String, and we quite explicitly want a 1:1 - // mapping between bytes and chars, with the high byte of the char set to zero. We can then safely - // reconstitute the original byte[] at a later date. This is unquestionably an abuse of the String - // type, but if we could efficiently store a byte[] we wouldn't have to do this. - String data = new String(buffer.toByteArray(), 0);*/ - - int sizeLimit = 65000; // constant strings are limited to 64K, and I'm not brave enough to push right up to the limit - if (data.length() < sizeLimit) { - return JavaField.newField(Modifier.PRIVATE | Modifier.STATIC, "java.lang.String", "$jaxxObjectDescriptor", TypeManager.getJavaCode(data)); - } else { - StringBuffer initializer = new StringBuffer(); - for (int i = 0; i < data.length(); i += sizeLimit) { - String name = "$jaxxObjectDescriptor" + i; - javaFile.addField(new JavaField(Modifier.PRIVATE | Modifier.STATIC, "java.lang.String", name, - TypeManager.getJavaCode(data.substring(i, Math.min(i + sizeLimit, data.length()))))); - if (initializer.length() > 0) { - initializer.append(" + "); - } - initializer.append("String.valueOf(").append(name).append(")"); - } - return JavaField.newField(Modifier.PRIVATE | Modifier.STATIC, "java.lang.String", "$jaxxObjectDescriptor", initializer.toString()); - } - } catch (IOException e) { - throw new RuntimeException("Internal error: can't-happen error", e); - } - } - - /*---------------------------------------------------------------------------------*/ - /*-- Create methods ---------------------------------------------------------------*/ - /*---------------------------------------------------------------------------------*/ - protected void addPropertyChangeSupport(CompiledObject root, JavaFile javaFile) { - ClassDescriptor currentClass = root.getObjectClass(); - MethodDescriptor firePropertyChange = null; - while (firePropertyChange == null && currentClass != null) { - try { - firePropertyChange = currentClass.getDeclaredMethodDescriptor("firePropertyChange", ClassDescriptorLoader.getClassDescriptor(String.class), - ClassDescriptorLoader.getClassDescriptor(Object.class), - ClassDescriptorLoader.getClassDescriptor(Object.class)); - - } catch (NoSuchMethodException e) { - currentClass = currentClass.getSuperclass(); - } - } - - int modifiers = firePropertyChange != null ? firePropertyChange.getModifiers() : 0; - if (Modifier.isPublic(modifiers)) { - // we have all the support we need - } - if (Modifier.isProtected(modifiers)) { - // there is property change support but the firePropertyChange method is protected - javaFile.addMethod(FIRE_PROPERTY_CHANGE_METHOD); - } else { - // either no support at all or firePropertyChange isn't accessible - javaFile.addField(PROPERTY_CHANGE_SUPPORT_FIELD); - javaFile.addMethod(GET_PROPERTY_CHANGE_SUPPORT_METHOD); - javaFile.addMethod(ADD_PROPERTY_CHANGE_SUPPORT_METHOD); - javaFile.addMethod(ADD_PROPERTY_CHANGE_SUPPORT_NAMED_METHOD); - javaFile.addMethod(REMOVE_PROPERTY_CHANGE_SUPPORT_METHOD); - javaFile.addMethod(REMOVE_PROPERTY_CHANGE_SUPPORT_NAMED_METHOD); - javaFile.addMethod(FIRE_PROPERTY_CHANGE_NAMED_METHOD); - } - } - - protected void addEventHandlers(JAXXCompiler compiler, JavaFile javaFile) { - for (Map.Entry<String, Map<ClassDescriptor, List<EventHandler>>> e1 : compiler.getEventHandlers().entrySet()) { - // outer loop is iterating over different objects (well, technically, different Java expressions) - for (Map.Entry<ClassDescriptor, List<EventHandler>> e2 : e1.getValue().entrySet()) { - // iterate over different types of listeners for this particular object (MouseListener, ComponentListener, etc.) - for (EventHandler handler : e2.getValue()) { - // iterate over individual event handlers of a single type - String methodName = compiler.getEventHandlerMethodName(handler); - MethodDescriptor listenerMethod = handler.getListenerMethod(); - if (listenerMethod.getParameterTypes().length != 1) { - throw new CompilerException("Expected event handler " + listenerMethod.getName() + " of class " + handler.getListenerClass() + " to have exactly one argument"); - } - javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC, "void", methodName, handler.getJavaCode(), - new JavaArgument(JAXXCompiler.getCanonicalName(listenerMethod.getParameterTypes()[0]), "event"))); - } - } - } - } - - protected JavaMethod createConstructor(JAXXCompiler compiler, String className, boolean superclassIsJAXXObject) throws CompilerException { - StringBuffer code = new StringBuffer(); - String constructorParams = compiler.getRootObject().getConstructorParams(); - if (constructorParams != null) { - code.append(" super(").append(constructorParams).append(");").append(JAXXCompiler.getLineSeparator()); - } else { - if (superclassIsJAXXObject) { - code.append(" super();").append(JAXXCompiler.getLineSeparator()); - } - } - code.append("$initialize();"); - code.append(JAXXCompiler.getLineSeparator()); - return JavaMethod.newMethod(Modifier.PUBLIC, null, className, code.toString()); - } - - protected JavaMethod createConstructorWithInitialContext(JAXXCompiler compiler, String className, boolean superclassIsJAXXObject) throws CompilerException { - StringBuffer code = new StringBuffer(); - String constructorParams = compiler.getRootObject().getConstructorParams(); - if (constructorParams != null) { - code.append(" super(").append(constructorParams).append(");").append(JAXXCompiler.getLineSeparator()); - } else { - if (superclassIsJAXXObject) { - code.append(" super(parentContext);").append(JAXXCompiler.getLineSeparator()); - } - } - if (!superclassIsJAXXObject) { - code.append("if (parentContext instanceof jaxx.runtime.JAXXInitialContext) {"); - code.append(JAXXCompiler.getLineSeparator()); - code.append(" ((jaxx.runtime.JAXXInitialContext)parentContext).to(this);"); - code.append(JAXXCompiler.getLineSeparator()); - code.append("} else {"); - code.append(JAXXCompiler.getLineSeparator()); - code.append(" setContextValue(parentContext);"); - code.append(JAXXCompiler.getLineSeparator()); - code.append("}"); - code.append(JAXXCompiler.getLineSeparator()); - } - code.append("$initialize();"); - code.append(JAXXCompiler.getLineSeparator()); - return JavaMethod.newMethod(Modifier.PUBLIC, null, className, code.toString(), new JavaArgument("jaxx.runtime.JAXXContext", "parentContext")); - } - - public JavaMethod createInitializer(JAXXCompiler compiler) throws CompilerException { - StringBuffer code = new StringBuffer(); - CompiledObject root = compiler.getRootObject(); - code.append("if (allComponentsCreated || !contextInitialized) {"); - code.append(JAXXCompiler.getLineSeparator()); - code.append(" return;"); - code.append(JAXXCompiler.getLineSeparator()); - code.append("}"); - code.append(JAXXCompiler.getLineSeparator()); - code.append("$objectMap.put(").append(TypeManager.getJavaCode(root.getId())).append(", this);"); - code.append(JAXXCompiler.getLineSeparator()); - - Iterator<CompiledObject> i = compiler.getObjectCreationOrder(); - boolean lastWasMethodCall = false; - while (i.hasNext()) { - CompiledObject object = i.next(); - if (object == root) { - continue; - } - CompiledObjectDecorator decorator = object.getDecorator(); - lastWasMethodCall = decorator.createInitializer(compiler, root, object, code, lastWasMethodCall); - /*if (object != root && !object.isOverride()) { - if (compiler.inlineCreation(object)) { - if (lastWasMethodCall) { - lastWasMethodCall = false; - code.append(JAXXCompiler.getLineSeparator()); - } - code.append(getCreationCode(compiler, object)); - code.append(JAXXCompiler.getLineSeparator()); - } else { - code.append(object.getCreationMethodName()).append("();"); - code.append(JAXXCompiler.getLineSeparator()); - lastWasMethodCall = true; - } - }*/ - } - root.getDecorator().createInitializer(compiler, root, root, code, lastWasMethodCall); - /*String rootCode = root.getInitializationCode(compiler); - if (rootCode != null && rootCode.length() > 0) { - code.append(rootCode); - code.append(JAXXCompiler.getLineSeparator()); - }*/ - code.append(JAXXCompiler.getLineSeparator()); - if (compiler.getInitializer().length() > 0) { - code.append(compiler.getInitializer()); - code.append(JAXXCompiler.getLineSeparator()); - } - code.append("$completeSetup();"); - code.append(JAXXCompiler.getLineSeparator()); - return JavaMethod.newMethod(Modifier.PRIVATE, "void", "$initialize", code.toString()); - } - - protected JavaMethod createCompleteSetupMethod(JAXXCompiler compiler, JavaFile javaFile, StringBuffer initDataBindings) { - StringBuffer code = new StringBuffer(); - code.append("allComponentsCreated = true;"); - code.append(JAXXCompiler.getLineSeparator()); - for (CompiledObject object : compiler.getObjects().values()) { - CompiledObjectDecorator decorator = object.getDecorator(); - code.append(decorator.createCompleteSetupMethod(compiler, object, javaFile, initDataBindings)); - - /*//TC - 20081017 only generate the method if not empty ? - if (object.getId().startsWith("$")) { - code.append(object.getAdditionCode()).append(JAXXCompiler.getLineSeparator()); - } else { - String additionCode = object.getAdditionCode(); - if (additionCode.length() > 0) { - code.append(object.getAdditionMethodName()).append("();").append(JAXXCompiler.getLineSeparator()); - additionCode = "if (!allComponentsCreated) {" + JAXXCompiler.getLineSeparator() + " return;" + JAXXCompiler.getLineSeparator() + "}" + JAXXCompiler.getLineSeparator() + additionCode; - javaFile.addMethod(JavaMethod.newMethod(Modifier.PROTECTED, "void", object.getAdditionMethodName(), additionCode)); - } - }*/ - //code.append(getLineSeparator()); - } - - code.append(initDataBindings); - - if (compiler.getLateInitializer().length() > 0) { - code.append(compiler.getLateInitializer()); - code.append(JAXXCompiler.getLineSeparator()); - } - //TC-20090313 add an extra method after complete setup - MethodDescriptor method = compiler.getScriptMethod("$afterCompleteSetup"); - if (method != null) { - code.append("$afterCompleteSetup();").append(JAXXCompiler.getLineSeparator()); - } - return JavaMethod.newMethod(Modifier.PRIVATE, "void", "$completeSetup", code.toString()); - } - - protected JavaMethod createProcessDataBindingMethod(JAXXCompiler compiler, boolean superclassIsJAXXObject) { - StringBuffer code = new StringBuffer(); - //boolean superclassIsJAXXObject = ClassDescriptorLoader.getClassDescriptor(JAXXObject.class).isAssignableFrom(compiler.getRootObject().getObjectClass()); - // the force parameter forces the update to happen even if it is already in activeBindings. This - // is used on superclass invocations b/c by the time the call gets to the superclass, it is already - // marked active and would otherwise be skipped - if (compiler.getProcessDataBinding().length() > 0) { - code.append(" if (!$force && $activeBindings.contains($dest)) { "); - code.append(JAXXCompiler.getLineSeparator()); - code.append(" return;"); - code.append(JAXXCompiler.getLineSeparator()); - code.append("}"); - code.append(JAXXCompiler.getLineSeparator()); - code.append("$activeBindings.add($dest);"); - code.append(JAXXCompiler.getLineSeparator()); - code.append("try {"); - code.append(JAXXCompiler.getLineSeparator()); - if (compiler.getProcessDataBinding().length() > 0) { - code.append(compiler.getProcessDataBinding().toString()); - //code.append(JAXXCompiler.getLineSeparator()); - } - if (superclassIsJAXXObject) { - code.append(" else {"); - code.append(JAXXCompiler.getLineSeparator()); - code.append(" super.processDataBinding($dest, true);"); - code.append(JAXXCompiler.getLineSeparator()); - code.append(" }"); - code.append(JAXXCompiler.getLineSeparator()); - } - code.append("} finally {"); - code.append(JAXXCompiler.getLineSeparator()); - code.append(" $activeBindings.remove($dest);"); - code.append(JAXXCompiler.getLineSeparator()); - code.append("}"); - code.append(JAXXCompiler.getLineSeparator()); - } else if (superclassIsJAXXObject) { - code.append("super.processDataBinding($dest, true);"); - code.append(JAXXCompiler.getLineSeparator()); - } - return JavaMethod.newMethod(Modifier.PUBLIC, "void", "processDataBinding", code.toString(), - new JavaArgument("String", "$dest"), new JavaArgument("boolean", "$force")); - } - - /*---------------------------------------------------------------------------------*/ - /*-- Create methods code ----------------------------------------------------------*/ - /*---------------------------------------------------------------------------------*/ - - /* protected String getCreationCode(JAXXCompiler compiler, CompiledObject object) throws CompilerException { - if (object instanceof ScriptInitializer) { - return object.getInitializationCode(compiler); - } - CompiledObjectDecorator decorator = object.getDecorator(); - String result = decorator.getCreationCode(compiler, object); - return result;*/ - /*StringBuffer result = new StringBuffer(); - result.append(object.getId()); - result.append(" = "); - if (object.isJavaBean() && object.getJavaBeanInitCode() != null) { - result.append(object.getJavaBeanInitCode()).append(";"); - } else { - String constructorParams = object.getConstructorParams(); - if (constructorParams != null) { - //TC - 20081017 compiledObject can have generics - result.append(" new ").append(JAXXCompiler.getCanonicalName(object)).append("(").append(constructorParams).append(");"); - //result.append("(").append(getCanonicalName(object.getObjectClass())).append(") new ").append(getCanonicalName(object.getObjectClass())).append("(").append(constructorParams).append(");"); - } else { - //TC - 20081017 compiledObject can have generics - result.append("new ").append(JAXXCompiler.getCanonicalName(object)).append("();"); - } - } - result.append(JAXXCompiler.getLineSeparator()); - String initCode = object.getInitializationCode(compiler); - if (initCode != null && initCode.length() > 0) { - result.append(initCode); - } - result.append("$objectMap.put(").append(TypeManager.getJavaCode(object.getId())).append(", ").append(object.getId()).append(");"); - - return result.toString();*/ -// } -} Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXProfile.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXProfile.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXProfile.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ package jaxx.compiler; import java.util.Arrays; @@ -5,7 +25,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.SortedMap; -import jaxx.compiler.JAXXCompilerLaunchor.LifeCycle; +import jaxx.compiler.JAXXEngine.LifeCycle; import org.nuiton.util.StringUtil; /** @@ -150,10 +170,11 @@ ProfileResult cfp = newProfileResult(LifeCycle.compile_first_pass); ProfileResult csp = newProfileResult(LifeCycle.compile_second_pass); ProfileResult ssp = newProfileResult(LifeCycle.stylesheet_pass); + ProfileResult fp = newProfileResult(LifeCycle.finalize_compiler); ProfileResult gp = newProfileResult(LifeCycle.generate_pass); - ProfileResult total = newProfileResult(cfp, csp, ssp, gp); + ProfileResult total = newProfileResult(cfp, csp, ssp,fp, gp); - String reportPattern = "\n|%1$-" + maxLength + "s|%2$15s|%3$15s|%4$15s|%5$15s|%6$15s|"; + String reportPattern = "\n|%1$-" + maxLength + "s|%2$15s|%3$15s|%4$15s|%5$15s|%6$15s|%7$15s|"; char[] tmpC = new char[maxLength]; Arrays.fill(tmpC, '-'); @@ -163,32 +184,33 @@ "---------------", "---------------", "---------------", + "---------------", "---------------"); buffer.append(line); buffer.append(String.format(reportPattern, "(files / stats) \\ passes", - "compile round 1", "compile round 2", "stylesheet", "generation", "all passes")); + "compile round 1", "compile round 2", "stylesheet", "finalize", "generation", "all passes")); buffer.append(line); // affiche les temps de tous les fichiers en temp total croissant for (Long l : total.times) { JAXXCompiler c = total.getCompiler(l); - printReportLine(buffer, reportPattern, c.getOutputClassName(), cfp.getTime(c), csp.getTime(c), ssp.getTime(c), gp.getTime(c), total.getTime(c)); + printReportLine(buffer, reportPattern, c.getOutputClassName(), cfp.getTime(c), csp.getTime(c), ssp.getTime(c), fp.getTime(c), gp.getTime(c), total.getTime(c)); } buffer.append(line); if (compilers.size() > 1) { - printReportLine(buffer, reportPattern, "total (" + compilers.size() + " files)", cfp.total, csp.total, ssp.total, gp.total, total.total); + printReportLine(buffer, reportPattern, "total (" + compilers.size() + " files)", cfp.total, csp.total, ssp.total, fp.total, gp.total, total.total); buffer.append(line); - printReportLine2(buffer, reportPattern, "min", cfp.min, csp.min, ssp.min, gp.min, total.min); - printReportLine2(buffer, reportPattern, "max", cfp.max, csp.max, ssp.max, gp.max, total.max); - printReportLine(buffer, reportPattern, "average", cfp.average, csp.average, ssp.average, gp.average, total.average); + printReportLine2(buffer, reportPattern, "min", cfp.min, csp.min, ssp.min, fp.min, gp.min, total.min); + printReportLine2(buffer, reportPattern, "max", cfp.max, csp.max, ssp.max, fp.max, gp.max, total.max); + printReportLine(buffer, reportPattern, "average", cfp.average, csp.average, ssp.average, fp.average, gp.average, total.average); buffer.append(line); } cfp.clear(); @@ -201,21 +223,23 @@ } public static final String TIME_PATTERN = "%1$9s - %2$2d%%"; - protected void printReportLine(StringBuilder buffer, String reportPattern, String label, long firstPassCounter, long secondPassCounter, long cssCounter, long generatorCounter, long totalCounter) { + protected void printReportLine(StringBuilder buffer, String reportPattern, String label, long firstPassCounter, long secondPassCounter, long cssCounter, long finalizeCounter, long generatorCounter, long totalCounter) { float percentCFP = ((float) firstPassCounter / totalCounter) * 100; float percentCSP = ((float) secondPassCounter / totalCounter) * 100; float percentCSSP = ((float) cssCounter / totalCounter) * 100; + float percentFP = ((float) finalizeCounter / totalCounter) * 100; float percentGP = ((float) generatorCounter / totalCounter) * 100; String strCFP = String.format(TIME_PATTERN, StringUtil.convertTime(firstPassCounter), (int) percentCFP); String strCSP = String.format(TIME_PATTERN, StringUtil.convertTime(secondPassCounter), (int) percentCSP); String strCSSP = String.format(TIME_PATTERN, StringUtil.convertTime(cssCounter), (int) percentCSSP); + String strFP = String.format(TIME_PATTERN, StringUtil.convertTime(finalizeCounter), (int) percentFP); String strGP = String.format(TIME_PATTERN, StringUtil.convertTime(generatorCounter), (int) percentGP); - buffer.append(String.format(reportPattern, label, strCFP, strCSP, strCSSP, strGP, StringUtil.convertTime(totalCounter))); + buffer.append(String.format(reportPattern, label, strCFP, strCSP, strCSSP, strFP, strGP, StringUtil.convertTime(totalCounter))); } - protected void printReportLine2(StringBuilder buffer, String reportPattern, String label, long firstPassCounter, long secondPassCounter, long cssCounter, long generatorCounter, long totalCounter) { - buffer.append(String.format(reportPattern, label, StringUtil.convertTime(firstPassCounter), StringUtil.convertTime(secondPassCounter), StringUtil.convertTime(cssCounter), StringUtil.convertTime(generatorCounter), StringUtil.convertTime(totalCounter))); + protected void printReportLine2(StringBuilder buffer, String reportPattern, String label, long firstPassCounter, long secondPassCounter, long cssCounter, long finalizeCounter, long generatorCounter, long totalCounter) { + buffer.append(String.format(reportPattern, label, StringUtil.convertTime(firstPassCounter), StringUtil.convertTime(secondPassCounter), StringUtil.convertTime(cssCounter), StringUtil.convertTime(finalizeCounter), StringUtil.convertTime(generatorCounter), StringUtil.convertTime(totalCounter))); } protected CompilerEntry getEntry(JAXXCompiler compiler) { Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/JavaArgument.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/JavaArgument.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/JavaArgument.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,86 +0,0 @@ -/* - * Copyright 2006 Ethan Nicholas. All rights reserved. - * Use is subject to license terms. - */ -package jaxx.compiler; - -/** - * Represents an argument to a <code>JavaMethod</code>. - * - * @see JavaMethod - */ -public class JavaArgument { - private String name; - private String type; - private boolean isFinal; - - - /** - * Creates a new <code>JavaArgument</code> with the specified name and type. For example, the method <code>main()</code> - * might have a <code>JavaArgument</code> with a name of <code>"arg"</code> and a type of <code>"java.lang.String[]"</code>. - * - * @param type the argument's type, as it would appear in Java source code - * @param name the argument's name - */ - public JavaArgument(String type, String name) { - this(type, name, false); - } - - - /** - * Creates a new <code>JavaArgument</code> with the specified name, type, and finality. For example, the method <code>main()</code> - * might have a <code>JavaArgument</code> with a name of <code>"arg"</code> and a type of <code>"java.lang.String[]"</code>. The - * <code>isFinal</code> parameter allows the presence of the <code>final</code> keyword on the argument to be controlled. - * - * @param type the argument's type, as it would appear in Java source code - * @param name the argument's name - * @param isFinal <code>true</code> if the argument should be marked final - */ - public JavaArgument(String type, String name, boolean isFinal) { - this.type = type; - this.name = name; - this.isFinal = isFinal; - } - - - /** - * Returns the argument's name. - * - * @return the name of the argument - */ - public String getName() { - return name; - } - - - /** - * Returns the argument's type as it would be represented in Java source code. - * - * @return the argument's type - */ - public String getType() { - return type; - } - - - /** - * Returns <code>true</code> if the <code>final</code> keyword should appear before the argument. - * - * @return <code>true</code> if the argument is final - */ - public boolean isFinal() { - return isFinal; - } - - - /** - * Returns the Java source code for this argument. - * - * @return the Java source code for this argument - */ - @Override - public String toString() { - String result = type + ' ' + name; - return isFinal ? "final " + result : result; - } -} \ No newline at end of file Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/JavaField.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/JavaField.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/JavaField.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,187 +0,0 @@ -/* - * Copyright 2006 Ethan Nicholas. All rights reserved. - * Use is subject to license terms. - */ -package jaxx.compiler; - -import java.lang.reflect.Modifier; -import java.util.Comparator; - -/** - * Represents a field in a Java source file being generated for output. <code>JavaFields</code> are created - * and added to a {@link JavaFile}, which can then output Java source code. - */ -public class JavaField implements Comparable<JavaField> { - - private int modifiers; - private String type; - private String name; - private String initializer; - - - /** - * Constructs a new <code>JavaField</code>. The <code>modifiers</code> parameter is a bit mask of the - * constants from {@link java.lang.reflect.Modifier}, and the <code>type</code> of the field should be - * represented as it would appear in Java source code. - * - * @param modifiers the modifier keywords that should appear as part of the field's declaration - * @param type the type of the field as it would appear in Java source code - * @param name the field's name - */ - public JavaField(int modifiers, String type, String name) { - this(modifiers, type, name, null); - } - - - /** - * Constructs a new <code>JavaField</code>. The <code>modifiers</code> parameter is a bit mask of the - * constants from <code>java.lang.reflect.Modifier</code>, and the <code>type</code> of the field should be - * represented as it would appear in Java source code. The <code>initializer</code> is the initial - * value of the field as it would appear in Java source code, or <code>null</code> to leave it at the - * default value. - * - * @param modifiers the modifier keywords that should appear as part of the field's declaration - * @param type the type of the field as it would appear in Java source code - * @param name the field's name - * @param initializer the initial value of the field, as it would appear in Java source code - */ - public JavaField(int modifiers, String type, String name, String initializer) { - this.modifiers = modifiers; - this.type = type; - this.name = name; - this.initializer = initializer; - } - - - /** - * Returns a bit mask describing the modifier keywords which should appear as part of this field's - * declaration. See <code>java.lang.reflect.Modifier</code> for more information on decoding this - * field. - * - * @return the modifier bit mask - */ - public int getModifiers() { - return modifiers; - } - - - /** - * Returns the field's name. - * - * @return the field's name - */ - public String getName() { - return name; - } - - - /** - * Returns the field's type, as it would be represented in Java source code. - * - * @return the field's type - */ - public String getType() { - return type; - } - - - /** - * Returns the Java source code for this field. - * - * @param lineSeparator line separator - * @return the Java source code for this field - */ - public String toString(String lineSeparator) { - StringBuffer result = new StringBuffer(); - result.append(JavaFile.getModifiersText(modifiers)); - result.append(type).append(' ').append(name); - if (initializer != null) { - result.append(" = ").append(initializer); - } - result.append(';').append(lineSeparator); - return result.toString(); - } - - public int compareTo(JavaField o) { - return COMPARATOR.compare(this, o); - } - - public static final Comparator<JavaField> COMPARATOR = new Comparator<JavaField>() { - - public int compare(JavaField o1, JavaField o2) { - - int result; - if ((result = compareStatic(o1, o2)) != 0) { - return result; - } - - // data sources must be on the last after all other fields - if ((result = compareDataSource(o1, o2)) != 0) { - return result; - } - - // same static - if ((result = compareVisibility(o1, o2)) != 0) { - return result; - } - // same visibility, test name - return o1.name.compareTo(o2.name); - } - - public int compareStatic(JavaField o1, JavaField o2) { - // first comparator modifiers : static always before none static - if (Modifier.isStatic(o1.modifiers) && !Modifier.isStatic(o2.modifiers)) { - return -1; - } - if (!Modifier.isStatic(o1.modifiers) && Modifier.isStatic(o2.modifiers)) { - return 1; - } - return 0; - } - - public int compareDataSource(JavaField o1, JavaField o2) { - // first comparator modifiers : static always before none static - if (o1.name.startsWith("$DataSource") && !o2.name.startsWith("$DataSource")) { - return 1; - } - if (!o1.name.startsWith("$DataSource") && o2.name.startsWith("$DataSource")) { - return -1; - } - return 0; - } - - public int compareVisibility(JavaField o1, JavaField o2) { - // first comparator modifiers : static always before none static - if (!Modifier.isPublic(o1.modifiers) && Modifier.isPublic(o2.modifiers)) { - return 1; - } - - if (Modifier.isPublic(o1.modifiers) && !Modifier.isPublic(o2.modifiers)) { - return -1; - } - - if (Modifier.isProtected(o1.modifiers) && !Modifier.isProtected(o2.modifiers)) { - return -1; - } - if (!Modifier.isProtected(o1.modifiers) && Modifier.isProtected(o2.modifiers)) { - return 1; - } - - if (Modifier.isPrivate(o1.modifiers) && !Modifier.isPrivate(o2.modifiers)) { - return -1; - } - if (!Modifier.isPrivate(o1.modifiers) && Modifier.isPrivate(o2.modifiers)) { - return 1; - } - return 0; - } - }; - - public static JavaField newField(int modifiers, String returnType, String name) { - return newField(modifiers, returnType, name, null); - } - - public static JavaField newField(int modifiers, String returnType, String name, String initializer) { - return new JavaField(modifiers, returnType, name, initializer); - } -} \ No newline at end of file Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/JavaFile.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/JavaFile.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/JavaFile.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,344 +0,0 @@ -/* - * Copyright 2006 Ethan Nicholas. All rights reserved. - * Use is subject to license terms. - */ -package jaxx.compiler; - -import jaxx.compiler.JavaMethod.MethodOrder; - -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.EnumMap; -import java.util.List; -import java.util.Map.Entry; - -/** - * A Java source file being generated for output. Once the class is completely initialized, use the - * {@link #toString} method to generate source code for it. - */ -public class JavaFile { - - protected static final String GETTER_PATTERN = "return %1$s;"; - - protected static final String BOOLEAN_GETTER_PATTERN = "return %1$s !=null && %1$s;"; - - protected static final String SETTER_PATTERN = "%1$s oldValue = this.%2$s;\nthis.%2$s = newValue;\nfirePropertyChange(\"%2$s\", oldValue, newValue);"; - - private int modifiers; - private String className; - private List<String> imports = new ArrayList<String>(); - private List<JavaField> fields = new ArrayList<JavaField>(); - private List<JavaMethod> methods = new ArrayList<JavaMethod>(); - private List<JavaFile> innerClasses = new ArrayList<JavaFile>(); - private String superClass; - private List<String> interfaces; - private StringBuffer rawBodyCode = new StringBuffer(); - private boolean superclassIsJAXXObject; - private boolean abstractClass; - private String genericType; - private String superGenericType; - - - public JavaFile() { - } - - - public JavaFile(int modifiers, String className, String superClass) { - this(modifiers, className, superClass, null); - } - - - public JavaFile(int modifiers, String className, String superClass, List<String> interfaces) { - this.modifiers = modifiers; - this.className = className; - this.superClass = superClass; - this.interfaces = interfaces; - } - - - public void addImport(String importString) { - imports.add(importString); - } - - public void addImport(Class importString) { - imports.add(importString.getName()); - } - - - public String[] getImports() { - return imports.toArray(new String[imports.size()]); - } - - - public int getModifiers() { - return modifiers; - } - - - public void setModifiers(int modifiers) { - this.modifiers = modifiers; - } - - - public String getClassName() { - return className; - } - - - public void setClassName(String className) { - this.className = className; - } - - - public String getSuperClass() { - return superClass; - } - - - public void setSuperClass(String superClass) { - this.superClass = superClass; - } - - - public List<String> getInterfaces() { - if (interfaces == null) { - interfaces = new ArrayList<String>(); - } - return interfaces; - } - - - public void setInterfaces(List<String> interfaces) { - this.interfaces = interfaces; - } - - public void setGenericType(String genericType) { - this.genericType = genericType; - } - - public void addMethod(JavaMethod method) { - methods.add(method); - } - - - public JavaMethod[] getMethods() { - return methods.toArray(new JavaMethod[methods.size()]); - } - - public void addField(JavaField field) { - addField(field, false); - } - - public void addField(JavaField field, boolean javaBean) { - addSimpleField(field); - String id = field.getName(); - String capitalizedName = org.apache.commons.lang.StringUtils.capitalize(id); - // add getter file - String content = String.format(GETTER_PATTERN, id); - addMethod(new JavaMethod( - Modifier.isProtected(field.getModifiers()) ? Modifier.PUBLIC : Modifier.PROTECTED, - field.getType(), "get" + capitalizedName, null, null, content)); - - if (javaBean) { - // add full javabean support - if (Boolean.class.getName().equals(field.getType())) { - content = String.format(BOOLEAN_GETTER_PATTERN, id); - addMethod(new JavaMethod(Modifier.PUBLIC, field.getType(), "is" + capitalizedName, null, null, content)); - } - content = String.format(SETTER_PATTERN, field.getType(), id); - JavaArgument arg = new JavaArgument(field.getType(), "newValue"); - addMethod(new JavaMethod(Modifier.PUBLIC, "void", "set" + capitalizedName, new JavaArgument[]{arg}, null, content)); - } - } - - public void addSimpleField(JavaField field) { - fields.add(field); - } - - - public JavaField[] getFields() { - return fields.toArray(new JavaField[fields.size()]); - } - - - public static String addIndentation(String source, int indentation, String lineSeparator) { - return indent(source, indentation, false, lineSeparator); - } - - - public static String setIndentation(String source, int indentation, String lineSeparator) { - return indent(source, indentation, true, lineSeparator); - } - - - public static String indent(String source, int indentation, boolean trim, String lineSeparator) { - if (trim) { - source = source.trim(); - } - char[] spaces = new char[indentation]; - Arrays.fill(spaces, ' '); - StringBuffer result = new StringBuffer(); - String[] lines = source.split(System.getProperty("line.separator") + "|\n"); - for (int i = 0; i < lines.length; i++) { - if (i > 0) { - result.append(lineSeparator); - } - result.append(spaces); - result.append(trim ? lines[i].trim() : lines[i]); - } - return result.toString(); - } - - - public void addBodyCode(String bodyCode) { - rawBodyCode.append(bodyCode); - } - - - public String getClassBody(String lineSeparator) { - StringBuffer result = new StringBuffer(); - if (fields.size() > 0) { - java.util.Collections.sort(fields); // sort fields - - for (JavaField field : fields) { - result.append(addIndentation(field.toString(lineSeparator), 4, lineSeparator)); - result.append(lineSeparator); - } - - result.append(lineSeparator); - } - - if (rawBodyCode.length() > 0) { - result.append(addIndentation("/* begin raw body code */\n", 4, lineSeparator)); - String s = rawBodyCode.toString(); - if (!s.startsWith(lineSeparator)) { - result.append(lineSeparator); - } - result.append(addIndentation(s, 4, lineSeparator)); - result.append(lineSeparator); - result.append(addIndentation("/* end raw body code */", 4, lineSeparator)); - result.append(lineSeparator); - } - - for (JavaFile innerClass : innerClasses) { - result.append(addIndentation(innerClass.toString(), 4, lineSeparator)); - result.append(lineSeparator).append(lineSeparator); - } - - EnumMap<MethodOrder, List<JavaMethod>> map = JavaMethod.getSortedMethods(methods); - for (Entry<MethodOrder, List<JavaMethod>> entry : map.entrySet()) { - List<JavaMethod> list = entry.getValue(); - entry.getKey().generate(result, list, lineSeparator); - list.clear(); - } - map.clear(); - - return result.toString(); - } - - - public String getClassDefinition(String lineSeparator) { - StringBuffer result = new StringBuffer(); - result.append(getModifiersText(modifiers)); - if (abstractClass) { - result.append("abstract "); - } - result.append("class "); - result.append(className.substring(className.lastIndexOf(".") + 1)); - if (genericType != null) { - result.append('<').append(genericType).append('>'); - } - result.append(" extends "); - result.append(superClass); - if (superGenericType != null) { - result.append('<').append(superGenericType).append('>'); - } - if (interfaces != null && !interfaces.isEmpty()) { - result.append(" implements ").append(interfaces.get(0)); - for (int i = 1; i < interfaces.size(); i++) { - /*if (i > 0) { - result.append(", "); - }*/ - result.append(", ").append(interfaces.get(i)); - } - } - result.append(" {"); - result.append(lineSeparator); - result.append(getClassBody(lineSeparator)); - result.append("}"); - return result.toString(); - } - - - public static String getModifiersText(int modifiers) { - if (modifiers == 0) { - return ""; - } else { - return Modifier.toString(modifiers) + ' '; - } - } - - - /** - * Returns the Java source code for this class. - * - * @param lineSeparator line separator - * @return a complete Java file for this class - */ - public String toString(String lineSeparator) { - StringBuffer result = new StringBuffer(); - if (className.indexOf(".") != -1) { - result.append("package ").append(className.substring(0, className.lastIndexOf("."))).append(";"); - result.append(lineSeparator); - result.append(lineSeparator); - } - - if (imports.size() > 0) { - for (String anImport : imports) { - result.append("import "); - result.append(anImport); - result.append(';'); - result.append(lineSeparator); - } - result.append(lineSeparator); - } - - result.append(getClassDefinition(lineSeparator)); - return result.toString(); - } - - public void addInterface(String canonicalName) { - if (interfaces == null || !interfaces.contains(canonicalName)) { - getInterfaces().add(canonicalName); - } - } - - public void addInterfaces(String[] canonicalNames) { - if (canonicalNames == null) { - return; - } - for (String canonicalName : canonicalNames) { - if (interfaces == null || !interfaces.contains(canonicalName)) { - getInterfaces().add(canonicalName); - } - } - } - - public boolean isSuperclassIsJAXXObject() { - return superclassIsJAXXObject; - } - - public void setSuperclassIsJAXXObject(boolean superclassIsJAXXObject) { - this.superclassIsJAXXObject = superclassIsJAXXObject; - } - - public void setAbstractClass(boolean abstractClass) { - this.abstractClass = abstractClass; - } - - - public void setSuperGenericType(String superGenericType) { - this.superGenericType = superGenericType; - } -} \ No newline at end of file Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/JavaMethod.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/JavaMethod.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/JavaMethod.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,499 +0,0 @@ -/* - * Copyright 2006 Ethan Nicholas. All rights reserved. - * Use is subject to license terms. - */ -package jaxx.compiler; - -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.EnumMap; -import java.util.EnumSet; -import java.util.Iterator; -import java.util.List; - -/** - * Represents a method in a Java source file being generated for output. <code>JavaMethods</code> are created - * and added to a {@link JavaFile}, which can then output Java source code. In addition to normal methods, a - * <code>JavaMethod</code> can represent a constructor -- constructors should be named after their containing - * classes and have a return type of <code>null</code>. - */ -public class JavaMethod implements Comparable<JavaMethod> { - private int modifiers; - private String returnType; - private String name; - private JavaArgument[] arguments; - private String[] exceptions; - private StringBuffer bodyCode; - - - /** - * Constructs a new no-argument <code>JavaMethod</code> which throws no checked exceptions. The - * <code>modifiers</code> parameter is a bit mask of the constants from {@link java.lang.reflect.Modifier}, - * and the <code>returnType</code> of the method should be represented as it would appear in Java source - * code (<code>null</code> for a constructor). The method body is initially empty. - * - * @param modifiers the modifier keywords that should appear as part of the method's declaration - * @param returnType the return type of the method as it would appear in Java source code - * @param name the method's name - * @see #appendBodyCode - */ - //public JavaMethod(int modifiers, String returnType, String name) { - // this(modifiers, returnType, name, null); - //} - - - /** - * Constructs a new <code>JavaMethod</code> which throws no checked exceptions. The <code>modifiers</code> - * parameter is a bit mask of the constants from {@link java.lang.reflect.Modifier}, and the - * <code>returnType</code> of the method should be represented as it would appear in Java source code - * (<code>null</code> for a constructor). The method body is initially empty. - * - * @param modifiers the modifier keywords that should appear as part of the method's declaration - * @param returnType the return type of the method as it would appear in Java source code - * @param name the method's name - * @param arguments the method's arguments - * @see #appendBodyCode - */ - //public JavaMethod(int modifiers, String returnType, String name, JavaArgument[] arguments) { - // this(modifiers, returnType, name, arguments, null); - //} - - - /** - * Constructs a new <code>JavaMethod</code>. The <code>modifiers</code> parameter is a bit mask of the - * constants from {@link java.lang.reflect.Modifier}, and the <code>returnType</code> and <code>exceptions</code> - * of the method should be represented as they would appear in Java source code (<code>null</code> for a - * constructor). The method body is initially empty. - * - * @param modifiers the modifier keywords that should appear as part of the method's declaration - * @param returnType the return type of the method as it would appear in Java source code - * @param name the method's name - * @param arguments the method's arguments - * @param exceptions a list of exceptions the methods can throw, as they would be represented in Java source code - * @see #appendBodyCode - */ - //public JavaMethod(int modifiers, String returnType, String name, JavaArgument[] arguments, String[] exceptions) { - // this(modifiers, returnType, name, arguments, exceptions, null); - //} - - - /** - * Constructs a new <code>JavaMethod</code> containing the specified body code. The <code>modifiers</code> parameter - * is a bit mask of the constants from {@link java.lang.reflect.Modifier}, and the <code>returnType</code> and - * <code>exceptions</code> of the method should be represented as they would appear in Java source code (<code>null</code> - * for a constructor). The method body is initially empty. - * - * @param modifiers the modifier keywords that should appear as part of the method's declaration - * @param returnType the return type of the method as it would appear in Java source code - * @param name the method's name - * @param arguments the method's arguments - * @param exceptions a list of exceptions the methods can throw, as they would be represented in Java source code - * @param bodyCode Java source code which should appear in the method body - */ - public JavaMethod(int modifiers, String returnType, String name, JavaArgument[] arguments, String[] exceptions, String bodyCode) { - this.modifiers = modifiers; - this.returnType = returnType; - this.name = name; - this.arguments = arguments; - this.exceptions = exceptions; - this.bodyCode = new StringBuffer(bodyCode != null ? bodyCode : ""); - } - - - /** - * Returns a bit mask describing the modifier keywords which should appear as part of this method's - * declaration. See <code>java.lang.reflect.Modifier</code> for more information on decoding this - * field. - * - * @return the modifier bit mask - */ - public int getModifiers() { - return modifiers; - } - - - /** - * Returns the method's return type, as it would be represented in Java source code. - * - * @return the method's return type - */ - public String getReturnType() { - return returnType; - } - - - /** - * Returns the method's name. - * - * @return the method's name - */ - public String getName() { - return name; - } - - - /** - * Returns a list of the method's arguments. - * - * @return the method's arguments - */ - public JavaArgument[] getArguments() { - return arguments; - } - - - /** - * Returns a list of exceptions the method can throw. - * - * @return the method's exceptions - */ - public String[] getExceptions() { - return exceptions; - } - - - /** - * Returns the Java source code for the method's body. - * - * @return the method's body code - */ - public String getBodyCode() { - return bodyCode.toString(); - } - - - /** - * Appends additional code to the method's body. - * - * @param extraCode Java source code to append to the method's body - * @param lineSeparator line separator - */ - public void appendBodyCode(String extraCode, String lineSeparator) { - if (extraCode.length() == 0) { - return; - } - if (bodyCode.length() > 0 && !bodyCode.toString().endsWith(lineSeparator)) { - bodyCode.append(lineSeparator); - } - bodyCode.append(extraCode); - } - - - /** - * Returns the Java source code for this method. - * - * @param lineSeparator line separator - * @return the Java source code for this method - */ - public String toString(String lineSeparator) { - StringBuffer result = new StringBuffer(); - result.append(JavaFile.getModifiersText(modifiers)); - if (returnType != null) { - result.append(returnType); - result.append(' '); - } - result.append(name); - result.append('('); - if (arguments != null) { - for (int i = 0; i < arguments.length; i++) { - if (i > 0) { - result.append(", "); - } - result.append(arguments[i].toString()); - } - } - result.append(") {"); - result.append(lineSeparator); - if (bodyCode != null) { - String formattedBodyCode = JavaFile.addIndentation(bodyCode.toString().trim(), 4, lineSeparator); - if (formattedBodyCode.length() > 0) { - result.append(formattedBodyCode); - result.append(lineSeparator); - } - } - result.append("}"); - return result.toString(); - } - - public int compareTo(JavaMethod o) { - return COMPARATOR.compare(this, o); - } - - public static JavaMethod newMethod(int modifiers, String returnType, String name, String initializer, String[] exceptions, JavaArgument... arguments) { - return new JavaMethod(modifiers, returnType, name, arguments, exceptions, initializer); - } - - public static JavaMethod newMethod(int modifiers, String returnType, String name, String initializer, JavaArgument... arguments) { - return newMethod(modifiers, returnType, name, initializer, new String[0], arguments); - } - - public enum MethodOrder { - - statics(Modifier.STATIC, "/*---------------------------------------------------------------------------------*/\n" + - "/*-- Statics methods --------------------------------------------------------------*/\n" + - "/*---------------------------------------------------------------------------------*/") { - }, - - constructors(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" + - "/*-- Constructors -----------------------------------------------------------------*/\n" + - "/*---------------------------------------------------------------------------------*/") { - public boolean accept(JavaMethod method) { - return method.returnType == null; - } - }, - - JAXXObject(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" + - "/*-- JAXXObject implementation ----------------------------------------------------*/\n" + - "/*---------------------------------------------------------------------------------*/") { - private List<String> methods = Arrays.asList("applyDataBinding", "firePropertyChange", "getObjectById", "get$objectMap", "processDataBinding", "removeDataBinding"); - - public boolean accept(JavaMethod method) { - return methods.contains(method.name); - } - }, - - JAXXContext(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" + - "/*-- JAXXContext implementation ---------------------------------------------------*/\n" + - "/*---------------------------------------------------------------------------------*/") { - private List<String> methods = Arrays.asList("getContextValue", "getDelegateContext", "getParentContainer", "removeContextValue", "setContextValue"); - public boolean accept(JavaMethod method) { - return methods.contains(method.name); - } - }, - - JAXXValidation(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" + - "/*-- JAXXValidation implementation ------------------------------------------------*/\n" + - "/*---------------------------------------------------------------------------------*/") { - private List<String> methods = Arrays.asList("getValidator", "getValidatorIds"); - - public boolean accept(JavaMethod method) { - return methods.contains(method.name); - } - }, - - events(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" + - "/*-- Event methods ----------------------------------------------------------------*/\n" + - "/*---------------------------------------------------------------------------------*/") { - public boolean accept(JavaMethod method) { - return (method.name.startsWith("do") && method.name.indexOf("__") > -1); - } - }, - - publicGetters(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" + - "/*-- public acessor methods -------------------------------------------------------*/\n" + - "/*---------------------------------------------------------------------------------*/") { - public boolean accept(JavaMethod method) { - return (method.name.startsWith("get") || method.name.startsWith("is")); - } - }, - - publicSetters(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" + - "/*-- public mutator methods -------------------------------------------------------*/\n" + - "/*---------------------------------------------------------------------------------*/") { - public boolean accept(JavaMethod method) { - return (method.name.startsWith("set")); - } - }, - - otherPublic(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" + - "/*-- public mutator methods -------------------------------------------------------*/\n" + - "/*---------------------------------------------------------------------------------*/") { - @Override - public boolean accept(int mod) { - return super.accept(mod) && !Modifier.isStatic(mod); - } - }, - - protectedGetters(Modifier.PROTECTED, "/*---------------------------------------------------------------------------------*/\n" + - "/*-- protected acessors methods ---------------------------------------------------*/\n" + - "/*---------------------------------------------------------------------------------*/") { - public boolean accept(JavaMethod method) { - return (method.name.startsWith("get") || method.name.startsWith("is")); - } - }, - - createMethod(Modifier.PROTECTED | Modifier.PRIVATE, "/*---------------------------------------------------------------------------------*/\n" + - "/*-- ui creation methods ----------------------------------------------------------*/\n" + - "/*---------------------------------------------------------------------------------*/") { - public boolean accept(JavaMethod method) { - return method.name.startsWith("create") || method.name.startsWith("add") || - method.name.equals("$completeSetup") || - method.name.equals("$initialize"); - } - }, - - protecteds(Modifier.PROTECTED, "/*---------------------------------------------------------------------------------*/\n" + - "/*-- Other protected methods ------------------------------------------------------*/\n" + - "/*---------------------------------------------------------------------------------*/") { - }, - - packageLocal(0, "/*---------------------------------------------------------------------------------*/\n" + - "/*-- Package methods --------------------------------------------------------------*/\n" + - "/*---------------------------------------------------------------------------------*/") { - @Override - public boolean accept(int mod) { - return !Modifier.isStatic(mod) && !Modifier.isPublic(mod) && !Modifier.isProtected(mod); - }}, - - privates(Modifier.PRIVATE, "/*---------------------------------------------------------------------------------*/\n" + - "/*-- Private methods --------------------------------------------------------------*/\n" + - "/*---------------------------------------------------------------------------------*/") { - }; - - private final String header; - - private int modifier; - - MethodOrder(int modifier, String header) { - this.header = header; - this.modifier = modifier; - } - - public String getHeader() { - return header; - } - - public boolean accept(JavaMethod method) { - return true; - } - - public boolean accept(int mod) { - return (mod & modifier) != 0; - } - - public boolean accept(int mod, JavaMethod method) { - return accept(mod) && accept(method); - } - - public static MethodOrder valueOf(JavaMethod method, int scope) { - for (MethodOrder o : values()) { - if (o.accept(scope, method)) { - return o; - } - } - throw new IllegalArgumentException("could not find a " + MethodOrder.class + " for method " + method); - } - - public void generate(StringBuffer buffer, List<JavaMethod> methods, String lineSeparator) { - if (methods.isEmpty()) { - return; - } - buffer.append(JavaFile.addIndentation(header, 4, lineSeparator)); - buffer.append(lineSeparator).append(lineSeparator); - for (JavaMethod method : methods) { - buffer.append(JavaFile.addIndentation(method.toString(lineSeparator), 4, lineSeparator)); - buffer.append(lineSeparator).append(lineSeparator); - } - } - } - - public static EnumMap<MethodOrder, List<JavaMethod>> getSortedMethods(List<JavaMethod> methods) { - - EnumMap<MethodOrder, List<JavaMethod>> result = new EnumMap<MethodOrder, List<JavaMethod>>(MethodOrder.class); - for (MethodOrder methodOrder : MethodOrder.values()) { - result.put(methodOrder, new ArrayList<JavaMethod>()); - } - - EnumSet<MethodOrder> allConstants = EnumSet.allOf(MethodOrder.class); - List<JavaMethod> allMethods = new ArrayList<JavaMethod>(methods); - int[] scopes = new int[]{Modifier.STATIC, Modifier.PUBLIC, Modifier.PROTECTED, Modifier.PRIVATE}; - for (int scope : scopes) { - EnumSet<MethodOrder> constants = getMethodOrderScope(allConstants, scope); - - Iterator<JavaMethod> itMethods = allMethods.iterator(); - while (itMethods.hasNext()) { - JavaMethod method = itMethods.next(); - for (MethodOrder constant : constants) { - if (constant.accept(method.getModifiers(), method)) { - result.get(constant).add(method); - itMethods.remove(); - break; - } - } - } - constants.clear(); - } - - if (!allMethods.isEmpty()) { - throw new IllegalArgumentException("could not find a " + MethodOrder.class + " for method " + allMethods); - } - - for (MethodOrder methodOrder : MethodOrder.values()) { - // sort methods - java.util.Collections.sort(result.get(methodOrder)); - } - return result; - } - - public static EnumSet<MethodOrder> getMethodOrderScope(EnumSet<MethodOrder> allConstants, int scope) { - EnumSet<MethodOrder> constants = EnumSet.noneOf(MethodOrder.class); - for (MethodOrder order : allConstants) { - if (order.accept(scope)) { - constants.add(order); - } - } - return constants; - } - - public static final Comparator<JavaMethod> COMPARATOR = new Comparator<JavaMethod>() { - - public int compare(JavaMethod o1, JavaMethod o2) { - - /*int result; - if ((result = compareStatic(o1, o2)) != 0) { - return result; - } - if ((result = compareConstructor(o1, o2)) != 0) { - return result; - } - if ((result = compareVisibility(o1, o2)) != 0) { - return result; - }*/ - return o1.name.compareTo(o2.name); - } - - public int compareStatic(JavaMethod o1, JavaMethod o2) { - if (Modifier.isStatic(o1.modifiers) && !Modifier.isStatic(o2.modifiers)) { - return -1; - } - if (!Modifier.isStatic(o1.modifiers) && Modifier.isStatic(o2.modifiers)) { - return 1; - } - return 0; - } - - public int compareConstructor(JavaMethod o1, JavaMethod o2) { - if (o1.returnType == null && o2.returnType != null) { - return -1; - } - if (o1.returnType != null && o2.returnType == null) { - return 1; - } - return 0; - } - - public int compareVisibility(JavaMethod o1, JavaMethod o2) { - if (Modifier.isPublic(o1.modifiers) && !Modifier.isPublic(o2.modifiers)) { - return -1; - } - if (!Modifier.isPublic(o1.modifiers) && Modifier.isPublic(o2.modifiers)) { - return 1; - } - if (Modifier.isProtected(o1.modifiers) && !Modifier.isProtected(o2.modifiers)) { - return -1; - } - if (!Modifier.isProtected(o1.modifiers) && Modifier.isProtected(o2.modifiers)) { - return 1; - } - if (Modifier.isPrivate(o1.modifiers) && !Modifier.isPrivate(o2.modifiers)) { - return -1; - } - if (!Modifier.isPrivate(o1.modifiers) && Modifier.isPrivate(o2.modifiers)) { - return 1; - } - return 0; - } - }; -} \ No newline at end of file Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/ScriptInitializer.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/ScriptInitializer.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/ScriptInitializer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,20 +0,0 @@ -/* - * Copyright 2006 Ethan Nicholas. All rights reserved. - * Use is subject to license terms. - */ -package jaxx.compiler; - -import jaxx.reflect.ClassDescriptorLoader; - -/** - * A dummy CompiledObject which serves to initialize scripted field. This is handled by - * a CompiledObject rather than (say) simply inlining the initialization code in order to - * ensure that the field is initialized in document order. - */ -public class ScriptInitializer extends CompiledObject { - public ScriptInitializer(String initializer, JAXXCompiler compiler) { - super(compiler.getAutoId(ClassDescriptorLoader.getClassDescriptor(ScriptInitializer.class)), - ClassDescriptorLoader.getClassDescriptor(ScriptInitializer.class), compiler, false); - appendInitializationCode(initializer); - } -} \ No newline at end of file Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/ScriptManager.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/ScriptManager.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/ScriptManager.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,336 +0,0 @@ -package jaxx.compiler; - -import jaxx.CompilerException; -import jaxx.parser.JavaParser; -import jaxx.parser.JavaParserTreeConstants; -import jaxx.parser.SimpleNode; -import jaxx.reflect.FieldDescriptor; -import jaxx.reflect.MethodDescriptor; -import jaxx.tags.TagManager; - -import java.io.StringReader; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class ScriptManager { - private JAXXCompiler compiler; - - - ScriptManager(JAXXCompiler compiler) { - this.compiler = compiler; - } - - - /** - * Strips unnecessary curly braces from around the script, generating a warning if they are found. - * - * @param script script to trim - * @return the trimed script - */ - public String trimScript(String script) { - script = script.trim(); - if (script.startsWith("{") && script.endsWith("}")) { - compiler.reportWarning("curly braces are unnecessary for script '" + script + "'"); - script = script.substring(1, script.length() - 1); - } - return script; - } - - - public void checkParse(String script) throws CompilerException { - script = trimScript(script); - JavaParser p = new JavaParser(new StringReader(script)); - while (!p.Line()) { - // ??? - } - } - - - public String preprocessScript(String script) throws CompilerException { - script = trimScript(script); - StringBuffer result = new StringBuffer(); - JavaParser p = new JavaParser(new StringReader(script)); - //JavaParser p = new JavaParser(new StringReader(script + ";")); - while (!p.Line()) { - SimpleNode node = p.popNode(); - if (node != null) { - preprocessScriptNode(node, false); - result.append(node.getText()); - } - } - return result.toString(); - } - - - /** - * Scans through a compound symbol (foo.bar.baz) to identify and compile the JAXX class it refers to, if any. - * - * @param symbol symbol to scan - */ - private void scanCompoundSymbol(String symbol) { - String[] tokens = symbol.split("\\."); - StringBuffer currentSymbol = new StringBuffer(); - for (String token : tokens) { - if (currentSymbol.length() > 0) - currentSymbol.append('.'); - currentSymbol.append(token.trim()); - - String contextClass = TagManager.resolveClassName(currentSymbol.toString(), compiler); - if (contextClass != null) { - compiler.addDependencyClass(contextClass); - } - } - } - - - private void preprocessScriptNode(SimpleNode node, boolean staticContext) throws CompilerException { - // identify static methods and initializers -- we can't fire events statically - if (node.getId() == JavaParserTreeConstants.JJTMETHODDECLARATION) { - if (node.getParent().getChild(0).getText().indexOf("static") != -1) { - staticContext = true; - } - } else if (node.getId() == JavaParserTreeConstants.JJTINITIALIZER) - if (node.getText().trim().startsWith("static")) { - staticContext = true; - } - - int count = node.jjtGetNumChildren(); - for (int i = 0; i < count; i++) { - preprocessScriptNode(node.getChild(i), staticContext); - } - - int id = node.getId(); - if (id == JavaParserTreeConstants.JJTNAME || id == JavaParserTreeConstants.JJTCLASSORINTERFACETYPE) { - scanCompoundSymbol(node.getText()); - } - if (!staticContext) { - String lhs = null; - if (id == JavaParserTreeConstants.JJTASSIGNMENTEXPRESSION || (id == JavaParserTreeConstants.JJTPOSTFIXEXPRESSION && node.jjtGetNumChildren() == 2)) { - lhs = ((SimpleNode) node.jjtGetChild(0)).getText().trim(); - } - else - if (id == JavaParserTreeConstants.JJTPREINCREMENTEXPRESSION || id == JavaParserTreeConstants.JJTPREDECREMENTEXPRESSION) { - lhs = ((SimpleNode) node.jjtGetChild(0)).getText().trim(); - } - if (lhs != null) { - FieldDescriptor[] fields = compiler.getScriptFields(); - for (FieldDescriptor field : fields) { - if (field.getName().equals(lhs)) { - //lhs.substring(lhs.lastIndexOf(".") + 1); - node.firstToken.image = "jaxx.runtime.Util.assignment(" + node.firstToken.image; - String outputClassName = compiler.getOutputClassName(); - node.lastToken.image = node.lastToken.image + ", \"" + lhs + "\", " + outputClassName + ".this)"; - } - } - } - } - } - - - /** - * Examines a Line to determine its real type. As all tokens returned by the parser are Lines, and - * they are just a tiny wrapper around the real node, this method strips off the wrapper layers to identify - * the real type of a node. - * - * @param line line to scan - * @return the line type - */ - private int getLineType(SimpleNode line) { - if (line.jjtGetNumChildren() == 1) { - SimpleNode node = line.getChild(0); - if (node.getId() == JavaParserTreeConstants.JJTBLOCKSTATEMENT) { - if (node.jjtGetNumChildren() == 1) { - return node.getChild(0).getId(); - } - } else - if (node.getId() == JavaParserTreeConstants.JJTCLASSORINTERFACEBODYDECLARATION) { - int id = node.getChild(0).getId(); - if (id == JavaParserTreeConstants.JJTMODIFIERS) { - return node.getChild(1).getId(); - } - if (id == JavaParserTreeConstants.JJTINITIALIZER) { - return id; - } - } - return node.getId(); - } - return JavaParserTreeConstants.JJTLINE; // generic value implying that it's okay to put into the initializer block - } - - - private SimpleNode findExplicitConstructorInvocation(SimpleNode parent) { - if (parent.getId() == JavaParserTreeConstants.JJTEXPLICITCONSTRUCTORINVOCATION) { - return parent; - } - - int count = parent.jjtGetNumChildren(); - for (int i = 0; i < count; i++) { - SimpleNode result = findExplicitConstructorInvocation(parent.getChild(i)); - if (result != null) { - return result; - } - } - return null; - } - - - private void processConstructor(String modifiers, SimpleNode node) { - assert node.getId() == JavaParserTreeConstants.JJTCONSTRUCTORDECLARATION : "expected node to be ConstructorDeclaration, found " + JavaParserTreeConstants.jjtNodeName[node.getId()] + " instead"; - assert node.getChild(0).getId() == JavaParserTreeConstants.JJTFORMALPARAMETERS : "expected node 0 to be FormalParameters, found " + JavaParserTreeConstants.jjtNodeName[node.getChild(1).getId()] + " instead"; - String code = ""; - if (node.getChild(0).jjtGetNumChildren() == 0) { - compiler.reportError("The default no-argument constructor may not be redefined"); - } - else { - SimpleNode explicitConstructorInvocation = findExplicitConstructorInvocation(node); - if (explicitConstructorInvocation == null || explicitConstructorInvocation.getText().trim().startsWith("super(")) { - code = "$initialize();" + JAXXCompiler.getLineSeparator(); - if (explicitConstructorInvocation == null) { - node.getChild(1).firstToken.image = node.getChild(1).firstToken.image; - } - else { - explicitConstructorInvocation.lastToken.image += code; - } - } - } - - compiler.appendBodyCode(modifiers + " "+ node.getText().substring(0,node.getText().length()-1) + code + "}"); - //compiler.bodyCode.append(";\n"); - } - - - private void scanScriptNode(SimpleNode node) throws CompilerException { - int nodeType = getLineType(node); - if (nodeType == JavaParserTreeConstants.JJTIMPORTDECLARATION) { // have to handle imports early so the preprocessing takes them into account - String text = node.getChild(0).getText().trim(); - if (text.startsWith("import")) { - text = text.substring("import".length()).trim(); - } - if (text.endsWith(";")) { - text = text.substring(0, text.length() - 1); - } - compiler.addImport(text); - } - - preprocessScriptNode(node, false); - - if (nodeType == JavaParserTreeConstants.JJTIMPORTDECLARATION) { - // do nothing, already handled above - } else if (nodeType == JavaParserTreeConstants.JJTMETHODDECLARATION) { - String returnType = null; - String name = null; - List<String> parameterTypes = new ArrayList<String>(); - //List<String> parameterNames = new ArrayList<String>(); - SimpleNode methodDeclaration = node.getChild(0).getChild(1); - assert methodDeclaration.getId() == JavaParserTreeConstants.JJTMETHODDECLARATION; - for (int i = 0; i < methodDeclaration.jjtGetNumChildren(); i++) { - SimpleNode child = methodDeclaration.getChild(i); - int type = child.getId(); - if (type == JavaParserTreeConstants.JJTRESULTTYPE) { - String rawReturnType = child.getText().trim(); - returnType = TagManager.resolveClassName(rawReturnType, compiler); - // FIXME: this check fails for inner classes defined in this file - //if (returnType == null) - // throw new CompilerException("could not find class '" + rawReturnType + "'"); - } else - if (type == JavaParserTreeConstants.JJTMETHODDECLARATOR) { - name = child.firstToken.image.trim(); - SimpleNode formalParameters = child.getChild(0); - assert formalParameters.getId() == JavaParserTreeConstants.JJTFORMALPARAMETERS; - for (int j = 0; j < formalParameters.jjtGetNumChildren(); j++) - { - SimpleNode parameter = formalParameters.getChild(j); - String rawParameterType = parameter.getChild(1).getText().trim().replaceAll("\\.\\.\\.", "[]"); - String parameterType = TagManager.resolveClassName(rawParameterType, compiler); - // FIXME: this check fails for inner classes defined in this file - //if (parameterType == null) - // throw new CompilerException("could not find class '" + rawParameterType + "'"); - parameterTypes.add(parameterType); - //parameterNames.add(parameter.getChild(2).getText().trim()); - } - } - } - compiler.appendBodyCode(node.getText()); - //compiler.bodyCode.append(";\n"); - compiler.addScriptMethod(new MethodDescriptor(name, Modifier.PUBLIC, returnType, parameterTypes.toArray(new String[parameterTypes.size()]), compiler.getClassLoader())); - } else - if (nodeType == JavaParserTreeConstants.JJTCLASSORINTERFACEDECLARATION || - nodeType == JavaParserTreeConstants.JJTINITIALIZER) { - String str = node.getText().trim(); - if (str.endsWith(";")) { - str+=";"; - } - compiler.appendBodyCode(str); - //compiler.bodyCode.append(";\n"); - } else - if (nodeType == JavaParserTreeConstants.JJTCONSTRUCTORDECLARATION) { - processConstructor(node.getChild(0).getChild(0).getText(), node.getChild(0).getChild(1)); - } else - if (nodeType == JavaParserTreeConstants.JJTLOCALVARIABLEDECLARATION || nodeType == JavaParserTreeConstants.JJTFIELDDECLARATION) { - // the "local" variable declarations in this expression aren't actually local -- they are flagged local - // just because there isn't an enclosing class scope visible to the parser. "Real" local variable - // declarations won't show up here, because they will be buried inside of methods. - String text = node.getText().trim(); - if (!text.endsWith(";")) { - text+=";"; - } - String declaration = text; - int equals = text.indexOf("="); - if (equals != -1) { - declaration = declaration.substring(0, equals); - } - declaration = declaration.trim(); - String[] declarationTokens = declaration.split("\\s"); - boolean isFinal = Arrays.asList(declarationTokens).contains("final"); - boolean isStatic = Arrays.asList(declarationTokens).contains("static"); - String name = declarationTokens[declarationTokens.length - 1]; - if (name.endsWith(";")) { - name = name.substring(0, name.length() - 1).trim(); - } - String className = declarationTokens[declarationTokens.length - 2]; - String type = TagManager.resolveClassName(className, compiler); - compiler.addScriptField(new FieldDescriptor(name, Modifier.PUBLIC, type, compiler.getClassLoader())); // TODO: determine the actual modifiers - if (equals != -1 && !isFinal && !isStatic) { // declare the field in the class body, but wait to actually initialize it - //compiler.bodyCode.append(text.substring(0, equals).trim()); - compiler.appendBodyCode(text.substring(0, equals).trim() + ";"); - String initializer = text.substring(equals + 1).trim(); - if (type.endsWith("[]")) { - initializer = "new " + type + " " + initializer; - } - final String finalInitializer = name + " = " + initializer; - compiler.registerInitializer(new Runnable() { - public void run() { - compiler.registerCompiledObject(new ScriptInitializer(finalInitializer, compiler)); - } - }); - } else { - compiler.appendBodyCode(text); - } - compiler.appendBodyCode("\n"); - //compiler.bodyCode.append(";\n"); - } else { - String text = node.getText().trim(); - if (text.length() > 0) { - if (!text.endsWith(";")) { - text += ";"; - } - compiler.appendInitializerCode(text); - //compiler.initializer.append(";\n"); - } - } - } - - - public void registerScript(String script) throws CompilerException { - JavaParser p = new JavaParser(new StringReader(script)); - //JavaParser p = new JavaParser(new StringReader(script + ";")); - while (!p.Line()) { - SimpleNode node = p.popNode(); - if (node != null) { - scanScriptNode(node); - } - } - } -} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/SwingCompiler.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/SwingCompiler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/SwingCompiler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,73 +0,0 @@ -/* - * Copyright 2006 Ethan Nicholas. All rights reserved. - * Use is subject to license terms. - */ -package jaxx.compiler; - -import jaxx.reflect.ClassDescriptorLoader; -import jaxx.tags.DefaultObjectHandler; - -import java.io.File; - -/** - * Swing JAXX compiler. - * <p/> - * todo finish javadoc - */ -public class SwingCompiler extends JAXXCompiler { - - /*---------------------------------------------------------------------------------*/ - /*-- Constructor methods ----------------------------------------------------------*/ - /*---------------------------------------------------------------------------------*/ - - public SwingCompiler(ClassLoader classLoader) { - super(classLoader, - new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(Object.class)), - "java.awt.*", - "java.awt.event.*", - "java.beans.*", - "java.io.*", - "java.lang.*", - "java.util.*", - "javax.swing.*", - "javax.swing.border.*", - "javax.swing.event.*", - "jaxx.runtime.swing.JAXXButtonGroup", - "jaxx.runtime.swing.HBox", - "jaxx.runtime.swing.VBox", - "jaxx.runtime.swing.Table", - "static org.nuiton.i18n.I18n._", - "static jaxx.runtime.Util.createImageIcon"); - - - } - - /** - * Creates a new SwingCompiler. - * - * @param baseDir classpath location - * @param options options to pass to javac - * @param src location of file to compile - * @param outputClassName the out file name - */ - public SwingCompiler(File baseDir, File src, String outputClassName, CompilerOptions options) { - super(baseDir, src, outputClassName, options, - new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(Object.class)), - "java.awt.*", - "java.awt.event.*", - "java.beans.*", - "java.io.*", - "java.lang.*", - "java.util.*", - "javax.swing.*", - "javax.swing.border.*", - "javax.swing.event.*", - "jaxx.runtime.swing.JAXXButtonGroup", - "jaxx.runtime.swing.HBox", - "jaxx.runtime.swing.VBox", - "jaxx.runtime.swing.Table", - "static org.nuiton.i18n.I18n._", - "static jaxx.runtime.Util.createImageIcon"); - } - -} \ No newline at end of file Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/SwingGenerator.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/SwingGenerator.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/SwingGenerator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,26 +0,0 @@ -package jaxx.compiler; - -import jaxx.reflect.ClassDescriptorLoader; - -import java.lang.reflect.Modifier; - -/** @author chemit */ -public class SwingGenerator implements Generator { - @Override - public void finalizeCompiler(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) { - - } - - @Override - public void prepareJavaFile(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) throws ClassNotFoundException { - - //TODO : move this to jaxx-compiler-swing generator - if (ClassDescriptorLoader.getClassDescriptor("jaxx.runtime.swing.Application").isAssignableFrom(root.getObjectClass()) && !compiler.isMainDeclared()) { - // TODO: check for existing main method first - javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC | Modifier.STATIC, "void", "main", - "SwingUtilities.invokeLater(new Runnable() { public void run() { new " + className + "().setVisible(true); } });", - new JavaArgument("String[]", "arg")) - ); - } - } -} Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/SymbolTable.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/SymbolTable.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/SymbolTable.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,7 +1,27 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ package jaxx.compiler; -import jaxx.reflect.FieldDescriptor; -import jaxx.reflect.MethodDescriptor; +import jaxx.compiler.reflect.FieldDescriptor; +import jaxx.compiler.reflect.MethodDescriptor; import java.util.ArrayList; import java.util.HashMap; @@ -12,27 +32,21 @@ public class SymbolTable { private String superclass; - // maps ID strings to class names -- we can't map directly to CompiledObjects, because we // can't create those until after the first pass private Map<String, String> ids = new HashMap<String, String>(); - private List<FieldDescriptor> scriptFields = new ArrayList<FieldDescriptor>(); - private List<MethodDescriptor> scriptMethods = new ArrayList<MethodDescriptor>(); - /** @return the fully-qualified name of the superclass of the class described by this symbol table. */ public String getSuperclassName() { return superclass; } - public void setSuperclassName(String superclass) { this.superclass = superclass; } - /** * @return a map of IDs to class names. Each entry in the map corresponds to a class tag with an * <code>id</code> attribute. The <code>id</code> is the key, and the fully-qualified class name @@ -42,15 +56,13 @@ return ids; } - /** @return a list of <code>FieldDescriptors</code> for fields defined in <script> tags. */ public List<FieldDescriptor> getScriptFields() { return scriptFields; } - /** @return a list of <code>MethodDescriptors</code> for methods defined in <script> tags. */ public List<MethodDescriptor> getScriptMethods() { return scriptMethods; } -} \ No newline at end of file +} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedAttributeException.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedAttributeException.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedAttributeException.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedAttributeException.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,63 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler; + +/** + * Thrown by <code>TagHandler</code> when an unsupported attribute is encountered. + * + * @see jaxx.compiler.tags.TagHandler + */ +public class UnsupportedAttributeException extends CompilerException { + + private static final long serialVersionUID = -6919583037172920343L; + + /** Creates a new <code>UnsupportedAttributeException</code>. */ + public UnsupportedAttributeException() { + } + + /** + * Creates a new <code>UnsupportedAttributeException</code> with the specified detail message. + * + * @param msg the exception's detail message + */ + public UnsupportedAttributeException(String msg) { + super(msg); + } + + /** + * Creates a new <code>UnsupportedAttributeException</code> with the specified cause. + * + * @param initCause the exception's initCause + */ + public UnsupportedAttributeException(Throwable initCause) { + super(initCause); + } + + /** + * Creates a new <code>UnsupportedAttributeException</code> with the specified detail message and cause. + * + * @param msg the exception's detail message + * @param initCause the exception's initCause + */ + public UnsupportedAttributeException(String msg, Throwable initCause) { + super(msg, initCause); + } +} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedTagException.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedTagException.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedTagException.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedTagException.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,61 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler; + +/** Thrown by the compiler when an unregistered tag is encountered. */ +public class UnsupportedTagException extends CompilerException { + private static final long serialVersionUID = 3199732135804426699L; + + /** Creates a new <code>UnsupportedTagException</code>. */ + public UnsupportedTagException() { + } + + + /** + * Creates a new <code>UnsupportedTagException</code> with the specified detail message. + * + * @param msg the exception's detail message + */ + public UnsupportedTagException(String msg) { + super(msg); + } + + + /** + * Creates a new <code>UnsupportedTagException</code> with the specified cause. + * + * @param initCause the exception's initCause + */ + public UnsupportedTagException(Throwable initCause) { + super(initCause); + } + + + /** + * Creates a new <code>UnsupportedTagException</code> with the specified detail message and cause. + * + * @param msg the exception's detail message + * @param initCause the exception's initCause + */ + public UnsupportedTagException(String msg, Throwable initCause) { + super(msg, initCause); + } +} \ No newline at end of file Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/ValidatorGenerator.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/ValidatorGenerator.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/ValidatorGenerator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,89 +0,0 @@ -package jaxx.compiler; - -import jaxx.compiler.CompiledObject.ChildRef; -import jaxx.reflect.ClassDescriptor; -import jaxx.reflect.ClassDescriptorLoader; -import jaxx.tags.validator.BeanValidatorHandler; -import jaxx.tags.validator.BeanValidatorHandler.CompiledBeanValidator; -import jaxx.types.TypeManager; - -import java.util.List; - -/** @author chemit */ -public class ValidatorGenerator implements Generator { - - protected static final JavaField VALIDATOR_IDS_FIELD = JavaField.newField(java.lang.reflect.Modifier.PROTECTED, - "java.util.List<String>", "validatorIds", "new ArrayList<String>()" - ); - - @Override - public void finalizeCompiler(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) { - - if (!BeanValidatorHandler.hasValidator(compiler)) { - return; - } - - for (CompiledObject object : compiler.getObjects().values()) { - List<ChildRef> childs = object.getChilds(); - if (childs == null || childs.isEmpty()) { - continue; - } - for (ChildRef child : childs) { - String javaCode = child.getChildJavaCode(); - // some validators are defined on this object - boolean found = BeanValidatorHandler.isComponentUsedByValidator(compiler, child.getChild().getId()); - if (found) { - // box the child component in a JxLayer - child.setChildJavaCode(jaxx.runtime.SwingUtil.class.getName()+".boxComponentWithJxLayer(" + javaCode + ")"); - } - } - } - // register validator - for (CompiledBeanValidator validator : BeanValidatorHandler.getValidators(compiler)) { - String id = TypeManager.getJavaCode(validator.getId()); - compiler.appendLateInitializer("validatorIds.add(" + id + ");"); - compiler.appendLateInitializer(JAXXCompiler.getLineSeparator()); - compiler.appendLateInitializer("getValidator(" + id + ").installUIs();"); - compiler.appendLateInitializer(JAXXCompiler.getLineSeparator()); - compiler.appendLateInitializer("getValidator(" + id + ").reloadBean();"); - //compiler.appendLateInitializer("getValidator(" + id + ").validate();"); - compiler.appendLateInitializer(JAXXCompiler.getLineSeparator()); - } - compiler.appendLateInitializer("validatorIds = java.util.Collections.unmodifiableList(validatorIds);"); - compiler.appendLateInitializer(JAXXCompiler.getLineSeparator()); - } - - @Override - public void prepareJavaFile(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) throws ClassNotFoundException { - if (!BeanValidatorHandler.hasValidator(compiler)) { - return; - } - Class<?> validatorClass = compiler.getOptions().getValidatorClass(); - String validatorFQN = validatorClass.getName(); - javaFile.addImport(validatorFQN); - - //TODO use the specific JAXXValidator interface (swing, gwt,...) - Class<?> validatorInterface = jaxx.runtime.JAXXValidator.class; - - if (javaFile.isSuperclassIsJAXXObject()) { - ClassDescriptor superClass = ClassDescriptorLoader.getClassDescriptor(javaFile.getSuperClass()); - boolean parentIsValidator = ClassDescriptorLoader.getClassDescriptor(validatorInterface).isAssignableFrom(superClass); - - if (parentIsValidator) { - // nothing to generate (use the parent directly) - return; - } - } - - // add JAXXValidator interface - javaFile.addInterface(JAXXCompiler.getCanonicalName(validatorInterface)); - - // implements JAXXValidator - javaFile.addField(VALIDATOR_IDS_FIELD); - javaFile.addMethod(JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, validatorFQN + "<?>", "getValidator", - "return (" + validatorFQN + ") (validatorIds.contains(validatorId) ? getObjectById(validatorId) : null);", - new JavaArgument("String", "validatorId") - )); - } - -} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/BeanInfoUtil.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/BeanInfoUtil.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/BeanInfoUtil.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,56 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.beans; - -import java.beans.Introspector; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** @author chemit */ -public class BeanInfoUtil { - - public static String[] originalBeanInfoSearchPath; - - public static void addJaxxBeanInfoPath(String... packageNames) { - - String[] searchPath = Introspector.getBeanInfoSearchPath(); - if (originalBeanInfoSearchPath == null) { - originalBeanInfoSearchPath = searchPath; - } - List<String> listSearchPath = new ArrayList<String>(Arrays.asList(searchPath)); - for (String packageName : packageNames) { - if (!listSearchPath.contains(packageName)) { - listSearchPath.add(packageName); - } - } - - Introspector.setBeanInfoSearchPath(listSearchPath.toArray(new String[listSearchPath.size()])); - } - - public static void reset() { - if (originalBeanInfoSearchPath != null) { - Introspector.setBeanInfoSearchPath(originalBeanInfoSearchPath); - originalBeanInfoSearchPath = null; - } - } - -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/BeanInfoUtil.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/BeanInfoUtil.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/BeanInfoUtil.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/BeanInfoUtil.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,56 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.beans; + +import java.beans.Introspector; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** @author chemit */ +public class BeanInfoUtil { + + public static String[] originalBeanInfoSearchPath; + + public static void addJaxxBeanInfoPath(String... packageNames) { + + String[] searchPath = Introspector.getBeanInfoSearchPath(); + if (originalBeanInfoSearchPath == null) { + originalBeanInfoSearchPath = searchPath; + } + List<String> listSearchPath = new ArrayList<String>(Arrays.asList(searchPath)); + for (String packageName : packageNames) { + if (!listSearchPath.contains(packageName)) { + listSearchPath.add(packageName); + } + } + + Introspector.setBeanInfoSearchPath(listSearchPath.toArray(new String[listSearchPath.size()])); + } + + public static void reset() { + if (originalBeanInfoSearchPath != null) { + Introspector.setBeanInfoSearchPath(originalBeanInfoSearchPath); + originalBeanInfoSearchPath = null; + } + } + +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanDescriptor.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanDescriptor.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanDescriptor.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,35 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.beans; - -import jaxx.compiler.reflect.ClassDescriptor; - -/** - * Mirrors the class <code>java.beans.BeanDescriptor</code>. JAXX uses its own introspector rather than the built-in - * <code>java.beans.Introspector</code> so that it can introspect {@link ClassDescriptor}, - * not just <code>java.lang.Class</code>. - */ -public class JAXXBeanDescriptor extends JAXXFeatureDescriptor { - - public JAXXBeanDescriptor(ClassDescriptor beanClass) { - super(beanClass, beanClass.getName()); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanDescriptor.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanDescriptor.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanDescriptor.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanDescriptor.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,35 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.beans; + +import jaxx.compiler.reflect.ClassDescriptor; + +/** + * Mirrors the class <code>java.beans.BeanDescriptor</code>. JAXX uses its own introspector rather than the built-in + * <code>java.beans.Introspector</code> so that it can introspect {@link ClassDescriptor}, + * not just <code>java.lang.Class</code>. + */ +public class JAXXBeanDescriptor extends JAXXFeatureDescriptor { + + public JAXXBeanDescriptor(ClassDescriptor beanClass) { + super(beanClass, beanClass.getName()); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanInfo.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanInfo.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanInfo.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,55 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.beans; - -import jaxx.compiler.reflect.ClassDescriptor; - -/** - * Mirrors the class <code>java.beans.BeanInfo</code>. JAXX uses its own introspector rather than the built-in - * <code>java.beans.Introspector</code> so that it can introspect {@link ClassDescriptor}, - * not just <code>java.lang.Class</code>. - */ -public class JAXXBeanInfo { - - private JAXXBeanDescriptor beanDescriptor; - private JAXXPropertyDescriptor[] propertyDescriptors; - private JAXXEventSetDescriptor[] eventSetDescriptors; - - public JAXXBeanInfo(JAXXBeanDescriptor beanDescriptor, - JAXXPropertyDescriptor[] propertyDescriptors, - JAXXEventSetDescriptor[] eventSetDescriptors) { - this.beanDescriptor = beanDescriptor; - this.propertyDescriptors = propertyDescriptors; - this.eventSetDescriptors = eventSetDescriptors; - } - - public JAXXBeanDescriptor getJAXXBeanDescriptor() { - return beanDescriptor; - } - - public JAXXPropertyDescriptor[] getJAXXPropertyDescriptors() { - return propertyDescriptors; - } - - public JAXXEventSetDescriptor[] getJAXXEventSetDescriptors() { - return eventSetDescriptors; - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanInfo.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanInfo.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanInfo.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanInfo.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,55 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.beans; + +import jaxx.compiler.reflect.ClassDescriptor; + +/** + * Mirrors the class <code>java.beans.BeanInfo</code>. JAXX uses its own introspector rather than the built-in + * <code>java.beans.Introspector</code> so that it can introspect {@link ClassDescriptor}, + * not just <code>java.lang.Class</code>. + */ +public class JAXXBeanInfo { + + private JAXXBeanDescriptor beanDescriptor; + private JAXXPropertyDescriptor[] propertyDescriptors; + private JAXXEventSetDescriptor[] eventSetDescriptors; + + public JAXXBeanInfo(JAXXBeanDescriptor beanDescriptor, + JAXXPropertyDescriptor[] propertyDescriptors, + JAXXEventSetDescriptor[] eventSetDescriptors) { + this.beanDescriptor = beanDescriptor; + this.propertyDescriptors = propertyDescriptors; + this.eventSetDescriptors = eventSetDescriptors; + } + + public JAXXBeanDescriptor getJAXXBeanDescriptor() { + return beanDescriptor; + } + + public JAXXPropertyDescriptor[] getJAXXPropertyDescriptors() { + return propertyDescriptors; + } + + public JAXXEventSetDescriptor[] getJAXXEventSetDescriptors() { + return eventSetDescriptors; + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXEventSetDescriptor.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXEventSetDescriptor.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXEventSetDescriptor.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,56 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.beans; - -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.MethodDescriptor; - -/** - * Mirrors the class <code>java.beans.EventSetDescriptor</code>. JAXX uses its own introspector rather than the built-in - * <code>java.beans.Introspector</code> so that it can introspect {@link ClassDescriptor}, - * not just <code>java.lang.Class</code>. - */ -public class JAXXEventSetDescriptor extends JAXXFeatureDescriptor { - - private MethodDescriptor addListenerMethod; - private MethodDescriptor removeListenerMethod; - private MethodDescriptor[] listenerMethods; - - public JAXXEventSetDescriptor(ClassDescriptor classDescriptor, String name, MethodDescriptor addListenerMethod, - MethodDescriptor removeListenerMethod, MethodDescriptor[] listenerMethods) { - super(classDescriptor, name); - this.addListenerMethod = addListenerMethod; - this.removeListenerMethod = removeListenerMethod; - this.listenerMethods = listenerMethods; - } - - public MethodDescriptor getAddListenerMethod() { - return addListenerMethod; - } - - public MethodDescriptor getRemoveListenerMethod() { - return removeListenerMethod; - } - - public MethodDescriptor[] getListenerMethods() { - return listenerMethods; - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXEventSetDescriptor.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXEventSetDescriptor.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXEventSetDescriptor.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXEventSetDescriptor.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,56 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.beans; + +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.MethodDescriptor; + +/** + * Mirrors the class <code>java.beans.EventSetDescriptor</code>. JAXX uses its own introspector rather than the built-in + * <code>java.beans.Introspector</code> so that it can introspect {@link ClassDescriptor}, + * not just <code>java.lang.Class</code>. + */ +public class JAXXEventSetDescriptor extends JAXXFeatureDescriptor { + + private MethodDescriptor addListenerMethod; + private MethodDescriptor removeListenerMethod; + private MethodDescriptor[] listenerMethods; + + public JAXXEventSetDescriptor(ClassDescriptor classDescriptor, String name, MethodDescriptor addListenerMethod, + MethodDescriptor removeListenerMethod, MethodDescriptor[] listenerMethods) { + super(classDescriptor, name); + this.addListenerMethod = addListenerMethod; + this.removeListenerMethod = removeListenerMethod; + this.listenerMethods = listenerMethods; + } + + public MethodDescriptor getAddListenerMethod() { + return addListenerMethod; + } + + public MethodDescriptor getRemoveListenerMethod() { + return removeListenerMethod; + } + + public MethodDescriptor[] getListenerMethods() { + return listenerMethods; + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXFeatureDescriptor.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXFeatureDescriptor.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXFeatureDescriptor.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,72 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.beans; - -import jaxx.compiler.reflect.ClassDescriptor; - -import java.util.HashMap; -import java.util.Map; - -/** - * Mirrors the class <code>java.beans.FeatureDescriptor</code>. JAXX uses its own introspector rather than the built-in - * <code>java.beans.Introspector</code> so that it can introspect {@link ClassDescriptor}, - * not just <code>java.lang.Class</code>. - */ -public class JAXXFeatureDescriptor { - - private String name; - private Map<String, Object> values; - private ClassDescriptor classDescriptor; - - JAXXFeatureDescriptor(ClassDescriptor classDescriptor, String name) { - if (name == null || classDescriptor == null) { - throw new NullPointerException(); - } - this.name = name; - this.classDescriptor = classDescriptor; - } - - public String getName() { - return name; - } - - public ClassDescriptor getClassDescriptor() { - return classDescriptor; - } - - public Object getValue(String key) { - return values != null ? values.get(key) : null; - } - - public void setValue(String key, Object value) { - if (values == null) { - values = new HashMap<String, Object>(); - } - values.put(key, value); - } - - public static String capitalize(String name) { - if (name.length() == 0) { - return name; - } - return Character.toUpperCase(name.charAt(0)) + name.substring(1); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXFeatureDescriptor.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXFeatureDescriptor.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXFeatureDescriptor.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXFeatureDescriptor.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,72 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.beans; + +import jaxx.compiler.reflect.ClassDescriptor; + +import java.util.HashMap; +import java.util.Map; + +/** + * Mirrors the class <code>java.beans.FeatureDescriptor</code>. JAXX uses its own introspector rather than the built-in + * <code>java.beans.Introspector</code> so that it can introspect {@link ClassDescriptor}, + * not just <code>java.lang.Class</code>. + */ +public class JAXXFeatureDescriptor { + + private String name; + private Map<String, Object> values; + private ClassDescriptor classDescriptor; + + JAXXFeatureDescriptor(ClassDescriptor classDescriptor, String name) { + if (name == null || classDescriptor == null) { + throw new NullPointerException(); + } + this.name = name; + this.classDescriptor = classDescriptor; + } + + public String getName() { + return name; + } + + public ClassDescriptor getClassDescriptor() { + return classDescriptor; + } + + public Object getValue(String key) { + return values != null ? values.get(key) : null; + } + + public void setValue(String key, Object value) { + if (values == null) { + values = new HashMap<String, Object>(); + } + values.put(key, value); + } + + public static String capitalize(String name) { + if (name.length() == 0) { + return name; + } + return Character.toUpperCase(name.charAt(0)) + name.substring(1); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXIntrospector.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXIntrospector.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXIntrospector.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,187 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.beans; - -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.reflect.MethodDescriptor; - -import java.beans.BeanDescriptor; -import java.beans.BeanInfo; -import java.beans.IntrospectionException; -import java.beans.Introspector; -import java.beans.PropertyChangeListener; -import java.beans.PropertyDescriptor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.Enumeration; -import java.util.EventListener; -import java.util.HashMap; -import java.util.Map; - -/** - * Performs introspection on a <code>ClassDescriptor</code>. Ideally, I could just have copied Sun's Introspector - * and changed a few things, but the licensing terms are incompatible. This implementation is incomplete -- it only - * bothers to report info that JAXX actually checks. It also relaxes some of Introspector's rules a bit, but I - * don't believe it results in any meaningful incompatibilities. - * <p/> - * JAXX uses its own introspector rather than the built-in - * <code>java.beans.Introspector</code> so that it can introspect {@link ClassDescriptor}, - * not just <code>java.lang.Class</code>. - */ -public class JAXXIntrospector { - - private ClassDescriptor classDescriptor; - private Map<String, JAXXPropertyDescriptor> propertyDescriptors = new HashMap<String, JAXXPropertyDescriptor>(); - private Map<String, JAXXEventSetDescriptor> eventSetDescriptors = new HashMap<String, JAXXEventSetDescriptor>(); - - private JAXXIntrospector(ClassDescriptor classDescriptor) { - this.classDescriptor = classDescriptor; - } - - /** - * Returns the <code>JAXXBeanInfo</code> for a given class. - * - * @param classDescriptor the class to introspect - * @return the <code>JAXXBeanInfo</code> for the bean class - * @throws IntrospectionException if an error occurs - */ - public static JAXXBeanInfo getJAXXBeanInfo(ClassDescriptor classDescriptor) throws IntrospectionException { - JAXXIntrospector introspector = new JAXXIntrospector(classDescriptor); - return introspector.createBeanInfo(); - } - - private JAXXBeanInfo createBeanInfo() { - ClassDescriptor explicitInfoClass = classDescriptor; - BeanInfo explicitBeanInfo = null; - while (explicitInfoClass != null) { - explicitBeanInfo = getExplicitBeanInfo(explicitInfoClass); - if (explicitBeanInfo != null) { - break; - } - explicitInfoClass = explicitInfoClass.getSuperclass(); - } - - if (explicitBeanInfo != null) { - PropertyDescriptor[] explicitProperties = explicitBeanInfo.getPropertyDescriptors(); - for (PropertyDescriptor explicitProperty : explicitProperties) { - Class type = explicitProperty.getPropertyType(); - Method readMethod = explicitProperty.getReadMethod(); - Method writeMethod = explicitProperty.getWriteMethod(); - try { - ClassDescriptor typeDescriptor = ClassDescriptorLoader.getClassDescriptor(type.getName(), type.getClassLoader()); - JAXXPropertyDescriptor propertyDescriptor = new JAXXPropertyDescriptor(classDescriptor, explicitProperty.getName(), - readMethod != null ? classDescriptor.getMethodDescriptor(readMethod.getName()) : null, - writeMethod != null ? classDescriptor.getMethodDescriptor(writeMethod.getName(), typeDescriptor) : null); - propertyDescriptor.setBound(explicitProperty.isBound()); - Enumeration<String> attributeNames = explicitProperty.attributeNames(); - while (attributeNames.hasMoreElements()) { - String name = attributeNames.nextElement(); - propertyDescriptor.setValue(name, explicitProperty.getValue(name)); - } - propertyDescriptors.put(propertyDescriptor.getName(), propertyDescriptor); - } catch (ClassNotFoundException e) { - throw new RuntimeException("Internal error: Could not find ClassDescriptor corresponding to Java " + type, e); - } catch (NoSuchMethodException e) { - throw new RuntimeException("Internal error: Could not find expected MethodDescriptor in " + classDescriptor, e); - } - } - } - - // if the class broadcasts PropertyChangeEvent, assume all properties are bound (java.beans.Introspector - // does the same) - boolean propertyChangeSource; - try { - classDescriptor.getMethodDescriptor("addPropertyChangeListener", ClassDescriptorLoader.getClassDescriptor(PropertyChangeListener.class)); - propertyChangeSource = true; - } catch (NoSuchMethodException e) { - propertyChangeSource = false; - } - - MethodDescriptor[] methods = classDescriptor.getMethodDescriptors(); - for (MethodDescriptor method : methods) { - String name = method.getName(); - if (name.startsWith("get") && name.length() > 3 && Character.isUpperCase(name.charAt(3)) && method.getParameterTypes().length == 0) { - String propertyName = Introspector.decapitalize(name.substring(3)); - if (!propertyDescriptors.containsKey(propertyName)) { - propertyDescriptors.put(propertyName, new JAXXPropertyDescriptor(classDescriptor, propertyName, method, null, propertyChangeSource)); - } - } else if (name.startsWith("is") && name.length() > 2 && Character.isUpperCase(name.charAt(2)) && method.getParameterTypes().length == 0) { - String propertyName = Introspector.decapitalize(name.substring(2)); - if (!propertyDescriptors.containsKey(propertyName)) { - propertyDescriptors.put(propertyName, new JAXXPropertyDescriptor(classDescriptor, propertyName, method, null, propertyChangeSource)); - } - } else if (name.startsWith("set") && name.length() > 3 && Character.isUpperCase(name.charAt(3)) && method.getParameterTypes().length == 1) { - String propertyName = Introspector.decapitalize(name.substring(3)); - if (!propertyDescriptors.containsKey(propertyName)) { - propertyDescriptors.put(propertyName, new JAXXPropertyDescriptor(classDescriptor, propertyName, null, method, propertyChangeSource)); - } - } else if (name.startsWith("add") && name.length() > 3 && Character.isUpperCase(name.charAt(3))) { - ClassDescriptor[] parameters = method.getParameterTypes(); - if (parameters.length != 1 || !ClassDescriptorLoader.getClassDescriptor(EventListener.class).isAssignableFrom(parameters[0])) { - continue; // not an event listener method - } - try { - String eventSetName = method.getName().substring(3); - MethodDescriptor remove = classDescriptor.getMethodDescriptor("remove" + eventSetName, parameters); - eventSetDescriptors.put(eventSetName, new JAXXEventSetDescriptor(classDescriptor, eventSetName, method, remove, parameters[0].getMethodDescriptors())); - } catch (NoSuchMethodException e) { - // no matching remove method, not a valid event - } - } - } - - JAXXBeanDescriptor beanDescriptor = new JAXXBeanDescriptor(classDescriptor); - if (explicitBeanInfo != null) { - BeanDescriptor explicitBeanDescriptor = explicitBeanInfo.getBeanDescriptor(); - if (explicitBeanDescriptor != null) { - Enumeration/*<String>*/ attributeNames = explicitBeanDescriptor.attributeNames(); - while (attributeNames.hasMoreElements()) { - String name = (String) attributeNames.nextElement(); - beanDescriptor.setValue(name, explicitBeanDescriptor.getValue(name)); - } - } - } - - return new JAXXBeanInfo(beanDescriptor, - propertyDescriptors.values().toArray(new JAXXPropertyDescriptor[propertyDescriptors.size()]), - eventSetDescriptors.values().toArray(new JAXXEventSetDescriptor[eventSetDescriptors.size()])); - } - - private static BeanInfo getExplicitBeanInfo(ClassDescriptor classDescriptor) { - try { - Class beanClass = Class.forName(classDescriptor.getName(), true, classDescriptor.getClassLoader()); // see if there is a class by that name in this package - Method findExplicitBeanInfo = Introspector.class.getDeclaredMethod("findExplicitBeanInfo", new Class[]{Class.class}); - findExplicitBeanInfo.setAccessible(true); - return (BeanInfo) findExplicitBeanInfo.invoke(null, beanClass); - } catch (ClassNotFoundException e) { - return null; // happens for uncompiled classes - } catch (NoClassDefFoundError e) { - return null; // wrong case, etc. - } catch (NoSuchMethodException e) { - throw new RuntimeException("Error: could not find method 'findExplicitBeanInfo' in java.beans.Introspector. You are most likely running a version of Java against which JAXX has not been tested."); - } catch (InvocationTargetException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXIntrospector.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXIntrospector.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXIntrospector.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXIntrospector.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,187 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.beans; + +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.reflect.MethodDescriptor; + +import java.beans.BeanDescriptor; +import java.beans.BeanInfo; +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.beans.PropertyChangeListener; +import java.beans.PropertyDescriptor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Enumeration; +import java.util.EventListener; +import java.util.HashMap; +import java.util.Map; + +/** + * Performs introspection on a <code>ClassDescriptor</code>. Ideally, I could just have copied Sun's Introspector + * and changed a few things, but the licensing terms are incompatible. This implementation is incomplete -- it only + * bothers to report info that JAXX actually checks. It also relaxes some of Introspector's rules a bit, but I + * don't believe it results in any meaningful incompatibilities. + * <p/> + * JAXX uses its own introspector rather than the built-in + * <code>java.beans.Introspector</code> so that it can introspect {@link ClassDescriptor}, + * not just <code>java.lang.Class</code>. + */ +public class JAXXIntrospector { + + private ClassDescriptor classDescriptor; + private Map<String, JAXXPropertyDescriptor> propertyDescriptors = new HashMap<String, JAXXPropertyDescriptor>(); + private Map<String, JAXXEventSetDescriptor> eventSetDescriptors = new HashMap<String, JAXXEventSetDescriptor>(); + + private JAXXIntrospector(ClassDescriptor classDescriptor) { + this.classDescriptor = classDescriptor; + } + + /** + * Returns the <code>JAXXBeanInfo</code> for a given class. + * + * @param classDescriptor the class to introspect + * @return the <code>JAXXBeanInfo</code> for the bean class + * @throws IntrospectionException if an error occurs + */ + public static JAXXBeanInfo getJAXXBeanInfo(ClassDescriptor classDescriptor) throws IntrospectionException { + JAXXIntrospector introspector = new JAXXIntrospector(classDescriptor); + return introspector.createBeanInfo(); + } + + private JAXXBeanInfo createBeanInfo() { + ClassDescriptor explicitInfoClass = classDescriptor; + BeanInfo explicitBeanInfo = null; + while (explicitInfoClass != null) { + explicitBeanInfo = getExplicitBeanInfo(explicitInfoClass); + if (explicitBeanInfo != null) { + break; + } + explicitInfoClass = explicitInfoClass.getSuperclass(); + } + + if (explicitBeanInfo != null) { + PropertyDescriptor[] explicitProperties = explicitBeanInfo.getPropertyDescriptors(); + for (PropertyDescriptor explicitProperty : explicitProperties) { + Class type = explicitProperty.getPropertyType(); + Method readMethod = explicitProperty.getReadMethod(); + Method writeMethod = explicitProperty.getWriteMethod(); + try { + ClassDescriptor typeDescriptor = ClassDescriptorLoader.getClassDescriptor(type.getName(), type.getClassLoader()); + JAXXPropertyDescriptor propertyDescriptor = new JAXXPropertyDescriptor(classDescriptor, explicitProperty.getName(), + readMethod != null ? classDescriptor.getMethodDescriptor(readMethod.getName()) : null, + writeMethod != null ? classDescriptor.getMethodDescriptor(writeMethod.getName(), typeDescriptor) : null); + propertyDescriptor.setBound(explicitProperty.isBound()); + Enumeration<String> attributeNames = explicitProperty.attributeNames(); + while (attributeNames.hasMoreElements()) { + String name = attributeNames.nextElement(); + propertyDescriptor.setValue(name, explicitProperty.getValue(name)); + } + propertyDescriptors.put(propertyDescriptor.getName(), propertyDescriptor); + } catch (ClassNotFoundException e) { + throw new RuntimeException("Internal error: Could not find ClassDescriptor corresponding to Java " + type, e); + } catch (NoSuchMethodException e) { + throw new RuntimeException("Internal error: Could not find expected MethodDescriptor in " + classDescriptor, e); + } + } + } + + // if the class broadcasts PropertyChangeEvent, assume all properties are bound (java.beans.Introspector + // does the same) + boolean propertyChangeSource; + try { + classDescriptor.getMethodDescriptor("addPropertyChangeListener", ClassDescriptorLoader.getClassDescriptor(PropertyChangeListener.class)); + propertyChangeSource = true; + } catch (NoSuchMethodException e) { + propertyChangeSource = false; + } + + MethodDescriptor[] methods = classDescriptor.getMethodDescriptors(); + for (MethodDescriptor method : methods) { + String name = method.getName(); + if (name.startsWith("get") && name.length() > 3 && Character.isUpperCase(name.charAt(3)) && method.getParameterTypes().length == 0) { + String propertyName = Introspector.decapitalize(name.substring(3)); + if (!propertyDescriptors.containsKey(propertyName)) { + propertyDescriptors.put(propertyName, new JAXXPropertyDescriptor(classDescriptor, propertyName, method, null, propertyChangeSource)); + } + } else if (name.startsWith("is") && name.length() > 2 && Character.isUpperCase(name.charAt(2)) && method.getParameterTypes().length == 0) { + String propertyName = Introspector.decapitalize(name.substring(2)); + if (!propertyDescriptors.containsKey(propertyName)) { + propertyDescriptors.put(propertyName, new JAXXPropertyDescriptor(classDescriptor, propertyName, method, null, propertyChangeSource)); + } + } else if (name.startsWith("set") && name.length() > 3 && Character.isUpperCase(name.charAt(3)) && method.getParameterTypes().length == 1) { + String propertyName = Introspector.decapitalize(name.substring(3)); + if (!propertyDescriptors.containsKey(propertyName)) { + propertyDescriptors.put(propertyName, new JAXXPropertyDescriptor(classDescriptor, propertyName, null, method, propertyChangeSource)); + } + } else if (name.startsWith("add") && name.length() > 3 && Character.isUpperCase(name.charAt(3))) { + ClassDescriptor[] parameters = method.getParameterTypes(); + if (parameters.length != 1 || !ClassDescriptorLoader.getClassDescriptor(EventListener.class).isAssignableFrom(parameters[0])) { + continue; // not an event listener method + } + try { + String eventSetName = method.getName().substring(3); + MethodDescriptor remove = classDescriptor.getMethodDescriptor("remove" + eventSetName, parameters); + eventSetDescriptors.put(eventSetName, new JAXXEventSetDescriptor(classDescriptor, eventSetName, method, remove, parameters[0].getMethodDescriptors())); + } catch (NoSuchMethodException e) { + // no matching remove method, not a valid event + } + } + } + + JAXXBeanDescriptor beanDescriptor = new JAXXBeanDescriptor(classDescriptor); + if (explicitBeanInfo != null) { + BeanDescriptor explicitBeanDescriptor = explicitBeanInfo.getBeanDescriptor(); + if (explicitBeanDescriptor != null) { + Enumeration/*<String>*/ attributeNames = explicitBeanDescriptor.attributeNames(); + while (attributeNames.hasMoreElements()) { + String name = (String) attributeNames.nextElement(); + beanDescriptor.setValue(name, explicitBeanDescriptor.getValue(name)); + } + } + } + + return new JAXXBeanInfo(beanDescriptor, + propertyDescriptors.values().toArray(new JAXXPropertyDescriptor[propertyDescriptors.size()]), + eventSetDescriptors.values().toArray(new JAXXEventSetDescriptor[eventSetDescriptors.size()])); + } + + private static BeanInfo getExplicitBeanInfo(ClassDescriptor classDescriptor) { + try { + Class beanClass = Class.forName(classDescriptor.getName(), true, classDescriptor.getClassLoader()); // see if there is a class by that name in this package + Method findExplicitBeanInfo = Introspector.class.getDeclaredMethod("findExplicitBeanInfo", new Class[]{Class.class}); + findExplicitBeanInfo.setAccessible(true); + return (BeanInfo) findExplicitBeanInfo.invoke(null, beanClass); + } catch (ClassNotFoundException e) { + return null; // happens for uncompiled classes + } catch (NoClassDefFoundError e) { + return null; // wrong case, etc. + } catch (NoSuchMethodException e) { + throw new RuntimeException("Error: could not find method 'findExplicitBeanInfo' in java.beans.Introspector. You are most likely running a version of Java against which JAXX has not been tested."); + } catch (InvocationTargetException e) { + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXPropertyDescriptor.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXPropertyDescriptor.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXPropertyDescriptor.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,107 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.beans; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.MethodDescriptor; - -/** - * Mirrors the class <code>java.beans.PropertyDescriptor</code>. JAXX uses its own introspector rather than the built-in - * <code>java.beans.Introspector</code> so that it can introspect {@link ClassDescriptor}, - * not just <code>java.lang.Class</code>. - */ -public class JAXXPropertyDescriptor extends JAXXFeatureDescriptor { - - private ClassDescriptor propertyType; - private MethodDescriptor readMethod; - private MethodDescriptor writeMethod; - private boolean bound; - - public JAXXPropertyDescriptor(ClassDescriptor classDescriptor, String propertyName) { - this(classDescriptor, propertyName, null, null); - } - - public JAXXPropertyDescriptor(ClassDescriptor classDescriptor, String propertyName, - MethodDescriptor readMethod, MethodDescriptor writeMethod) { - this(classDescriptor, propertyName, readMethod, writeMethod, false); - } - - public JAXXPropertyDescriptor(ClassDescriptor classDescriptor, String propertyName, - MethodDescriptor readMethod, MethodDescriptor writeMethod, - boolean bound) { - super(classDescriptor, propertyName); - this.readMethod = readMethod; - this.writeMethod = writeMethod; - this.bound = bound; - } - - public MethodDescriptor getReadMethodDescriptor() { - if (readMethod == null) { - try { - readMethod = getClassDescriptor().getMethodDescriptor("get" + capitalize(getName())); - } catch (NoSuchMethodException e) { - try { - readMethod = getClassDescriptor().getMethodDescriptor("is" + capitalize(getName())); - } catch (NoSuchMethodException e2) { - } - } - } - return readMethod; - } - - public MethodDescriptor getWriteMethodDescriptor() { - if (writeMethod == null) { - try { - String methodName = "set" + capitalize(getName()); - MethodDescriptor read = getReadMethodDescriptor(); - if (read != null) { - writeMethod = getClassDescriptor().getMethodDescriptor(methodName, read.getReturnType()); - } else { - throw new CompilerException("Internal error: requesting 'set' method for property of unknown type: '" + getName() + "' (in " + getClassDescriptor() + ")"); - } - } catch (NoSuchMethodException e) { - } - } - return writeMethod; - } - - public ClassDescriptor getPropertyType() { - if (propertyType == null) { - MethodDescriptor read = getReadMethodDescriptor(); - if (read != null) { - propertyType = read.getReturnType(); - } else { - MethodDescriptor write = getWriteMethodDescriptor(); - propertyType = write.getParameterTypes()[0]; - } - } - return propertyType; - } - - public boolean isBound() { - return bound; - } - - public void setBound(boolean bound) { - this.bound = bound; - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXPropertyDescriptor.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXPropertyDescriptor.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXPropertyDescriptor.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXPropertyDescriptor.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,107 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.beans; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.MethodDescriptor; + +/** + * Mirrors the class <code>java.beans.PropertyDescriptor</code>. JAXX uses its own introspector rather than the built-in + * <code>java.beans.Introspector</code> so that it can introspect {@link ClassDescriptor}, + * not just <code>java.lang.Class</code>. + */ +public class JAXXPropertyDescriptor extends JAXXFeatureDescriptor { + + private ClassDescriptor propertyType; + private MethodDescriptor readMethod; + private MethodDescriptor writeMethod; + private boolean bound; + + public JAXXPropertyDescriptor(ClassDescriptor classDescriptor, String propertyName) { + this(classDescriptor, propertyName, null, null); + } + + public JAXXPropertyDescriptor(ClassDescriptor classDescriptor, String propertyName, + MethodDescriptor readMethod, MethodDescriptor writeMethod) { + this(classDescriptor, propertyName, readMethod, writeMethod, false); + } + + public JAXXPropertyDescriptor(ClassDescriptor classDescriptor, String propertyName, + MethodDescriptor readMethod, MethodDescriptor writeMethod, + boolean bound) { + super(classDescriptor, propertyName); + this.readMethod = readMethod; + this.writeMethod = writeMethod; + this.bound = bound; + } + + public MethodDescriptor getReadMethodDescriptor() { + if (readMethod == null) { + try { + readMethod = getClassDescriptor().getMethodDescriptor("get" + capitalize(getName())); + } catch (NoSuchMethodException e) { + try { + readMethod = getClassDescriptor().getMethodDescriptor("is" + capitalize(getName())); + } catch (NoSuchMethodException e2) { + } + } + } + return readMethod; + } + + public MethodDescriptor getWriteMethodDescriptor() { + if (writeMethod == null) { + try { + String methodName = "set" + capitalize(getName()); + MethodDescriptor read = getReadMethodDescriptor(); + if (read != null) { + writeMethod = getClassDescriptor().getMethodDescriptor(methodName, read.getReturnType()); + } else { + throw new CompilerException("Internal error: requesting 'set' method for property of unknown type: '" + getName() + "' (in " + getClassDescriptor() + ")"); + } + } catch (NoSuchMethodException e) { + } + } + return writeMethod; + } + + public ClassDescriptor getPropertyType() { + if (propertyType == null) { + MethodDescriptor read = getReadMethodDescriptor(); + if (read != null) { + propertyType = read.getReturnType(); + } else { + MethodDescriptor write = getWriteMethodDescriptor(); + propertyType = write.getParameterTypes()[0]; + } + } + return propertyType; + } + + public boolean isBound() { + return bound; + } + + public void setBound(boolean bound) { + this.bound = bound; + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataBinding.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataBinding.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataBinding.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,278 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.binding; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.java.JavaFileGenerator; -import jaxx.compiler.java.JavaMethod; -import jaxx.compiler.types.TypeManager; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.ArrayList; -import java.util.List; - -/** - * Represents a data binding in a JAXX file. <code>DataBinding</code> uses - * {@link DataSource} to track changes to a source expression and update - * the destination. - */ -public class DataBinding { - - /** - * Logger - */ - protected static final Log log = LogFactory.getLog(DataBinding.class); - /** - * Id of the data binding - */ - private String id; - /** - * Real Id of the data binding (can be suffix by a number for css binding to avoid collisions) - */ - private String realId; - /** - * Constant id build from the {@link #realId} and used instead of {@link #realId} in generated code - */ - protected String constantId; - /** - * source of the data binding - */ - private String source; - /** - * A Java snippet which will cause the destination property to be updated with the current value of - * the binding. - */ - private String assignment; - /** - * A internal flag to - */ - private boolean quickNoDependencies; - - /** - * Compiled data source - */ - protected DataSource dataSource; - - /** - * code to add to processDataBinding (null if no binding) - */ - protected String processDataBinding; - /** - * code to register the databinding (null if no binding) - */ - protected String initDataBinding; - /** - * code to put in applyDataBinding method on generated java file - */ - private StringBuffer addListenerCode = new StringBuffer(); - /** - * code to put in removeDataBinding method on generated java file - */ - private StringBuffer removeListenerCode = new StringBuffer(); - /** - * Extra method to add to the binding - */ - protected final List<JavaMethod> methods = new ArrayList<JavaMethod>(); - /** - * internal state passed to {@code true} when {@link #compile(jaxx.compiler.JAXXCompiler)} method is invoked - */ - private boolean compiled; - - /** - * Creates a new data binding. - * - * @param id the data binding destination in the form <code>id.propertyName</code> - * @param source the Java source code for the data binding expression - * @param assignment Java snippet which will cause the destination property to be updated with the current value of the binding - * @param quickNoDependencies internal flag to not treate process databinding in not a real binding - */ - public DataBinding(String id, String source, String assignment, boolean quickNoDependencies) { -// public DataBinding(String source, String id, String assignment, boolean quickNoDependencies) { - this.id = id; - this.source = source; - this.assignment = assignment; - this.quickNoDependencies = quickNoDependencies; - if (log.isDebugEnabled()) { - log.debug("id=" + id + " assignement=" + assignment + " source=" + source + " quickNoDependencies=" + quickNoDependencies); - } - } - -// public String getId() { -// return id; -// } - -// public DataSource getDataSource() { -// return dataSource; -// } - - public String getAssignment() { - return assignment; - } - - public String getSource() { - return source; - } - - public boolean isQuickNoDependencies() { - return quickNoDependencies; - } - - public String getProcessDataBinding() { - return processDataBinding; - } - - public String getInitDataBinding() { - return initDataBinding; - } - - public String getAddListenerCode() { - return addListenerCode.toString(); - } - - public String getRemoveListenerCode() { - return removeListenerCode.toString(); - } - - public String getRealId() { - return realId; - } - - public String getConstantId() { - return constantId; - } - - public List<JavaMethod> getMethods() { - return methods; - } - - @Override - public String toString() { - ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE); - b.append("id", id); - b.append("source", source); - b.append("assignement", assignment); - b.append("quickNoDependencies", quickNoDependencies); - if (compiled) { - b.append("realdId", realId); - b.append("constantId", getConstantId()); - if (!addListenerCode.toString().trim().isEmpty()) { - b.append("addListenerCode", addListenerCode.toString().trim()); - } - if (!removeListenerCode.toString().trim().isEmpty()) { - b.append("removeListenerCode", removeListenerCode.toString().trim()); - } - b.append("dataSource", dataSource); - } - return b.toString(); - } - - /** - * Compiles the data binding expression. This method calls methods in - * <code>JAXXCompiler</code> to add the Java code that performs the data - * binding setup. - * - * @param compiler compiler which includes the data binding - * // * @param quickNoDependencies true to optimize bindings with no dependencies by simply running them at startup time - * @return {@code true} if the expression has dependencies, {@code false} otherwise - * @throws jaxx.compiler.CompilerException - * if a compilation error occurs - */ - public boolean compile(JAXXCompiler compiler) throws CompilerException { -// public boolean compile(JAXXCompiler compiler, boolean quickNoDependencies) throws CompilerException { - - if (compiled) { - throw new IllegalStateException(this + " has already been compiled"); - } - - DataBindingHelper bindingHelper = compiler.getBindingHelper(); - - realId = bindingHelper.getSafeId(id.trim()); - constantId = TypeManager.convertVariableNameToConstantName("binding_" + realId); - - dataSource = new DataSource(realId, constantId, getSource(), compiler, addListenerCode, removeListenerCode, methods); - - // handles all of the listener additions - - boolean isBinding = dataSource.compile(); - - if (!isBinding) { - - bindingHelper.revertSafeId(id.trim()); - } - - // was compiled - compiled = true; - - if (isBinding && (DataBindingHelper.SHOW_LOG || log.isDebugEnabled())) { - log.info("detect a databinding\n" + this); - } - - // update initDataBinding code - - initDataBinding = getInitDataBindingCode(compiler, dataSource, isBinding); - - // update processDataBinding code - - processDataBinding = getProcessDataBindingCode(compiler, dataSource, isBinding); - - return isBinding; - } - - protected String getInitDataBindingCode(JAXXCompiler compiler, DataSource dataSource, boolean isBinding) { - String eol = JAXXCompiler.getLineSeparator(); - if (isBinding) { - return null; - } - if (isQuickNoDependencies()) { - // layout is specially handled early in the chain - if (!id.endsWith(".layout")) { - return getAssignment() + eol; - } - } - return null; - } - - protected String getProcessDataBindingCode(JAXXCompiler compiler, DataSource dataSource, boolean isBinding) { - if (!isBinding) { - // no binding = no process code - return null; - } - String eol = JAXXCompiler.getLineSeparator(); - StringBuilder buffer = new StringBuilder(); - - String objectCode = dataSource.getObjectCode(); - - // no need to test objectCode not null if on root object - boolean needTest = objectCode != null && !compiler.getRootObject().getId().equals(objectCode); - if (needTest) { - buffer.append("if (").append(objectCode).append(" != null) {").append(eol); - } - buffer.append(JavaFileGenerator.indent(getAssignment(), needTest ? 4 : 0, false, eol)); - if (needTest) { - buffer.append(eol).append("}"); - } - return buffer.toString(); - } -} \ No newline at end of file Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataBinding.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataBinding.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataBinding.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataBinding.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,278 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.binding; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.java.JavaFileGenerator; +import jaxx.compiler.java.JavaMethod; +import jaxx.compiler.types.TypeManager; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.util.ArrayList; +import java.util.List; + +/** + * Represents a data binding in a JAXX file. <code>DataBinding</code> uses + * {@link DataSource} to track changes to a source expression and update + * the destination. + */ +public class DataBinding { + + /** + * Logger + */ + protected static final Log log = LogFactory.getLog(DataBinding.class); + /** + * Id of the data binding + */ + private String id; + /** + * Real Id of the data binding (can be suffix by a number for css binding to avoid collisions) + */ + private String realId; + /** + * Constant id build from the {@link #realId} and used instead of {@link #realId} in generated code + */ + protected String constantId; + /** + * source of the data binding + */ + private String source; + /** + * A Java snippet which will cause the destination property to be updated with the current value of + * the binding. + */ + private String assignment; + /** + * A internal flag to + */ + private boolean quickNoDependencies; + + /** + * Compiled data source + */ + protected DataSource dataSource; + + /** + * code to add to processDataBinding (null if no binding) + */ + protected String processDataBinding; + /** + * code to register the databinding (null if no binding) + */ + protected String initDataBinding; + /** + * code to put in applyDataBinding method on generated java file + */ + private StringBuffer addListenerCode = new StringBuffer(); + /** + * code to put in removeDataBinding method on generated java file + */ + private StringBuffer removeListenerCode = new StringBuffer(); + /** + * Extra method to add to the binding + */ + protected final List<JavaMethod> methods = new ArrayList<JavaMethod>(); + /** + * internal state passed to {@code true} when {@link #compile(jaxx.compiler.JAXXCompiler)} method is invoked + */ + private boolean compiled; + + /** + * Creates a new data binding. + * + * @param id the data binding destination in the form <code>id.propertyName</code> + * @param source the Java source code for the data binding expression + * @param assignment Java snippet which will cause the destination property to be updated with the current value of the binding + * @param quickNoDependencies internal flag to not treate process databinding in not a real binding + */ + public DataBinding(String id, String source, String assignment, boolean quickNoDependencies) { +// public DataBinding(String source, String id, String assignment, boolean quickNoDependencies) { + this.id = id; + this.source = source; + this.assignment = assignment; + this.quickNoDependencies = quickNoDependencies; + if (log.isDebugEnabled()) { + log.debug("id=" + id + " assignement=" + assignment + " source=" + source + " quickNoDependencies=" + quickNoDependencies); + } + } + +// public String getId() { +// return id; +// } + +// public DataSource getDataSource() { +// return dataSource; +// } + + public String getAssignment() { + return assignment; + } + + public String getSource() { + return source; + } + + public boolean isQuickNoDependencies() { + return quickNoDependencies; + } + + public String getProcessDataBinding() { + return processDataBinding; + } + + public String getInitDataBinding() { + return initDataBinding; + } + + public String getAddListenerCode() { + return addListenerCode.toString(); + } + + public String getRemoveListenerCode() { + return removeListenerCode.toString(); + } + + public String getRealId() { + return realId; + } + + public String getConstantId() { + return constantId; + } + + public List<JavaMethod> getMethods() { + return methods; + } + + @Override + public String toString() { + ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE); + b.append("id", id); + b.append("source", source); + b.append("assignement", assignment); + b.append("quickNoDependencies", quickNoDependencies); + if (compiled) { + b.append("realdId", realId); + b.append("constantId", getConstantId()); + if (!addListenerCode.toString().trim().isEmpty()) { + b.append("addListenerCode", addListenerCode.toString().trim()); + } + if (!removeListenerCode.toString().trim().isEmpty()) { + b.append("removeListenerCode", removeListenerCode.toString().trim()); + } + b.append("dataSource", dataSource); + } + return b.toString(); + } + + /** + * Compiles the data binding expression. This method calls methods in + * <code>JAXXCompiler</code> to add the Java code that performs the data + * binding setup. + * + * @param compiler compiler which includes the data binding + * // * @param quickNoDependencies true to optimize bindings with no dependencies by simply running them at startup time + * @return {@code true} if the expression has dependencies, {@code false} otherwise + * @throws jaxx.compiler.CompilerException + * if a compilation error occurs + */ + public boolean compile(JAXXCompiler compiler) throws CompilerException { +// public boolean compile(JAXXCompiler compiler, boolean quickNoDependencies) throws CompilerException { + + if (compiled) { + throw new IllegalStateException(this + " has already been compiled"); + } + + DataBindingHelper bindingHelper = compiler.getBindingHelper(); + + realId = bindingHelper.getSafeId(id.trim()); + constantId = TypeManager.convertVariableNameToConstantName("binding_" + realId); + + dataSource = new DataSource(realId, constantId, getSource(), compiler, addListenerCode, removeListenerCode, methods); + + // handles all of the listener additions + + boolean isBinding = dataSource.compile(); + + if (!isBinding) { + + bindingHelper.revertSafeId(id.trim()); + } + + // was compiled + compiled = true; + + if (isBinding && (DataBindingHelper.SHOW_LOG || log.isDebugEnabled())) { + log.info("detect a databinding\n" + this); + } + + // update initDataBinding code + + initDataBinding = getInitDataBindingCode(compiler, dataSource, isBinding); + + // update processDataBinding code + + processDataBinding = getProcessDataBindingCode(compiler, dataSource, isBinding); + + return isBinding; + } + + protected String getInitDataBindingCode(JAXXCompiler compiler, DataSource dataSource, boolean isBinding) { + String eol = JAXXCompiler.getLineSeparator(); + if (isBinding) { + return null; + } + if (isQuickNoDependencies()) { + // layout is specially handled early in the chain + if (!id.endsWith(".layout")) { + return getAssignment() + eol; + } + } + return null; + } + + protected String getProcessDataBindingCode(JAXXCompiler compiler, DataSource dataSource, boolean isBinding) { + if (!isBinding) { + // no binding = no process code + return null; + } + String eol = JAXXCompiler.getLineSeparator(); + StringBuilder buffer = new StringBuilder(); + + String objectCode = dataSource.getObjectCode(); + + // no need to test objectCode not null if on root object + boolean needTest = objectCode != null && !compiler.getRootObject().getId().equals(objectCode); + if (needTest) { + buffer.append("if (").append(objectCode).append(" != null) {").append(eol); + } + buffer.append(JavaFileGenerator.indent(getAssignment(), needTest ? 4 : 0, false, eol)); + if (needTest) { + buffer.append(eol).append("}"); + } + return buffer.toString(); + } +} \ No newline at end of file Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataBindingHelper.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataBindingHelper.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataBindingHelper.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,243 +0,0 @@ -package jaxx.compiler.binding; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.JAXXCompiler; - -import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Helper to be used by compiler to treate data bindings. - * <p/> - * Note : The code in this class was previously directly in JAXXCompiler, now prefer have a separate - * class to make {@link JAXXCompiler} more simple and clear. - * <p/> - * Created: 27 nov. 2009 - * - * @author Tony Chemit <chemit@codelutin.com> Copyright Code Lutin - * @version $Revision$ - * <p/> - * Mise a jour: $Date$ par : - * $Author: tchemit $ - * @since 2.0.0 - */ -public class DataBindingHelper { - - /** - * To debug binding without any log interference - */ - public static boolean SHOW_LOG = true; - /** - * left brace matcher - */ - protected static final Matcher leftBraceMatcher = Pattern.compile("^(\\{)|[^\\\\](\\{)").matcher(""); - /** - * right brace matcher - */ - protected static final Matcher rightBraceMatcher = Pattern.compile("^(\\})|[^\\\\](\\})").matcher(""); - /** - * Registred data binding for the compiler, then after the invocation of method {@link #finalizeBindings()} - * only the real data bindings, the simple bindings will be moved to {@link #simpleBindings}. - */ - protected final List<DataBinding> dataBindings = new ArrayList<DataBinding>(); - /** - * Simpel bindings for the compiler - */ - protected final List<DataBinding> simpleBindings = new ArrayList<DataBinding>(); - /** - * Associated compiler - */ - protected final JAXXCompiler compiler; - /** - * Counter by unsafe type - */ - protected final Map<String, Integer> autoUnsafeGenIds = new TreeMap<String, Integer>(); - - public DataBindingHelper(JAXXCompiler compiler) { - this.compiler = compiler; - } - - /** - * Examine an attribute value for data binding expressions. Returns a 'cooked' expression which - * can be used to determine the resulting value. It is expected that this expression will be used - * as the source expression in a call to {@link #registerDataBinding}. - * If the attribute value does not invoke data binding, this method returns <code>null</code> - * - * @param stringValue the string value of the property from the XML - * @return a processed version of the expression - * @throws jaxx.compiler.CompilerException - * ? - */ - public static String processDataBindings(String stringValue) throws CompilerException { - int pos = getNextLeftBrace(stringValue, 0); - if (pos != -1) { - StringBuffer expression = new StringBuffer(); - int lastPos = 0; - while (pos != -1 && pos < stringValue.length()) { - if (pos > lastPos) { - if (expression.length() > 0) { - expression.append(" + "); - } - expression.append('"'); - expression.append(JAXXCompiler.escapeJavaString(stringValue.substring(lastPos, pos))); - expression.append('"'); - } - boolean multi = expression.length() > 0; - if (multi) { - expression.append(" + "); - expression.append('('); - } - int pos2 = getNextRightBrace(stringValue, pos + 1); - if (pos2 == -1) { - throw new CompilerException("unmatched '{' in expression: " + stringValue); - } - expression.append(stringValue.substring(pos + 1, pos2)); - if (multi) { - expression.append(')'); - } - pos2++; - if (pos2 < stringValue.length()) { - pos = getNextLeftBrace(stringValue, pos2); - lastPos = pos2; - } else { - pos = stringValue.length(); - lastPos = pos; - } - } - if (lastPos < stringValue.length()) { - if (expression.length() > 0) { - expression.append(" + "); - } - expression.append('"'); - expression.append(JAXXCompiler.escapeJavaString(stringValue.substring(lastPos))); - expression.append('"'); - } - //TC-20091027 : developper must write extact databinding - // the fact of adding the String boxed for String type binding is not - // a good thing, since it add one more call to process in binding - // and add nothing special more ? -// return type == ClassDescriptorLoader.getClassDescriptor(String.class) ? "String.valueOf(" + expression + ")" : expression.toString(); - return expression.toString(); - } - return null; - } - - public DataBinding[] getDataBindings() { - return dataBindings.toArray(new DataBinding[dataBindings.size()]); - } - - public DataBinding[] getSimpleBindings() { - return simpleBindings.toArray(new DataBinding[simpleBindings.size()]); - } - - public void registerDataBinding(String id, String binding, String assignment) { - binding = compiler.checkJavaCode(binding); - registerDataBinding(new DataBinding(id, binding, assignment, true)); - } - - public void registerDataBinding(DataBinding binding) { - dataBindings.add(binding); - } - - public void clear() { - simpleBindings.clear(); - dataBindings.clear(); - autoUnsafeGenIds.clear(); - } - - /** - * Obtain the next safe id for the given binding id. - * <p/> - * With css, we can obtain the same binding id, so we must - * check for unicity each time we want a new binding id. - * <p/> - * If an id is already taken, we suffix by {@code _XXX} until - * found a free id. - * - * @param id the id of the binding - * @return the safe id of the binding - */ - public String getSafeId(String id) { - - Integer integer = autoUnsafeGenIds.get(id); - String result = id; - if (integer == null) { - integer = 0; - } else { - result += "_" + integer; - } - autoUnsafeGenIds.put(id, ++integer); - return result; - } - - /** - * Revert a previous computed safe id. - * <p/> - * This is needed when a binding compiled is not an data binding, we want to free - * the safe id to avoid hole in numbers. - * - * @param id the original id to revert in counter. - */ - public void revertSafeId(String id) { - Integer integer = autoUnsafeGenIds.get(id); - if (integer != null) { - integer--; - if (integer > 0) { - autoUnsafeGenIds.put(id, integer); - } else { - autoUnsafeGenIds.remove(id); - } - } - } - - /** - * Finalize discovered bindings for the associated compiler. - * <p/> - * The method will compile all bindings. The one which are not data binding, are just - * process as property set (with the binding assigment) and remove from the binding list. - */ - public void finalizeBindings() { - - for (Iterator<DataBinding> itr = dataBindings.iterator(); itr.hasNext();) { - DataBinding binding = itr.next(); - boolean isBinding = binding.compile(compiler); - if (!isBinding) { - // ce n'est pas un binding, on enregistre le code d'init (si il existe) - simpleBindings.add(binding); - // on supprime le faux binding - itr.remove(); - } - } - } - - protected static int getNextLeftBrace(String string, int pos) { - leftBraceMatcher.reset(string); - return leftBraceMatcher.find(pos) ? Math.max(leftBraceMatcher.start(1), leftBraceMatcher.start(2)) : -1; - } - - protected static int getNextRightBrace(String string, int pos) { - leftBraceMatcher.reset(string); - rightBraceMatcher.reset(string); - int openCount = 1; - int rightPos; - while (openCount > 0) { - pos++; - int leftPos = leftBraceMatcher.find(pos) ? Math.max(leftBraceMatcher.start(1), leftBraceMatcher.start(2)) : -1; - rightPos = rightBraceMatcher.find(pos) ? Math.max(rightBraceMatcher.start(1), rightBraceMatcher.start(2)) : -1; - assert leftPos == -1 || leftPos >= pos; - assert rightPos == -1 || rightPos >= pos; - if (leftPos != -1 && leftPos < rightPos) { - pos = leftPos; - openCount++; - } else if (rightPos != -1) { - pos = rightPos; - openCount--; - } else { - openCount = 0; - } - } - return pos; - } - -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataBindingHelper.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataBindingHelper.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataBindingHelper.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataBindingHelper.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,243 @@ +package jaxx.compiler.binding; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.JAXXCompiler; + +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Helper to be used by compiler to treate data bindings. + * <p/> + * Note : The code in this class was previously directly in JAXXCompiler, now prefer have a separate + * class to make {@link JAXXCompiler} more simple and clear. + * <p/> + * Created: 27 nov. 2009 + * + * @author Tony Chemit <chemit@codelutin.com> Copyright Code Lutin + * @version $Revision$ + * <p/> + * Mise a jour: $Date$ par : + * $Author: tchemit $ + * @since 2.0.0 + */ +public class DataBindingHelper { + + /** + * To debug binding without any log interference + */ + public static boolean SHOW_LOG = false; + /** + * left brace matcher + */ + protected static final Matcher leftBraceMatcher = Pattern.compile("^(\\{)|[^\\\\](\\{)").matcher(""); + /** + * right brace matcher + */ + protected static final Matcher rightBraceMatcher = Pattern.compile("^(\\})|[^\\\\](\\})").matcher(""); + /** + * Registred data binding for the compiler, then after the invocation of method {@link #finalizeBindings()} + * only the real data bindings, the simple bindings will be moved to {@link #simpleBindings}. + */ + protected final List<DataBinding> dataBindings = new ArrayList<DataBinding>(); + /** + * Simpel bindings for the compiler + */ + protected final List<DataBinding> simpleBindings = new ArrayList<DataBinding>(); + /** + * Associated compiler + */ + protected final JAXXCompiler compiler; + /** + * Counter by unsafe type + */ + protected final Map<String, Integer> autoUnsafeGenIds = new TreeMap<String, Integer>(); + + public DataBindingHelper(JAXXCompiler compiler) { + this.compiler = compiler; + } + + /** + * Examine an attribute value for data binding expressions. Returns a 'cooked' expression which + * can be used to determine the resulting value. It is expected that this expression will be used + * as the source expression in a call to {@link #registerDataBinding}. + * If the attribute value does not invoke data binding, this method returns <code>null</code> + * + * @param stringValue the string value of the property from the XML + * @return a processed version of the expression + * @throws jaxx.compiler.CompilerException + * ? + */ + public static String processDataBindings(String stringValue) throws CompilerException { + int pos = getNextLeftBrace(stringValue, 0); + if (pos != -1) { + StringBuffer expression = new StringBuffer(); + int lastPos = 0; + while (pos != -1 && pos < stringValue.length()) { + if (pos > lastPos) { + if (expression.length() > 0) { + expression.append(" + "); + } + expression.append('"'); + expression.append(JAXXCompiler.escapeJavaString(stringValue.substring(lastPos, pos))); + expression.append('"'); + } + boolean multi = expression.length() > 0; + if (multi) { + expression.append(" + "); + expression.append('('); + } + int pos2 = getNextRightBrace(stringValue, pos + 1); + if (pos2 == -1) { + throw new CompilerException("unmatched '{' in expression: " + stringValue); + } + expression.append(stringValue.substring(pos + 1, pos2)); + if (multi) { + expression.append(')'); + } + pos2++; + if (pos2 < stringValue.length()) { + pos = getNextLeftBrace(stringValue, pos2); + lastPos = pos2; + } else { + pos = stringValue.length(); + lastPos = pos; + } + } + if (lastPos < stringValue.length()) { + if (expression.length() > 0) { + expression.append(" + "); + } + expression.append('"'); + expression.append(JAXXCompiler.escapeJavaString(stringValue.substring(lastPos))); + expression.append('"'); + } + //TC-20091027 : developper must write extact databinding + // the fact of adding the String boxed for String type binding is not + // a good thing, since it add one more call to process in binding + // and add nothing special more ? +// return type == ClassDescriptorLoader.getClassDescriptor(String.class) ? "String.valueOf(" + expression + ")" : expression.toString(); + return expression.toString(); + } + return null; + } + + public DataBinding[] getDataBindings() { + return dataBindings.toArray(new DataBinding[dataBindings.size()]); + } + + public DataBinding[] getSimpleBindings() { + return simpleBindings.toArray(new DataBinding[simpleBindings.size()]); + } + + public void registerDataBinding(String id, String binding, String assignment) { + binding = compiler.checkJavaCode(binding); + registerDataBinding(new DataBinding(id, binding, assignment, true)); + } + + public void registerDataBinding(DataBinding binding) { + dataBindings.add(binding); + } + + public void clear() { + simpleBindings.clear(); + dataBindings.clear(); + autoUnsafeGenIds.clear(); + } + + /** + * Obtain the next safe id for the given binding id. + * <p/> + * With css, we can obtain the same binding id, so we must + * check for unicity each time we want a new binding id. + * <p/> + * If an id is already taken, we suffix by {@code _XXX} until + * found a free id. + * + * @param id the id of the binding + * @return the safe id of the binding + */ + public String getSafeId(String id) { + + Integer integer = autoUnsafeGenIds.get(id); + String result = id; + if (integer == null) { + integer = 0; + } else { + result += "_" + integer; + } + autoUnsafeGenIds.put(id, ++integer); + return result; + } + + /** + * Revert a previous computed safe id. + * <p/> + * This is needed when a binding compiled is not an data binding, we want to free + * the safe id to avoid hole in numbers. + * + * @param id the original id to revert in counter. + */ + public void revertSafeId(String id) { + Integer integer = autoUnsafeGenIds.get(id); + if (integer != null) { + integer--; + if (integer > 0) { + autoUnsafeGenIds.put(id, integer); + } else { + autoUnsafeGenIds.remove(id); + } + } + } + + /** + * Finalize discovered bindings for the associated compiler. + * <p/> + * The method will compile all bindings. The one which are not data binding, are just + * process as property set (with the binding assigment) and remove from the binding list. + */ + public void finalizeBindings() { + + for (Iterator<DataBinding> itr = dataBindings.iterator(); itr.hasNext();) { + DataBinding binding = itr.next(); + boolean isBinding = binding.compile(compiler); + if (!isBinding) { + // ce n'est pas un binding, on enregistre le code d'init (si il existe) + simpleBindings.add(binding); + // on supprime le faux binding + itr.remove(); + } + } + } + + protected static int getNextLeftBrace(String string, int pos) { + leftBraceMatcher.reset(string); + return leftBraceMatcher.find(pos) ? Math.max(leftBraceMatcher.start(1), leftBraceMatcher.start(2)) : -1; + } + + protected static int getNextRightBrace(String string, int pos) { + leftBraceMatcher.reset(string); + rightBraceMatcher.reset(string); + int openCount = 1; + int rightPos; + while (openCount > 0) { + pos++; + int leftPos = leftBraceMatcher.find(pos) ? Math.max(leftBraceMatcher.start(1), leftBraceMatcher.start(2)) : -1; + rightPos = rightBraceMatcher.find(pos) ? Math.max(rightBraceMatcher.start(1), rightBraceMatcher.start(2)) : -1; + assert leftPos == -1 || leftPos >= pos; + assert rightPos == -1 || rightPos >= pos; + if (leftPos != -1 && leftPos < rightPos) { + pos = leftPos; + openCount++; + } else if (rightPos != -1) { + pos = rightPos; + openCount--; + } else { + openCount = 0; + } + } + return pos; + } + +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataSource.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataSource.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataSource.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,719 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.binding; - -import jaxx.compiler.CompiledObject; -import jaxx.compiler.CompilerException; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.UnsupportedAttributeException; -import jaxx.compiler.java.JavaArgument; -import jaxx.compiler.java.JavaFileGenerator; -import jaxx.compiler.java.JavaMethod; -import jaxx.compiler.java.parser.JavaParser; -import jaxx.compiler.java.parser.JavaParserConstants; -import jaxx.compiler.java.parser.JavaParserTreeConstants; -import jaxx.compiler.java.parser.SimpleNode; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.reflect.FieldDescriptor; -import jaxx.compiler.reflect.MethodDescriptor; -import jaxx.compiler.tags.DefaultObjectHandler; -import jaxx.compiler.tags.TagManager; -import jaxx.compiler.types.TypeManager; -import jaxx.runtime.Util; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.beans.Introspector; -import java.beans.PropertyChangeListener; -import java.io.StringReader; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * Represents a Java expression which fires a <code>PropertyChangeEvent</code> when it can be - * determined that its value may have changed. Events are fired on a "best effort" basis, and events - * may either be fired too often (the value has not actually changed) or not often enough (the value - * changed but no event was fired). - */ -public class DataSource { - - /** - * Logger - */ - protected static final Log log = LogFactory.getLog(DataSource.class); - - /** - * type attached to "null" constants in parsed expressions - */ - private class NULL { - } - - /** - * id of data source - */ - private final String id; - /** - * Constant id - */ - protected final String constantId; - /** - * The Java source code for the expression. - */ - private final String source; - /** - * The current <code>JAXXCompiler</code>. - */ - private final JAXXCompiler compiler; - /** - * List of symbols which this data source expression depends on. - */ - private final List<String> dependencySymbols = new ArrayList<String>(); - /** - * code to put in applyDataBinding method on generated java file - */ - private final StringBuffer addListenerCode; - /** - * code to put in removeDataBinding method on generated java file - */ - private final StringBuffer removeListenerCode; - /** - * the delegate of property to be required - */ - private String objectCode; - - protected final List<JavaMethod> methods; - - /** - * Creates a new data source. After creating a <code>DataSource</code>, use {@link #compile()} - * to cause it to function at runtime. - * - * @param id the DataSource's id - * @param constantId the DataSource constant id - * @param source the Java source code for the data source expression - * @param compiler the current <code>JAXXCompiler</code> - * @param addListenerCode where to push add code - * @param removeListenerCode where to push remove code - * @param methods where to store extra method to add to binding - */ - public DataSource(String id, String constantId, String source, JAXXCompiler compiler, StringBuffer addListenerCode, StringBuffer removeListenerCode, List<JavaMethod> methods) { - this.id = id; - this.constantId = constantId; - this.source = source; - this.compiler = compiler; - this.addListenerCode = addListenerCode; - this.removeListenerCode = removeListenerCode; - this.methods = methods; - } - - public String getObjectCode() { - return objectCode; - } - - @Override - public String toString() { - ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE); - b.append("source:id", id); - b.append("source:source", source); - b.append("source:objectCode", objectCode); - if (dependencySymbols != null && !dependencySymbols.isEmpty()) { - b.append("source:dependencySymbols", dependencySymbols.size()); - for (String d : dependencySymbols) { - b.append("source:depencendy ", d); - } - } - return b.toString(); - } - - /** - * Compiles the data source expression and listener. This method calls methods in <code>JAXXCompiler</code> - * to add the Java code that performs the data source setup. Adding listeners to <code>DataSource</code> is - * slightly more complicated than with ordinary classes, because <code>DataSource</code> only exists at compile - * time. You must pass in a Java expression which evaluates to a <code>PropertyChangeListener</code>; this - * expression will be compiled and evaluated at runtime to yield the <code>DataSource's</code> listener. - * - * @return <code>true</code> if the expression has dependencies, <code>false</code> otherwise - * @throws jaxx.compiler.CompilerException - * if a compilation error occurs - * @throws IllegalStateException if data source was already compiled - */ - protected boolean compile() throws CompilerException, IllegalStateException { - - if (DataBindingHelper.SHOW_LOG || log.isDebugEnabled()) { - log.debug("try to compile dataSource\n" + this); - } - JavaParser p = new JavaParser(new StringReader(source)); - while (!p.Line()) { - SimpleNode node = p.popNode(); - if (log.isDebugEnabled()) { - log.debug("will scan node " + node.getText()); - } - scanNode(node); - } - if (log.isDebugEnabled()) { - log.debug("dependencySymbols=" + dependencySymbols); - } - - boolean isBinding = !dependencySymbols.isEmpty(); - - return isBinding; - } - - /** - * Examines a node to identify any dependencies it contains. - * - * @param node node to scan - * @throws jaxx.compiler.CompilerException - * ? - */ - private void scanNode(SimpleNode node) throws CompilerException { - if (node.getId() == JavaParserTreeConstants.JJTMETHODDECLARATION || - node.getId() == JavaParserTreeConstants.JJTFIELDDECLARATION) { - return; - } - if (log.isTraceEnabled()) { - log.trace(node.getText()); - } - int count = node.jjtGetNumChildren(); - for (int i = 0; i < count; i++) { - scanNode(node.getChild(i)); - } - // determine node type - ClassDescriptor type = null; - if (node.jjtGetNumChildren() == 1) { - type = node.getChild(0).getJavaType(); - } - switch (node.getId()) { - case JavaParserTreeConstants.JJTCLASSORINTERFACETYPE: - type = ClassDescriptorLoader.getClassDescriptor(Class.class); - break; - case JavaParserTreeConstants.JJTPRIMARYEXPRESSION: - type = determineExpressionType(node); - if (log.isDebugEnabled()) { - log.debug("result of determineExpressionType for " + node.getText() + " = " + type); - } - break; - case JavaParserTreeConstants.JJTLITERAL: - type = determineLiteralType(node); - break; - case JavaParserTreeConstants.JJTCASTEXPRESSION: - type = TagManager.resolveClass(node.getChild(0).getText(), compiler); - break; - } - node.setJavaType(type); - } - - /** - * Adds type information to nodes where possible, and as a side effect adds event listeners to nodes which - * can be tracked. - * - * @param expression the node to scan - * @return the class descriptor of the return type or null - */ - private ClassDescriptor determineExpressionType(SimpleNode expression) { - if (log.isDebugEnabled()) { - log.debug("for expression " + expression.getText()); - } - assert expression.getId() == JavaParserTreeConstants.JJTPRIMARYEXPRESSION; - SimpleNode prefix = expression.getChild(0); - if (prefix.jjtGetNumChildren() == 1) { - int type = prefix.getChild(0).getId(); - if (type == JavaParserTreeConstants.JJTLITERAL || type == JavaParserTreeConstants.JJTEXPRESSION) { - prefix.setJavaType(prefix.getChild(0).getJavaType()); - } else if (type == JavaParserTreeConstants.JJTNAME && expression.jjtGetNumChildren() == 1) { - // name with no arguments after it - ClassDescriptor classDescriptor = scanCompoundSymbol(prefix.getText().trim(), compiler.getRootObject().getObjectClass(), false); - if (log.isDebugEnabled()) { - log.debug("scanCompoundSymbol result for node " + prefix.getText().trim() + " = " + classDescriptor); - } - prefix.setJavaType(classDescriptor); - } - } - - if (expression.jjtGetNumChildren() == 1) { - return prefix.getJavaType(); - } - - ClassDescriptor contextClass = prefix.getJavaType(); - if (contextClass == null) { - contextClass = compiler.getRootObject().getObjectClass(); - } - String lastNode = prefix.getText().trim(); - - for (int i = 1; i < expression.jjtGetNumChildren(); i++) { - SimpleNode suffix = expression.getChild(i); - if (suffix.jjtGetNumChildren() == 1 && suffix.getChild(0).getId() == JavaParserTreeConstants.JJTARGUMENTS) { - if (suffix.getChild(0).jjtGetNumChildren() == 0) { - // at the moment only no-argument methods are trackable - contextClass = scanCompoundSymbol(lastNode, contextClass, true); - if (log.isDebugEnabled()) { - log.debug("scanCompoundSymbol result for node " + lastNode + " = " + contextClass); - } - if (contextClass == null) { - return null; - } - int dotPos = lastNode.lastIndexOf("."); - String code = dotPos == -1 ? "" : lastNode.substring(0, dotPos); - for (int j = i - 2; j >= 0; j--) { - code = expression.getChild(j).getText() + code; - } - if (code.length() == 0) { - code = compiler.getRootObject().getJavaCode(); - } - String methodName = lastNode.substring(dotPos + 1).trim(); - if (log.isDebugEnabled()) { - log.debug("try to find type for method " + methodName + ", code : " + code); - } - try { - MethodDescriptor method = contextClass.getMethodDescriptor(methodName); - trackMemberIfPossible(code, contextClass, method.getName(), true); - if (log.isDebugEnabled()) { - log.debug("method found = " + method); - } - return method.getReturnType(); - } catch (NoSuchMethodException e) { - // happens for methods defined in the current JAXX file via scripts - String propertyName = null; - if (methodName.startsWith("is")) { - propertyName = Introspector.decapitalize(methodName.substring("is".length())); - } else if (methodName.startsWith("get")) { - propertyName = Introspector.decapitalize(methodName.substring("get".length())); - } - if (propertyName != null) { - //TC-20091026 use the getScriptMethod from compiler - MethodDescriptor newMethod = compiler.getScriptMethod(methodName); - if (newMethod != null) { - //TC-20091202 must suffix dependency by property, otherwise can not have two bindings - // on the same parent... -// addListener(compiler.getRootObject().getId(), - addListener(compiler.getRootObject().getId()+"."+propertyName, - null, - "addPropertyChangeListener(\"" + propertyName + "\", this);" + JAXXCompiler.getLineSeparator(), - "removePropertyChangeListener(\"" + propertyName + "\", this);" + JAXXCompiler.getLineSeparator()); - contextClass = newMethod.getReturnType(); - } - } - } - } - } - lastNode = suffix.getText().trim(); - if (lastNode.startsWith(".")) { - lastNode = lastNode.substring(1); - } - } - - return null; - } - - private ClassDescriptor determineLiteralType(SimpleNode node) { - assert node.getId() == JavaParserTreeConstants.JJTLITERAL; - if (node.jjtGetNumChildren() == 1) { - int childId = node.getChild(0).getId(); - if (childId == JavaParserTreeConstants.JJTBOOLEANLITERAL) { - return ClassDescriptorLoader.getClassDescriptor(boolean.class); - } - if (childId == JavaParserTreeConstants.JJTNULLLITERAL) { - return ClassDescriptorLoader.getClassDescriptor(NULL.class); - } - throw new RuntimeException("Expected BooleanLiteral or NullLiteral, found " + JavaParserTreeConstants.jjtNodeName[childId]); - } - int nodeId = node.firstToken.kind; - switch (nodeId) { - case JavaParserConstants.INTEGER_LITERAL: - if (node.firstToken.image.toLowerCase().endsWith("l")) { - return ClassDescriptorLoader.getClassDescriptor(long.class); - } - return ClassDescriptorLoader.getClassDescriptor(int.class); - case JavaParserConstants.CHARACTER_LITERAL: - return ClassDescriptorLoader.getClassDescriptor(char.class); - case JavaParserConstants.FLOATING_POINT_LITERAL: - if (node.firstToken.image.toLowerCase().endsWith("f")) { - return ClassDescriptorLoader.getClassDescriptor(float.class); - } - return ClassDescriptorLoader.getClassDescriptor(double.class); - case JavaParserConstants.STRING_LITERAL: - return ClassDescriptorLoader.getClassDescriptor(String.class); - default: - throw new RuntimeException("Expected literal token, found " + JavaParserConstants.tokenImage[nodeId]); - } - } - - /** - * Scans through a compound symbol (foo.bar.baz) to identify and track all trackable pieces of it. - * - * @param symbol symbol to scan - * @param contextClass current class context - * @param isMethod flag to search a method - * @return the type of the symbol (or null if it could not be determined). - */ - private ClassDescriptor scanCompoundSymbol(String symbol, ClassDescriptor contextClass, boolean isMethod) { - String[] tokens = symbol.split("\\s*\\.\\s*"); - if (log.isDebugEnabled()) { - log.debug("for symbol " + symbol + ", contextClass " + contextClass + ", isMethod " + isMethod); - log.debug("tokens " + Arrays.toString(tokens)); - } - StringBuffer currentSymbol = new StringBuffer(); - StringBuffer tokensSeenSoFar = new StringBuffer(); - // if this ends up false, it means we weren't able to figure out - boolean accepted; - // which object the method is being invoked on - boolean recognizeClassNames = true; - for (int j = 0; j < tokens.length - (isMethod ? 1 : 0); j++) { - accepted = false; - - if (tokensSeenSoFar.length() > 0) { - tokensSeenSoFar.append('.'); - } - tokensSeenSoFar.append(tokens[j]); - if (currentSymbol.length() > 0) { - currentSymbol.append('.'); - } - currentSymbol.append(tokens[j]); - if (log.isDebugEnabled()) { - log.debug("try to find type for " + currentSymbol); - } - if (currentSymbol.indexOf(".") == -1) { - String memberName = currentSymbol.toString(); - CompiledObject object = compiler.getCompiledObject(memberName); - if (object != null) { - if (log.isDebugEnabled()) { - log.debug("detected an object " + object); - } - contextClass = object.getObjectClass(); - currentSymbol.setLength(0); - accepted = true; - recognizeClassNames = false; - } else { - try { - FieldDescriptor field = contextClass.getFieldDescriptor(memberName); - trackMemberIfPossible(tokensSeenSoFar.toString(), contextClass, field.getName(), false); - try { - contextClass = field.getType(); - } catch (Exception e) { - log.warn("could not find type for field " + field); - throw new NoSuchFieldException(e.getMessage()); - } - - currentSymbol.setLength(0); - accepted = true; - recognizeClassNames = false; - } catch (NoSuchFieldException e) { - if (j == 0 || j == 1 && tokens[0].equals(compiler.getRootObject().getId())) { - // still in root context - FieldDescriptor newField = compiler.getScriptField(memberName); - if (newField != null) { - if (log.isDebugEnabled()) { - log.debug("Detect a field script to use in binding : " + newField); - } - contextClass = newField.getType(); - - if (log.isDebugEnabled()) { - log.debug("Add listener for expression " + tokensSeenSoFar.toString()); - } - String eol = JAXXCompiler.getLineSeparator(); - addListener(tokensSeenSoFar.toString(), - null, - "addPropertyChangeListener(\"" + memberName + "\", this);" + eol, -// "addPropertyChangeListener(\"" + memberName + "\", " + listenerId + ");" + eol, - "removePropertyChangeListener(\"" + memberName + "\", this);" + eol); -// "removePropertyChangeListener(\"" + memberName + "\", " + listenerId + ");" + eol); - - assert contextClass != null : "script field '" + memberName + "' is defined, but has type null"; - currentSymbol.setLength(0); - accepted = true; - recognizeClassNames = false; - } - } - } - } - } - if (currentSymbol.length() > 0 && recognizeClassNames) { - if (log.isDebugEnabled()) { - log.debug("Try to recognizeClassNames for symbol " + currentSymbol); - } - contextClass = TagManager.resolveClass(currentSymbol.toString(), compiler); - if (contextClass != null) { - currentSymbol.setLength(0); - //accepted = true; - //recognizeClassNames = false; - // TODO: for now we don't handle statics - return null; - } - } - if (!accepted) { - if (log.isDebugEnabled()) { - log.debug("symbol " + symbol + " was not accepted."); - } - return null; - } - } - - return contextClass; - } - - private void trackMemberIfPossible(String objectCode, ClassDescriptor objectClass, String memberName, boolean method) { - - if (log.isDebugEnabled()) { - log.debug("for [objectCode:" + objectCode + ", objectClass:" + objectClass + ", memberName:" + memberName + ", isMethod:" + method); - } - DefaultObjectHandler handler = TagManager.getTagHandler(objectClass); - try { - if (handler.isMemberBound(memberName)) { - addListener(objectCode + "." + memberName + (method ? "()" : ""), - objectCode, - getAddMemberListenerCode(handler, objectCode, memberName, "this", compiler), - getRemoveMemberListenerCode(handler, objectCode, memberName, "this", compiler)); - } - } catch (UnsupportedAttributeException e) { - // ignore -- this is thrown for methods like toString(), for which there is no tracking and - // no setting support - } - } - - private void addListener(String dependencySymbol, String objectCode, String addCode, String removeCode) { - this.objectCode = objectCode; - boolean needTest = objectCode != null && !compiler.getRootObject().getId().equals(objectCode); - if (log.isDebugEnabled()) { - log.debug("try to add listener [dependencySymbol:" + dependencySymbol + ", objectCode:" + objectCode + ", addCode:" + addCode + "]"); - } - if (!dependencySymbols.contains(dependencySymbol)) { - if (log.isDebugEnabled()) { - log.debug("add [dependencySymbol:" + dependencySymbol + ", objectCode:" + objectCode + "]"); - } - dependencySymbols.add(dependencySymbol); - String eol = JAXXCompiler.getLineSeparator(); - if (dependencySymbols.size() > 1) { - addListenerCode.append(eol); - } - if (needTest) { - addListenerCode.append("if (").append(objectCode).append(" != null) {").append(eol); - } - addListenerCode.append(JavaFileGenerator.indent(addCode, needTest ? 4 : 0, false, eol)); - if (needTest) { - addListenerCode.append(eol).append("}"); - } - - if (dependencySymbols.size() > 1) { - removeListenerCode.append(eol); - } - if (needTest) { - removeListenerCode.append("if (").append(objectCode).append(" != null) {").append(eol); - } - removeListenerCode.append(JavaFileGenerator.indent(removeCode, needTest ? 4 : 0, false, eol)); - if (needTest) { - removeListenerCode.append(eol).append("}"); - } - } - } - - public boolean hasMethod(String methodName) { - for (JavaMethod method : methods) { - if (methodName.equals(method.getName())) { - return true; - } - } - return false; - } - - /** - * 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 - * of a Java code snippet that evaluates to a listener object. - * <p/> - * For ordinary bound JavaBeans properties, the Java code returned is a simple call to - * <code>addPropertyChangeListener</code>. Fields and methods which do not actually fire - * <code>PropertyChangeEvents</code> when they change necessitate more complex code. - * - * @param handler Object handler (containts known events - * @param objectCode Java code which evaluates to the object to which to add the listener - * *@param dataBinding the name of the data binding this listener is a part of - * @param memberName the name of the field or method to listen to - * @param propertyChangeListenerCode Java code which evaluates to a <code>PropertyChangeListener</code> - * @param compiler the current <code>JAXXCompiler</code> - * @return Java code snippet which causes the listener to be added to the object - */ - public String getAddMemberListenerCode(DefaultObjectHandler handler, String objectCode, String memberName, String propertyChangeListenerCode, JAXXCompiler compiler) { - if ("getClass".equals(memberName)) { - return null; - } - - DefaultObjectHandler.ProxyEventInfo eventInfo = handler.getEventInfo(memberName); -// DefaultObjectHandler.ProxyEventInfo eventInfo = eventInfos != null ? eventInfos.get(memberName) : null; - if (eventInfo != null) { - // a "proxied" event is one that doesn't fire PropertyChangeEvent, so we need to convert its native event type into PropertyChangeEvents - StringBuffer result = new StringBuffer(); - String methodName = "$pr" + compiler.getUniqueId(propertyChangeListenerCode.equals("this") ? constantId : propertyChangeListenerCode); -// String methodName = "$pr" + compiler.getUniqueId(propertyChangeListenerCode); - boolean methodExists = hasMethod(methodName); -// boolean methodExists = compiler.hasMethod(methodName); - ClassDescriptor eventClass = DefaultObjectHandler.getEventClass(eventInfo.getListenerClass()); -// ClassDescriptor eventClass = getEventClass(eventInfo.listenerClass); - if (!methodExists) { - methods.add(new JavaMethod(Modifier.PUBLIC, "void", methodName, - new JavaArgument[]{new JavaArgument(JAXXCompiler.getCanonicalName(eventClass), "event")}, null, - "propertyChange(null);", false)); -// compiler.getJavaFile().addMethod(new JavaMethod(Modifier.PUBLIC, "void", methodName, -// new JavaArgument[]{new JavaArgument(JAXXCompiler.getCanonicalName(eventClass), "event")}, null, -// propertyChangeListenerCode + ".propertyChange(null);", false)); - } - String code = objectCode + (eventInfo.getModelName() != null ? ".get" + StringUtils.capitalize(eventInfo.getModelName()) + "()" : ""); -// String code = objectCode + (eventInfo.modelName != null ? ".get" + StringUtils.capitalize(eventInfo.modelName) + "()" : ""); - result.append("$bindingSources.put(\"").append(code).append("\", ").append(code).append(");").append(JAXXCompiler.getLineSeparator()); - //TC-20091105 Util.getEventListener is generic, no more need cast and use simple listener name - result.append(code).append('.').append(eventInfo.getAddMethod()).append("( Util.getEventListener(").append(eventInfo.getListenerClass().getSimpleName()).append(".class, ").append("this").append(", ").append(TypeManager.getJavaCode(methodName)).append("));"); -// result.append(code).append('.').append(eventInfo.getAddMethod()).append("( Util.getEventListener(").append(eventInfo.getListenerClass().getSimpleName()).append(".class, ").append(compiler.getRootObject().getJavaCode()).append(", ").append(TypeManager.getJavaCode(methodName)).append("));"); -// result.append(code).append('.').append(eventInfo.addMethod).append("( Util.getEventListener(").append(eventInfo.listenerClass.getSimpleName()).append(".class, ").append(compiler.getRootObject().getJavaCode()).append(", ").append(TypeManager.getJavaCode(methodName)).append("));"); - result.append(JAXXCompiler.getLineSeparator()); -// if (eventInfo.modelName != null) { - if (eventInfo.getModelName() != null) { -// result.append(getAddMemberListenerCode(objectCode, dataBinding, "get" + StringUtils.capitalize(eventInfo.modelName), - result.append(getAddMemberListenerCode(handler, objectCode, "get" + StringUtils.capitalize(eventInfo.getModelName()), - Util.class.getSimpleName() + ".getDataBindingUpdateListener(" + (compiler.getOutputClassName() + ".this") + ", " + constantId + ")", -// Util.class.getSimpleName() + ".getDataBindingUpdateListener(this , " + dataBinding + ")", -// Util.class.getSimpleName() + ".getDataBindingUpdateListener(this , \"" + dataBinding + "\")", - compiler)); - } - return result.toString(); - } else { - String propertyName = null; - if (memberName.startsWith("get")) { - propertyName = Introspector.decapitalize(memberName.substring("get".length())); - } else if (memberName.startsWith("is")) { - propertyName = Introspector.decapitalize(memberName.substring("is".length())); - } else { - try { - handler.getBeanClass().getFieldDescriptor(memberName); -// getBeanClass().getFieldDescriptor(memberName); - propertyName = memberName; - } catch (NoSuchFieldException e) { - // ignore ? - } - } - if (propertyName != null) { - //TC-20091026 when on root object, do not prefix with objectCode - String prefix = objectCode.trim() + "."; - if (objectCode.equals(compiler.getRootObject().getJavaCode())) { - prefix = ""; - } - try { - // check for property-specific addPropertyChangeListener method -// getBeanClass().getMethodDescriptor("addPropertyChangeListener", ClassDescriptorLoader.getClassDescriptor(String.class), - handler.getBeanClass().getMethodDescriptor("addPropertyChangeListener", ClassDescriptorLoader.getClassDescriptor(String.class), - ClassDescriptorLoader.getClassDescriptor(PropertyChangeListener.class)); - return prefix + "addPropertyChangeListener(\"" + propertyName + "\", " + propertyChangeListenerCode + ");\n"; - } catch (NoSuchMethodException e) { - // no property-specific method, use general one - return prefix + "addPropertyChangeListener(" + propertyChangeListenerCode + ");\n"; - } - } - return null; - } - } - - public String getRemoveMemberListenerCode(DefaultObjectHandler handler, String objectCode, String memberName, String propertyChangeListenerCode, JAXXCompiler compiler) { - if ("getClass".equals(memberName)) { - return null; - } - - DefaultObjectHandler.ProxyEventInfo eventInfo = handler.getEventInfo(memberName); -// ProxyEventInfo eventInfo = eventInfos != null ? eventInfos.get(memberName) : null; - if (eventInfo != null) { - // a "proxied" event is one that doesn't fire PropertyChangeEvent, - // so we need to convert its native event type into PropertyChangeEvents - StringBuffer result = new StringBuffer(); - String methodName = "$pr" + compiler.getUniqueId(propertyChangeListenerCode.equals("this") ? constantId : propertyChangeListenerCode); - boolean methodExists = hasMethod(methodName); -// boolean methodExists = compiler.hasMethod(methodName); - if (!methodExists) { - ClassDescriptor eventClass = DefaultObjectHandler.getEventClass(eventInfo.getListenerClass()); -// ClassDescriptor eventClass = getEventClass(eventInfo.listenerClass); - methods.add(new JavaMethod(Modifier.PUBLIC, "void", methodName, - new JavaArgument[]{new JavaArgument(JAXXCompiler.getCanonicalName(eventClass), "event")}, null, - "propertyChange(null);", false)); -// compiler.getJavaFile().addMethod(new JavaMethod(Modifier.PUBLIC, "void", methodName, -// new JavaArgument[]{new JavaArgument(JAXXCompiler.getCanonicalName(eventClass), "event")}, null, -// propertyChangeListenerCode + ".propertyChange(null);", false)); - } - try { - String modelMemberName = eventInfo.getModelName() != null ? "get" + StringUtils.capitalize(eventInfo.getModelName()) : null; - String modelClassName = modelMemberName != null ? handler.getBeanClass().getMethodDescriptor(modelMemberName).getReturnType().getName() : JAXXCompiler.getCanonicalName(handler.getBeanClass()); - String code = objectCode + (eventInfo.getModelName() != null ? "." + modelMemberName + "()" : ""); -// String modelMemberName = eventInfo.modelName != null ? "get" + StringUtils.capitalize(eventInfo.modelName) : null; -// String modelClassName = modelMemberName != null ? getBeanClass().getMethodDescriptor(modelMemberName).getReturnType().getName() : JAXXCompiler.getCanonicalName(getBeanClass()); -// String code = objectCode + (eventInfo.modelName != null ? "." + modelMemberName + "()" : ""); - String eol = JAXXCompiler.getLineSeparator(); - result.append(modelClassName).append(" $target = ((").append(modelClassName).append(") $bindingSources.remove(\"").append(code).append("\"));").append(eol); - //TC-20091105 test if $target is not null - result.append("if ($target != null) {").append(eol); - //TC-20091105 Util.getEventListener is generic, no more need cast and use simple listener name - result.append(" $target.").append(eventInfo.getRemoveMethod()).append("( Util.getEventListener(").append(eventInfo.getListenerClass().getSimpleName()).append(".class, ").append("this").append(", ").append(TypeManager.getJavaCode(methodName)).append("));").append(eol); -// result.append(" $target.").append(eventInfo.removeMethod).append("( Util.getEventListener(").append(eventInfo.listenerClass.getSimpleName()).append(".class, ").append(compiler.getRootObject().getJavaCode()).append(", ").append(TypeManager.getJavaCode(methodName)).append("));").append(eol); - result.append("}").append(eol); - if (eventInfo.getModelName() != null) { - result.append(getRemoveMemberListenerCode(handler, objectCode, "get" + StringUtils.capitalize(eventInfo.getModelName()), - Util.class.getSimpleName() + ".getDataBindingUpdateListener(" + compiler.getOutputClassName() + ".this, " + constantId + ")", -// Util.class.getSimpleName() + ".getDataBindingUpdateListener(this, \"" + dataBinding + "\")", - compiler)); - } - return result.toString(); - } catch (NoSuchMethodException e) { - throw new CompilerException("Internal error: " + e); - } - } else { - String propertyName = null; - if (memberName.startsWith("get")) { - propertyName = Introspector.decapitalize(memberName.substring("get".length())); - } else if (memberName.startsWith("is")) { - propertyName = Introspector.decapitalize(memberName.substring("is".length())); - } else { - try { - handler.getBeanClass().getFieldDescriptor(memberName); -// getBeanClass().getFieldDescriptor(memberName); - propertyName = memberName; - } catch (NoSuchFieldException e) { - // ignore ? - } - } - if (propertyName != null) { - //TC-20091026 when on root object, do not prefix with objectCode - String prefix = objectCode.trim() + "."; - if (objectCode.equals(compiler.getRootObject().getJavaCode())) { - prefix = ""; - } - try { - // check for property-specific removePropertyChangeListener method - handler.getBeanClass().getMethodDescriptor("removePropertyChangeListener", ClassDescriptorLoader.getClassDescriptor(String.class), - ClassDescriptorLoader.getClassDescriptor(PropertyChangeListener.class)); - return prefix + "removePropertyChangeListener(\"" + propertyName + "\", " + propertyChangeListenerCode + ");\n"; - } catch (NoSuchMethodException e) { - // no property-specific method, use general one - return prefix + "removePropertyChangeListener(" + propertyChangeListenerCode + ");\n"; - } - } - return null; - } - } -} \ No newline at end of file Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataSource.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataSource.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataSource.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataSource.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,719 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.binding; + +import jaxx.compiler.CompiledObject; +import jaxx.compiler.CompilerException; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.UnsupportedAttributeException; +import jaxx.compiler.java.JavaArgument; +import jaxx.compiler.java.JavaFileGenerator; +import jaxx.compiler.java.JavaMethod; +import jaxx.compiler.java.parser.JavaParser; +import jaxx.compiler.java.parser.JavaParserConstants; +import jaxx.compiler.java.parser.JavaParserTreeConstants; +import jaxx.compiler.java.parser.SimpleNode; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.reflect.FieldDescriptor; +import jaxx.compiler.reflect.MethodDescriptor; +import jaxx.compiler.tags.DefaultObjectHandler; +import jaxx.compiler.tags.TagManager; +import jaxx.compiler.types.TypeManager; +import jaxx.runtime.Util; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.beans.Introspector; +import java.beans.PropertyChangeListener; +import java.io.StringReader; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * Represents a Java expression which fires a <code>PropertyChangeEvent</code> when it can be + * determined that its value may have changed. Events are fired on a "best effort" basis, and events + * may either be fired too often (the value has not actually changed) or not often enough (the value + * changed but no event was fired). + */ +public class DataSource { + + /** + * Logger + */ + protected static final Log log = LogFactory.getLog(DataSource.class); + + /** + * type attached to "null" constants in parsed expressions + */ + private class NULL { + } + + /** + * id of data source + */ + private final String id; + /** + * Constant id + */ + protected final String constantId; + /** + * The Java source code for the expression. + */ + private final String source; + /** + * The current <code>JAXXCompiler</code>. + */ + private final JAXXCompiler compiler; + /** + * List of symbols which this data source expression depends on. + */ + private final List<String> dependencySymbols = new ArrayList<String>(); + /** + * code to put in applyDataBinding method on generated java file + */ + private final StringBuffer addListenerCode; + /** + * code to put in removeDataBinding method on generated java file + */ + private final StringBuffer removeListenerCode; + /** + * the delegate of property to be required + */ + private String objectCode; + + protected final List<JavaMethod> methods; + + /** + * Creates a new data source. After creating a <code>DataSource</code>, use {@link #compile()} + * to cause it to function at runtime. + * + * @param id the DataSource's id + * @param constantId the DataSource constant id + * @param source the Java source code for the data source expression + * @param compiler the current <code>JAXXCompiler</code> + * @param addListenerCode where to push add code + * @param removeListenerCode where to push remove code + * @param methods where to store extra method to add to binding + */ + public DataSource(String id, String constantId, String source, JAXXCompiler compiler, StringBuffer addListenerCode, StringBuffer removeListenerCode, List<JavaMethod> methods) { + this.id = id; + this.constantId = constantId; + this.source = source; + this.compiler = compiler; + this.addListenerCode = addListenerCode; + this.removeListenerCode = removeListenerCode; + this.methods = methods; + } + + public String getObjectCode() { + return objectCode; + } + + @Override + public String toString() { + ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE); + b.append("source:id", id); + b.append("source:source", source); + b.append("source:objectCode", objectCode); + if (dependencySymbols != null && !dependencySymbols.isEmpty()) { + b.append("source:dependencySymbols", dependencySymbols.size()); + for (String d : dependencySymbols) { + b.append("source:depencendy ", d); + } + } + return b.toString(); + } + + /** + * Compiles the data source expression and listener. This method calls methods in <code>JAXXCompiler</code> + * to add the Java code that performs the data source setup. Adding listeners to <code>DataSource</code> is + * slightly more complicated than with ordinary classes, because <code>DataSource</code> only exists at compile + * time. You must pass in a Java expression which evaluates to a <code>PropertyChangeListener</code>; this + * expression will be compiled and evaluated at runtime to yield the <code>DataSource's</code> listener. + * + * @return <code>true</code> if the expression has dependencies, <code>false</code> otherwise + * @throws jaxx.compiler.CompilerException + * if a compilation error occurs + * @throws IllegalStateException if data source was already compiled + */ + protected boolean compile() throws CompilerException, IllegalStateException { + + if (DataBindingHelper.SHOW_LOG || log.isDebugEnabled()) { + log.debug("try to compile dataSource\n" + this); + } + JavaParser p = new JavaParser(new StringReader(source)); + while (!p.Line()) { + SimpleNode node = p.popNode(); + if (log.isDebugEnabled()) { + log.debug("will scan node " + node.getText()); + } + scanNode(node); + } + if (log.isDebugEnabled()) { + log.debug("dependencySymbols=" + dependencySymbols); + } + + boolean isBinding = !dependencySymbols.isEmpty(); + + return isBinding; + } + + /** + * Examines a node to identify any dependencies it contains. + * + * @param node node to scan + * @throws jaxx.compiler.CompilerException + * ? + */ + private void scanNode(SimpleNode node) throws CompilerException { + if (node.getId() == JavaParserTreeConstants.JJTMETHODDECLARATION || + node.getId() == JavaParserTreeConstants.JJTFIELDDECLARATION) { + return; + } + if (log.isTraceEnabled()) { + log.trace(node.getText()); + } + int count = node.jjtGetNumChildren(); + for (int i = 0; i < count; i++) { + scanNode(node.getChild(i)); + } + // determine node type + ClassDescriptor type = null; + if (node.jjtGetNumChildren() == 1) { + type = node.getChild(0).getJavaType(); + } + switch (node.getId()) { + case JavaParserTreeConstants.JJTCLASSORINTERFACETYPE: + type = ClassDescriptorLoader.getClassDescriptor(Class.class); + break; + case JavaParserTreeConstants.JJTPRIMARYEXPRESSION: + type = determineExpressionType(node); + if (log.isDebugEnabled()) { + log.debug("result of determineExpressionType for " + node.getText() + " = " + type); + } + break; + case JavaParserTreeConstants.JJTLITERAL: + type = determineLiteralType(node); + break; + case JavaParserTreeConstants.JJTCASTEXPRESSION: + type = TagManager.resolveClass(node.getChild(0).getText(), compiler); + break; + } + node.setJavaType(type); + } + + /** + * Adds type information to nodes where possible, and as a side effect adds event listeners to nodes which + * can be tracked. + * + * @param expression the node to scan + * @return the class descriptor of the return type or null + */ + private ClassDescriptor determineExpressionType(SimpleNode expression) { + if (log.isDebugEnabled()) { + log.debug("for expression " + expression.getText()); + } + assert expression.getId() == JavaParserTreeConstants.JJTPRIMARYEXPRESSION; + SimpleNode prefix = expression.getChild(0); + if (prefix.jjtGetNumChildren() == 1) { + int type = prefix.getChild(0).getId(); + if (type == JavaParserTreeConstants.JJTLITERAL || type == JavaParserTreeConstants.JJTEXPRESSION) { + prefix.setJavaType(prefix.getChild(0).getJavaType()); + } else if (type == JavaParserTreeConstants.JJTNAME && expression.jjtGetNumChildren() == 1) { + // name with no arguments after it + ClassDescriptor classDescriptor = scanCompoundSymbol(prefix.getText().trim(), compiler.getRootObject().getObjectClass(), false); + if (log.isDebugEnabled()) { + log.debug("scanCompoundSymbol result for node " + prefix.getText().trim() + " = " + classDescriptor); + } + prefix.setJavaType(classDescriptor); + } + } + + if (expression.jjtGetNumChildren() == 1) { + return prefix.getJavaType(); + } + + ClassDescriptor contextClass = prefix.getJavaType(); + if (contextClass == null) { + contextClass = compiler.getRootObject().getObjectClass(); + } + String lastNode = prefix.getText().trim(); + + for (int i = 1; i < expression.jjtGetNumChildren(); i++) { + SimpleNode suffix = expression.getChild(i); + if (suffix.jjtGetNumChildren() == 1 && suffix.getChild(0).getId() == JavaParserTreeConstants.JJTARGUMENTS) { + if (suffix.getChild(0).jjtGetNumChildren() == 0) { + // at the moment only no-argument methods are trackable + contextClass = scanCompoundSymbol(lastNode, contextClass, true); + if (log.isDebugEnabled()) { + log.debug("scanCompoundSymbol result for node " + lastNode + " = " + contextClass); + } + if (contextClass == null) { + return null; + } + int dotPos = lastNode.lastIndexOf("."); + String code = dotPos == -1 ? "" : lastNode.substring(0, dotPos); + for (int j = i - 2; j >= 0; j--) { + code = expression.getChild(j).getText() + code; + } + if (code.length() == 0) { + code = compiler.getRootObject().getJavaCode(); + } + String methodName = lastNode.substring(dotPos + 1).trim(); + if (log.isDebugEnabled()) { + log.debug("try to find type for method " + methodName + ", code : " + code); + } + try { + MethodDescriptor method = contextClass.getMethodDescriptor(methodName); + trackMemberIfPossible(code, contextClass, method.getName(), true); + if (log.isDebugEnabled()) { + log.debug("method found = " + method); + } + return method.getReturnType(); + } catch (NoSuchMethodException e) { + // happens for methods defined in the current JAXX file via scripts + String propertyName = null; + if (methodName.startsWith("is")) { + propertyName = Introspector.decapitalize(methodName.substring("is".length())); + } else if (methodName.startsWith("get")) { + propertyName = Introspector.decapitalize(methodName.substring("get".length())); + } + if (propertyName != null) { + //TC-20091026 use the getScriptMethod from compiler + MethodDescriptor newMethod = compiler.getScriptMethod(methodName); + if (newMethod != null) { + //TC-20091202 must suffix dependency by property, otherwise can not have two bindings + // on the same parent... +// addListener(compiler.getRootObject().getId(), + addListener(compiler.getRootObject().getId()+"."+propertyName, + null, + "addPropertyChangeListener(\"" + propertyName + "\", this);" + JAXXCompiler.getLineSeparator(), + "removePropertyChangeListener(\"" + propertyName + "\", this);" + JAXXCompiler.getLineSeparator()); + contextClass = newMethod.getReturnType(); + } + } + } + } + } + lastNode = suffix.getText().trim(); + if (lastNode.startsWith(".")) { + lastNode = lastNode.substring(1); + } + } + + return null; + } + + private ClassDescriptor determineLiteralType(SimpleNode node) { + assert node.getId() == JavaParserTreeConstants.JJTLITERAL; + if (node.jjtGetNumChildren() == 1) { + int childId = node.getChild(0).getId(); + if (childId == JavaParserTreeConstants.JJTBOOLEANLITERAL) { + return ClassDescriptorLoader.getClassDescriptor(boolean.class); + } + if (childId == JavaParserTreeConstants.JJTNULLLITERAL) { + return ClassDescriptorLoader.getClassDescriptor(NULL.class); + } + throw new RuntimeException("Expected BooleanLiteral or NullLiteral, found " + JavaParserTreeConstants.jjtNodeName[childId]); + } + int nodeId = node.firstToken.kind; + switch (nodeId) { + case JavaParserConstants.INTEGER_LITERAL: + if (node.firstToken.image.toLowerCase().endsWith("l")) { + return ClassDescriptorLoader.getClassDescriptor(long.class); + } + return ClassDescriptorLoader.getClassDescriptor(int.class); + case JavaParserConstants.CHARACTER_LITERAL: + return ClassDescriptorLoader.getClassDescriptor(char.class); + case JavaParserConstants.FLOATING_POINT_LITERAL: + if (node.firstToken.image.toLowerCase().endsWith("f")) { + return ClassDescriptorLoader.getClassDescriptor(float.class); + } + return ClassDescriptorLoader.getClassDescriptor(double.class); + case JavaParserConstants.STRING_LITERAL: + return ClassDescriptorLoader.getClassDescriptor(String.class); + default: + throw new RuntimeException("Expected literal token, found " + JavaParserConstants.tokenImage[nodeId]); + } + } + + /** + * Scans through a compound symbol (foo.bar.baz) to identify and track all trackable pieces of it. + * + * @param symbol symbol to scan + * @param contextClass current class context + * @param isMethod flag to search a method + * @return the type of the symbol (or null if it could not be determined). + */ + private ClassDescriptor scanCompoundSymbol(String symbol, ClassDescriptor contextClass, boolean isMethod) { + String[] tokens = symbol.split("\\s*\\.\\s*"); + if (log.isDebugEnabled()) { + log.debug("for symbol " + symbol + ", contextClass " + contextClass + ", isMethod " + isMethod); + log.debug("tokens " + Arrays.toString(tokens)); + } + StringBuffer currentSymbol = new StringBuffer(); + StringBuffer tokensSeenSoFar = new StringBuffer(); + // if this ends up false, it means we weren't able to figure out + boolean accepted; + // which object the method is being invoked on + boolean recognizeClassNames = true; + for (int j = 0; j < tokens.length - (isMethod ? 1 : 0); j++) { + accepted = false; + + if (tokensSeenSoFar.length() > 0) { + tokensSeenSoFar.append('.'); + } + tokensSeenSoFar.append(tokens[j]); + if (currentSymbol.length() > 0) { + currentSymbol.append('.'); + } + currentSymbol.append(tokens[j]); + if (log.isDebugEnabled()) { + log.debug("try to find type for " + currentSymbol); + } + if (currentSymbol.indexOf(".") == -1) { + String memberName = currentSymbol.toString(); + CompiledObject object = compiler.getCompiledObject(memberName); + if (object != null) { + if (log.isDebugEnabled()) { + log.debug("detected an object " + object); + } + contextClass = object.getObjectClass(); + currentSymbol.setLength(0); + accepted = true; + recognizeClassNames = false; + } else { + try { + FieldDescriptor field = contextClass.getFieldDescriptor(memberName); + trackMemberIfPossible(tokensSeenSoFar.toString(), contextClass, field.getName(), false); + try { + contextClass = field.getType(); + } catch (Exception e) { + log.warn("could not find type for field " + field); + throw new NoSuchFieldException(e.getMessage()); + } + + currentSymbol.setLength(0); + accepted = true; + recognizeClassNames = false; + } catch (NoSuchFieldException e) { + if (j == 0 || j == 1 && tokens[0].equals(compiler.getRootObject().getId())) { + // still in root context + FieldDescriptor newField = compiler.getScriptField(memberName); + if (newField != null) { + if (log.isDebugEnabled()) { + log.debug("Detect a field script to use in binding : " + newField); + } + contextClass = newField.getType(); + + if (log.isDebugEnabled()) { + log.debug("Add listener for expression " + tokensSeenSoFar.toString()); + } + String eol = JAXXCompiler.getLineSeparator(); + addListener(tokensSeenSoFar.toString(), + null, + "addPropertyChangeListener(\"" + memberName + "\", this);" + eol, +// "addPropertyChangeListener(\"" + memberName + "\", " + listenerId + ");" + eol, + "removePropertyChangeListener(\"" + memberName + "\", this);" + eol); +// "removePropertyChangeListener(\"" + memberName + "\", " + listenerId + ");" + eol); + + assert contextClass != null : "script field '" + memberName + "' is defined, but has type null"; + currentSymbol.setLength(0); + accepted = true; + recognizeClassNames = false; + } + } + } + } + } + if (currentSymbol.length() > 0 && recognizeClassNames) { + if (log.isDebugEnabled()) { + log.debug("Try to recognizeClassNames for symbol " + currentSymbol); + } + contextClass = TagManager.resolveClass(currentSymbol.toString(), compiler); + if (contextClass != null) { + currentSymbol.setLength(0); + //accepted = true; + //recognizeClassNames = false; + // TODO: for now we don't handle statics + return null; + } + } + if (!accepted) { + if (log.isDebugEnabled()) { + log.debug("symbol " + symbol + " was not accepted."); + } + return null; + } + } + + return contextClass; + } + + private void trackMemberIfPossible(String objectCode, ClassDescriptor objectClass, String memberName, boolean method) { + + if (log.isDebugEnabled()) { + log.debug("for [objectCode:" + objectCode + ", objectClass:" + objectClass + ", memberName:" + memberName + ", isMethod:" + method); + } + DefaultObjectHandler handler = TagManager.getTagHandler(objectClass); + try { + if (handler.isMemberBound(memberName)) { + addListener(objectCode + "." + memberName + (method ? "()" : ""), + objectCode, + getAddMemberListenerCode(handler, objectCode, memberName, "this", compiler), + getRemoveMemberListenerCode(handler, objectCode, memberName, "this", compiler)); + } + } catch (UnsupportedAttributeException e) { + // ignore -- this is thrown for methods like toString(), for which there is no tracking and + // no setting support + } + } + + private void addListener(String dependencySymbol, String objectCode, String addCode, String removeCode) { + this.objectCode = objectCode; + boolean needTest = objectCode != null && !compiler.getRootObject().getId().equals(objectCode); + if (log.isDebugEnabled()) { + log.debug("try to add listener [dependencySymbol:" + dependencySymbol + ", objectCode:" + objectCode + ", addCode:" + addCode + "]"); + } + if (!dependencySymbols.contains(dependencySymbol)) { + if (log.isDebugEnabled()) { + log.debug("add [dependencySymbol:" + dependencySymbol + ", objectCode:" + objectCode + "]"); + } + dependencySymbols.add(dependencySymbol); + String eol = JAXXCompiler.getLineSeparator(); + if (dependencySymbols.size() > 1) { + addListenerCode.append(eol); + } + if (needTest) { + addListenerCode.append("if (").append(objectCode).append(" != null) {").append(eol); + } + addListenerCode.append(JavaFileGenerator.indent(addCode, needTest ? 4 : 0, false, eol)); + if (needTest) { + addListenerCode.append(eol).append("}"); + } + + if (dependencySymbols.size() > 1) { + removeListenerCode.append(eol); + } + if (needTest) { + removeListenerCode.append("if (").append(objectCode).append(" != null) {").append(eol); + } + removeListenerCode.append(JavaFileGenerator.indent(removeCode, needTest ? 4 : 0, false, eol)); + if (needTest) { + removeListenerCode.append(eol).append("}"); + } + } + } + + public boolean hasMethod(String methodName) { + for (JavaMethod method : methods) { + if (methodName.equals(method.getName())) { + return true; + } + } + return false; + } + + /** + * 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 + * of a Java code snippet that evaluates to a listener object. + * <p/> + * For ordinary bound JavaBeans properties, the Java code returned is a simple call to + * <code>addPropertyChangeListener</code>. Fields and methods which do not actually fire + * <code>PropertyChangeEvents</code> when they change necessitate more complex code. + * + * @param handler Object handler (containts known events + * @param objectCode Java code which evaluates to the object to which to add the listener + * *@param dataBinding the name of the data binding this listener is a part of + * @param memberName the name of the field or method to listen to + * @param propertyChangeListenerCode Java code which evaluates to a <code>PropertyChangeListener</code> + * @param compiler the current <code>JAXXCompiler</code> + * @return Java code snippet which causes the listener to be added to the object + */ + public String getAddMemberListenerCode(DefaultObjectHandler handler, String objectCode, String memberName, String propertyChangeListenerCode, JAXXCompiler compiler) { + if ("getClass".equals(memberName)) { + return null; + } + + DefaultObjectHandler.ProxyEventInfo eventInfo = handler.getEventInfo(memberName); +// DefaultObjectHandler.ProxyEventInfo eventInfo = eventInfos != null ? eventInfos.get(memberName) : null; + if (eventInfo != null) { + // a "proxied" event is one that doesn't fire PropertyChangeEvent, so we need to convert its native event type into PropertyChangeEvents + StringBuffer result = new StringBuffer(); + String methodName = "$pr" + compiler.getUniqueId(propertyChangeListenerCode.equals("this") ? constantId : propertyChangeListenerCode); +// String methodName = "$pr" + compiler.getUniqueId(propertyChangeListenerCode); + boolean methodExists = hasMethod(methodName); +// boolean methodExists = compiler.hasMethod(methodName); + ClassDescriptor eventClass = DefaultObjectHandler.getEventClass(eventInfo.getListenerClass()); +// ClassDescriptor eventClass = getEventClass(eventInfo.listenerClass); + if (!methodExists) { + methods.add(new JavaMethod(Modifier.PUBLIC, "void", methodName, + new JavaArgument[]{new JavaArgument(JAXXCompiler.getCanonicalName(eventClass), "event")}, null, + "propertyChange(null);", false)); +// compiler.getJavaFile().addMethod(new JavaMethod(Modifier.PUBLIC, "void", methodName, +// new JavaArgument[]{new JavaArgument(JAXXCompiler.getCanonicalName(eventClass), "event")}, null, +// propertyChangeListenerCode + ".propertyChange(null);", false)); + } + String code = objectCode + (eventInfo.getModelName() != null ? ".get" + StringUtils.capitalize(eventInfo.getModelName()) + "()" : ""); +// String code = objectCode + (eventInfo.modelName != null ? ".get" + StringUtils.capitalize(eventInfo.modelName) + "()" : ""); + result.append("$bindingSources.put(\"").append(code).append("\", ").append(code).append(");").append(JAXXCompiler.getLineSeparator()); + //TC-20091105 Util.getEventListener is generic, no more need cast and use simple listener name + result.append(code).append('.').append(eventInfo.getAddMethod()).append("( Util.getEventListener(").append(eventInfo.getListenerClass().getSimpleName()).append(".class, ").append("this").append(", ").append(TypeManager.getJavaCode(methodName)).append("));"); +// result.append(code).append('.').append(eventInfo.getAddMethod()).append("( Util.getEventListener(").append(eventInfo.getListenerClass().getSimpleName()).append(".class, ").append(compiler.getRootObject().getJavaCode()).append(", ").append(TypeManager.getJavaCode(methodName)).append("));"); +// result.append(code).append('.').append(eventInfo.addMethod).append("( Util.getEventListener(").append(eventInfo.listenerClass.getSimpleName()).append(".class, ").append(compiler.getRootObject().getJavaCode()).append(", ").append(TypeManager.getJavaCode(methodName)).append("));"); + result.append(JAXXCompiler.getLineSeparator()); +// if (eventInfo.modelName != null) { + if (eventInfo.getModelName() != null) { +// result.append(getAddMemberListenerCode(objectCode, dataBinding, "get" + StringUtils.capitalize(eventInfo.modelName), + result.append(getAddMemberListenerCode(handler, objectCode, "get" + StringUtils.capitalize(eventInfo.getModelName()), + Util.class.getSimpleName() + ".getDataBindingUpdateListener(" + (compiler.getOutputClassName() + ".this") + ", " + constantId + ")", +// Util.class.getSimpleName() + ".getDataBindingUpdateListener(this , " + dataBinding + ")", +// Util.class.getSimpleName() + ".getDataBindingUpdateListener(this , \"" + dataBinding + "\")", + compiler)); + } + return result.toString(); + } else { + String propertyName = null; + if (memberName.startsWith("get")) { + propertyName = Introspector.decapitalize(memberName.substring("get".length())); + } else if (memberName.startsWith("is")) { + propertyName = Introspector.decapitalize(memberName.substring("is".length())); + } else { + try { + handler.getBeanClass().getFieldDescriptor(memberName); +// getBeanClass().getFieldDescriptor(memberName); + propertyName = memberName; + } catch (NoSuchFieldException e) { + // ignore ? + } + } + if (propertyName != null) { + //TC-20091026 when on root object, do not prefix with objectCode + String prefix = objectCode.trim() + "."; + if (objectCode.equals(compiler.getRootObject().getJavaCode())) { + prefix = ""; + } + try { + // check for property-specific addPropertyChangeListener method +// getBeanClass().getMethodDescriptor("addPropertyChangeListener", ClassDescriptorLoader.getClassDescriptor(String.class), + handler.getBeanClass().getMethodDescriptor("addPropertyChangeListener", ClassDescriptorLoader.getClassDescriptor(String.class), + ClassDescriptorLoader.getClassDescriptor(PropertyChangeListener.class)); + return prefix + "addPropertyChangeListener(\"" + propertyName + "\", " + propertyChangeListenerCode + ");\n"; + } catch (NoSuchMethodException e) { + // no property-specific method, use general one + return prefix + "addPropertyChangeListener(" + propertyChangeListenerCode + ");\n"; + } + } + return null; + } + } + + public String getRemoveMemberListenerCode(DefaultObjectHandler handler, String objectCode, String memberName, String propertyChangeListenerCode, JAXXCompiler compiler) { + if ("getClass".equals(memberName)) { + return null; + } + + DefaultObjectHandler.ProxyEventInfo eventInfo = handler.getEventInfo(memberName); +// ProxyEventInfo eventInfo = eventInfos != null ? eventInfos.get(memberName) : null; + if (eventInfo != null) { + // a "proxied" event is one that doesn't fire PropertyChangeEvent, + // so we need to convert its native event type into PropertyChangeEvents + StringBuffer result = new StringBuffer(); + String methodName = "$pr" + compiler.getUniqueId(propertyChangeListenerCode.equals("this") ? constantId : propertyChangeListenerCode); + boolean methodExists = hasMethod(methodName); +// boolean methodExists = compiler.hasMethod(methodName); + if (!methodExists) { + ClassDescriptor eventClass = DefaultObjectHandler.getEventClass(eventInfo.getListenerClass()); +// ClassDescriptor eventClass = getEventClass(eventInfo.listenerClass); + methods.add(new JavaMethod(Modifier.PUBLIC, "void", methodName, + new JavaArgument[]{new JavaArgument(JAXXCompiler.getCanonicalName(eventClass), "event")}, null, + "propertyChange(null);", false)); +// compiler.getJavaFile().addMethod(new JavaMethod(Modifier.PUBLIC, "void", methodName, +// new JavaArgument[]{new JavaArgument(JAXXCompiler.getCanonicalName(eventClass), "event")}, null, +// propertyChangeListenerCode + ".propertyChange(null);", false)); + } + try { + String modelMemberName = eventInfo.getModelName() != null ? "get" + StringUtils.capitalize(eventInfo.getModelName()) : null; + String modelClassName = modelMemberName != null ? handler.getBeanClass().getMethodDescriptor(modelMemberName).getReturnType().getName() : JAXXCompiler.getCanonicalName(handler.getBeanClass()); + String code = objectCode + (eventInfo.getModelName() != null ? "." + modelMemberName + "()" : ""); +// String modelMemberName = eventInfo.modelName != null ? "get" + StringUtils.capitalize(eventInfo.modelName) : null; +// String modelClassName = modelMemberName != null ? getBeanClass().getMethodDescriptor(modelMemberName).getReturnType().getName() : JAXXCompiler.getCanonicalName(getBeanClass()); +// String code = objectCode + (eventInfo.modelName != null ? "." + modelMemberName + "()" : ""); + String eol = JAXXCompiler.getLineSeparator(); + result.append(modelClassName).append(" $target = ((").append(modelClassName).append(") $bindingSources.remove(\"").append(code).append("\"));").append(eol); + //TC-20091105 test if $target is not null + result.append("if ($target != null) {").append(eol); + //TC-20091105 Util.getEventListener is generic, no more need cast and use simple listener name + result.append(" $target.").append(eventInfo.getRemoveMethod()).append("( Util.getEventListener(").append(eventInfo.getListenerClass().getSimpleName()).append(".class, ").append("this").append(", ").append(TypeManager.getJavaCode(methodName)).append("));").append(eol); +// result.append(" $target.").append(eventInfo.removeMethod).append("( Util.getEventListener(").append(eventInfo.listenerClass.getSimpleName()).append(".class, ").append(compiler.getRootObject().getJavaCode()).append(", ").append(TypeManager.getJavaCode(methodName)).append("));").append(eol); + result.append("}").append(eol); + if (eventInfo.getModelName() != null) { + result.append(getRemoveMemberListenerCode(handler, objectCode, "get" + StringUtils.capitalize(eventInfo.getModelName()), + Util.class.getSimpleName() + ".getDataBindingUpdateListener(" + compiler.getOutputClassName() + ".this, " + constantId + ")", +// Util.class.getSimpleName() + ".getDataBindingUpdateListener(this, \"" + dataBinding + "\")", + compiler)); + } + return result.toString(); + } catch (NoSuchMethodException e) { + throw new CompilerException("Internal error: " + e); + } + } else { + String propertyName = null; + if (memberName.startsWith("get")) { + propertyName = Introspector.decapitalize(memberName.substring("get".length())); + } else if (memberName.startsWith("is")) { + propertyName = Introspector.decapitalize(memberName.substring("is".length())); + } else { + try { + handler.getBeanClass().getFieldDescriptor(memberName); +// getBeanClass().getFieldDescriptor(memberName); + propertyName = memberName; + } catch (NoSuchFieldException e) { + // ignore ? + } + } + if (propertyName != null) { + //TC-20091026 when on root object, do not prefix with objectCode + String prefix = objectCode.trim() + "."; + if (objectCode.equals(compiler.getRootObject().getJavaCode())) { + prefix = ""; + } + try { + // check for property-specific removePropertyChangeListener method + handler.getBeanClass().getMethodDescriptor("removePropertyChangeListener", ClassDescriptorLoader.getClassDescriptor(String.class), + ClassDescriptorLoader.getClassDescriptor(PropertyChangeListener.class)); + return prefix + "removePropertyChangeListener(\"" + propertyName + "\", " + propertyChangeListenerCode + ");\n"; + } catch (NoSuchMethodException e) { + // no property-specific method, use general one + return prefix + "removePropertyChangeListener(" + propertyChangeListenerCode + ");\n"; + } + } + return null; + } + } +} \ No newline at end of file Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/PseudoClassDataBinding.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/binding/PseudoClassDataBinding.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/PseudoClassDataBinding.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,123 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.binding; - -import jaxx.compiler.CompiledObject; -import jaxx.compiler.CompilerException; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.java.JavaFileGenerator; -import jaxx.compiler.java.parser.JavaParser; -import jaxx.compiler.java.parser.JavaParserTreeConstants; -import jaxx.compiler.java.parser.SimpleNode; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.io.StringReader; - -/** - * Represents a data binding in a JAXX file. <code>DataBinding</code> uses - * {@link jaxx.compiler.binding.DataSource} to track changes to a source expression and update - * the destination. - */ -public class PseudoClassDataBinding extends DataBinding { - - /** - * Logger - */ - protected static final Log log = LogFactory.getLog(PseudoClassDataBinding.class); - - protected final boolean invert; - - public static PseudoClassDataBinding newPseudoClassDataBinding(String pseudoClass, CompiledObject object, String propertyCode, String methodName, boolean invertTest) { - PseudoClassDataBinding binding = null; - if (pseudoClass.startsWith("{")) { - pseudoClass = pseudoClass.substring(1, pseudoClass.length() - 1).trim(); - pseudoClass = replaceObjectReferences(pseudoClass, object.getJavaCode()); - String id = object.getId() + ".style." + pseudoClass + "." + methodName; - binding = new PseudoClassDataBinding(id, pseudoClass, propertyCode, invertTest); - } - return binding; - } - - protected PseudoClassDataBinding(String id, String source, String assignment, boolean invert) { - super(id, source, assignment, false); - this.invert = invert; - } - - /** - * Replaces all references to the variable "object" with the actual object ID. - * - * @param code ? - * @param id ? - * @return ? - * @throws jaxx.compiler.CompilerException - * ? - */ - public static String replaceObjectReferences(String code, String id) throws CompilerException { - JavaParser p = new JavaParser(new StringReader(code + ";")); - p.Expression(); - jaxx.compiler.java.parser.SimpleNode node = p.popNode(); - scanNode(node, id); - return node.getText(); - } - - public static void scanNode(SimpleNode node, String id) { - if (node.getId() == JavaParserTreeConstants.JJTNAME) { - String name = node.getText(); - if (name.equals("object") || (name.indexOf(".") != -1 && name.substring(0, name.indexOf(".")).trim().equals("object"))) { - node.firstToken.image = id; - } - } else { - int count = node.jjtGetNumChildren(); - for (int i = 0; i < count; i++) { - scanNode(node.getChild(i), id); - } - } - } - - @Override - protected String getInitDataBindingCode(JAXXCompiler compiler, DataSource dataSource, boolean isBinding) { - // nothing to init - return null; - } - - @Override - protected String getProcessDataBindingCode(JAXXCompiler compiler, DataSource dataSource, boolean isBinding) { - if (!isBinding) { - return null; - } - - String eol = JAXXCompiler.getLineSeparator(); - - StringBuilder buffer = new StringBuilder(); - - String realSource = invert ? invert(getSource()) : getSource(); - buffer.append("if (").append(realSource).append(") {").append(eol); - buffer.append(JavaFileGenerator.indent(getAssignment(), 4, false, eol)).append(eol); - buffer.append("}"); - return buffer.toString(); - } - - protected String invert(String javaCode) { - javaCode = javaCode.trim(); - return javaCode.startsWith("!") ? javaCode.substring(1) : "!(" + javaCode + ")"; - } -} \ No newline at end of file Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/PseudoClassDataBinding.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/binding/PseudoClassDataBinding.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/PseudoClassDataBinding.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/PseudoClassDataBinding.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,123 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.binding; + +import jaxx.compiler.CompiledObject; +import jaxx.compiler.CompilerException; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.java.JavaFileGenerator; +import jaxx.compiler.java.parser.JavaParser; +import jaxx.compiler.java.parser.JavaParserTreeConstants; +import jaxx.compiler.java.parser.SimpleNode; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.io.StringReader; + +/** + * Represents a data binding in a JAXX file. <code>DataBinding</code> uses + * {@link jaxx.compiler.binding.DataSource} to track changes to a source expression and update + * the destination. + */ +public class PseudoClassDataBinding extends DataBinding { + + /** + * Logger + */ + protected static final Log log = LogFactory.getLog(PseudoClassDataBinding.class); + + protected final boolean invert; + + public static PseudoClassDataBinding newPseudoClassDataBinding(String pseudoClass, CompiledObject object, String propertyCode, String methodName, boolean invertTest) { + PseudoClassDataBinding binding = null; + if (pseudoClass.startsWith("{")) { + pseudoClass = pseudoClass.substring(1, pseudoClass.length() - 1).trim(); + pseudoClass = replaceObjectReferences(pseudoClass, object.getJavaCode()); + String id = object.getId() + ".style." + pseudoClass + "." + methodName; + binding = new PseudoClassDataBinding(id, pseudoClass, propertyCode, invertTest); + } + return binding; + } + + protected PseudoClassDataBinding(String id, String source, String assignment, boolean invert) { + super(id, source, assignment, false); + this.invert = invert; + } + + /** + * Replaces all references to the variable "object" with the actual object ID. + * + * @param code ? + * @param id ? + * @return ? + * @throws jaxx.compiler.CompilerException + * ? + */ + public static String replaceObjectReferences(String code, String id) throws CompilerException { + JavaParser p = new JavaParser(new StringReader(code + ";")); + p.Expression(); + jaxx.compiler.java.parser.SimpleNode node = p.popNode(); + scanNode(node, id); + return node.getText(); + } + + public static void scanNode(SimpleNode node, String id) { + if (node.getId() == JavaParserTreeConstants.JJTNAME) { + String name = node.getText(); + if (name.equals("object") || (name.indexOf(".") != -1 && name.substring(0, name.indexOf(".")).trim().equals("object"))) { + node.firstToken.image = id; + } + } else { + int count = node.jjtGetNumChildren(); + for (int i = 0; i < count; i++) { + scanNode(node.getChild(i), id); + } + } + } + + @Override + protected String getInitDataBindingCode(JAXXCompiler compiler, DataSource dataSource, boolean isBinding) { + // nothing to init + return null; + } + + @Override + protected String getProcessDataBindingCode(JAXXCompiler compiler, DataSource dataSource, boolean isBinding) { + if (!isBinding) { + return null; + } + + String eol = JAXXCompiler.getLineSeparator(); + + StringBuilder buffer = new StringBuilder(); + + String realSource = invert ? invert(getSource()) : getSource(); + buffer.append("if (").append(realSource).append(") {").append(eol); + buffer.append(JavaFileGenerator.indent(getAssignment(), 4, false, eol)).append(eol); + buffer.append("}"); + return buffer.toString(); + } + + protected String invert(String javaCode) { + javaCode = javaCode.trim(); + return javaCode.startsWith("!") ? javaCode.substring(1) : "!(" + javaCode + ")"; + } +} \ No newline at end of file Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/StylesheetHelper.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/StylesheetHelper.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/StylesheetHelper.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,595 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.css; - -import jaxx.compiler.CompiledObject; -import jaxx.compiler.CompilerException; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.binding.DataBinding; -import jaxx.compiler.binding.DataBindingHelper; -import jaxx.compiler.binding.PseudoClassDataBinding; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.reflect.MethodDescriptor; -import jaxx.compiler.tags.DefaultObjectHandler; -import jaxx.compiler.tags.TagManager; -import jaxx.compiler.types.TypeManager; -import jaxx.runtime.css.Rule; -import jaxx.runtime.css.Selector; -import jaxx.runtime.css.Stylesheet; - -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.util.*; - -/** - * A helper class to compute {@link Stylesheet}, {@link Rule} and {@link Selector} - * and extract all the compiler logic from this class. - * <p/> - * In that way we can make the compiler as a single module and a runtime as another module. - * - * @author chemit - */ -public class StylesheetHelper { - - public enum MouseEventEnum { - - mouseover("mouseEntered", "mouseExited"), - mouseout("mouseExited", "mouseReleased"), - mousedown("mousePressed", "mousePressed"), - mouseup("mouseReleased", "mousePressed"); - - final String addMethod; - final String removeMethod; - -// ClassDescriptor mouseListenerDescriptor; -// ClassDescriptor mouseEventDescriptor; - - MouseEventEnum(String addMethod, String removeMethod) { - this.removeMethod = removeMethod; - this.addMethod = addMethod; - } - - public String getProperty(int i) { - return i == 0 ? addMethod : removeMethod; - } - -// public ClassDescriptor getMouseEventDescriptor() { -// if (mouseEventDescriptor == null) { -// mouseEventDescriptor = ClassDescriptorLoader.getClassDescriptor(MouseEvent.class); -// } -// return mouseEventDescriptor; -// } -// -// public ClassDescriptor getMouseListenerDescriptor() { -// if (mouseListenerDescriptor == null) { -// mouseListenerDescriptor = ClassDescriptorLoader.getClassDescriptor(MouseListener.class); -// } -// return mouseListenerDescriptor; -// } -// -// public MethodDescriptor getAddMouseListenerMethod(CompiledObject object) { -// try { -// MethodDescriptor addMouseListener = object.getObjectClass().getMethodDescriptor("addMouseListener", getMouseListenerDescriptor()); -// return addMouseListener; -// } catch (NoSuchMethodException e) { -// throw new CompilerException("could not find addMouseListener for object " + object); -// } -// } -// -// public MethodDescriptor getMouseListenerMethod(CompiledObject object, String property) { -// try { -// MethodDescriptor methodDescriptor = getMouseListenerDescriptor().getMethodDescriptor(property, getMouseEventDescriptor()); -// return methodDescriptor; -// } catch (NoSuchMethodException e) { -// throw new CompilerException("could not find " + property + " for object " + object); -// } -// } - } - - static ClassDescriptor mouseListenerDescriptor; - static ClassDescriptor mouseEventDescriptor; - - public static ClassDescriptor getMouseEventDescriptor() { - if (mouseEventDescriptor == null) { - mouseEventDescriptor = ClassDescriptorLoader.getClassDescriptor(MouseEvent.class); - } - return mouseEventDescriptor; - } - - public static ClassDescriptor getMouseListenerDescriptor() { - if (mouseListenerDescriptor == null) { - mouseListenerDescriptor = ClassDescriptorLoader.getClassDescriptor(MouseListener.class); - } - return mouseListenerDescriptor; - } - - public static MethodDescriptor getAddMouseListenerMethod(CompiledObject object) { - try { - MethodDescriptor addMouseListener = object.getObjectClass().getMethodDescriptor("addMouseListener", getMouseListenerDescriptor()); - return addMouseListener; - } catch (NoSuchMethodException e) { - throw new CompilerException("could not find addMouseListener for object " + object); - } - } - - public static MethodDescriptor getMouseListenerMethod(CompiledObject object, String property) { - try { - MethodDescriptor methodDescriptor = getMouseListenerDescriptor().getMethodDescriptor(property, getMouseEventDescriptor()); - return methodDescriptor; - } catch (NoSuchMethodException e) { - throw new CompilerException("could not find " + property + " for object " + object); - } - } - - public static void applyTo(CompiledObject object, JAXXCompiler compiler, Stylesheet stylesheet, Stylesheet overrides) throws CompilerException { - Map<String, String> overriddenProperties; - if (overrides != null) { - overriddenProperties = getApplicableProperties(overrides, object); - //overriddenProperties = overrides.getApplicableProperties(s,object); - } else { - overriddenProperties = null; - } - - Map<String, String> properties = getApplicableProperties(stylesheet, object); - if (properties != null) { - if (overriddenProperties != null) { - properties.keySet().removeAll(overriddenProperties.keySet()); - } - DefaultObjectHandler handler = TagManager.getTagHandler(object.getObjectClass()); - for (Map.Entry<String, String> e : properties.entrySet()) { - String value = e.getValue(); - if (value.equals(Rule.INLINE_ATTRIBUTE) || value.equals(Rule.DATA_BINDING)) { - continue; - } - handler.setAttribute(object, e.getKey(), e.getValue(), false, compiler); - } - } - - Rule[] pseudoClasses = getApplicablePseudoClasses(stylesheet, object); - if (pseudoClasses != null) { - Map<String, Map<String, String>> combinedPseudoClasses = new LinkedHashMap<String, Map<String, String>>(); - for (Rule pseudoClass1 : pseudoClasses) { - Selector[] selectors = pseudoClass1.getSelectors(); - for (Selector selector : selectors) { - if (appliesTo(selector, object) == Selector.PSEUDOCLASS_APPLIES) { - properties = pseudoClass1.getProperties(); - String pseudoClass = selector.getPseudoClass(); - // TODO: overrides by downstream pseudoclasses are not handled - Map<String, String> combinedProperties = combinedPseudoClasses.get(pseudoClass); - if (combinedProperties == null) { - combinedProperties = new HashMap<String, String>(); - combinedPseudoClasses.put(pseudoClass, combinedProperties); - } - combinedProperties.putAll(properties); - } - } - } - - int count = 0; - for (Map.Entry<String, Map<String, String>> e : combinedPseudoClasses.entrySet()) { - applyPseudoClass(e.getKey(), e.getValue(), object, compiler, count++); - } - } - } - -// /** -// * Replaces all references to the variable "object" with the actual object ID. -// * -// * @param code ? -// * @param id ? -// * @return ? -// * @throws CompilerException ? -// */ -// public static String replaceObjectReferences(String code, String id) throws CompilerException { -// JavaParser p = new JavaParser(new StringReader(code + ";")); -// p.Expression(); -// jaxx.compiler.java.parser.SimpleNode node = p.popNode(); -// scanNode(node, id); -// return node.getText(); -// } -// -// public static void scanNode(SimpleNode node, String id) { -// if (node.getId() == JavaParserTreeConstants.JJTNAME) { -// String name = node.getText(); -// if (name.equals("object") || (name.indexOf(".") != -1 && name.substring(0, name.indexOf(".")).trim().equals("object"))) { -// node.firstToken.image = id; -// } -// } else { -// int count = node.jjtGetNumChildren(); -// for (int i = 0; i < count; i++) { -// scanNode(node.getChild(i), id); -// } -// } -// } - -// public static void compilePseudoClassAdd(String pseudoClass, CompiledObject object, String propertyCode, JAXXCompiler compiler) throws CompilerException { -// -// if (pseudoClass.startsWith("{")) { -// pseudoClass = pseudoClass.substring(1, pseudoClass.length() - 1).trim(); -// pseudoClass = replaceObjectReferences(pseudoClass, object.getJavaCode()); -// String dest = object.getId() + ".style." + pseudoClass + ".add"; -// String destCode = TypeManager.getJavaCode(dest); -// DataBindingHelper bindingHelper = compiler.getBindingHelper(); -// if (bindingHelper.hasProcessDataBinding()) { -// bindingHelper.appendProcessDataBinding("else "); -// } -// bindingHelper.appendProcessDataBinding("if ($dest.equals(" + destCode + ")) { if (" + pseudoClass + ") { " + propertyCode + "} }"); -// new DataSource(dest, pseudoClass, compiler).compile("new DataBindingListener(" + compiler.getRootObject().getJavaCode() + ", " + destCode + ")"); -// bindingHelper.appendInitDataBindings("applyDataBinding(" + destCode + ");"); -// return; -// } -// -// MouseEventEnum constant = MouseEventEnum.valueOf(pseudoClass); -// -// String property = null; -// switch (constant) { -// case mousedown: -// property = "mousePressed"; -// break; -// case mouseout: -// property = "mouseExited"; -// break; -// case mouseover: -// property = "mouseEntered"; -// break; -// case mouseup: -// property = "mouseReleased"; -// break; -// } -// -// ClassDescriptor mouseListenerDescriptor = ClassDescriptorLoader.getClassDescriptor(MouseListener.class); -// ClassDescriptor mouseEventDescriptor = ClassDescriptorLoader.getClassDescriptor(MouseEvent.class); -// -// try { -// MethodDescriptor addMouseListener = object.getObjectClass().getMethodDescriptor("addMouseListener", mouseListenerDescriptor); -// MethodDescriptor methodDescriptor = mouseListenerDescriptor.getMethodDescriptor(property, mouseEventDescriptor); -// object.addEventHandler("style." + pseudoClass + ".add", addMouseListener, methodDescriptor, propertyCode, compiler); -// -// } catch (NoSuchMethodException e) { -// compiler.reportError("mouseover pseudoclass cannot be applied to object " + object.getObjectClass().getName() + " (no addMouseListener method)"); -// } -// } - -// public static void compilePseudoClassRemove(String pseudoClass, CompiledObject object, String propertyCode, JAXXCompiler compiler) throws CompilerException { -// if (pseudoClass.startsWith("{")) { -// pseudoClass = pseudoClass.substring(1, pseudoClass.length() - 1).trim(); -// pseudoClass = replaceObjectReferences(pseudoClass, object.getJavaCode()); -// String dest = object.getId() + ".style." + pseudoClass + ".remove"; -// String destCode = TypeManager.getJavaCode(dest); -// DataBindingHelper bindingHelper = compiler.getBindingHelper(); -// if (bindingHelper.hasProcessDataBinding()) { -// bindingHelper.appendProcessDataBinding("else "); -// } -// bindingHelper.appendProcessDataBinding("if ($dest.equals(" + destCode + ")) { if (" + invert(pseudoClass) + ") { " + propertyCode + "} }"); -// new DataSource(dest, pseudoClass, compiler).compile("new DataBindingListener(" + compiler.getRootObject().getJavaCode() + ", " + destCode + ")"); -// bindingHelper.appendInitDataBindings("applyDataBinding(" + destCode + ");"); -// return; -// } -// -// MouseEventEnum constant = MouseEventEnum.valueOf(pseudoClass); -// -// String property = null; -// switch (constant) { -// case mousedown: -// property = "mousePressed"; -// break; -// case mouseout: -// property = "mouseReleased"; -// break; -// case mouseover: -// property = "mouseExited"; -// break; -// case mouseup: -// property = "mousePressed"; -// break; -// } -// -// ClassDescriptor mouseListenerDescriptor = ClassDescriptorLoader.getClassDescriptor(MouseListener.class); -// ClassDescriptor mouseEventDescriptor = ClassDescriptorLoader.getClassDescriptor(MouseEvent.class); -// -// try { -// MethodDescriptor addMouseListener = object.getObjectClass().getMethodDescriptor("addMouseListener", mouseListenerDescriptor); -// MethodDescriptor methodDescriptor = mouseListenerDescriptor.getMethodDescriptor(property, mouseEventDescriptor); -// object.addEventHandler("style." + pseudoClass + ".remove", addMouseListener, methodDescriptor, propertyCode, compiler); -// -// } catch (NoSuchMethodException e) { -// compiler.reportError("mouseover pseudoclass cannot be applied to object " + object.getObjectClass().getName() + " (no addMouseListener method)"); -// } -// } -// -// public static String invert(String javaCode) { -// javaCode = javaCode.trim(); -// return javaCode.startsWith("!") ? javaCode.substring(1) : "!(" + javaCode + ")"; -// } - - public static String unwrap(ClassDescriptor type, String valueCode) { - if (type == ClassDescriptorLoader.getClassDescriptor(boolean.class)) { - return "((java.lang.Boolean) " + valueCode + ").booleanValue()"; - } - if (type == ClassDescriptorLoader.getClassDescriptor(byte.class)) { - return "((java.lang.Byte) " + valueCode + ").byteValue()"; - } - if (type == ClassDescriptorLoader.getClassDescriptor(short.class)) { - return "((java.lang.Short) " + valueCode + ").shortValue()"; - } - if (type == ClassDescriptorLoader.getClassDescriptor(int.class)) { - return "((java.lang.Integer) " + valueCode + ").intValue()"; - } - if (type == ClassDescriptorLoader.getClassDescriptor(long.class)) { - return "((java.lang.Long) " + valueCode + ").longValue()"; - } - if (type == ClassDescriptorLoader.getClassDescriptor(float.class)) { - return "((java.lang.Float) " + valueCode + ").floatValue()"; - } - if (type == ClassDescriptorLoader.getClassDescriptor(double.class)) { - return "((java.lang.Double) " + valueCode + ").doubleValue()"; - } - if (type == ClassDescriptorLoader.getClassDescriptor(char.class)) { - return "((java.lang.Character) " + valueCode + ").charValue()"; - } - return valueCode; - } - - public enum PseudoClassEnum { - focused("{ object.hasFocus() }"), - unfocused("{ !object.hasFocus() }"), - enabled("{ object.isEnabled() }"), - disabled("{ !object.isEnabled() }"), - selected("{ object.isSelected() }"), - deselected("{ !object.isSelected() }"); - - final String code; - - PseudoClassEnum(String code) { - this.code = code; - } - - public String getCode() { - return code; - } - } - - public static void applyPseudoClass(String pseudoClass, Map<String, String> properties, - CompiledObject object, JAXXCompiler compiler, int priority) throws CompilerException { - if (pseudoClass.indexOf("[") != -1) { - pseudoClass = pseudoClass.substring(0, pseudoClass.indexOf("[")); - } - final StringBuffer buffer = new StringBuffer(); - - DefaultObjectHandler handler = TagManager.getTagHandler(object.getObjectClass()); - boolean valueDeclared = false; - String eol = JAXXCompiler.getLineSeparator(); - DataBindingHelper bindingHelper = compiler.getBindingHelper(); - for (Map.Entry<String, String> e : properties.entrySet()) { - String property = e.getKey(); - ClassDescriptor type = handler.getPropertyType(object, property, compiler); - String dataBindingCode = DataBindingHelper.processDataBindings(e.getValue()); - String valueCode; - if (dataBindingCode != null) { - valueCode = "new jaxx.runtime.css.DataBinding(" + TypeManager.getJavaCode(object.getId() + "." + property + "." + priority) + ")"; - DataBinding binding = new DataBinding(object.getId() + "." + property + "." + priority, dataBindingCode, handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + dataBindingCode, compiler), false); - bindingHelper.registerDataBinding(binding); -// DataBinding binding = new DataBinding(dataBindingCode, object.getId() + "." + property + "." + priority, handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + dataBindingCode, compiler), false); -// DataBinding dataBinding1 = new DataBinding(dataBinding, object.getId() + "." + property + "." + priority, handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + dataBinding, compiler)); -// DataBinding dataBinding1 = new DataBinding(dataBinding, object.getId() + "." + property + "." + priority, handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + dataBinding, compiler)); -// binding.compile(compiler); -// dataBinding1.compile(compiler, false); - } else { - try { - Class<?> typeClass = type != null ? ClassDescriptorLoader.getClass(type.getName(), type.getClassLoader()) : null; - valueCode = TypeManager.getJavaCode(TypeManager.convertFromString(e.getValue(), typeClass)); - } catch (ClassNotFoundException ex) { - compiler.reportError("could not find class " + type.getName()); - return; - } - } - if (!valueDeclared) { - buffer.append("java.lang.Object "); - valueDeclared = true; - } - buffer.append("value = jaxx.runtime.css.Pseudoclasses.applyProperty(").append(compiler.getOutputClassName()).append(".this, ").append(object.getJavaCode()).append(", ").append(TypeManager.getJavaCode(property)).append(", ").append(valueCode).append(", jaxx.runtime.css.Pseudoclasses.wrap(").append(handler.getGetPropertyCode(object.getJavaCode(), property, compiler)).append("), ").append(priority).append(");").append(eol); - buffer.append("if (!(value instanceof jaxx.runtime.css.DataBinding)) {").append(eol); - String unwrappedValue = unwrap(type, "value"); - buffer.append(" ").append(handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + unwrappedValue, compiler)).append(eol); - buffer.append("}").append(eol); - } - - try { - PseudoClassEnum classEnum = PseudoClassEnum.valueOf(pseudoClass); - pseudoClass = classEnum.getCode(); - } catch (IllegalArgumentException e) { - // should never happens ? -// throw new RuntimeException("could not find " + PseudoClassEnum.class + " with pseudoClass " + pseudoClass, e); - } - -// if (pseudoClass.equals("focused")) { -// pseudoClass = "{ object.hasFocus() }"; -// } else if (pseudoClass.equals("unfocused")) { -// pseudoClass = "{ !object.hasFocus() }"; -// } else if (pseudoClass.equals("enabled")) { -// pseudoClass = "{ object.isEnabled() }"; -// } else if (pseudoClass.equals("disabled")) { -// pseudoClass = "{ !object.isEnabled() }"; -// } else if (pseudoClass.equals("selected")) { -// pseudoClass = "{ object.isSelected() }"; -// } else if (pseudoClass.equals("deselected")) { -// pseudoClass = "{ !object.isSelected() }"; -// } - -// compilePseudoClassAdd(pseudoClass, object, buffer.toString(), compiler); - compilePseudoClass(pseudoClass, object, buffer.toString(), 0, "add", compiler, false); - - buffer.setLength(0); - valueDeclared = false; - for (Map.Entry<String, String> e : properties.entrySet()) { - String property = e.getKey(); - ClassDescriptor type = handler.getPropertyType(object, property, compiler); - String dataBindingCode = DataBindingHelper.processDataBindings(e.getValue()); - String valueCode; - if (dataBindingCode != null) { - valueCode = "new jaxx.runtime.css.DataBinding(" + TypeManager.getJavaCode(object.getId() + "." + property + "." + priority) + ")"; - DataBinding binding = new DataBinding(object.getId() + "." + property + "." + priority, dataBindingCode, handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + dataBindingCode, compiler), false); -// DataBinding binding = new DataBinding(dataBindingCode, object.getId() + "." + property + "." + priority, handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + dataBindingCode, compiler), false); -// DataBinding binding = new DataBinding(dataBindingCode, object.getId() + "." + property + "." + priority, handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + dataBindingCode, compiler)); -// DataBinding binding = new DataBinding(dataBindingCode, object.getId() + "." + property + "." + priority, handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + dataBindingCode, compiler)); - bindingHelper.registerDataBinding(binding); -// binding.compile(compiler); -// binding.compile(compiler, false); - } else { - try { - Class<?> typeClass = type != null ? ClassDescriptorLoader.getClass(type.getName(), type.getClassLoader()) : null; - valueCode = TypeManager.getJavaCode(TypeManager.convertFromString(e.getValue(), typeClass)); - } catch (ClassNotFoundException ex) { - compiler.reportError("could not find class " + type.getName()); - return; - } - } - if (!valueDeclared) { - buffer.append("java.lang.Object "); - valueDeclared = true; - } - buffer.append("value = jaxx.runtime.css.Pseudoclasses.removeProperty(").append(compiler.getOutputClassName()).append(".this, ").append(object.getJavaCode()).append(", ").append(TypeManager.getJavaCode(property)).append(", ").append(valueCode).append(", jaxx.runtime.css.Pseudoclasses.wrap(").append(handler.getGetPropertyCode(object.getJavaCode(), property, compiler)).append("), ").append(priority).append(");").append(eol); - buffer.append("if (!(value instanceof jaxx.runtime.css.DataBinding)) {").append(eol); - String unwrappedValue = unwrap(type, "value"); - buffer.append(" ").append(handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + unwrappedValue, compiler)).append(eol); - buffer.append("}").append(eol); - } -// compilePseudoClassRemove(pseudoClass, object, buffer.toString(), compiler); - compilePseudoClass(pseudoClass, object, buffer.toString(), 1, "remove", compiler, true); - } - - - public static void compilePseudoClass(String pseudoClass, CompiledObject object, String propertyCode, int pos, String methodName, JAXXCompiler compiler, boolean invertTest) throws CompilerException { - PseudoClassDataBinding binding = PseudoClassDataBinding.newPseudoClassDataBinding(pseudoClass, object, propertyCode, methodName, invertTest); - if (binding != null) { - compiler.getBindingHelper().registerDataBinding(binding); - return; - } -// if (pseudoClass.startsWith("{")) { -// pseudoClass = pseudoClass.substring(1, pseudoClass.length() - 1).trim(); -// pseudoClass = replaceObjectReferences(pseudoClass, object.getJavaCode()); -// String id = object.getId() + ".style." + pseudoClass + "." + methodName; -// PseudoClassDataBinding binding = new PseudoClassDataBinding(id, pseudoClass, propertyCode, invertTest); -// compiler.getBindingHelper().registerDataBinding(binding); -//// binding.compile(compiler); -// return; -// } - MouseEventEnum constant = MouseEventEnum.valueOf(pseudoClass); - String property = constant.getProperty(pos); - MethodDescriptor addMouseListener = getAddMouseListenerMethod(object); - MethodDescriptor methodDescriptor = getMouseListenerMethod(object, property); - object.addEventHandler("style." + pseudoClass + "." + methodName, addMouseListener, methodDescriptor, propertyCode, compiler); - } - - public static Map<String, String> getApplicableProperties(Stylesheet s, CompiledObject object) throws CompilerException { - DefaultObjectHandler handler = TagManager.getTagHandler(object.getObjectClass()); - Map<String, String> result = null; - for (Rule rule : s.getRules()) { - int apply = appliesTo(rule, object); - if (apply == Selector.ALWAYS_APPLIES || apply == Selector.ALWAYS_APPLIES_INHERIT_ONLY) { - if (result == null) { - result = new HashMap<String, String>(); - } - for (Map.Entry<String, String> entry : rule.getProperties().entrySet()) { - String property = entry.getKey(); - if (apply == Selector.ALWAYS_APPLIES || handler.isPropertyInherited(property)) { - result.put(property, entry.getValue()); - } - } - } - } - return result; - } - - public static Rule[] getApplicablePseudoClasses(Stylesheet s, CompiledObject object) throws CompilerException { - List<Rule> result = null; - for (Rule rule : s.getRules()) { - if (appliesTo(rule, object) == Selector.PSEUDOCLASS_APPLIES) { - if (result == null) { - result = new ArrayList<Rule>(); - } - result.add(rule); - } - } - return result != null ? result.toArray(new Rule[result.size()]) : null; - } - - public static Rule inlineAttribute(CompiledObject object, String propertyName, boolean dataBinding) { - Map<String, String> properties = new HashMap<String, String>(); - properties.put(propertyName, dataBinding ? Rule.DATA_BINDING : Rule.INLINE_ATTRIBUTE); - return new Rule(new Selector[]{new Selector(null, null, null, object.getId(), true)}, properties); - } - - public static int appliesTo(Rule rule, CompiledObject object) throws CompilerException { - int appliesTo = Selector.NEVER_APPLIES; - for (Selector selector : rule.getSelectors()) { - appliesTo = Math.max(appliesTo(selector, object), appliesTo); - if (appliesTo == Selector.ALWAYS_APPLIES || appliesTo == Selector.ALWAYS_APPLIES_INHERIT_ONLY) { - break; - } - } - return appliesTo; - } - - public static int appliesTo(Selector selector, CompiledObject object) { - boolean inheritOnly = false; - CompiledObject parent = object; - String javaClassName = selector.getJavaClassName(); - String styleClass = selector.getStyleClass(); - String pseudoClass = selector.getPseudoClass(); - String id = selector.getId(); - - while (parent != null) { - boolean classMatch = (javaClassName == null); - if (!classMatch) { - ClassDescriptor javaClass = parent.getObjectClass(); - do { - String name = javaClass.getName(); - if (name.equals(javaClassName) || name.substring(name.lastIndexOf(".") + 1).equals(javaClassName)) { - classMatch = true; - break; - } - javaClass = javaClass.getSuperclass(); - } while (javaClass != null); - } - - boolean styleClassMatch = (styleClass == null || styleClass.equals(parent.getStyleClass())); - - String objectId = parent.getId(); - objectId = objectId.substring(objectId.lastIndexOf(".") + 1); - boolean idMatch = (id == null || (' ' + objectId + ' ').indexOf(' ' + id + ' ') > -1); - - if (classMatch && styleClassMatch && idMatch) { - if (pseudoClass != null) { - return inheritOnly ? Selector.PSEUDOCLASS_APPLIES_INHERIT_ONLY : Selector.PSEUDOCLASS_APPLIES; - } else { - return inheritOnly ? Selector.ALWAYS_APPLIES_INHERIT_ONLY : Selector.ALWAYS_APPLIES; - } - } - - parent = parent.getParent(); - inheritOnly = true; - } - return Selector.NEVER_APPLIES; - } - -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/StylesheetHelper.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/StylesheetHelper.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/StylesheetHelper.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/StylesheetHelper.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,595 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.css; + +import jaxx.compiler.CompiledObject; +import jaxx.compiler.CompilerException; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.binding.DataBinding; +import jaxx.compiler.binding.DataBindingHelper; +import jaxx.compiler.binding.PseudoClassDataBinding; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.reflect.MethodDescriptor; +import jaxx.compiler.tags.DefaultObjectHandler; +import jaxx.compiler.tags.TagManager; +import jaxx.compiler.types.TypeManager; +import jaxx.runtime.css.Rule; +import jaxx.runtime.css.Selector; +import jaxx.runtime.css.Stylesheet; + +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.util.*; + +/** + * A helper class to compute {@link Stylesheet}, {@link Rule} and {@link Selector} + * and extract all the compiler logic from this class. + * <p/> + * In that way we can make the compiler as a single module and a runtime as another module. + * + * @author chemit + */ +public class StylesheetHelper { + + public enum MouseEventEnum { + + mouseover("mouseEntered", "mouseExited"), + mouseout("mouseExited", "mouseReleased"), + mousedown("mousePressed", "mousePressed"), + mouseup("mouseReleased", "mousePressed"); + + final String addMethod; + final String removeMethod; + +// ClassDescriptor mouseListenerDescriptor; +// ClassDescriptor mouseEventDescriptor; + + MouseEventEnum(String addMethod, String removeMethod) { + this.removeMethod = removeMethod; + this.addMethod = addMethod; + } + + public String getProperty(int i) { + return i == 0 ? addMethod : removeMethod; + } + +// public ClassDescriptor getMouseEventDescriptor() { +// if (mouseEventDescriptor == null) { +// mouseEventDescriptor = ClassDescriptorLoader.getClassDescriptor(MouseEvent.class); +// } +// return mouseEventDescriptor; +// } +// +// public ClassDescriptor getMouseListenerDescriptor() { +// if (mouseListenerDescriptor == null) { +// mouseListenerDescriptor = ClassDescriptorLoader.getClassDescriptor(MouseListener.class); +// } +// return mouseListenerDescriptor; +// } +// +// public MethodDescriptor getAddMouseListenerMethod(CompiledObject object) { +// try { +// MethodDescriptor addMouseListener = object.getObjectClass().getMethodDescriptor("addMouseListener", getMouseListenerDescriptor()); +// return addMouseListener; +// } catch (NoSuchMethodException e) { +// throw new CompilerException("could not find addMouseListener for object " + object); +// } +// } +// +// public MethodDescriptor getMouseListenerMethod(CompiledObject object, String property) { +// try { +// MethodDescriptor methodDescriptor = getMouseListenerDescriptor().getMethodDescriptor(property, getMouseEventDescriptor()); +// return methodDescriptor; +// } catch (NoSuchMethodException e) { +// throw new CompilerException("could not find " + property + " for object " + object); +// } +// } + } + + static ClassDescriptor mouseListenerDescriptor; + static ClassDescriptor mouseEventDescriptor; + + public static ClassDescriptor getMouseEventDescriptor() { + if (mouseEventDescriptor == null) { + mouseEventDescriptor = ClassDescriptorLoader.getClassDescriptor(MouseEvent.class); + } + return mouseEventDescriptor; + } + + public static ClassDescriptor getMouseListenerDescriptor() { + if (mouseListenerDescriptor == null) { + mouseListenerDescriptor = ClassDescriptorLoader.getClassDescriptor(MouseListener.class); + } + return mouseListenerDescriptor; + } + + public static MethodDescriptor getAddMouseListenerMethod(CompiledObject object) { + try { + MethodDescriptor addMouseListener = object.getObjectClass().getMethodDescriptor("addMouseListener", getMouseListenerDescriptor()); + return addMouseListener; + } catch (NoSuchMethodException e) { + throw new CompilerException("could not find addMouseListener for object " + object); + } + } + + public static MethodDescriptor getMouseListenerMethod(CompiledObject object, String property) { + try { + MethodDescriptor methodDescriptor = getMouseListenerDescriptor().getMethodDescriptor(property, getMouseEventDescriptor()); + return methodDescriptor; + } catch (NoSuchMethodException e) { + throw new CompilerException("could not find " + property + " for object " + object); + } + } + + public static void applyTo(CompiledObject object, JAXXCompiler compiler, Stylesheet stylesheet, Stylesheet overrides) throws CompilerException { + Map<String, String> overriddenProperties; + if (overrides != null) { + overriddenProperties = getApplicableProperties(overrides, object); + //overriddenProperties = overrides.getApplicableProperties(s,object); + } else { + overriddenProperties = null; + } + + Map<String, String> properties = getApplicableProperties(stylesheet, object); + if (properties != null) { + if (overriddenProperties != null) { + properties.keySet().removeAll(overriddenProperties.keySet()); + } + DefaultObjectHandler handler = TagManager.getTagHandler(object.getObjectClass()); + for (Map.Entry<String, String> e : properties.entrySet()) { + String value = e.getValue(); + if (value.equals(Rule.INLINE_ATTRIBUTE) || value.equals(Rule.DATA_BINDING)) { + continue; + } + handler.setAttribute(object, e.getKey(), e.getValue(), false, compiler); + } + } + + Rule[] pseudoClasses = getApplicablePseudoClasses(stylesheet, object); + if (pseudoClasses != null) { + Map<String, Map<String, String>> combinedPseudoClasses = new LinkedHashMap<String, Map<String, String>>(); + for (Rule pseudoClass1 : pseudoClasses) { + Selector[] selectors = pseudoClass1.getSelectors(); + for (Selector selector : selectors) { + if (appliesTo(selector, object) == Selector.PSEUDOCLASS_APPLIES) { + properties = pseudoClass1.getProperties(); + String pseudoClass = selector.getPseudoClass(); + // TODO: overrides by downstream pseudoclasses are not handled + Map<String, String> combinedProperties = combinedPseudoClasses.get(pseudoClass); + if (combinedProperties == null) { + combinedProperties = new HashMap<String, String>(); + combinedPseudoClasses.put(pseudoClass, combinedProperties); + } + combinedProperties.putAll(properties); + } + } + } + + int count = 0; + for (Map.Entry<String, Map<String, String>> e : combinedPseudoClasses.entrySet()) { + applyPseudoClass(e.getKey(), e.getValue(), object, compiler, count++); + } + } + } + +// /** +// * Replaces all references to the variable "object" with the actual object ID. +// * +// * @param code ? +// * @param id ? +// * @return ? +// * @throws CompilerException ? +// */ +// public static String replaceObjectReferences(String code, String id) throws CompilerException { +// JavaParser p = new JavaParser(new StringReader(code + ";")); +// p.Expression(); +// jaxx.compiler.java.parser.SimpleNode node = p.popNode(); +// scanNode(node, id); +// return node.getText(); +// } +// +// public static void scanNode(SimpleNode node, String id) { +// if (node.getId() == JavaParserTreeConstants.JJTNAME) { +// String name = node.getText(); +// if (name.equals("object") || (name.indexOf(".") != -1 && name.substring(0, name.indexOf(".")).trim().equals("object"))) { +// node.firstToken.image = id; +// } +// } else { +// int count = node.jjtGetNumChildren(); +// for (int i = 0; i < count; i++) { +// scanNode(node.getChild(i), id); +// } +// } +// } + +// public static void compilePseudoClassAdd(String pseudoClass, CompiledObject object, String propertyCode, JAXXCompiler compiler) throws CompilerException { +// +// if (pseudoClass.startsWith("{")) { +// pseudoClass = pseudoClass.substring(1, pseudoClass.length() - 1).trim(); +// pseudoClass = replaceObjectReferences(pseudoClass, object.getJavaCode()); +// String dest = object.getId() + ".style." + pseudoClass + ".add"; +// String destCode = TypeManager.getJavaCode(dest); +// DataBindingHelper bindingHelper = compiler.getBindingHelper(); +// if (bindingHelper.hasProcessDataBinding()) { +// bindingHelper.appendProcessDataBinding("else "); +// } +// bindingHelper.appendProcessDataBinding("if ($dest.equals(" + destCode + ")) { if (" + pseudoClass + ") { " + propertyCode + "} }"); +// new DataSource(dest, pseudoClass, compiler).compile("new DataBindingListener(" + compiler.getRootObject().getJavaCode() + ", " + destCode + ")"); +// bindingHelper.appendInitDataBindings("applyDataBinding(" + destCode + ");"); +// return; +// } +// +// MouseEventEnum constant = MouseEventEnum.valueOf(pseudoClass); +// +// String property = null; +// switch (constant) { +// case mousedown: +// property = "mousePressed"; +// break; +// case mouseout: +// property = "mouseExited"; +// break; +// case mouseover: +// property = "mouseEntered"; +// break; +// case mouseup: +// property = "mouseReleased"; +// break; +// } +// +// ClassDescriptor mouseListenerDescriptor = ClassDescriptorLoader.getClassDescriptor(MouseListener.class); +// ClassDescriptor mouseEventDescriptor = ClassDescriptorLoader.getClassDescriptor(MouseEvent.class); +// +// try { +// MethodDescriptor addMouseListener = object.getObjectClass().getMethodDescriptor("addMouseListener", mouseListenerDescriptor); +// MethodDescriptor methodDescriptor = mouseListenerDescriptor.getMethodDescriptor(property, mouseEventDescriptor); +// object.addEventHandler("style." + pseudoClass + ".add", addMouseListener, methodDescriptor, propertyCode, compiler); +// +// } catch (NoSuchMethodException e) { +// compiler.reportError("mouseover pseudoclass cannot be applied to object " + object.getObjectClass().getName() + " (no addMouseListener method)"); +// } +// } + +// public static void compilePseudoClassRemove(String pseudoClass, CompiledObject object, String propertyCode, JAXXCompiler compiler) throws CompilerException { +// if (pseudoClass.startsWith("{")) { +// pseudoClass = pseudoClass.substring(1, pseudoClass.length() - 1).trim(); +// pseudoClass = replaceObjectReferences(pseudoClass, object.getJavaCode()); +// String dest = object.getId() + ".style." + pseudoClass + ".remove"; +// String destCode = TypeManager.getJavaCode(dest); +// DataBindingHelper bindingHelper = compiler.getBindingHelper(); +// if (bindingHelper.hasProcessDataBinding()) { +// bindingHelper.appendProcessDataBinding("else "); +// } +// bindingHelper.appendProcessDataBinding("if ($dest.equals(" + destCode + ")) { if (" + invert(pseudoClass) + ") { " + propertyCode + "} }"); +// new DataSource(dest, pseudoClass, compiler).compile("new DataBindingListener(" + compiler.getRootObject().getJavaCode() + ", " + destCode + ")"); +// bindingHelper.appendInitDataBindings("applyDataBinding(" + destCode + ");"); +// return; +// } +// +// MouseEventEnum constant = MouseEventEnum.valueOf(pseudoClass); +// +// String property = null; +// switch (constant) { +// case mousedown: +// property = "mousePressed"; +// break; +// case mouseout: +// property = "mouseReleased"; +// break; +// case mouseover: +// property = "mouseExited"; +// break; +// case mouseup: +// property = "mousePressed"; +// break; +// } +// +// ClassDescriptor mouseListenerDescriptor = ClassDescriptorLoader.getClassDescriptor(MouseListener.class); +// ClassDescriptor mouseEventDescriptor = ClassDescriptorLoader.getClassDescriptor(MouseEvent.class); +// +// try { +// MethodDescriptor addMouseListener = object.getObjectClass().getMethodDescriptor("addMouseListener", mouseListenerDescriptor); +// MethodDescriptor methodDescriptor = mouseListenerDescriptor.getMethodDescriptor(property, mouseEventDescriptor); +// object.addEventHandler("style." + pseudoClass + ".remove", addMouseListener, methodDescriptor, propertyCode, compiler); +// +// } catch (NoSuchMethodException e) { +// compiler.reportError("mouseover pseudoclass cannot be applied to object " + object.getObjectClass().getName() + " (no addMouseListener method)"); +// } +// } +// +// public static String invert(String javaCode) { +// javaCode = javaCode.trim(); +// return javaCode.startsWith("!") ? javaCode.substring(1) : "!(" + javaCode + ")"; +// } + + public static String unwrap(ClassDescriptor type, String valueCode) { + if (type == ClassDescriptorLoader.getClassDescriptor(boolean.class)) { + return "((java.lang.Boolean) " + valueCode + ").booleanValue()"; + } + if (type == ClassDescriptorLoader.getClassDescriptor(byte.class)) { + return "((java.lang.Byte) " + valueCode + ").byteValue()"; + } + if (type == ClassDescriptorLoader.getClassDescriptor(short.class)) { + return "((java.lang.Short) " + valueCode + ").shortValue()"; + } + if (type == ClassDescriptorLoader.getClassDescriptor(int.class)) { + return "((java.lang.Integer) " + valueCode + ").intValue()"; + } + if (type == ClassDescriptorLoader.getClassDescriptor(long.class)) { + return "((java.lang.Long) " + valueCode + ").longValue()"; + } + if (type == ClassDescriptorLoader.getClassDescriptor(float.class)) { + return "((java.lang.Float) " + valueCode + ").floatValue()"; + } + if (type == ClassDescriptorLoader.getClassDescriptor(double.class)) { + return "((java.lang.Double) " + valueCode + ").doubleValue()"; + } + if (type == ClassDescriptorLoader.getClassDescriptor(char.class)) { + return "((java.lang.Character) " + valueCode + ").charValue()"; + } + return valueCode; + } + + public enum PseudoClassEnum { + focused("{ object.hasFocus() }"), + unfocused("{ !object.hasFocus() }"), + enabled("{ object.isEnabled() }"), + disabled("{ !object.isEnabled() }"), + selected("{ object.isSelected() }"), + deselected("{ !object.isSelected() }"); + + final String code; + + PseudoClassEnum(String code) { + this.code = code; + } + + public String getCode() { + return code; + } + } + + public static void applyPseudoClass(String pseudoClass, Map<String, String> properties, + CompiledObject object, JAXXCompiler compiler, int priority) throws CompilerException { + if (pseudoClass.indexOf("[") != -1) { + pseudoClass = pseudoClass.substring(0, pseudoClass.indexOf("[")); + } + final StringBuffer buffer = new StringBuffer(); + + DefaultObjectHandler handler = TagManager.getTagHandler(object.getObjectClass()); + boolean valueDeclared = false; + String eol = JAXXCompiler.getLineSeparator(); + DataBindingHelper bindingHelper = compiler.getBindingHelper(); + for (Map.Entry<String, String> e : properties.entrySet()) { + String property = e.getKey(); + ClassDescriptor type = handler.getPropertyType(object, property, compiler); + String dataBindingCode = DataBindingHelper.processDataBindings(e.getValue()); + String valueCode; + if (dataBindingCode != null) { + valueCode = "new jaxx.runtime.css.DataBinding(" + TypeManager.getJavaCode(object.getId() + "." + property + "." + priority) + ")"; + DataBinding binding = new DataBinding(object.getId() + "." + property + "." + priority, dataBindingCode, handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + dataBindingCode, compiler), false); + bindingHelper.registerDataBinding(binding); +// DataBinding binding = new DataBinding(dataBindingCode, object.getId() + "." + property + "." + priority, handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + dataBindingCode, compiler), false); +// DataBinding dataBinding1 = new DataBinding(dataBinding, object.getId() + "." + property + "." + priority, handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + dataBinding, compiler)); +// DataBinding dataBinding1 = new DataBinding(dataBinding, object.getId() + "." + property + "." + priority, handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + dataBinding, compiler)); +// binding.compile(compiler); +// dataBinding1.compile(compiler, false); + } else { + try { + Class<?> typeClass = type != null ? ClassDescriptorLoader.getClass(type.getName(), type.getClassLoader()) : null; + valueCode = TypeManager.getJavaCode(TypeManager.convertFromString(e.getValue(), typeClass)); + } catch (ClassNotFoundException ex) { + compiler.reportError("could not find class " + type.getName()); + return; + } + } + if (!valueDeclared) { + buffer.append("java.lang.Object "); + valueDeclared = true; + } + buffer.append("value = jaxx.runtime.css.Pseudoclasses.applyProperty(").append(compiler.getOutputClassName()).append(".this, ").append(object.getJavaCode()).append(", ").append(TypeManager.getJavaCode(property)).append(", ").append(valueCode).append(", jaxx.runtime.css.Pseudoclasses.wrap(").append(handler.getGetPropertyCode(object.getJavaCode(), property, compiler)).append("), ").append(priority).append(");").append(eol); + buffer.append("if (!(value instanceof jaxx.runtime.css.DataBinding)) {").append(eol); + String unwrappedValue = unwrap(type, "value"); + buffer.append(" ").append(handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + unwrappedValue, compiler)).append(eol); + buffer.append("}").append(eol); + } + + try { + PseudoClassEnum classEnum = PseudoClassEnum.valueOf(pseudoClass); + pseudoClass = classEnum.getCode(); + } catch (IllegalArgumentException e) { + // should never happens ? +// throw new RuntimeException("could not find " + PseudoClassEnum.class + " with pseudoClass " + pseudoClass, e); + } + +// if (pseudoClass.equals("focused")) { +// pseudoClass = "{ object.hasFocus() }"; +// } else if (pseudoClass.equals("unfocused")) { +// pseudoClass = "{ !object.hasFocus() }"; +// } else if (pseudoClass.equals("enabled")) { +// pseudoClass = "{ object.isEnabled() }"; +// } else if (pseudoClass.equals("disabled")) { +// pseudoClass = "{ !object.isEnabled() }"; +// } else if (pseudoClass.equals("selected")) { +// pseudoClass = "{ object.isSelected() }"; +// } else if (pseudoClass.equals("deselected")) { +// pseudoClass = "{ !object.isSelected() }"; +// } + +// compilePseudoClassAdd(pseudoClass, object, buffer.toString(), compiler); + compilePseudoClass(pseudoClass, object, buffer.toString(), 0, "add", compiler, false); + + buffer.setLength(0); + valueDeclared = false; + for (Map.Entry<String, String> e : properties.entrySet()) { + String property = e.getKey(); + ClassDescriptor type = handler.getPropertyType(object, property, compiler); + String dataBindingCode = DataBindingHelper.processDataBindings(e.getValue()); + String valueCode; + if (dataBindingCode != null) { + valueCode = "new jaxx.runtime.css.DataBinding(" + TypeManager.getJavaCode(object.getId() + "." + property + "." + priority) + ")"; + DataBinding binding = new DataBinding(object.getId() + "." + property + "." + priority, dataBindingCode, handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + dataBindingCode, compiler), false); +// DataBinding binding = new DataBinding(dataBindingCode, object.getId() + "." + property + "." + priority, handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + dataBindingCode, compiler), false); +// DataBinding binding = new DataBinding(dataBindingCode, object.getId() + "." + property + "." + priority, handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + dataBindingCode, compiler)); +// DataBinding binding = new DataBinding(dataBindingCode, object.getId() + "." + property + "." + priority, handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + dataBindingCode, compiler)); + bindingHelper.registerDataBinding(binding); +// binding.compile(compiler); +// binding.compile(compiler, false); + } else { + try { + Class<?> typeClass = type != null ? ClassDescriptorLoader.getClass(type.getName(), type.getClassLoader()) : null; + valueCode = TypeManager.getJavaCode(TypeManager.convertFromString(e.getValue(), typeClass)); + } catch (ClassNotFoundException ex) { + compiler.reportError("could not find class " + type.getName()); + return; + } + } + if (!valueDeclared) { + buffer.append("java.lang.Object "); + valueDeclared = true; + } + buffer.append("value = jaxx.runtime.css.Pseudoclasses.removeProperty(").append(compiler.getOutputClassName()).append(".this, ").append(object.getJavaCode()).append(", ").append(TypeManager.getJavaCode(property)).append(", ").append(valueCode).append(", jaxx.runtime.css.Pseudoclasses.wrap(").append(handler.getGetPropertyCode(object.getJavaCode(), property, compiler)).append("), ").append(priority).append(");").append(eol); + buffer.append("if (!(value instanceof jaxx.runtime.css.DataBinding)) {").append(eol); + String unwrappedValue = unwrap(type, "value"); + buffer.append(" ").append(handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + unwrappedValue, compiler)).append(eol); + buffer.append("}").append(eol); + } +// compilePseudoClassRemove(pseudoClass, object, buffer.toString(), compiler); + compilePseudoClass(pseudoClass, object, buffer.toString(), 1, "remove", compiler, true); + } + + + public static void compilePseudoClass(String pseudoClass, CompiledObject object, String propertyCode, int pos, String methodName, JAXXCompiler compiler, boolean invertTest) throws CompilerException { + PseudoClassDataBinding binding = PseudoClassDataBinding.newPseudoClassDataBinding(pseudoClass, object, propertyCode, methodName, invertTest); + if (binding != null) { + compiler.getBindingHelper().registerDataBinding(binding); + return; + } +// if (pseudoClass.startsWith("{")) { +// pseudoClass = pseudoClass.substring(1, pseudoClass.length() - 1).trim(); +// pseudoClass = replaceObjectReferences(pseudoClass, object.getJavaCode()); +// String id = object.getId() + ".style." + pseudoClass + "." + methodName; +// PseudoClassDataBinding binding = new PseudoClassDataBinding(id, pseudoClass, propertyCode, invertTest); +// compiler.getBindingHelper().registerDataBinding(binding); +//// binding.compile(compiler); +// return; +// } + MouseEventEnum constant = MouseEventEnum.valueOf(pseudoClass); + String property = constant.getProperty(pos); + MethodDescriptor addMouseListener = getAddMouseListenerMethod(object); + MethodDescriptor methodDescriptor = getMouseListenerMethod(object, property); + object.addEventHandler("style." + pseudoClass + "." + methodName, addMouseListener, methodDescriptor, propertyCode, compiler); + } + + public static Map<String, String> getApplicableProperties(Stylesheet s, CompiledObject object) throws CompilerException { + DefaultObjectHandler handler = TagManager.getTagHandler(object.getObjectClass()); + Map<String, String> result = null; + for (Rule rule : s.getRules()) { + int apply = appliesTo(rule, object); + if (apply == Selector.ALWAYS_APPLIES || apply == Selector.ALWAYS_APPLIES_INHERIT_ONLY) { + if (result == null) { + result = new HashMap<String, String>(); + } + for (Map.Entry<String, String> entry : rule.getProperties().entrySet()) { + String property = entry.getKey(); + if (apply == Selector.ALWAYS_APPLIES || handler.isPropertyInherited(property)) { + result.put(property, entry.getValue()); + } + } + } + } + return result; + } + + public static Rule[] getApplicablePseudoClasses(Stylesheet s, CompiledObject object) throws CompilerException { + List<Rule> result = null; + for (Rule rule : s.getRules()) { + if (appliesTo(rule, object) == Selector.PSEUDOCLASS_APPLIES) { + if (result == null) { + result = new ArrayList<Rule>(); + } + result.add(rule); + } + } + return result != null ? result.toArray(new Rule[result.size()]) : null; + } + + public static Rule inlineAttribute(CompiledObject object, String propertyName, boolean dataBinding) { + Map<String, String> properties = new HashMap<String, String>(); + properties.put(propertyName, dataBinding ? Rule.DATA_BINDING : Rule.INLINE_ATTRIBUTE); + return new Rule(new Selector[]{new Selector(null, null, null, object.getId(), true)}, properties); + } + + public static int appliesTo(Rule rule, CompiledObject object) throws CompilerException { + int appliesTo = Selector.NEVER_APPLIES; + for (Selector selector : rule.getSelectors()) { + appliesTo = Math.max(appliesTo(selector, object), appliesTo); + if (appliesTo == Selector.ALWAYS_APPLIES || appliesTo == Selector.ALWAYS_APPLIES_INHERIT_ONLY) { + break; + } + } + return appliesTo; + } + + public static int appliesTo(Selector selector, CompiledObject object) { + boolean inheritOnly = false; + CompiledObject parent = object; + String javaClassName = selector.getJavaClassName(); + String styleClass = selector.getStyleClass(); + String pseudoClass = selector.getPseudoClass(); + String id = selector.getId(); + + while (parent != null) { + boolean classMatch = (javaClassName == null); + if (!classMatch) { + ClassDescriptor javaClass = parent.getObjectClass(); + do { + String name = javaClass.getName(); + if (name.equals(javaClassName) || name.substring(name.lastIndexOf(".") + 1).equals(javaClassName)) { + classMatch = true; + break; + } + javaClass = javaClass.getSuperclass(); + } while (javaClass != null); + } + + boolean styleClassMatch = (styleClass == null || styleClass.equals(parent.getStyleClass())); + + String objectId = parent.getId(); + objectId = objectId.substring(objectId.lastIndexOf(".") + 1); + boolean idMatch = (id == null || (' ' + objectId + ' ').indexOf(' ' + id + ' ') > -1); + + if (classMatch && styleClassMatch && idMatch) { + if (pseudoClass != null) { + return inheritOnly ? Selector.PSEUDOCLASS_APPLIES_INHERIT_ONLY : Selector.PSEUDOCLASS_APPLIES; + } else { + return inheritOnly ? Selector.ALWAYS_APPLIES_INHERIT_ONLY : Selector.ALWAYS_APPLIES; + } + } + + parent = parent.getParent(); + inheritOnly = true; + } + return Selector.NEVER_APPLIES; + } + +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSS.jj =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSS.jj 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSS.jj 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,587 +0,0 @@ -/*@bgen(jjtree) Generated By:JJTree: Do not edit this line. .\CSS.jj */ -/*@egen*//* - * Copyright 2006 Ethan Nicholas. All rights reserved. - * Use is subject to license terms. - */ - -// I would love to have used an existing CSS parser, but all of the ones I could -// find are licensed under the LGPL. As JAXX is BSD licensed and I'm not a big -// fan of the LGPL, unfortunately that won't work. -options { - STATIC = false; - JDK_VERSION = "1.4"; -} - -PARSER_BEGIN(CSSParser) -package jaxx.css; - -public class CSSParser/*@bgen(jjtree)*/implements CSSParserTreeConstants/*@egen*/ {/*@bgen(jjtree)*/ - protected JJTCSSParserState jjtree = new JJTCSSParserState(); - -/*@egen*/ - public SimpleNode popNode() { - if ( jjtree.nodeArity() > 0) // number of child nodes - return (SimpleNode)jjtree.popNode(); - else - return null; - } - - void jjtreeOpenNodeScope(Node n) { - ((SimpleNode) n).firstToken = getToken(1); - } - - void jjtreeCloseNodeScope(Node n) { - ((SimpleNode) n).lastToken = getToken(0); - } - - public static void main(String args[]) { - System.out.println("Reading from standard input..."); - CSSParser css = new CSSParser(System.in); - try { - SimpleNode n = css.Stylesheet(); - n.dump(""); - System.out.println("Thank you."); - } catch (Exception e) { - System.out.println("Oops."); - System.out.println(e.getMessage()); - e.printStackTrace(); - } - } -} - -PARSER_END(CSSParser) - - -<DEFAULT, IN_RULE> SKIP : -{ - " " -| "\t" -| "\n" -| "\r" -| <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")> -| <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/"> -} - -<*> TOKEN : /* LITERALS */ -{ - <DECIMAL_LITERAL: <INTEGER_LITERAL> ("." <INTEGER_LITERAL>)?> -| - <#INTEGER_LITERAL: (["0"-"9"])+> -} - -<DEFAULT, IN_RULE> TOKEN : /* IDENTIFIER */ -{ - <IDENTIFIER: <LETTER> (<LETTER>|<DIGIT>)*> -| - <#LETTER: ["_", "-", "a"-"z", "A"-"Z"]> -| - <#DIGIT: ["0"-"9"]> -} - -<IN_PSEUDOCLASS> TOKEN : /* PSEUDOCLASS_IDENTIFIER */ -{ - <PSEUDOCLASS_IDENTIFIER: <IDENTIFIER>> : DEFAULT -} - -<DEFAULT> TOKEN: /* COLON */ -{ - <PSEUDOCLASS_COLON: ":"> : IN_PSEUDOCLASS -} - -<IN_RULE> TOKEN: /* COLON_IN_RULE */ -{ - <COLON: ":"> -} - -<*> TOKEN: /* SEMICOLON */ -{ - <SEMICOLON: ";"> -} - -TOKEN : /* LEFT BRACE */ -{ - <LEFT_BRACE: "{"> : IN_RULE -} - -<IN_RULE> TOKEN : /* RIGHT BRACE */ -{ - <RIGHT_BRACE: "}"> : DEFAULT -} - -<IN_RULE> TOKEN : /* JAVA_CODE_RULE START */ -{ - <JAVA_CODE_START: <LEFT_BRACE>> : JAVA_CODE_RULE -} - -<JAVA_CODE_RULE> TOKEN : /* JAVA_CODE_RULE */ -{ - <JAVA_CODE: (~["}"])+ > -} - -<JAVA_CODE_RULE> TOKEN : /* JAVA_CODE_RULE END */ -{ - <JAVA_CODE_END: <RIGHT_BRACE>> : IN_RULE -} - - -<IN_PSEUDOCLASS> TOKEN : /* PROGRAMMATIC_PSEUDOCLASS */ -{ - <PROGRAMMATIC_PSEUDOCLASS: "{" (~["}"])+ "}"> : DEFAULT -} - -<IN_RULE> TOKEN : /* STRINGS */ -{ - <STRING: "\"" (~["\"", "\\", "\n", "\r"])* "\""> -} - -<IN_RULE> TOKEN : /* COLORS */ -{ - <HEXCOLOR: "#" <HEXDIGIT> <HEXDIGIT> <HEXDIGIT> (<HEXDIGIT> <HEXDIGIT> <HEXDIGIT>)?> -| - <#HEXDIGIT: ["0"-"9", "a"-"f", "A"-"F"]> -} - - -<IN_RULE> TOKEN : /* EMS */ -{ - <EMS: <DECIMAL_LITERAL> "em"> -} - - -<IN_RULE> TOKEN : /* EXS */ -{ - <EXS: <DECIMAL_LITERAL> "ex"> -} - - -<IN_RULE> TOKEN : /* LENGTH */ -{ - <LENGTH: <DECIMAL_LITERAL> ("pt" | "mm" | "cm" | "pc" | "in")> -} - - -SimpleNode Stylesheet() : {/*@bgen(jjtree) Stylesheet */ - SimpleNode jjtn000 = new SimpleNode(JJTSTYLESHEET); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) Stylesheet */ - try { -/*@egen*/ - (Rule())*/*@bgen(jjtree)*/ - { - jjtree.closeNodeScope(jjtn000, true); - jjtc000 = false; - jjtreeCloseNodeScope(jjtn000); - } -/*@egen*/ - { return jjtn000; }/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - - -void Rule() : {/*@bgen(jjtree) Rule */ - SimpleNode jjtn000 = new SimpleNode(JJTRULE); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) Rule */ - try { -/*@egen*/ - Selectors() - <LEFT_BRACE> Declaration() (";" (Declaration())?)* <RIGHT_BRACE>/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - - -void Selectors() : {/*@bgen(jjtree) Selectors */ - SimpleNode jjtn000 = new SimpleNode(JJTSELECTORS); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) Selectors */ - try { -/*@egen*/ - Selector() ("," Selector())*/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - - -void Selector() : {/*@bgen(jjtree) Selector */ - SimpleNode jjtn000 = new SimpleNode(JJTSELECTOR); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) Selector */ - try { -/*@egen*/ - JavaClass() (Id())? (Class())? (PseudoClass())? -| - Id() (Class())? (PseudoClass())? -| - Class() (PseudoClass())? -| - PseudoClass()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - - -void JavaClass() : {/*@bgen(jjtree) JavaClass */ - SimpleNode jjtn000 = new SimpleNode(JJTJAVACLASS); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) JavaClass */ - try { -/*@egen*/ - <IDENTIFIER> | "*"/*@bgen(jjtree)*/ - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - - -void Id() : {/*@bgen(jjtree) Id */ - SimpleNode jjtn000 = new SimpleNode(JJTID); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) Id */ - try { -/*@egen*/ - "#" <IDENTIFIER>/*@bgen(jjtree)*/ - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - - -void Class() : {/*@bgen(jjtree) Class */ - SimpleNode jjtn000 = new SimpleNode(JJTCLASS); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) Class */ - try { -/*@egen*/ - "." <IDENTIFIER>/*@bgen(jjtree)*/ - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - - -void PseudoClass() : {/*@bgen(jjtree) PseudoClass */ - SimpleNode jjtn000 = new SimpleNode(JJTPSEUDOCLASS); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) PseudoClass */ - try { -/*@egen*/ - <PSEUDOCLASS_COLON> (<PSEUDOCLASS_IDENTIFIER> | <PROGRAMMATIC_PSEUDOCLASS>) (AnimationProperties())?/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - - -void AnimationProperties() : {/*@bgen(jjtree) AnimationProperties */ - SimpleNode jjtn000 = new SimpleNode(JJTANIMATIONPROPERTIES); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) AnimationProperties */ - try { -/*@egen*/ - "[" AnimationProperty() ("," AnimationProperty())* "]"/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - - -void AnimationProperty() : {/*@bgen(jjtree) AnimationProperty */ - SimpleNode jjtn000 = new SimpleNode(JJTANIMATIONPROPERTY); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) AnimationProperty */ - try { -/*@egen*/ - <IDENTIFIER> "=" <DECIMAL_LITERAL> (<IDENTIFIER>)?/*@bgen(jjtree)*/ - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - - -void Declaration() : {/*@bgen(jjtree) Declaration */ - SimpleNode jjtn000 = new SimpleNode(JJTDECLARATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) Declaration */ - try { -/*@egen*/ - Property() <COLON> Expression()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - - -void Property() : {/*@bgen(jjtree) Property */ - SimpleNode jjtn000 = new SimpleNode(JJTPROPERTY); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) Property */ - try { -/*@egen*/ - <IDENTIFIER>/*@bgen(jjtree)*/ - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - - -void Expression() : {/*@bgen(jjtree) Expression */ - SimpleNode jjtn000 = new SimpleNode(JJTEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) Expression */ - try { -/*@egen*/ - (<DECIMAL_LITERAL> | <STRING> | <IDENTIFIER> | <HEXCOLOR> | <EMS> | <EXS> | <LENGTH> | - JavaCode())/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - - -void JavaCode() : {/*@bgen(jjtree) JavaCode */ - SimpleNode jjtn000 = new SimpleNode(JJTJAVACODE); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) JavaCode */ - try { -/*@egen*/ - <JAVA_CODE_START> <JAVA_CODE> <JAVA_CODE_END>/*@bgen(jjtree)*/ - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - - -void Identifier() : {/*@bgen(jjtree) Identifier */ - SimpleNode jjtn000 = new SimpleNode(JJTIDENTIFIER); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) Identifier */ - try { -/*@egen*/ - <IDENTIFIER>/*@bgen(jjtree)*/ - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSS.jj (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSS.jj) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSS.jj (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSS.jj 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,587 @@ +/*@bgen(jjtree) Generated By:JJTree: Do not edit this line. .\CSS.jj */ +/*@egen*//* + * Copyright 2006 Ethan Nicholas. All rights reserved. + * Use is subject to license terms. + */ + +// I would love to have used an existing CSS parser, but all of the ones I could +// find are licensed under the LGPL. As JAXX is BSD licensed and I'm not a big +// fan of the LGPL, unfortunately that won't work. +options { + STATIC = false; + JDK_VERSION = "1.4"; +} + +PARSER_BEGIN(CSSParser) +package jaxx.css; + +public class CSSParser/*@bgen(jjtree)*/implements CSSParserTreeConstants/*@egen*/ {/*@bgen(jjtree)*/ + protected JJTCSSParserState jjtree = new JJTCSSParserState(); + +/*@egen*/ + public SimpleNode popNode() { + if ( jjtree.nodeArity() > 0) // number of child nodes + return (SimpleNode)jjtree.popNode(); + else + return null; + } + + void jjtreeOpenNodeScope(Node n) { + ((SimpleNode) n).firstToken = getToken(1); + } + + void jjtreeCloseNodeScope(Node n) { + ((SimpleNode) n).lastToken = getToken(0); + } + + public static void main(String args[]) { + System.out.println("Reading from standard input..."); + CSSParser css = new CSSParser(System.in); + try { + SimpleNode n = css.Stylesheet(); + n.dump(""); + System.out.println("Thank you."); + } catch (Exception e) { + System.out.println("Oops."); + System.out.println(e.getMessage()); + e.printStackTrace(); + } + } +} + +PARSER_END(CSSParser) + + +<DEFAULT, IN_RULE> SKIP : +{ + " " +| "\t" +| "\n" +| "\r" +| <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")> +| <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/"> +} + +<*> TOKEN : /* LITERALS */ +{ + <DECIMAL_LITERAL: <INTEGER_LITERAL> ("." <INTEGER_LITERAL>)?> +| + <#INTEGER_LITERAL: (["0"-"9"])+> +} + +<DEFAULT, IN_RULE> TOKEN : /* IDENTIFIER */ +{ + <IDENTIFIER: <LETTER> (<LETTER>|<DIGIT>)*> +| + <#LETTER: ["_", "-", "a"-"z", "A"-"Z"]> +| + <#DIGIT: ["0"-"9"]> +} + +<IN_PSEUDOCLASS> TOKEN : /* PSEUDOCLASS_IDENTIFIER */ +{ + <PSEUDOCLASS_IDENTIFIER: <IDENTIFIER>> : DEFAULT +} + +<DEFAULT> TOKEN: /* COLON */ +{ + <PSEUDOCLASS_COLON: ":"> : IN_PSEUDOCLASS +} + +<IN_RULE> TOKEN: /* COLON_IN_RULE */ +{ + <COLON: ":"> +} + +<*> TOKEN: /* SEMICOLON */ +{ + <SEMICOLON: ";"> +} + +TOKEN : /* LEFT BRACE */ +{ + <LEFT_BRACE: "{"> : IN_RULE +} + +<IN_RULE> TOKEN : /* RIGHT BRACE */ +{ + <RIGHT_BRACE: "}"> : DEFAULT +} + +<IN_RULE> TOKEN : /* JAVA_CODE_RULE START */ +{ + <JAVA_CODE_START: <LEFT_BRACE>> : JAVA_CODE_RULE +} + +<JAVA_CODE_RULE> TOKEN : /* JAVA_CODE_RULE */ +{ + <JAVA_CODE: (~["}"])+ > +} + +<JAVA_CODE_RULE> TOKEN : /* JAVA_CODE_RULE END */ +{ + <JAVA_CODE_END: <RIGHT_BRACE>> : IN_RULE +} + + +<IN_PSEUDOCLASS> TOKEN : /* PROGRAMMATIC_PSEUDOCLASS */ +{ + <PROGRAMMATIC_PSEUDOCLASS: "{" (~["}"])+ "}"> : DEFAULT +} + +<IN_RULE> TOKEN : /* STRINGS */ +{ + <STRING: "\"" (~["\"", "\\", "\n", "\r"])* "\""> +} + +<IN_RULE> TOKEN : /* COLORS */ +{ + <HEXCOLOR: "#" <HEXDIGIT> <HEXDIGIT> <HEXDIGIT> (<HEXDIGIT> <HEXDIGIT> <HEXDIGIT>)?> +| + <#HEXDIGIT: ["0"-"9", "a"-"f", "A"-"F"]> +} + + +<IN_RULE> TOKEN : /* EMS */ +{ + <EMS: <DECIMAL_LITERAL> "em"> +} + + +<IN_RULE> TOKEN : /* EXS */ +{ + <EXS: <DECIMAL_LITERAL> "ex"> +} + + +<IN_RULE> TOKEN : /* LENGTH */ +{ + <LENGTH: <DECIMAL_LITERAL> ("pt" | "mm" | "cm" | "pc" | "in")> +} + + +SimpleNode Stylesheet() : {/*@bgen(jjtree) Stylesheet */ + SimpleNode jjtn000 = new SimpleNode(JJTSTYLESHEET); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) Stylesheet */ + try { +/*@egen*/ + (Rule())*/*@bgen(jjtree)*/ + { + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtreeCloseNodeScope(jjtn000); + } +/*@egen*/ + { return jjtn000; }/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + + +void Rule() : {/*@bgen(jjtree) Rule */ + SimpleNode jjtn000 = new SimpleNode(JJTRULE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) Rule */ + try { +/*@egen*/ + Selectors() + <LEFT_BRACE> Declaration() (";" (Declaration())?)* <RIGHT_BRACE>/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + + +void Selectors() : {/*@bgen(jjtree) Selectors */ + SimpleNode jjtn000 = new SimpleNode(JJTSELECTORS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) Selectors */ + try { +/*@egen*/ + Selector() ("," Selector())*/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + + +void Selector() : {/*@bgen(jjtree) Selector */ + SimpleNode jjtn000 = new SimpleNode(JJTSELECTOR); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) Selector */ + try { +/*@egen*/ + JavaClass() (Id())? (Class())? (PseudoClass())? +| + Id() (Class())? (PseudoClass())? +| + Class() (PseudoClass())? +| + PseudoClass()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + + +void JavaClass() : {/*@bgen(jjtree) JavaClass */ + SimpleNode jjtn000 = new SimpleNode(JJTJAVACLASS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) JavaClass */ + try { +/*@egen*/ + <IDENTIFIER> | "*"/*@bgen(jjtree)*/ + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + + +void Id() : {/*@bgen(jjtree) Id */ + SimpleNode jjtn000 = new SimpleNode(JJTID); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) Id */ + try { +/*@egen*/ + "#" <IDENTIFIER>/*@bgen(jjtree)*/ + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + + +void Class() : {/*@bgen(jjtree) Class */ + SimpleNode jjtn000 = new SimpleNode(JJTCLASS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) Class */ + try { +/*@egen*/ + "." <IDENTIFIER>/*@bgen(jjtree)*/ + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + + +void PseudoClass() : {/*@bgen(jjtree) PseudoClass */ + SimpleNode jjtn000 = new SimpleNode(JJTPSEUDOCLASS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) PseudoClass */ + try { +/*@egen*/ + <PSEUDOCLASS_COLON> (<PSEUDOCLASS_IDENTIFIER> | <PROGRAMMATIC_PSEUDOCLASS>) (AnimationProperties())?/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + + +void AnimationProperties() : {/*@bgen(jjtree) AnimationProperties */ + SimpleNode jjtn000 = new SimpleNode(JJTANIMATIONPROPERTIES); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) AnimationProperties */ + try { +/*@egen*/ + "[" AnimationProperty() ("," AnimationProperty())* "]"/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + + +void AnimationProperty() : {/*@bgen(jjtree) AnimationProperty */ + SimpleNode jjtn000 = new SimpleNode(JJTANIMATIONPROPERTY); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) AnimationProperty */ + try { +/*@egen*/ + <IDENTIFIER> "=" <DECIMAL_LITERAL> (<IDENTIFIER>)?/*@bgen(jjtree)*/ + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + + +void Declaration() : {/*@bgen(jjtree) Declaration */ + SimpleNode jjtn000 = new SimpleNode(JJTDECLARATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) Declaration */ + try { +/*@egen*/ + Property() <COLON> Expression()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + + +void Property() : {/*@bgen(jjtree) Property */ + SimpleNode jjtn000 = new SimpleNode(JJTPROPERTY); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) Property */ + try { +/*@egen*/ + <IDENTIFIER>/*@bgen(jjtree)*/ + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + + +void Expression() : {/*@bgen(jjtree) Expression */ + SimpleNode jjtn000 = new SimpleNode(JJTEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) Expression */ + try { +/*@egen*/ + (<DECIMAL_LITERAL> | <STRING> | <IDENTIFIER> | <HEXCOLOR> | <EMS> | <EXS> | <LENGTH> | + JavaCode())/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + + +void JavaCode() : {/*@bgen(jjtree) JavaCode */ + SimpleNode jjtn000 = new SimpleNode(JJTJAVACODE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) JavaCode */ + try { +/*@egen*/ + <JAVA_CODE_START> <JAVA_CODE> <JAVA_CODE_END>/*@bgen(jjtree)*/ + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + + +void Identifier() : {/*@bgen(jjtree) Identifier */ + SimpleNode jjtn000 = new SimpleNode(JJTIDENTIFIER); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) Identifier */ + try { +/*@egen*/ + <IDENTIFIER>/*@bgen(jjtree)*/ + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSS.jjt =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSS.jjt 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSS.jjt 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,256 +0,0 @@ -/* - * Copyright 2006 Ethan Nicholas. All rights reserved. - * Use is subject to license terms. - */ - -// I would love to have used an existing CSS parser, but all of the ones I could -// find are licensed under the LGPL. As JAXX is BSD licensed and I'm not a big -// fan of the LGPL, unfortunately that won't work. -options { - STATIC = false; - JDK_VERSION = "1.4"; - NODE_SCOPE_HOOK = true; -} - -PARSER_BEGIN(CSSParser) -package jaxx.css; - -public class CSSParser { - public SimpleNode popNode() { - if ( jjtree.nodeArity() > 0) // number of child nodes - return (SimpleNode)jjtree.popNode(); - else - return null; - } - - void jjtreeOpenNodeScope(Node n) { - ((SimpleNode) n).firstToken = getToken(1); - } - - void jjtreeCloseNodeScope(Node n) { - ((SimpleNode) n).lastToken = getToken(0); - } - - public static void main(String args[]) { - System.out.println("Reading from standard input..."); - CSSParser css = new CSSParser(System.in); - try { - SimpleNode n = css.Stylesheet(); - n.dump(""); - System.out.println("Thank you."); - } catch (Exception e) { - System.out.println("Oops."); - System.out.println(e.getMessage()); - e.printStackTrace(); - } - } -} - -PARSER_END(CSSParser) - - -<DEFAULT, IN_RULE> SKIP : -{ - " " -| "\t" -| "\n" -| "\r" -| <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")> -| <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/"> -} - -<*> TOKEN : /* LITERALS */ -{ - <DECIMAL_LITERAL: <INTEGER_LITERAL> ("." <INTEGER_LITERAL>)?> -| - <#INTEGER_LITERAL: (["0"-"9"])+> -} - -<DEFAULT, IN_RULE> TOKEN : /* IDENTIFIER */ -{ - <IDENTIFIER: <LETTER> (<LETTER>|<DIGIT>)*> -| - <#LETTER: ["_", "-", "a"-"z", "A"-"Z"]> -| - <#DIGIT: ["0"-"9"]> -} - -<IN_PSEUDOCLASS> TOKEN : /* PSEUDOCLASS_IDENTIFIER */ -{ - <PSEUDOCLASS_IDENTIFIER: <IDENTIFIER>> : DEFAULT -} - -<DEFAULT> TOKEN: /* COLON */ -{ - <PSEUDOCLASS_COLON: ":"> : IN_PSEUDOCLASS -} - -<IN_RULE> TOKEN: /* COLON_IN_RULE */ -{ - <COLON: ":"> -} - -<*> TOKEN: /* SEMICOLON */ -{ - <SEMICOLON: ";"> -} - -TOKEN : /* LEFT BRACE */ -{ - <LEFT_BRACE: "{"> : IN_RULE -} - -<IN_RULE> TOKEN : /* RIGHT BRACE */ -{ - <RIGHT_BRACE: "}"> : DEFAULT -} - -<IN_RULE> TOKEN : /* JAVA_CODE_RULE START */ -{ - <JAVA_CODE_START: <LEFT_BRACE>> : JAVA_CODE_RULE -} - -<JAVA_CODE_RULE> TOKEN : /* JAVA_CODE_RULE */ -{ - <JAVA_CODE: (~["}"])+ > -} - -<JAVA_CODE_RULE> TOKEN : /* JAVA_CODE_RULE END */ -{ - <JAVA_CODE_END: <RIGHT_BRACE>> : IN_RULE -} - - -<IN_PSEUDOCLASS> TOKEN : /* PROGRAMMATIC_PSEUDOCLASS */ -{ - <PROGRAMMATIC_PSEUDOCLASS: "{" (~["}"])+ "}"> : DEFAULT -} - -<IN_RULE> TOKEN : /* STRINGS */ -{ - <STRING: "\"" (~["\"", "\\", "\n", "\r"])* "\""> -} - -<IN_RULE> TOKEN : /* COLORS */ -{ - <HEXCOLOR: "#" <HEXDIGIT> <HEXDIGIT> <HEXDIGIT> (<HEXDIGIT> <HEXDIGIT> <HEXDIGIT>)?> -| - <#HEXDIGIT: ["0"-"9", "a"-"f", "A"-"F"]> -} - - -<IN_RULE> TOKEN : /* EMS */ -{ - <EMS: <DECIMAL_LITERAL> "em"> -} - - -<IN_RULE> TOKEN : /* EXS */ -{ - <EXS: <DECIMAL_LITERAL> "ex"> -} - - -<IN_RULE> TOKEN : /* LENGTH */ -{ - <LENGTH: <DECIMAL_LITERAL> ("pt" | "mm" | "cm" | "pc" | "in")> -} - - -SimpleNode Stylesheet() : {} -{ - (Rule())* - { return jjtThis; } -} - - -void Rule() : {} -{ - Selectors() - <LEFT_BRACE> Declaration() (";" (Declaration())?)* <RIGHT_BRACE> -} - - -void Selectors() : {} -{ - Selector() ("," Selector())* -} - - -void Selector() : {} -{ - JavaClass() (Id())? (Class())? (PseudoClass())? -| - Id() (Class())? (PseudoClass())? -| - Class() (PseudoClass())? -| - PseudoClass() -} - - -void JavaClass() : {} -{ - <IDENTIFIER> | "*" -} - - -void Id() : {} -{ - "#" <IDENTIFIER> -} - - -void Class() : {} -{ - "." <IDENTIFIER> -} - - -void PseudoClass() : {} -{ - <PSEUDOCLASS_COLON> (<PSEUDOCLASS_IDENTIFIER> | <PROGRAMMATIC_PSEUDOCLASS>) (AnimationProperties())? -} - - -void AnimationProperties() : {} -{ - "[" AnimationProperty() ("," AnimationProperty())* "]" -} - - -void AnimationProperty() : {} -{ - <IDENTIFIER> "=" <DECIMAL_LITERAL> (<IDENTIFIER>)? -} - - -void Declaration() : {} -{ - Property() <COLON> Expression() -} - - -void Property() : {} -{ - <IDENTIFIER> -} - - -void Expression() : {} -{ - (<DECIMAL_LITERAL> | <STRING> | <IDENTIFIER> | <HEXCOLOR> | <EMS> | <EXS> | <LENGTH> | - JavaCode()) -} - - -void JavaCode() : {} -{ - <JAVA_CODE_START> <JAVA_CODE> <JAVA_CODE_END> -} - - -void Identifier() : {} -{ - <IDENTIFIER> -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSS.jjt (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSS.jjt) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSS.jjt (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSS.jjt 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,256 @@ +/* + * Copyright 2006 Ethan Nicholas. All rights reserved. + * Use is subject to license terms. + */ + +// I would love to have used an existing CSS parser, but all of the ones I could +// find are licensed under the LGPL. As JAXX is BSD licensed and I'm not a big +// fan of the LGPL, unfortunately that won't work. +options { + STATIC = false; + JDK_VERSION = "1.4"; + NODE_SCOPE_HOOK = true; +} + +PARSER_BEGIN(CSSParser) +package jaxx.css; + +public class CSSParser { + public SimpleNode popNode() { + if ( jjtree.nodeArity() > 0) // number of child nodes + return (SimpleNode)jjtree.popNode(); + else + return null; + } + + void jjtreeOpenNodeScope(Node n) { + ((SimpleNode) n).firstToken = getToken(1); + } + + void jjtreeCloseNodeScope(Node n) { + ((SimpleNode) n).lastToken = getToken(0); + } + + public static void main(String args[]) { + System.out.println("Reading from standard input..."); + CSSParser css = new CSSParser(System.in); + try { + SimpleNode n = css.Stylesheet(); + n.dump(""); + System.out.println("Thank you."); + } catch (Exception e) { + System.out.println("Oops."); + System.out.println(e.getMessage()); + e.printStackTrace(); + } + } +} + +PARSER_END(CSSParser) + + +<DEFAULT, IN_RULE> SKIP : +{ + " " +| "\t" +| "\n" +| "\r" +| <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")> +| <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/"> +} + +<*> TOKEN : /* LITERALS */ +{ + <DECIMAL_LITERAL: <INTEGER_LITERAL> ("." <INTEGER_LITERAL>)?> +| + <#INTEGER_LITERAL: (["0"-"9"])+> +} + +<DEFAULT, IN_RULE> TOKEN : /* IDENTIFIER */ +{ + <IDENTIFIER: <LETTER> (<LETTER>|<DIGIT>)*> +| + <#LETTER: ["_", "-", "a"-"z", "A"-"Z"]> +| + <#DIGIT: ["0"-"9"]> +} + +<IN_PSEUDOCLASS> TOKEN : /* PSEUDOCLASS_IDENTIFIER */ +{ + <PSEUDOCLASS_IDENTIFIER: <IDENTIFIER>> : DEFAULT +} + +<DEFAULT> TOKEN: /* COLON */ +{ + <PSEUDOCLASS_COLON: ":"> : IN_PSEUDOCLASS +} + +<IN_RULE> TOKEN: /* COLON_IN_RULE */ +{ + <COLON: ":"> +} + +<*> TOKEN: /* SEMICOLON */ +{ + <SEMICOLON: ";"> +} + +TOKEN : /* LEFT BRACE */ +{ + <LEFT_BRACE: "{"> : IN_RULE +} + +<IN_RULE> TOKEN : /* RIGHT BRACE */ +{ + <RIGHT_BRACE: "}"> : DEFAULT +} + +<IN_RULE> TOKEN : /* JAVA_CODE_RULE START */ +{ + <JAVA_CODE_START: <LEFT_BRACE>> : JAVA_CODE_RULE +} + +<JAVA_CODE_RULE> TOKEN : /* JAVA_CODE_RULE */ +{ + <JAVA_CODE: (~["}"])+ > +} + +<JAVA_CODE_RULE> TOKEN : /* JAVA_CODE_RULE END */ +{ + <JAVA_CODE_END: <RIGHT_BRACE>> : IN_RULE +} + + +<IN_PSEUDOCLASS> TOKEN : /* PROGRAMMATIC_PSEUDOCLASS */ +{ + <PROGRAMMATIC_PSEUDOCLASS: "{" (~["}"])+ "}"> : DEFAULT +} + +<IN_RULE> TOKEN : /* STRINGS */ +{ + <STRING: "\"" (~["\"", "\\", "\n", "\r"])* "\""> +} + +<IN_RULE> TOKEN : /* COLORS */ +{ + <HEXCOLOR: "#" <HEXDIGIT> <HEXDIGIT> <HEXDIGIT> (<HEXDIGIT> <HEXDIGIT> <HEXDIGIT>)?> +| + <#HEXDIGIT: ["0"-"9", "a"-"f", "A"-"F"]> +} + + +<IN_RULE> TOKEN : /* EMS */ +{ + <EMS: <DECIMAL_LITERAL> "em"> +} + + +<IN_RULE> TOKEN : /* EXS */ +{ + <EXS: <DECIMAL_LITERAL> "ex"> +} + + +<IN_RULE> TOKEN : /* LENGTH */ +{ + <LENGTH: <DECIMAL_LITERAL> ("pt" | "mm" | "cm" | "pc" | "in")> +} + + +SimpleNode Stylesheet() : {} +{ + (Rule())* + { return jjtThis; } +} + + +void Rule() : {} +{ + Selectors() + <LEFT_BRACE> Declaration() (";" (Declaration())?)* <RIGHT_BRACE> +} + + +void Selectors() : {} +{ + Selector() ("," Selector())* +} + + +void Selector() : {} +{ + JavaClass() (Id())? (Class())? (PseudoClass())? +| + Id() (Class())? (PseudoClass())? +| + Class() (PseudoClass())? +| + PseudoClass() +} + + +void JavaClass() : {} +{ + <IDENTIFIER> | "*" +} + + +void Id() : {} +{ + "#" <IDENTIFIER> +} + + +void Class() : {} +{ + "." <IDENTIFIER> +} + + +void PseudoClass() : {} +{ + <PSEUDOCLASS_COLON> (<PSEUDOCLASS_IDENTIFIER> | <PROGRAMMATIC_PSEUDOCLASS>) (AnimationProperties())? +} + + +void AnimationProperties() : {} +{ + "[" AnimationProperty() ("," AnimationProperty())* "]" +} + + +void AnimationProperty() : {} +{ + <IDENTIFIER> "=" <DECIMAL_LITERAL> (<IDENTIFIER>)? +} + + +void Declaration() : {} +{ + Property() <COLON> Expression() +} + + +void Property() : {} +{ + <IDENTIFIER> +} + + +void Expression() : {} +{ + (<DECIMAL_LITERAL> | <STRING> | <IDENTIFIER> | <HEXCOLOR> | <EMS> | <EXS> | <LENGTH> | + JavaCode()) +} + + +void JavaCode() : {} +{ + <JAVA_CODE_START> <JAVA_CODE> <JAVA_CODE_END> +} + + +void Identifier() : {} +{ + <IDENTIFIER> +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParser.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParser.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParser.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,819 +0,0 @@ -/* Generated By:JJTree&JavaCC: Do not edit this line. CSSParser.java */ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.css.parser; - -public class CSSParser/*@bgen(jjtree)*/ implements CSSParserTreeConstants, CSSParserConstants {/*@bgen(jjtree)*/ - protected JJTCSSParserState jjtree = new JJTCSSParserState(); - - public SimpleNode popNode() { - if (jjtree.nodeArity() > 0) // number of child nodes - return (SimpleNode) jjtree.popNode(); - else - return null; - } - - void jjtreeOpenNodeScope(Node n) { - ((SimpleNode) n).firstToken = getToken(1); - } - - void jjtreeCloseNodeScope(Node n) { - ((SimpleNode) n).lastToken = getToken(0); - } - - public static void main(String args[]) { - System.out.println("Reading from standard input..."); - CSSParser css = new CSSParser(System.in); - try { - SimpleNode n = css.Stylesheet(); - n.dump(""); - System.out.println("Thank you."); - } catch (Exception e) { - System.out.println("Oops."); - System.out.println(e.getMessage()); - e.printStackTrace(); - } - } - - final public SimpleNode Stylesheet() throws ParseException { - /*@bgen(jjtree) Stylesheet */ - SimpleNode jjtn000 = new SimpleNode(JJTSTYLESHEET); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - label_1: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IDENTIFIER: - case PSEUDOCLASS_COLON: - case 29: - case 30: - case 31: - ; - break; - default: - jj_la1[0] = jj_gen; - break label_1; - } - Rule(); - } - jjtree.closeNodeScope(jjtn000, true); - jjtc000 = false; - jjtreeCloseNodeScope(jjtn000); - { - if (true) return jjtn000; - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - throw new Error("Missing return statement in function"); - } - - final public void Rule() throws ParseException { - /*@bgen(jjtree) Rule */ - SimpleNode jjtn000 = new SimpleNode(JJTRULE); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - Selectors(); - jj_consume_token(LEFT_BRACE); - Declaration(); - label_2: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case SEMICOLON: - ; - break; - default: - jj_la1[1] = jj_gen; - break label_2; - } - jj_consume_token(SEMICOLON); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IDENTIFIER: - Declaration(); - break; - default: - jj_la1[2] = jj_gen; - ; - } - } - jj_consume_token(RIGHT_BRACE); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void Selectors() throws ParseException { - /*@bgen(jjtree) Selectors */ - SimpleNode jjtn000 = new SimpleNode(JJTSELECTORS); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - Selector(); - label_3: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case 28: - ; - break; - default: - jj_la1[3] = jj_gen; - break label_3; - } - jj_consume_token(28); - Selector(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void Selector() throws ParseException { - /*@bgen(jjtree) Selector */ - SimpleNode jjtn000 = new SimpleNode(JJTSELECTOR); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IDENTIFIER: - case 29: - JavaClass(); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case 30: - Id(); - break; - default: - jj_la1[4] = jj_gen; - ; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case 31: - Class(); - break; - default: - jj_la1[5] = jj_gen; - ; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PSEUDOCLASS_COLON: - PseudoClass(); - break; - default: - jj_la1[6] = jj_gen; - ; - } - break; - case 30: - Id(); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case 31: - Class(); - break; - default: - jj_la1[7] = jj_gen; - ; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PSEUDOCLASS_COLON: - PseudoClass(); - break; - default: - jj_la1[8] = jj_gen; - ; - } - break; - case 31: - Class(); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PSEUDOCLASS_COLON: - PseudoClass(); - break; - default: - jj_la1[9] = jj_gen; - ; - } - break; - case PSEUDOCLASS_COLON: - PseudoClass(); - break; - default: - jj_la1[10] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void JavaClass() throws ParseException { - /*@bgen(jjtree) JavaClass */ - SimpleNode jjtn000 = new SimpleNode(JJTJAVACLASS); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IDENTIFIER: - jj_consume_token(IDENTIFIER); - break; - case 29: - jj_consume_token(29); - break; - default: - jj_la1[11] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void Id() throws ParseException { - /*@bgen(jjtree) Id */ - SimpleNode jjtn000 = new SimpleNode(JJTID); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(30); - jj_consume_token(IDENTIFIER); - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void Class() throws ParseException { - /*@bgen(jjtree) Class */ - SimpleNode jjtn000 = new SimpleNode(JJTCLASS); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(31); - jj_consume_token(IDENTIFIER); - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void PseudoClass() throws ParseException { - /*@bgen(jjtree) PseudoClass */ - SimpleNode jjtn000 = new SimpleNode(JJTPSEUDOCLASS); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(PSEUDOCLASS_COLON); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PSEUDOCLASS_IDENTIFIER: - jj_consume_token(PSEUDOCLASS_IDENTIFIER); - break; - case PROGRAMMATIC_PSEUDOCLASS: - jj_consume_token(PROGRAMMATIC_PSEUDOCLASS); - break; - default: - jj_la1[12] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case 32: - AnimationProperties(); - break; - default: - jj_la1[13] = jj_gen; - ; - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void AnimationProperties() throws ParseException { - /*@bgen(jjtree) AnimationProperties */ - SimpleNode jjtn000 = new SimpleNode(JJTANIMATIONPROPERTIES); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(32); - AnimationProperty(); - label_4: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case 28: - ; - break; - default: - jj_la1[14] = jj_gen; - break label_4; - } - jj_consume_token(28); - AnimationProperty(); - } - jj_consume_token(33); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void AnimationProperty() throws ParseException { - /*@bgen(jjtree) AnimationProperty */ - SimpleNode jjtn000 = new SimpleNode(JJTANIMATIONPROPERTY); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(IDENTIFIER); - jj_consume_token(34); - jj_consume_token(DECIMAL_LITERAL); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IDENTIFIER: - jj_consume_token(IDENTIFIER); - break; - default: - jj_la1[15] = jj_gen; - ; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void Declaration() throws ParseException { - /*@bgen(jjtree) Declaration */ - SimpleNode jjtn000 = new SimpleNode(JJTDECLARATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - Property(); - jj_consume_token(COLON); - Expression(); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void Property() throws ParseException { - /*@bgen(jjtree) Property */ - SimpleNode jjtn000 = new SimpleNode(JJTPROPERTY); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(IDENTIFIER); - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void Expression() throws ParseException { - /*@bgen(jjtree) Expression */ - SimpleNode jjtn000 = new SimpleNode(JJTEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case DECIMAL_LITERAL: - jj_consume_token(DECIMAL_LITERAL); - break; - case STRING: - jj_consume_token(STRING); - break; - case IDENTIFIER: - jj_consume_token(IDENTIFIER); - break; - case HEXCOLOR: - jj_consume_token(HEXCOLOR); - break; - case EMS: - jj_consume_token(EMS); - break; - case EXS: - jj_consume_token(EXS); - break; - case LENGTH: - jj_consume_token(LENGTH); - break; - case JAVA_CODE_START: - JavaCode(); - break; - default: - jj_la1[16] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void JavaCode() throws ParseException { - /*@bgen(jjtree) JavaCode */ - SimpleNode jjtn000 = new SimpleNode(JJTJAVACODE); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(JAVA_CODE_START); - jj_consume_token(JAVA_CODE); - jj_consume_token(JAVA_CODE_END); - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void Identifier() throws ParseException { - /*@bgen(jjtree) Identifier */ - SimpleNode jjtn000 = new SimpleNode(JJTIDENTIFIER); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(IDENTIFIER); - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - public CSSParserTokenManager token_source; - SimpleCharStream jj_input_stream; - public Token token, jj_nt; - private int jj_ntk; - private int jj_gen; - final private int[] jj_la1 = new int[17]; - static private int[] jj_la1_0; - static private int[] jj_la1_1; - - static { - jj_la1_0(); - jj_la1_1(); - } - - private static void jj_la1_0() { - jj_la1_0 = new int[]{0xe0002200, 0x8000, 0x200, 0x10000000, 0x40000000, 0x80000000, 0x2000, 0x80000000, 0x2000, 0x2000, 0xe0002200, 0x20000200, 0x201000, 0x0, 0x10000000, 0x200, 0xec40280,}; - } - - private static void jj_la1_1() { - jj_la1_1 = new int[]{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0,}; - } - - public CSSParser(java.io.InputStream stream) { - this(stream, null); - } - - public CSSParser(java.io.InputStream stream, String encoding) { - try { - jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); - } catch (java.io.UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - token_source = new CSSParserTokenManager(jj_input_stream); - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 17; i++) jj_la1[i] = -1; - } - - public void ReInit(java.io.InputStream stream) { - ReInit(stream, null); - } - - public void ReInit(java.io.InputStream stream, String encoding) { - try { - jj_input_stream.ReInit(stream, encoding, 1, 1); - } catch (java.io.UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - token_source.ReInit(jj_input_stream); - token = new Token(); - jj_ntk = -1; - jjtree.reset(); - jj_gen = 0; - for (int i = 0; i < 17; i++) jj_la1[i] = -1; - } - - public CSSParser(java.io.Reader stream) { - jj_input_stream = new SimpleCharStream(stream, 1, 1); - token_source = new CSSParserTokenManager(jj_input_stream); - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 17; i++) jj_la1[i] = -1; - } - - public void ReInit(java.io.Reader stream) { - jj_input_stream.ReInit(stream, 1, 1); - token_source.ReInit(jj_input_stream); - token = new Token(); - jj_ntk = -1; - jjtree.reset(); - jj_gen = 0; - for (int i = 0; i < 17; i++) jj_la1[i] = -1; - } - - public CSSParser(CSSParserTokenManager tm) { - token_source = tm; - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 17; i++) jj_la1[i] = -1; - } - - public void ReInit(CSSParserTokenManager tm) { - token_source = tm; - token = new Token(); - jj_ntk = -1; - jjtree.reset(); - jj_gen = 0; - for (int i = 0; i < 17; i++) jj_la1[i] = -1; - } - - final private Token jj_consume_token(int kind) throws ParseException { - Token oldToken; - if ((oldToken = token).next != null) token = token.next; - else token = token.next = token_source.getNextToken(); - jj_ntk = -1; - if (token.kind == kind) { - jj_gen++; - return token; - } - token = oldToken; - jj_kind = kind; - throw generateParseException(); - } - - final public Token getNextToken() { - if (token.next != null) token = token.next; - else token = token.next = token_source.getNextToken(); - jj_ntk = -1; - jj_gen++; - return token; - } - - final public Token getToken(int index) { - Token t = token; - for (int i = 0; i < index; i++) { - if (t.next != null) t = t.next; - else t = t.next = token_source.getNextToken(); - } - return t; - } - - final private int jj_ntk() { - if ((jj_nt = token.next) == null) - return (jj_ntk = (token.next = token_source.getNextToken()).kind); - else - return (jj_ntk = jj_nt.kind); - } - - private java.util.Vector jj_expentries = new java.util.Vector(); - private int[] jj_expentry; - private int jj_kind = -1; - - public ParseException generateParseException() { - Token errortok = token.next; - int line = errortok.beginLine, column = errortok.beginColumn; - String mess = (errortok.kind == 0) ? tokenImage[0] : errortok.image; - return new ParseException("Parse error. Encountered: " + mess, line, column); - } - - final public void enable_tracing() { - } - - final public void disable_tracing() { - } - -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParser.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParser.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParser.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParser.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,819 @@ +/* Generated By:JJTree&JavaCC: Do not edit this line. CSSParser.java */ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.css.parser; + +public class CSSParser/*@bgen(jjtree)*/ implements CSSParserTreeConstants, CSSParserConstants {/*@bgen(jjtree)*/ + protected JJTCSSParserState jjtree = new JJTCSSParserState(); + + public SimpleNode popNode() { + if (jjtree.nodeArity() > 0) // number of child nodes + return (SimpleNode) jjtree.popNode(); + else + return null; + } + + void jjtreeOpenNodeScope(Node n) { + ((SimpleNode) n).firstToken = getToken(1); + } + + void jjtreeCloseNodeScope(Node n) { + ((SimpleNode) n).lastToken = getToken(0); + } + + public static void main(String args[]) { + System.out.println("Reading from standard input..."); + CSSParser css = new CSSParser(System.in); + try { + SimpleNode n = css.Stylesheet(); + n.dump(""); + System.out.println("Thank you."); + } catch (Exception e) { + System.out.println("Oops."); + System.out.println(e.getMessage()); + e.printStackTrace(); + } + } + + final public SimpleNode Stylesheet() throws ParseException { + /*@bgen(jjtree) Stylesheet */ + SimpleNode jjtn000 = new SimpleNode(JJTSTYLESHEET); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + label_1: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case IDENTIFIER: + case PSEUDOCLASS_COLON: + case 29: + case 30: + case 31: + ; + break; + default: + jj_la1[0] = jj_gen; + break label_1; + } + Rule(); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtreeCloseNodeScope(jjtn000); + { + if (true) return jjtn000; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + throw new Error("Missing return statement in function"); + } + + final public void Rule() throws ParseException { + /*@bgen(jjtree) Rule */ + SimpleNode jjtn000 = new SimpleNode(JJTRULE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + Selectors(); + jj_consume_token(LEFT_BRACE); + Declaration(); + label_2: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case SEMICOLON: + ; + break; + default: + jj_la1[1] = jj_gen; + break label_2; + } + jj_consume_token(SEMICOLON); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case IDENTIFIER: + Declaration(); + break; + default: + jj_la1[2] = jj_gen; + ; + } + } + jj_consume_token(RIGHT_BRACE); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void Selectors() throws ParseException { + /*@bgen(jjtree) Selectors */ + SimpleNode jjtn000 = new SimpleNode(JJTSELECTORS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + Selector(); + label_3: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case 28: + ; + break; + default: + jj_la1[3] = jj_gen; + break label_3; + } + jj_consume_token(28); + Selector(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void Selector() throws ParseException { + /*@bgen(jjtree) Selector */ + SimpleNode jjtn000 = new SimpleNode(JJTSELECTOR); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case IDENTIFIER: + case 29: + JavaClass(); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case 30: + Id(); + break; + default: + jj_la1[4] = jj_gen; + ; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case 31: + Class(); + break; + default: + jj_la1[5] = jj_gen; + ; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PSEUDOCLASS_COLON: + PseudoClass(); + break; + default: + jj_la1[6] = jj_gen; + ; + } + break; + case 30: + Id(); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case 31: + Class(); + break; + default: + jj_la1[7] = jj_gen; + ; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PSEUDOCLASS_COLON: + PseudoClass(); + break; + default: + jj_la1[8] = jj_gen; + ; + } + break; + case 31: + Class(); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PSEUDOCLASS_COLON: + PseudoClass(); + break; + default: + jj_la1[9] = jj_gen; + ; + } + break; + case PSEUDOCLASS_COLON: + PseudoClass(); + break; + default: + jj_la1[10] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void JavaClass() throws ParseException { + /*@bgen(jjtree) JavaClass */ + SimpleNode jjtn000 = new SimpleNode(JJTJAVACLASS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case IDENTIFIER: + jj_consume_token(IDENTIFIER); + break; + case 29: + jj_consume_token(29); + break; + default: + jj_la1[11] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void Id() throws ParseException { + /*@bgen(jjtree) Id */ + SimpleNode jjtn000 = new SimpleNode(JJTID); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(30); + jj_consume_token(IDENTIFIER); + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void Class() throws ParseException { + /*@bgen(jjtree) Class */ + SimpleNode jjtn000 = new SimpleNode(JJTCLASS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(31); + jj_consume_token(IDENTIFIER); + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void PseudoClass() throws ParseException { + /*@bgen(jjtree) PseudoClass */ + SimpleNode jjtn000 = new SimpleNode(JJTPSEUDOCLASS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(PSEUDOCLASS_COLON); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PSEUDOCLASS_IDENTIFIER: + jj_consume_token(PSEUDOCLASS_IDENTIFIER); + break; + case PROGRAMMATIC_PSEUDOCLASS: + jj_consume_token(PROGRAMMATIC_PSEUDOCLASS); + break; + default: + jj_la1[12] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case 32: + AnimationProperties(); + break; + default: + jj_la1[13] = jj_gen; + ; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void AnimationProperties() throws ParseException { + /*@bgen(jjtree) AnimationProperties */ + SimpleNode jjtn000 = new SimpleNode(JJTANIMATIONPROPERTIES); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(32); + AnimationProperty(); + label_4: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case 28: + ; + break; + default: + jj_la1[14] = jj_gen; + break label_4; + } + jj_consume_token(28); + AnimationProperty(); + } + jj_consume_token(33); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void AnimationProperty() throws ParseException { + /*@bgen(jjtree) AnimationProperty */ + SimpleNode jjtn000 = new SimpleNode(JJTANIMATIONPROPERTY); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(IDENTIFIER); + jj_consume_token(34); + jj_consume_token(DECIMAL_LITERAL); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case IDENTIFIER: + jj_consume_token(IDENTIFIER); + break; + default: + jj_la1[15] = jj_gen; + ; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void Declaration() throws ParseException { + /*@bgen(jjtree) Declaration */ + SimpleNode jjtn000 = new SimpleNode(JJTDECLARATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + Property(); + jj_consume_token(COLON); + Expression(); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void Property() throws ParseException { + /*@bgen(jjtree) Property */ + SimpleNode jjtn000 = new SimpleNode(JJTPROPERTY); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(IDENTIFIER); + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void Expression() throws ParseException { + /*@bgen(jjtree) Expression */ + SimpleNode jjtn000 = new SimpleNode(JJTEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case DECIMAL_LITERAL: + jj_consume_token(DECIMAL_LITERAL); + break; + case STRING: + jj_consume_token(STRING); + break; + case IDENTIFIER: + jj_consume_token(IDENTIFIER); + break; + case HEXCOLOR: + jj_consume_token(HEXCOLOR); + break; + case EMS: + jj_consume_token(EMS); + break; + case EXS: + jj_consume_token(EXS); + break; + case LENGTH: + jj_consume_token(LENGTH); + break; + case JAVA_CODE_START: + JavaCode(); + break; + default: + jj_la1[16] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void JavaCode() throws ParseException { + /*@bgen(jjtree) JavaCode */ + SimpleNode jjtn000 = new SimpleNode(JJTJAVACODE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(JAVA_CODE_START); + jj_consume_token(JAVA_CODE); + jj_consume_token(JAVA_CODE_END); + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void Identifier() throws ParseException { + /*@bgen(jjtree) Identifier */ + SimpleNode jjtn000 = new SimpleNode(JJTIDENTIFIER); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(IDENTIFIER); + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + public CSSParserTokenManager token_source; + SimpleCharStream jj_input_stream; + public Token token, jj_nt; + private int jj_ntk; + private int jj_gen; + final private int[] jj_la1 = new int[17]; + static private int[] jj_la1_0; + static private int[] jj_la1_1; + + static { + jj_la1_0(); + jj_la1_1(); + } + + private static void jj_la1_0() { + jj_la1_0 = new int[]{0xe0002200, 0x8000, 0x200, 0x10000000, 0x40000000, 0x80000000, 0x2000, 0x80000000, 0x2000, 0x2000, 0xe0002200, 0x20000200, 0x201000, 0x0, 0x10000000, 0x200, 0xec40280,}; + } + + private static void jj_la1_1() { + jj_la1_1 = new int[]{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0,}; + } + + public CSSParser(java.io.InputStream stream) { + this(stream, null); + } + + public CSSParser(java.io.InputStream stream, String encoding) { + try { + jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); + } catch (java.io.UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + token_source = new CSSParserTokenManager(jj_input_stream); + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 17; i++) jj_la1[i] = -1; + } + + public void ReInit(java.io.InputStream stream) { + ReInit(stream, null); + } + + public void ReInit(java.io.InputStream stream, String encoding) { + try { + jj_input_stream.ReInit(stream, encoding, 1, 1); + } catch (java.io.UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + token_source.ReInit(jj_input_stream); + token = new Token(); + jj_ntk = -1; + jjtree.reset(); + jj_gen = 0; + for (int i = 0; i < 17; i++) jj_la1[i] = -1; + } + + public CSSParser(java.io.Reader stream) { + jj_input_stream = new SimpleCharStream(stream, 1, 1); + token_source = new CSSParserTokenManager(jj_input_stream); + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 17; i++) jj_la1[i] = -1; + } + + public void ReInit(java.io.Reader stream) { + jj_input_stream.ReInit(stream, 1, 1); + token_source.ReInit(jj_input_stream); + token = new Token(); + jj_ntk = -1; + jjtree.reset(); + jj_gen = 0; + for (int i = 0; i < 17; i++) jj_la1[i] = -1; + } + + public CSSParser(CSSParserTokenManager tm) { + token_source = tm; + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 17; i++) jj_la1[i] = -1; + } + + public void ReInit(CSSParserTokenManager tm) { + token_source = tm; + token = new Token(); + jj_ntk = -1; + jjtree.reset(); + jj_gen = 0; + for (int i = 0; i < 17; i++) jj_la1[i] = -1; + } + + final private Token jj_consume_token(int kind) throws ParseException { + Token oldToken; + if ((oldToken = token).next != null) token = token.next; + else token = token.next = token_source.getNextToken(); + jj_ntk = -1; + if (token.kind == kind) { + jj_gen++; + return token; + } + token = oldToken; + jj_kind = kind; + throw generateParseException(); + } + + final public Token getNextToken() { + if (token.next != null) token = token.next; + else token = token.next = token_source.getNextToken(); + jj_ntk = -1; + jj_gen++; + return token; + } + + final public Token getToken(int index) { + Token t = token; + for (int i = 0; i < index; i++) { + if (t.next != null) t = t.next; + else t = t.next = token_source.getNextToken(); + } + return t; + } + + final private int jj_ntk() { + if ((jj_nt = token.next) == null) + return (jj_ntk = (token.next = token_source.getNextToken()).kind); + else + return (jj_ntk = jj_nt.kind); + } + + private java.util.Vector jj_expentries = new java.util.Vector(); + private int[] jj_expentry; + private int jj_kind = -1; + + public ParseException generateParseException() { + Token errortok = token.next; + int line = errortok.beginLine, column = errortok.beginColumn; + String mess = (errortok.kind == 0) ? tokenImage[0] : errortok.image; + return new ParseException("Parse error. Encountered: " + mess, line, column); + } + + final public void enable_tracing() { + } + + final public void disable_tracing() { + } + +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParserConstants.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParserConstants.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParserConstants.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,92 +0,0 @@ -/* Generated By:JJTree&JavaCC: Do not edit this line. CSSParserConstants.java */ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.css.parser; - -public interface CSSParserConstants { - - int EOF = 0; - int DECIMAL_LITERAL = 7; - int INTEGER_LITERAL = 8; - int IDENTIFIER = 9; - int LETTER = 10; - int DIGIT = 11; - int PSEUDOCLASS_IDENTIFIER = 12; - int PSEUDOCLASS_COLON = 13; - int COLON = 14; - int SEMICOLON = 15; - int LEFT_BRACE = 16; - int RIGHT_BRACE = 17; - int JAVA_CODE_START = 18; - int JAVA_CODE = 19; - int JAVA_CODE_END = 20; - int PROGRAMMATIC_PSEUDOCLASS = 21; - int STRING = 22; - int HEXCOLOR = 23; - int HEXDIGIT = 24; - int EMS = 25; - int EXS = 26; - int LENGTH = 27; - - int DEFAULT = 0; - int IN_RULE = 1; - int JAVA_CODE_RULE = 2; - int IN_PSEUDOCLASS = 3; - - String[] tokenImage = { - "<EOF>", - "\" \"", - "\"\\t\"", - "\"\\n\"", - "\"\\r\"", - "<token of kind 5>", - "<token of kind 6>", - "<DECIMAL_LITERAL>", - "<INTEGER_LITERAL>", - "<IDENTIFIER>", - "<LETTER>", - "<DIGIT>", - "<PSEUDOCLASS_IDENTIFIER>", - "\":\"", - "\":\"", - "\";\"", - "\"{\"", - "\"}\"", - "<JAVA_CODE_START>", - "<JAVA_CODE>", - "<JAVA_CODE_END>", - "<PROGRAMMATIC_PSEUDOCLASS>", - "<STRING>", - "<HEXCOLOR>", - "<HEXDIGIT>", - "<EMS>", - "<EXS>", - "<LENGTH>", - "\",\"", - "\"*\"", - "\"#\"", - "\".\"", - "\"[\"", - "\"]\"", - "\"=\"", - }; - -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParserConstants.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParserConstants.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParserConstants.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParserConstants.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,92 @@ +/* Generated By:JJTree&JavaCC: Do not edit this line. CSSParserConstants.java */ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.css.parser; + +public interface CSSParserConstants { + + int EOF = 0; + int DECIMAL_LITERAL = 7; + int INTEGER_LITERAL = 8; + int IDENTIFIER = 9; + int LETTER = 10; + int DIGIT = 11; + int PSEUDOCLASS_IDENTIFIER = 12; + int PSEUDOCLASS_COLON = 13; + int COLON = 14; + int SEMICOLON = 15; + int LEFT_BRACE = 16; + int RIGHT_BRACE = 17; + int JAVA_CODE_START = 18; + int JAVA_CODE = 19; + int JAVA_CODE_END = 20; + int PROGRAMMATIC_PSEUDOCLASS = 21; + int STRING = 22; + int HEXCOLOR = 23; + int HEXDIGIT = 24; + int EMS = 25; + int EXS = 26; + int LENGTH = 27; + + int DEFAULT = 0; + int IN_RULE = 1; + int JAVA_CODE_RULE = 2; + int IN_PSEUDOCLASS = 3; + + String[] tokenImage = { + "<EOF>", + "\" \"", + "\"\\t\"", + "\"\\n\"", + "\"\\r\"", + "<token of kind 5>", + "<token of kind 6>", + "<DECIMAL_LITERAL>", + "<INTEGER_LITERAL>", + "<IDENTIFIER>", + "<LETTER>", + "<DIGIT>", + "<PSEUDOCLASS_IDENTIFIER>", + "\":\"", + "\":\"", + "\";\"", + "\"{\"", + "\"}\"", + "<JAVA_CODE_START>", + "<JAVA_CODE>", + "<JAVA_CODE_END>", + "<PROGRAMMATIC_PSEUDOCLASS>", + "<STRING>", + "<HEXCOLOR>", + "<HEXDIGIT>", + "<EMS>", + "<EXS>", + "<LENGTH>", + "\",\"", + "\"*\"", + "\"#\"", + "\".\"", + "\"[\"", + "\"]\"", + "\"=\"", + }; + +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParserTokenManager.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParserTokenManager.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParserTokenManager.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,1172 +0,0 @@ -/* Generated By:JJTree&JavaCC: Do not edit this line. CSSParserTokenManager.java */ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.css.parser; - -public class CSSParserTokenManager implements CSSParserConstants { - public java.io.PrintStream debugStream = System.out; - - public void setDebugStream(java.io.PrintStream ds) { - debugStream = ds; - } - - private int jjStopStringLiteralDfa_0(int pos, long active0) { - switch (pos) { - default: - return -1; - } - } - - private int jjStartNfa_0(int pos, long active0) { - return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1); - } - - private int jjStopAtPos(int pos, int kind) { - jjmatchedKind = kind; - jjmatchedPos = pos; - return pos + 1; - } - - private int jjStartNfaWithStates_0(int pos, int kind, int state) { - jjmatchedKind = kind; - jjmatchedPos = pos; - try { - curChar = input_stream.readChar(); - } - catch (java.io.IOException e) { - return pos + 1; - } - return jjMoveNfa_0(state, pos + 1); - } - - private int jjMoveStringLiteralDfa0_0() { - switch (curChar) { - case 35: - return jjStopAtPos(0, 30); - case 42: - return jjStopAtPos(0, 29); - case 44: - return jjStopAtPos(0, 28); - case 46: - return jjStopAtPos(0, 31); - case 58: - return jjStopAtPos(0, 13); - case 59: - return jjStopAtPos(0, 15); - case 61: - return jjStopAtPos(0, 34); - case 91: - return jjStopAtPos(0, 32); - case 93: - return jjStopAtPos(0, 33); - case 123: - return jjStopAtPos(0, 16); - default: - return jjMoveNfa_0(3, 0); - } - } - - private void jjCheckNAdd(int state) { - if (jjrounds[state] != jjround) { - jjstateSet[jjnewStateCnt++] = state; - jjrounds[state] = jjround; - } - } - - private void jjAddStates(int start, int end) { - do { - jjstateSet[jjnewStateCnt++] = jjnextStates[start]; - } while (start++ != end); - } - - private void jjCheckNAddTwoStates(int state1, int state2) { - jjCheckNAdd(state1); - jjCheckNAdd(state2); - } - - private void jjCheckNAddStates(int start, int end) { - do { - jjCheckNAdd(jjnextStates[start]); - } while (start++ != end); - } - - private void jjCheckNAddStates(int start) { - jjCheckNAdd(jjnextStates[start]); - jjCheckNAdd(jjnextStates[start + 1]); - } - - static final long[] jjbitVec0 = { - 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL - }; - - private int jjMoveNfa_0(int startState, int curPos) { - int[] nextStates; - int startsAt = 0; - jjnewStateCnt = 17; - int i = 1; - jjstateSet[0] = startState; - int j, kind = 0x7fffffff; - for (; ;) { - if (++jjround == 0x7fffffff) - ReInitRounds(); - if (curChar < 64) { - long l = 1L << curChar; - MatchLoop: - do { - switch (jjstateSet[--i]) { - case 3: - if ((0x3ff000000000000L & l) != 0L) { - if (kind > 7) - kind = 7; - jjCheckNAddTwoStates(0, 1); - } else if (curChar == 47) - jjAddStates(0, 1); - else if (curChar == 45) { - if (kind > 9) - kind = 9; - jjCheckNAdd(4); - } - break; - case 0: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 7) - kind = 7; - jjCheckNAddTwoStates(0, 1); - break; - case 1: - if (curChar == 46) - jjCheckNAdd(2); - break; - case 2: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 7) - kind = 7; - jjCheckNAdd(2); - break; - case 4: - if ((0x3ff200000000000L & l) == 0L) - break; - if (kind > 9) - kind = 9; - jjCheckNAdd(4); - break; - case 5: - if (curChar == 47) - jjAddStates(0, 1); - break; - case 6: - if (curChar == 47) - jjCheckNAddStates(2, 4); - break; - case 7: - if ((0xffffffffffffdbffL & l) != 0L) - jjCheckNAddStates(2, 4); - break; - case 8: - if ((0x2400L & l) != 0L && kind > 5) - kind = 5; - break; - case 9: - if (curChar == 10 && kind > 5) - kind = 5; - break; - case 10: - if (curChar == 13) - jjstateSet[jjnewStateCnt++] = 9; - break; - case 11: - if (curChar == 42) - jjCheckNAddTwoStates(12, 13); - break; - case 12: - if ((0xfffffbffffffffffL & l) != 0L) - jjCheckNAddTwoStates(12, 13); - break; - case 13: - if (curChar == 42) - jjAddStates(5, 6); - break; - case 14: - if ((0xffff7fffffffffffL & l) != 0L) - jjCheckNAddTwoStates(15, 13); - break; - case 15: - if ((0xfffffbffffffffffL & l) != 0L) - jjCheckNAddTwoStates(15, 13); - break; - case 16: - if (curChar == 47 && kind > 6) - kind = 6; - break; - default: - break; - } - } while (i != startsAt); - } else if (curChar < 128) { - long l = 1L << (curChar & 077); - MatchLoop: - do { - switch (jjstateSet[--i]) { - case 3: - case 4: - if ((0x7fffffe87fffffeL & l) == 0L) - break; - if (kind > 9) - kind = 9; - jjCheckNAdd(4); - break; - case 7: - jjAddStates(2, 4); - break; - case 12: - jjCheckNAddTwoStates(12, 13); - break; - case 14: - case 15: - jjCheckNAddTwoStates(15, 13); - break; - default: - break; - } - } while (i != startsAt); - } else { - int i2 = (curChar & 0xff) >> 6; - long l2 = 1L << (curChar & 077); - MatchLoop: - do { - switch (jjstateSet[--i]) { - case 7: - if ((jjbitVec0[i2] & l2) != 0L) - jjAddStates(2, 4); - break; - case 12: - if ((jjbitVec0[i2] & l2) != 0L) - jjCheckNAddTwoStates(12, 13); - break; - case 14: - case 15: - if ((jjbitVec0[i2] & l2) != 0L) - jjCheckNAddTwoStates(15, 13); - break; - default: - break; - } - } while (i != startsAt); - } - if (kind != 0x7fffffff) { - jjmatchedKind = kind; - jjmatchedPos = curPos; - kind = 0x7fffffff; - } - ++curPos; - if ((i = jjnewStateCnt) == (startsAt = 17 - (jjnewStateCnt = startsAt))) - return curPos; - try { - curChar = input_stream.readChar(); - } - catch (java.io.IOException e) { - return curPos; - } - } - } - - private int jjStopStringLiteralDfa_3(int pos, long active0) { - switch (pos) { - default: - return -1; - } - } - - private int jjStartNfa_3(int pos, long active0) { - return jjMoveNfa_3(jjStopStringLiteralDfa_3(pos, active0), pos + 1); - } - - private int jjStartNfaWithStates_3(int pos, int kind, int state) { - jjmatchedKind = kind; - jjmatchedPos = pos; - try { - curChar = input_stream.readChar(); - } - catch (java.io.IOException e) { - return pos + 1; - } - return jjMoveNfa_3(state, pos + 1); - } - - private int jjMoveStringLiteralDfa0_3() { - switch (curChar) { - case 59: - return jjStopAtPos(0, 15); - default: - return jjMoveNfa_3(3, 0); - } - } - - private int jjMoveNfa_3(int startState, int curPos) { - int[] nextStates; - int startsAt = 0; - jjnewStateCnt = 8; - int i = 1; - jjstateSet[0] = startState; - int j, kind = 0x7fffffff; - for (; ;) { - if (++jjround == 0x7fffffff) - ReInitRounds(); - if (curChar < 64) { - long l = 1L << curChar; - MatchLoop: - do { - switch (jjstateSet[--i]) { - case 3: - if ((0x3ff000000000000L & l) != 0L) { - if (kind > 7) - kind = 7; - jjCheckNAddTwoStates(0, 1); - } else if (curChar == 45) { - if (kind > 12) - kind = 12; - jjCheckNAdd(4); - } - break; - case 0: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 7) - kind = 7; - jjCheckNAddTwoStates(0, 1); - break; - case 1: - if (curChar == 46) - jjCheckNAdd(2); - break; - case 2: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 7) - kind = 7; - jjCheckNAdd(2); - break; - case 4: - if ((0x3ff200000000000L & l) == 0L) - break; - if (kind > 12) - kind = 12; - jjCheckNAdd(4); - break; - case 6: - jjAddStates(7, 8); - break; - default: - break; - } - } while (i != startsAt); - } else if (curChar < 128) { - long l = 1L << (curChar & 077); - MatchLoop: - do { - switch (jjstateSet[--i]) { - case 3: - if ((0x7fffffe87fffffeL & l) != 0L) { - if (kind > 12) - kind = 12; - jjCheckNAdd(4); - } else if (curChar == 123) - jjCheckNAdd(6); - break; - case 4: - if ((0x7fffffe87fffffeL & l) == 0L) - break; - if (kind > 12) - kind = 12; - jjCheckNAdd(4); - break; - case 5: - if (curChar == 123) - jjCheckNAdd(6); - break; - case 6: - if ((0xdfffffffffffffffL & l) != 0L) - jjCheckNAddTwoStates(6, 7); - break; - case 7: - if (curChar == 125) - kind = 21; - break; - default: - break; - } - } while (i != startsAt); - } else { - int i2 = (curChar & 0xff) >> 6; - long l2 = 1L << (curChar & 077); - MatchLoop: - do { - switch (jjstateSet[--i]) { - case 6: - if ((jjbitVec0[i2] & l2) != 0L) - jjAddStates(7, 8); - break; - default: - break; - } - } while (i != startsAt); - } - if (kind != 0x7fffffff) { - jjmatchedKind = kind; - jjmatchedPos = curPos; - kind = 0x7fffffff; - } - ++curPos; - if ((i = jjnewStateCnt) == (startsAt = 8 - (jjnewStateCnt = startsAt))) - return curPos; - try { - curChar = input_stream.readChar(); - } - catch (java.io.IOException e) { - return curPos; - } - } - } - - private int jjStopStringLiteralDfa_1(int pos, long active0) { - switch (pos) { - default: - return -1; - } - } - - private int jjStartNfa_1(int pos, long active0) { - return jjMoveNfa_1(jjStopStringLiteralDfa_1(pos, active0), pos + 1); - } - - private int jjStartNfaWithStates_1(int pos, int kind, int state) { - jjmatchedKind = kind; - jjmatchedPos = pos; - try { - curChar = input_stream.readChar(); - } - catch (java.io.IOException e) { - return pos + 1; - } - return jjMoveNfa_1(state, pos + 1); - } - - private int jjMoveStringLiteralDfa0_1() { - switch (curChar) { - case 58: - return jjStopAtPos(0, 14); - case 59: - return jjStopAtPos(0, 15); - case 125: - return jjStopAtPos(0, 17); - default: - return jjMoveNfa_1(0, 0); - } - } - - private int jjMoveNfa_1(int startState, int curPos) { - int[] nextStates; - int startsAt = 0; - jjnewStateCnt = 50; - int i = 1; - jjstateSet[0] = startState; - int j, kind = 0x7fffffff; - for (; ;) { - if (++jjround == 0x7fffffff) - ReInitRounds(); - if (curChar < 64) { - long l = 1L << curChar; - MatchLoop: - do { - switch (jjstateSet[--i]) { - case 0: - if ((0x3ff000000000000L & l) != 0L) { - if (kind > 7) - kind = 7; - jjCheckNAddStates(9, 22); - } else if (curChar == 47) - jjAddStates(23, 24); - else if (curChar == 35) - jjstateSet[jjnewStateCnt++] = 7; - else if (curChar == 34) - jjCheckNAddTwoStates(4, 5); - else if (curChar == 45) { - if (kind > 9) - kind = 9; - jjCheckNAdd(1); - } - break; - case 1: - if ((0x3ff200000000000L & l) == 0L) - break; - if (kind > 9) - kind = 9; - jjCheckNAdd(1); - break; - case 3: - if (curChar == 34) - jjCheckNAddTwoStates(4, 5); - break; - case 4: - if ((0xfffffffbffffdbffL & l) != 0L) - jjCheckNAddTwoStates(4, 5); - break; - case 5: - if (curChar == 34 && kind > 22) - kind = 22; - break; - case 6: - if (curChar == 35) - jjstateSet[jjnewStateCnt++] = 7; - break; - case 7: - if ((0x3ff000000000000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 8; - break; - case 8: - if ((0x3ff000000000000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 9; - break; - case 9: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 23) - kind = 23; - jjstateSet[jjnewStateCnt++] = 10; - break; - case 10: - if ((0x3ff000000000000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 11; - break; - case 11: - if ((0x3ff000000000000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 12; - break; - case 12: - if ((0x3ff000000000000L & l) != 0L && kind > 23) - kind = 23; - break; - case 13: - if (curChar == 47) - jjAddStates(23, 24); - break; - case 14: - if (curChar == 47) - jjCheckNAddStates(25, 27); - break; - case 15: - if ((0xffffffffffffdbffL & l) != 0L) - jjCheckNAddStates(25, 27); - break; - case 16: - if ((0x2400L & l) != 0L && kind > 5) - kind = 5; - break; - case 17: - if (curChar == 10 && kind > 5) - kind = 5; - break; - case 18: - if (curChar == 13) - jjstateSet[jjnewStateCnt++] = 17; - break; - case 19: - if (curChar == 42) - jjCheckNAddTwoStates(20, 21); - break; - case 20: - if ((0xfffffbffffffffffL & l) != 0L) - jjCheckNAddTwoStates(20, 21); - break; - case 21: - if (curChar == 42) - jjAddStates(28, 29); - break; - case 22: - if ((0xffff7fffffffffffL & l) != 0L) - jjCheckNAddTwoStates(23, 21); - break; - case 23: - if ((0xfffffbffffffffffL & l) != 0L) - jjCheckNAddTwoStates(23, 21); - break; - case 24: - if (curChar == 47 && kind > 6) - kind = 6; - break; - case 25: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 7) - kind = 7; - jjCheckNAddStates(9, 22); - break; - case 26: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 7) - kind = 7; - jjCheckNAddTwoStates(26, 27); - break; - case 27: - if (curChar == 46) - jjCheckNAdd(28); - break; - case 28: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 7) - kind = 7; - jjCheckNAdd(28); - break; - case 29: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(30, 32); - break; - case 30: - if (curChar == 46) - jjCheckNAdd(31); - break; - case 31: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(31, 33); - break; - case 34: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(33, 35); - break; - case 35: - if (curChar == 46) - jjCheckNAdd(36); - break; - case 36: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(36, 38); - break; - case 39: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(36, 41); - break; - case 40: - if (curChar == 46) - jjCheckNAdd(41); - break; - case 41: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(42, 46); - break; - default: - break; - } - } while (i != startsAt); - } else if (curChar < 128) { - long l = 1L << (curChar & 077); - MatchLoop: - do { - switch (jjstateSet[--i]) { - case 0: - if ((0x7fffffe87fffffeL & l) != 0L) { - if (kind > 9) - kind = 9; - jjCheckNAdd(1); - } else if (curChar == 123) { - if (kind > 18) - kind = 18; - } - break; - case 1: - if ((0x7fffffe87fffffeL & l) == 0L) - break; - if (kind > 9) - kind = 9; - jjCheckNAdd(1); - break; - case 2: - if (curChar == 123 && kind > 18) - kind = 18; - break; - case 4: - if ((0xffffffffefffffffL & l) != 0L) - jjAddStates(47, 48); - break; - case 7: - if ((0x7e0000007eL & l) != 0L) - jjstateSet[jjnewStateCnt++] = 8; - break; - case 8: - if ((0x7e0000007eL & l) != 0L) - jjstateSet[jjnewStateCnt++] = 9; - break; - case 9: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 23) - kind = 23; - jjstateSet[jjnewStateCnt++] = 10; - break; - case 10: - if ((0x7e0000007eL & l) != 0L) - jjstateSet[jjnewStateCnt++] = 11; - break; - case 11: - if ((0x7e0000007eL & l) != 0L) - jjstateSet[jjnewStateCnt++] = 12; - break; - case 12: - if ((0x7e0000007eL & l) != 0L && kind > 23) - kind = 23; - break; - case 15: - jjAddStates(25, 27); - break; - case 20: - jjCheckNAddTwoStates(20, 21); - break; - case 22: - case 23: - jjCheckNAddTwoStates(23, 21); - break; - case 32: - if (curChar == 109 && kind > 25) - kind = 25; - break; - case 33: - if (curChar == 101) - jjstateSet[jjnewStateCnt++] = 32; - break; - case 37: - if (curChar == 120 && kind > 26) - kind = 26; - break; - case 38: - if (curChar == 101) - jjstateSet[jjnewStateCnt++] = 37; - break; - case 42: - if (curChar == 109 && kind > 27) - kind = 27; - break; - case 43: - if (curChar == 109) - jjCheckNAdd(42); - break; - case 44: - if (curChar == 99) - jjCheckNAdd(42); - break; - case 45: - if (curChar == 110 && kind > 27) - kind = 27; - break; - case 46: - if (curChar == 105) - jjstateSet[jjnewStateCnt++] = 45; - break; - case 47: - if (curChar == 112) - jjAddStates(49, 50); - break; - case 48: - if (curChar == 116 && kind > 27) - kind = 27; - break; - case 49: - if (curChar == 99 && kind > 27) - kind = 27; - break; - default: - break; - } - } while (i != startsAt); - } else { - int i2 = (curChar & 0xff) >> 6; - long l2 = 1L << (curChar & 077); - MatchLoop: - do { - switch (jjstateSet[--i]) { - case 4: - if ((jjbitVec0[i2] & l2) != 0L) - jjAddStates(47, 48); - break; - case 15: - if ((jjbitVec0[i2] & l2) != 0L) - jjAddStates(25, 27); - break; - case 20: - if ((jjbitVec0[i2] & l2) != 0L) - jjCheckNAddTwoStates(20, 21); - break; - case 22: - case 23: - if ((jjbitVec0[i2] & l2) != 0L) - jjCheckNAddTwoStates(23, 21); - break; - default: - break; - } - } while (i != startsAt); - } - if (kind != 0x7fffffff) { - jjmatchedKind = kind; - jjmatchedPos = curPos; - kind = 0x7fffffff; - } - ++curPos; - if ((i = jjnewStateCnt) == (startsAt = 50 - (jjnewStateCnt = startsAt))) - return curPos; - try { - curChar = input_stream.readChar(); - } - catch (java.io.IOException e) { - return curPos; - } - } - } - - private int jjStopStringLiteralDfa_2(int pos, long active0) { - switch (pos) { - default: - return -1; - } - } - - private int jjStartNfa_2(int pos, long active0) { - return jjMoveNfa_2(jjStopStringLiteralDfa_2(pos, active0), pos + 1); - } - - private int jjStartNfaWithStates_2(int pos, int kind, int state) { - jjmatchedKind = kind; - jjmatchedPos = pos; - try { - curChar = input_stream.readChar(); - } - catch (java.io.IOException e) { - return pos + 1; - } - return jjMoveNfa_2(state, pos + 1); - } - - private int jjMoveStringLiteralDfa0_2() { - switch (curChar) { - case 59: - return jjStartNfaWithStates_2(0, 15, 3); - default: - return jjMoveNfa_2(4, 0); - } - } - - private int jjMoveNfa_2(int startState, int curPos) { - int[] nextStates; - int startsAt = 0; - jjnewStateCnt = 5; - int i = 1; - jjstateSet[0] = startState; - int j, kind = 0x7fffffff; - for (; ;) { - if (++jjround == 0x7fffffff) - ReInitRounds(); - if (curChar < 64) { - long l = 1L << curChar; - MatchLoop: - do { - switch (jjstateSet[--i]) { - case 4: - if (kind > 19) - kind = 19; - jjCheckNAdd(3); - if ((0x3ff000000000000L & l) != 0L) { - if (kind > 7) - kind = 7; - jjCheckNAddTwoStates(0, 1); - } - break; - case 0: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 7) - kind = 7; - jjCheckNAddTwoStates(0, 1); - break; - case 1: - if (curChar == 46) - jjCheckNAdd(2); - break; - case 2: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 7) - kind = 7; - jjCheckNAdd(2); - break; - case 3: - if (kind > 19) - kind = 19; - jjCheckNAdd(3); - break; - default: - break; - } - } while (i != startsAt); - } else if (curChar < 128) { - long l = 1L << (curChar & 077); - MatchLoop: - do { - switch (jjstateSet[--i]) { - case 4: - if ((0xdfffffffffffffffL & l) != 0L) { - if (kind > 19) - kind = 19; - jjCheckNAdd(3); - } else if (curChar == 125) { - if (kind > 20) - kind = 20; - } - break; - case 3: - if ((0xdfffffffffffffffL & l) == 0L) - break; - kind = 19; - jjCheckNAdd(3); - break; - default: - break; - } - } while (i != startsAt); - } else { - int i2 = (curChar & 0xff) >> 6; - long l2 = 1L << (curChar & 077); - MatchLoop: - do { - switch (jjstateSet[--i]) { - case 4: - case 3: - if ((jjbitVec0[i2] & l2) == 0L) - break; - if (kind > 19) - kind = 19; - jjCheckNAdd(3); - break; - default: - break; - } - } while (i != startsAt); - } - if (kind != 0x7fffffff) { - jjmatchedKind = kind; - jjmatchedPos = curPos; - kind = 0x7fffffff; - } - ++curPos; - if ((i = jjnewStateCnt) == (startsAt = 5 - (jjnewStateCnt = startsAt))) - return curPos; - try { - curChar = input_stream.readChar(); - } - catch (java.io.IOException e) { - return curPos; - } - } - } - - static final int[] jjnextStates = { - 6, 11, 7, 8, 10, 14, 16, 6, 7, 26, 27, 29, 30, 33, 34, 35, - 38, 39, 40, 43, 44, 46, 47, 14, 19, 15, 16, 18, 22, 24, 29, 30, - 33, 34, 35, 38, 39, 40, 43, 44, 46, 47, 41, 43, 44, 46, 47, 4, - 5, 48, 49, - }; - public static final String[] jjstrLiteralImages = { - "", null, null, null, null, null, null, null, null, null, null, null, null, - "\72", "\72", "\73", "\173", "\175", null, null, null, null, null, null, null, null, - null, null, "\54", "\52", "\43", "\56", "\133", "\135", "\75",}; - public static final String[] lexStateNames = { - "DEFAULT", - "IN_RULE", - "JAVA_CODE_RULE", - "IN_PSEUDOCLASS", - }; - public static final int[] jjnewLexState = { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 3, -1, -1, 1, 0, 2, -1, 1, 0, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - }; - static final long[] jjtoToken = { - 0x7fefff281L, - }; - static final long[] jjtoSkip = { - 0x7eL, - }; - protected SimpleCharStream input_stream; - private final int[] jjrounds = new int[50]; - private final int[] jjstateSet = new int[100]; - protected char curChar; - - public CSSParserTokenManager(SimpleCharStream stream) { - if (SimpleCharStream.staticFlag) - throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); - input_stream = stream; - } - - public CSSParserTokenManager(SimpleCharStream stream, int lexState) { - this(stream); - SwitchTo(lexState); - } - - public void ReInit(SimpleCharStream stream) { - jjmatchedPos = jjnewStateCnt = 0; - curLexState = defaultLexState; - input_stream = stream; - ReInitRounds(); - } - - private void ReInitRounds() { - int i; - jjround = 0x80000001; - for (i = 50; i-- > 0;) - jjrounds[i] = 0x80000000; - } - - public void ReInit(SimpleCharStream stream, int lexState) { - ReInit(stream); - SwitchTo(lexState); - } - - public void SwitchTo(int lexState) { - if (lexState >= 4 || lexState < 0) - throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); - else - curLexState = lexState; - } - - protected Token jjFillToken() { - Token t = Token.newToken(jjmatchedKind); - t.kind = jjmatchedKind; - String im = jjstrLiteralImages[jjmatchedKind]; - t.image = (im == null) ? input_stream.GetImage() : im; - t.beginLine = input_stream.getBeginLine(); - t.beginColumn = input_stream.getBeginColumn(); - t.endLine = input_stream.getEndLine(); - t.endColumn = input_stream.getEndColumn(); - return t; - } - - int curLexState = 0; - int defaultLexState = 0; - int jjnewStateCnt; - int jjround; - int jjmatchedPos; - int jjmatchedKind; - - public Token getNextToken() { - int kind; - Token specialToken = null; - Token matchedToken; - int curPos = 0; - - EOFLoop: - for (; ;) { - try { - curChar = input_stream.BeginToken(); - } - catch (java.io.IOException e) { - jjmatchedKind = 0; - matchedToken = jjFillToken(); - return matchedToken; - } - - switch (curLexState) { - case 0: - try { - input_stream.backup(0); - while (curChar <= 32 && (0x100002600L & (1L << curChar)) != 0L) - curChar = input_stream.BeginToken(); - } - catch (java.io.IOException e1) { - continue EOFLoop; - } - jjmatchedKind = 0x7fffffff; - jjmatchedPos = 0; - curPos = jjMoveStringLiteralDfa0_0(); - break; - case 1: - try { - input_stream.backup(0); - while (curChar <= 32 && (0x100002600L & (1L << curChar)) != 0L) - curChar = input_stream.BeginToken(); - } - catch (java.io.IOException e1) { - continue EOFLoop; - } - jjmatchedKind = 0x7fffffff; - jjmatchedPos = 0; - curPos = jjMoveStringLiteralDfa0_1(); - break; - case 2: - jjmatchedKind = 0x7fffffff; - jjmatchedPos = 0; - curPos = jjMoveStringLiteralDfa0_2(); - break; - case 3: - jjmatchedKind = 0x7fffffff; - jjmatchedPos = 0; - curPos = jjMoveStringLiteralDfa0_3(); - break; - } - if (jjmatchedKind != 0x7fffffff) { - if (jjmatchedPos + 1 < curPos) - input_stream.backup(curPos - jjmatchedPos - 1); - if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) { - matchedToken = jjFillToken(); - if (jjnewLexState[jjmatchedKind] != -1) - curLexState = jjnewLexState[jjmatchedKind]; - return matchedToken; - } else { - if (jjnewLexState[jjmatchedKind] != -1) - curLexState = jjnewLexState[jjmatchedKind]; - continue EOFLoop; - } - } - int error_line = input_stream.getEndLine(); - int error_column = input_stream.getEndColumn(); - String error_after = null; - boolean EOFSeen = false; - try { - input_stream.readChar(); - input_stream.backup(1); - } - catch (java.io.IOException e1) { - EOFSeen = true; - error_after = curPos <= 1 ? "" : input_stream.GetImage(); - if (curChar == '\n' || curChar == '\r') { - error_line++; - error_column = 0; - } else - error_column++; - } - if (!EOFSeen) { - input_stream.backup(1); - error_after = curPos <= 1 ? "" : input_stream.GetImage(); - } - throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR); - } - } - -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParserTokenManager.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParserTokenManager.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParserTokenManager.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParserTokenManager.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,1172 @@ +/* Generated By:JJTree&JavaCC: Do not edit this line. CSSParserTokenManager.java */ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.css.parser; + +public class CSSParserTokenManager implements CSSParserConstants { + public java.io.PrintStream debugStream = System.out; + + public void setDebugStream(java.io.PrintStream ds) { + debugStream = ds; + } + + private int jjStopStringLiteralDfa_0(int pos, long active0) { + switch (pos) { + default: + return -1; + } + } + + private int jjStartNfa_0(int pos, long active0) { + return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1); + } + + private int jjStopAtPos(int pos, int kind) { + jjmatchedKind = kind; + jjmatchedPos = pos; + return pos + 1; + } + + private int jjStartNfaWithStates_0(int pos, int kind, int state) { + jjmatchedKind = kind; + jjmatchedPos = pos; + try { + curChar = input_stream.readChar(); + } + catch (java.io.IOException e) { + return pos + 1; + } + return jjMoveNfa_0(state, pos + 1); + } + + private int jjMoveStringLiteralDfa0_0() { + switch (curChar) { + case 35: + return jjStopAtPos(0, 30); + case 42: + return jjStopAtPos(0, 29); + case 44: + return jjStopAtPos(0, 28); + case 46: + return jjStopAtPos(0, 31); + case 58: + return jjStopAtPos(0, 13); + case 59: + return jjStopAtPos(0, 15); + case 61: + return jjStopAtPos(0, 34); + case 91: + return jjStopAtPos(0, 32); + case 93: + return jjStopAtPos(0, 33); + case 123: + return jjStopAtPos(0, 16); + default: + return jjMoveNfa_0(3, 0); + } + } + + private void jjCheckNAdd(int state) { + if (jjrounds[state] != jjround) { + jjstateSet[jjnewStateCnt++] = state; + jjrounds[state] = jjround; + } + } + + private void jjAddStates(int start, int end) { + do { + jjstateSet[jjnewStateCnt++] = jjnextStates[start]; + } while (start++ != end); + } + + private void jjCheckNAddTwoStates(int state1, int state2) { + jjCheckNAdd(state1); + jjCheckNAdd(state2); + } + + private void jjCheckNAddStates(int start, int end) { + do { + jjCheckNAdd(jjnextStates[start]); + } while (start++ != end); + } + + private void jjCheckNAddStates(int start) { + jjCheckNAdd(jjnextStates[start]); + jjCheckNAdd(jjnextStates[start + 1]); + } + + static final long[] jjbitVec0 = { + 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL + }; + + private int jjMoveNfa_0(int startState, int curPos) { + int[] nextStates; + int startsAt = 0; + jjnewStateCnt = 17; + int i = 1; + jjstateSet[0] = startState; + int j, kind = 0x7fffffff; + for (; ;) { + if (++jjround == 0x7fffffff) + ReInitRounds(); + if (curChar < 64) { + long l = 1L << curChar; + MatchLoop: + do { + switch (jjstateSet[--i]) { + case 3: + if ((0x3ff000000000000L & l) != 0L) { + if (kind > 7) + kind = 7; + jjCheckNAddTwoStates(0, 1); + } else if (curChar == 47) + jjAddStates(0, 1); + else if (curChar == 45) { + if (kind > 9) + kind = 9; + jjCheckNAdd(4); + } + break; + case 0: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 7) + kind = 7; + jjCheckNAddTwoStates(0, 1); + break; + case 1: + if (curChar == 46) + jjCheckNAdd(2); + break; + case 2: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 7) + kind = 7; + jjCheckNAdd(2); + break; + case 4: + if ((0x3ff200000000000L & l) == 0L) + break; + if (kind > 9) + kind = 9; + jjCheckNAdd(4); + break; + case 5: + if (curChar == 47) + jjAddStates(0, 1); + break; + case 6: + if (curChar == 47) + jjCheckNAddStates(2, 4); + break; + case 7: + if ((0xffffffffffffdbffL & l) != 0L) + jjCheckNAddStates(2, 4); + break; + case 8: + if ((0x2400L & l) != 0L && kind > 5) + kind = 5; + break; + case 9: + if (curChar == 10 && kind > 5) + kind = 5; + break; + case 10: + if (curChar == 13) + jjstateSet[jjnewStateCnt++] = 9; + break; + case 11: + if (curChar == 42) + jjCheckNAddTwoStates(12, 13); + break; + case 12: + if ((0xfffffbffffffffffL & l) != 0L) + jjCheckNAddTwoStates(12, 13); + break; + case 13: + if (curChar == 42) + jjAddStates(5, 6); + break; + case 14: + if ((0xffff7fffffffffffL & l) != 0L) + jjCheckNAddTwoStates(15, 13); + break; + case 15: + if ((0xfffffbffffffffffL & l) != 0L) + jjCheckNAddTwoStates(15, 13); + break; + case 16: + if (curChar == 47 && kind > 6) + kind = 6; + break; + default: + break; + } + } while (i != startsAt); + } else if (curChar < 128) { + long l = 1L << (curChar & 077); + MatchLoop: + do { + switch (jjstateSet[--i]) { + case 3: + case 4: + if ((0x7fffffe87fffffeL & l) == 0L) + break; + if (kind > 9) + kind = 9; + jjCheckNAdd(4); + break; + case 7: + jjAddStates(2, 4); + break; + case 12: + jjCheckNAddTwoStates(12, 13); + break; + case 14: + case 15: + jjCheckNAddTwoStates(15, 13); + break; + default: + break; + } + } while (i != startsAt); + } else { + int i2 = (curChar & 0xff) >> 6; + long l2 = 1L << (curChar & 077); + MatchLoop: + do { + switch (jjstateSet[--i]) { + case 7: + if ((jjbitVec0[i2] & l2) != 0L) + jjAddStates(2, 4); + break; + case 12: + if ((jjbitVec0[i2] & l2) != 0L) + jjCheckNAddTwoStates(12, 13); + break; + case 14: + case 15: + if ((jjbitVec0[i2] & l2) != 0L) + jjCheckNAddTwoStates(15, 13); + break; + default: + break; + } + } while (i != startsAt); + } + if (kind != 0x7fffffff) { + jjmatchedKind = kind; + jjmatchedPos = curPos; + kind = 0x7fffffff; + } + ++curPos; + if ((i = jjnewStateCnt) == (startsAt = 17 - (jjnewStateCnt = startsAt))) + return curPos; + try { + curChar = input_stream.readChar(); + } + catch (java.io.IOException e) { + return curPos; + } + } + } + + private int jjStopStringLiteralDfa_3(int pos, long active0) { + switch (pos) { + default: + return -1; + } + } + + private int jjStartNfa_3(int pos, long active0) { + return jjMoveNfa_3(jjStopStringLiteralDfa_3(pos, active0), pos + 1); + } + + private int jjStartNfaWithStates_3(int pos, int kind, int state) { + jjmatchedKind = kind; + jjmatchedPos = pos; + try { + curChar = input_stream.readChar(); + } + catch (java.io.IOException e) { + return pos + 1; + } + return jjMoveNfa_3(state, pos + 1); + } + + private int jjMoveStringLiteralDfa0_3() { + switch (curChar) { + case 59: + return jjStopAtPos(0, 15); + default: + return jjMoveNfa_3(3, 0); + } + } + + private int jjMoveNfa_3(int startState, int curPos) { + int[] nextStates; + int startsAt = 0; + jjnewStateCnt = 8; + int i = 1; + jjstateSet[0] = startState; + int j, kind = 0x7fffffff; + for (; ;) { + if (++jjround == 0x7fffffff) + ReInitRounds(); + if (curChar < 64) { + long l = 1L << curChar; + MatchLoop: + do { + switch (jjstateSet[--i]) { + case 3: + if ((0x3ff000000000000L & l) != 0L) { + if (kind > 7) + kind = 7; + jjCheckNAddTwoStates(0, 1); + } else if (curChar == 45) { + if (kind > 12) + kind = 12; + jjCheckNAdd(4); + } + break; + case 0: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 7) + kind = 7; + jjCheckNAddTwoStates(0, 1); + break; + case 1: + if (curChar == 46) + jjCheckNAdd(2); + break; + case 2: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 7) + kind = 7; + jjCheckNAdd(2); + break; + case 4: + if ((0x3ff200000000000L & l) == 0L) + break; + if (kind > 12) + kind = 12; + jjCheckNAdd(4); + break; + case 6: + jjAddStates(7, 8); + break; + default: + break; + } + } while (i != startsAt); + } else if (curChar < 128) { + long l = 1L << (curChar & 077); + MatchLoop: + do { + switch (jjstateSet[--i]) { + case 3: + if ((0x7fffffe87fffffeL & l) != 0L) { + if (kind > 12) + kind = 12; + jjCheckNAdd(4); + } else if (curChar == 123) + jjCheckNAdd(6); + break; + case 4: + if ((0x7fffffe87fffffeL & l) == 0L) + break; + if (kind > 12) + kind = 12; + jjCheckNAdd(4); + break; + case 5: + if (curChar == 123) + jjCheckNAdd(6); + break; + case 6: + if ((0xdfffffffffffffffL & l) != 0L) + jjCheckNAddTwoStates(6, 7); + break; + case 7: + if (curChar == 125) + kind = 21; + break; + default: + break; + } + } while (i != startsAt); + } else { + int i2 = (curChar & 0xff) >> 6; + long l2 = 1L << (curChar & 077); + MatchLoop: + do { + switch (jjstateSet[--i]) { + case 6: + if ((jjbitVec0[i2] & l2) != 0L) + jjAddStates(7, 8); + break; + default: + break; + } + } while (i != startsAt); + } + if (kind != 0x7fffffff) { + jjmatchedKind = kind; + jjmatchedPos = curPos; + kind = 0x7fffffff; + } + ++curPos; + if ((i = jjnewStateCnt) == (startsAt = 8 - (jjnewStateCnt = startsAt))) + return curPos; + try { + curChar = input_stream.readChar(); + } + catch (java.io.IOException e) { + return curPos; + } + } + } + + private int jjStopStringLiteralDfa_1(int pos, long active0) { + switch (pos) { + default: + return -1; + } + } + + private int jjStartNfa_1(int pos, long active0) { + return jjMoveNfa_1(jjStopStringLiteralDfa_1(pos, active0), pos + 1); + } + + private int jjStartNfaWithStates_1(int pos, int kind, int state) { + jjmatchedKind = kind; + jjmatchedPos = pos; + try { + curChar = input_stream.readChar(); + } + catch (java.io.IOException e) { + return pos + 1; + } + return jjMoveNfa_1(state, pos + 1); + } + + private int jjMoveStringLiteralDfa0_1() { + switch (curChar) { + case 58: + return jjStopAtPos(0, 14); + case 59: + return jjStopAtPos(0, 15); + case 125: + return jjStopAtPos(0, 17); + default: + return jjMoveNfa_1(0, 0); + } + } + + private int jjMoveNfa_1(int startState, int curPos) { + int[] nextStates; + int startsAt = 0; + jjnewStateCnt = 50; + int i = 1; + jjstateSet[0] = startState; + int j, kind = 0x7fffffff; + for (; ;) { + if (++jjround == 0x7fffffff) + ReInitRounds(); + if (curChar < 64) { + long l = 1L << curChar; + MatchLoop: + do { + switch (jjstateSet[--i]) { + case 0: + if ((0x3ff000000000000L & l) != 0L) { + if (kind > 7) + kind = 7; + jjCheckNAddStates(9, 22); + } else if (curChar == 47) + jjAddStates(23, 24); + else if (curChar == 35) + jjstateSet[jjnewStateCnt++] = 7; + else if (curChar == 34) + jjCheckNAddTwoStates(4, 5); + else if (curChar == 45) { + if (kind > 9) + kind = 9; + jjCheckNAdd(1); + } + break; + case 1: + if ((0x3ff200000000000L & l) == 0L) + break; + if (kind > 9) + kind = 9; + jjCheckNAdd(1); + break; + case 3: + if (curChar == 34) + jjCheckNAddTwoStates(4, 5); + break; + case 4: + if ((0xfffffffbffffdbffL & l) != 0L) + jjCheckNAddTwoStates(4, 5); + break; + case 5: + if (curChar == 34 && kind > 22) + kind = 22; + break; + case 6: + if (curChar == 35) + jjstateSet[jjnewStateCnt++] = 7; + break; + case 7: + if ((0x3ff000000000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 8; + break; + case 8: + if ((0x3ff000000000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 9; + break; + case 9: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 23) + kind = 23; + jjstateSet[jjnewStateCnt++] = 10; + break; + case 10: + if ((0x3ff000000000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 11; + break; + case 11: + if ((0x3ff000000000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 12; + break; + case 12: + if ((0x3ff000000000000L & l) != 0L && kind > 23) + kind = 23; + break; + case 13: + if (curChar == 47) + jjAddStates(23, 24); + break; + case 14: + if (curChar == 47) + jjCheckNAddStates(25, 27); + break; + case 15: + if ((0xffffffffffffdbffL & l) != 0L) + jjCheckNAddStates(25, 27); + break; + case 16: + if ((0x2400L & l) != 0L && kind > 5) + kind = 5; + break; + case 17: + if (curChar == 10 && kind > 5) + kind = 5; + break; + case 18: + if (curChar == 13) + jjstateSet[jjnewStateCnt++] = 17; + break; + case 19: + if (curChar == 42) + jjCheckNAddTwoStates(20, 21); + break; + case 20: + if ((0xfffffbffffffffffL & l) != 0L) + jjCheckNAddTwoStates(20, 21); + break; + case 21: + if (curChar == 42) + jjAddStates(28, 29); + break; + case 22: + if ((0xffff7fffffffffffL & l) != 0L) + jjCheckNAddTwoStates(23, 21); + break; + case 23: + if ((0xfffffbffffffffffL & l) != 0L) + jjCheckNAddTwoStates(23, 21); + break; + case 24: + if (curChar == 47 && kind > 6) + kind = 6; + break; + case 25: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 7) + kind = 7; + jjCheckNAddStates(9, 22); + break; + case 26: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 7) + kind = 7; + jjCheckNAddTwoStates(26, 27); + break; + case 27: + if (curChar == 46) + jjCheckNAdd(28); + break; + case 28: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 7) + kind = 7; + jjCheckNAdd(28); + break; + case 29: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(30, 32); + break; + case 30: + if (curChar == 46) + jjCheckNAdd(31); + break; + case 31: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(31, 33); + break; + case 34: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(33, 35); + break; + case 35: + if (curChar == 46) + jjCheckNAdd(36); + break; + case 36: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(36, 38); + break; + case 39: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(36, 41); + break; + case 40: + if (curChar == 46) + jjCheckNAdd(41); + break; + case 41: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(42, 46); + break; + default: + break; + } + } while (i != startsAt); + } else if (curChar < 128) { + long l = 1L << (curChar & 077); + MatchLoop: + do { + switch (jjstateSet[--i]) { + case 0: + if ((0x7fffffe87fffffeL & l) != 0L) { + if (kind > 9) + kind = 9; + jjCheckNAdd(1); + } else if (curChar == 123) { + if (kind > 18) + kind = 18; + } + break; + case 1: + if ((0x7fffffe87fffffeL & l) == 0L) + break; + if (kind > 9) + kind = 9; + jjCheckNAdd(1); + break; + case 2: + if (curChar == 123 && kind > 18) + kind = 18; + break; + case 4: + if ((0xffffffffefffffffL & l) != 0L) + jjAddStates(47, 48); + break; + case 7: + if ((0x7e0000007eL & l) != 0L) + jjstateSet[jjnewStateCnt++] = 8; + break; + case 8: + if ((0x7e0000007eL & l) != 0L) + jjstateSet[jjnewStateCnt++] = 9; + break; + case 9: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 23) + kind = 23; + jjstateSet[jjnewStateCnt++] = 10; + break; + case 10: + if ((0x7e0000007eL & l) != 0L) + jjstateSet[jjnewStateCnt++] = 11; + break; + case 11: + if ((0x7e0000007eL & l) != 0L) + jjstateSet[jjnewStateCnt++] = 12; + break; + case 12: + if ((0x7e0000007eL & l) != 0L && kind > 23) + kind = 23; + break; + case 15: + jjAddStates(25, 27); + break; + case 20: + jjCheckNAddTwoStates(20, 21); + break; + case 22: + case 23: + jjCheckNAddTwoStates(23, 21); + break; + case 32: + if (curChar == 109 && kind > 25) + kind = 25; + break; + case 33: + if (curChar == 101) + jjstateSet[jjnewStateCnt++] = 32; + break; + case 37: + if (curChar == 120 && kind > 26) + kind = 26; + break; + case 38: + if (curChar == 101) + jjstateSet[jjnewStateCnt++] = 37; + break; + case 42: + if (curChar == 109 && kind > 27) + kind = 27; + break; + case 43: + if (curChar == 109) + jjCheckNAdd(42); + break; + case 44: + if (curChar == 99) + jjCheckNAdd(42); + break; + case 45: + if (curChar == 110 && kind > 27) + kind = 27; + break; + case 46: + if (curChar == 105) + jjstateSet[jjnewStateCnt++] = 45; + break; + case 47: + if (curChar == 112) + jjAddStates(49, 50); + break; + case 48: + if (curChar == 116 && kind > 27) + kind = 27; + break; + case 49: + if (curChar == 99 && kind > 27) + kind = 27; + break; + default: + break; + } + } while (i != startsAt); + } else { + int i2 = (curChar & 0xff) >> 6; + long l2 = 1L << (curChar & 077); + MatchLoop: + do { + switch (jjstateSet[--i]) { + case 4: + if ((jjbitVec0[i2] & l2) != 0L) + jjAddStates(47, 48); + break; + case 15: + if ((jjbitVec0[i2] & l2) != 0L) + jjAddStates(25, 27); + break; + case 20: + if ((jjbitVec0[i2] & l2) != 0L) + jjCheckNAddTwoStates(20, 21); + break; + case 22: + case 23: + if ((jjbitVec0[i2] & l2) != 0L) + jjCheckNAddTwoStates(23, 21); + break; + default: + break; + } + } while (i != startsAt); + } + if (kind != 0x7fffffff) { + jjmatchedKind = kind; + jjmatchedPos = curPos; + kind = 0x7fffffff; + } + ++curPos; + if ((i = jjnewStateCnt) == (startsAt = 50 - (jjnewStateCnt = startsAt))) + return curPos; + try { + curChar = input_stream.readChar(); + } + catch (java.io.IOException e) { + return curPos; + } + } + } + + private int jjStopStringLiteralDfa_2(int pos, long active0) { + switch (pos) { + default: + return -1; + } + } + + private int jjStartNfa_2(int pos, long active0) { + return jjMoveNfa_2(jjStopStringLiteralDfa_2(pos, active0), pos + 1); + } + + private int jjStartNfaWithStates_2(int pos, int kind, int state) { + jjmatchedKind = kind; + jjmatchedPos = pos; + try { + curChar = input_stream.readChar(); + } + catch (java.io.IOException e) { + return pos + 1; + } + return jjMoveNfa_2(state, pos + 1); + } + + private int jjMoveStringLiteralDfa0_2() { + switch (curChar) { + case 59: + return jjStartNfaWithStates_2(0, 15, 3); + default: + return jjMoveNfa_2(4, 0); + } + } + + private int jjMoveNfa_2(int startState, int curPos) { + int[] nextStates; + int startsAt = 0; + jjnewStateCnt = 5; + int i = 1; + jjstateSet[0] = startState; + int j, kind = 0x7fffffff; + for (; ;) { + if (++jjround == 0x7fffffff) + ReInitRounds(); + if (curChar < 64) { + long l = 1L << curChar; + MatchLoop: + do { + switch (jjstateSet[--i]) { + case 4: + if (kind > 19) + kind = 19; + jjCheckNAdd(3); + if ((0x3ff000000000000L & l) != 0L) { + if (kind > 7) + kind = 7; + jjCheckNAddTwoStates(0, 1); + } + break; + case 0: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 7) + kind = 7; + jjCheckNAddTwoStates(0, 1); + break; + case 1: + if (curChar == 46) + jjCheckNAdd(2); + break; + case 2: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 7) + kind = 7; + jjCheckNAdd(2); + break; + case 3: + if (kind > 19) + kind = 19; + jjCheckNAdd(3); + break; + default: + break; + } + } while (i != startsAt); + } else if (curChar < 128) { + long l = 1L << (curChar & 077); + MatchLoop: + do { + switch (jjstateSet[--i]) { + case 4: + if ((0xdfffffffffffffffL & l) != 0L) { + if (kind > 19) + kind = 19; + jjCheckNAdd(3); + } else if (curChar == 125) { + if (kind > 20) + kind = 20; + } + break; + case 3: + if ((0xdfffffffffffffffL & l) == 0L) + break; + kind = 19; + jjCheckNAdd(3); + break; + default: + break; + } + } while (i != startsAt); + } else { + int i2 = (curChar & 0xff) >> 6; + long l2 = 1L << (curChar & 077); + MatchLoop: + do { + switch (jjstateSet[--i]) { + case 4: + case 3: + if ((jjbitVec0[i2] & l2) == 0L) + break; + if (kind > 19) + kind = 19; + jjCheckNAdd(3); + break; + default: + break; + } + } while (i != startsAt); + } + if (kind != 0x7fffffff) { + jjmatchedKind = kind; + jjmatchedPos = curPos; + kind = 0x7fffffff; + } + ++curPos; + if ((i = jjnewStateCnt) == (startsAt = 5 - (jjnewStateCnt = startsAt))) + return curPos; + try { + curChar = input_stream.readChar(); + } + catch (java.io.IOException e) { + return curPos; + } + } + } + + static final int[] jjnextStates = { + 6, 11, 7, 8, 10, 14, 16, 6, 7, 26, 27, 29, 30, 33, 34, 35, + 38, 39, 40, 43, 44, 46, 47, 14, 19, 15, 16, 18, 22, 24, 29, 30, + 33, 34, 35, 38, 39, 40, 43, 44, 46, 47, 41, 43, 44, 46, 47, 4, + 5, 48, 49, + }; + public static final String[] jjstrLiteralImages = { + "", null, null, null, null, null, null, null, null, null, null, null, null, + "\72", "\72", "\73", "\173", "\175", null, null, null, null, null, null, null, null, + null, null, "\54", "\52", "\43", "\56", "\133", "\135", "\75",}; + public static final String[] lexStateNames = { + "DEFAULT", + "IN_RULE", + "JAVA_CODE_RULE", + "IN_PSEUDOCLASS", + }; + public static final int[] jjnewLexState = { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 3, -1, -1, 1, 0, 2, -1, 1, 0, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + }; + static final long[] jjtoToken = { + 0x7fefff281L, + }; + static final long[] jjtoSkip = { + 0x7eL, + }; + protected SimpleCharStream input_stream; + private final int[] jjrounds = new int[50]; + private final int[] jjstateSet = new int[100]; + protected char curChar; + + public CSSParserTokenManager(SimpleCharStream stream) { + if (SimpleCharStream.staticFlag) + throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); + input_stream = stream; + } + + public CSSParserTokenManager(SimpleCharStream stream, int lexState) { + this(stream); + SwitchTo(lexState); + } + + public void ReInit(SimpleCharStream stream) { + jjmatchedPos = jjnewStateCnt = 0; + curLexState = defaultLexState; + input_stream = stream; + ReInitRounds(); + } + + private void ReInitRounds() { + int i; + jjround = 0x80000001; + for (i = 50; i-- > 0;) + jjrounds[i] = 0x80000000; + } + + public void ReInit(SimpleCharStream stream, int lexState) { + ReInit(stream); + SwitchTo(lexState); + } + + public void SwitchTo(int lexState) { + if (lexState >= 4 || lexState < 0) + throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); + else + curLexState = lexState; + } + + protected Token jjFillToken() { + Token t = Token.newToken(jjmatchedKind); + t.kind = jjmatchedKind; + String im = jjstrLiteralImages[jjmatchedKind]; + t.image = (im == null) ? input_stream.GetImage() : im; + t.beginLine = input_stream.getBeginLine(); + t.beginColumn = input_stream.getBeginColumn(); + t.endLine = input_stream.getEndLine(); + t.endColumn = input_stream.getEndColumn(); + return t; + } + + int curLexState = 0; + int defaultLexState = 0; + int jjnewStateCnt; + int jjround; + int jjmatchedPos; + int jjmatchedKind; + + public Token getNextToken() { + int kind; + Token specialToken = null; + Token matchedToken; + int curPos = 0; + + EOFLoop: + for (; ;) { + try { + curChar = input_stream.BeginToken(); + } + catch (java.io.IOException e) { + jjmatchedKind = 0; + matchedToken = jjFillToken(); + return matchedToken; + } + + switch (curLexState) { + case 0: + try { + input_stream.backup(0); + while (curChar <= 32 && (0x100002600L & (1L << curChar)) != 0L) + curChar = input_stream.BeginToken(); + } + catch (java.io.IOException e1) { + continue EOFLoop; + } + jjmatchedKind = 0x7fffffff; + jjmatchedPos = 0; + curPos = jjMoveStringLiteralDfa0_0(); + break; + case 1: + try { + input_stream.backup(0); + while (curChar <= 32 && (0x100002600L & (1L << curChar)) != 0L) + curChar = input_stream.BeginToken(); + } + catch (java.io.IOException e1) { + continue EOFLoop; + } + jjmatchedKind = 0x7fffffff; + jjmatchedPos = 0; + curPos = jjMoveStringLiteralDfa0_1(); + break; + case 2: + jjmatchedKind = 0x7fffffff; + jjmatchedPos = 0; + curPos = jjMoveStringLiteralDfa0_2(); + break; + case 3: + jjmatchedKind = 0x7fffffff; + jjmatchedPos = 0; + curPos = jjMoveStringLiteralDfa0_3(); + break; + } + if (jjmatchedKind != 0x7fffffff) { + if (jjmatchedPos + 1 < curPos) + input_stream.backup(curPos - jjmatchedPos - 1); + if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) { + matchedToken = jjFillToken(); + if (jjnewLexState[jjmatchedKind] != -1) + curLexState = jjnewLexState[jjmatchedKind]; + return matchedToken; + } else { + if (jjnewLexState[jjmatchedKind] != -1) + curLexState = jjnewLexState[jjmatchedKind]; + continue EOFLoop; + } + } + int error_line = input_stream.getEndLine(); + int error_column = input_stream.getEndColumn(); + String error_after = null; + boolean EOFSeen = false; + try { + input_stream.readChar(); + input_stream.backup(1); + } + catch (java.io.IOException e1) { + EOFSeen = true; + error_after = curPos <= 1 ? "" : input_stream.GetImage(); + if (curChar == '\n' || curChar == '\r') { + error_line++; + error_column = 0; + } else + error_column++; + } + if (!EOFSeen) { + input_stream.backup(1); + error_after = curPos <= 1 ? "" : input_stream.GetImage(); + } + throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR); + } + } + +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParserTreeConstants.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParserTreeConstants.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParserTreeConstants.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,60 +0,0 @@ -/* Generated By:JJTree: Do not edit this line. .\CSSParserTreeConstants.java */ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ - -package jaxx.compiler.css.parser; - -public interface CSSParserTreeConstants { - public int JJTSTYLESHEET = 0; - public int JJTRULE = 1; - public int JJTSELECTORS = 2; - public int JJTSELECTOR = 3; - public int JJTJAVACLASS = 4; - public int JJTID = 5; - public int JJTCLASS = 6; - public int JJTPSEUDOCLASS = 7; - public int JJTANIMATIONPROPERTIES = 8; - public int JJTANIMATIONPROPERTY = 9; - public int JJTDECLARATION = 10; - public int JJTPROPERTY = 11; - public int JJTEXPRESSION = 12; - public int JJTJAVACODE = 13; - public int JJTIDENTIFIER = 14; - - - public String[] jjtNodeName = { - "Stylesheet", - "Rule", - "Selectors", - "Selector", - "JavaClass", - "Id", - "Class", - "PseudoClass", - "AnimationProperties", - "AnimationProperty", - "Declaration", - "Property", - "Expression", - "JavaCode", - "Identifier", - }; -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParserTreeConstants.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParserTreeConstants.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParserTreeConstants.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/CSSParserTreeConstants.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,60 @@ +/* Generated By:JJTree: Do not edit this line. .\CSSParserTreeConstants.java */ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ + +package jaxx.compiler.css.parser; + +public interface CSSParserTreeConstants { + public int JJTSTYLESHEET = 0; + public int JJTRULE = 1; + public int JJTSELECTORS = 2; + public int JJTSELECTOR = 3; + public int JJTJAVACLASS = 4; + public int JJTID = 5; + public int JJTCLASS = 6; + public int JJTPSEUDOCLASS = 7; + public int JJTANIMATIONPROPERTIES = 8; + public int JJTANIMATIONPROPERTY = 9; + public int JJTDECLARATION = 10; + public int JJTPROPERTY = 11; + public int JJTEXPRESSION = 12; + public int JJTJAVACODE = 13; + public int JJTIDENTIFIER = 14; + + + public String[] jjtNodeName = { + "Stylesheet", + "Rule", + "Selectors", + "Selector", + "JavaClass", + "Id", + "Class", + "PseudoClass", + "AnimationProperties", + "AnimationProperty", + "Declaration", + "Property", + "Expression", + "JavaCode", + "Identifier", + }; +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/JJTCSSParserState.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/JJTCSSParserState.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/JJTCSSParserState.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,143 +0,0 @@ -/* Generated By:JJTree: Do not edit this line. .\JJTCSSParserState.java */ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ - -package jaxx.compiler.css.parser; - -class JJTCSSParserState { - private java.util.Stack<Node> nodes; - private java.util.Stack<Integer> marks; - - private int sp; // number of nodes on stack - private int mk; // current mark - private boolean node_created; - - JJTCSSParserState() { - nodes = new java.util.Stack<Node>(); - marks = new java.util.Stack<Integer>(); - sp = 0; - mk = 0; - } - - /* Determines whether the current node was actually closed and - pushed. This should only be called in the final user action of a - node scope. */ - boolean nodeCreated() { - return node_created; - } - - /* Call this to reinitialize the node stack. It is called -automatically by the parser's ReInit() method. */ - void reset() { - nodes.removeAllElements(); - marks.removeAllElements(); - sp = 0; - mk = 0; - } - - /* Returns the root node of the AST. It only makes sense to call -this after a successful parse. */ - Node rootNode() { - return nodes.elementAt(0); - } - - /* Pushes a node on to the stack. */ - void pushNode(Node n) { - nodes.push(n); - ++sp; - } - - /* Returns the node on the top of the stack, and remove it from the - stack. */ - Node popNode() { - if (--sp < mk) { - mk = marks.pop(); - } - return nodes.pop(); - } - - /* Returns the node currently on the top of the stack. */ - Node peekNode() { - return nodes.peek(); - } - - /* Returns the number of children on the stack in the current node - scope. */ - int nodeArity() { - return sp - mk; - } - - - void clearNodeScope(Node n) { - while (sp > mk) { - popNode(); - } - mk = marks.pop(); - } - - - void openNodeScope(Node n) { - marks.push(mk); - mk = sp; - n.jjtOpen(); - } - - - /* A definite node is constructed from a specified number of -children. That number of nodes are popped from the stack and -made the children of the definite node. Then the definite node -is pushed on to the stack. */ - void closeNodeScope(Node n, int num) { - mk = marks.pop(); - while (num-- > 0) { - Node c = popNode(); - c.jjtSetParent(n); - n.jjtAddChild(c, num); - } - n.jjtClose(); - pushNode(n); - node_created = true; - } - - - /* A conditional node is constructed if its condition is true. All -the nodes that have been pushed since the node was opened are -made children of the the conditional node, which is then pushed -on to the stack. If the condition is false the node is not -constructed and they are left on the stack. */ - void closeNodeScope(Node n, boolean condition) { - if (condition) { - int a = nodeArity(); - mk = marks.pop(); - while (a-- > 0) { - Node c = popNode(); - c.jjtSetParent(n); - n.jjtAddChild(c, a); - } - n.jjtClose(); - pushNode(n); - node_created = true; - } else { - mk = marks.pop(); - node_created = false; - } - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/JJTCSSParserState.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/JJTCSSParserState.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/JJTCSSParserState.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/JJTCSSParserState.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,143 @@ +/* Generated By:JJTree: Do not edit this line. .\JJTCSSParserState.java */ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ + +package jaxx.compiler.css.parser; + +class JJTCSSParserState { + private java.util.Stack<Node> nodes; + private java.util.Stack<Integer> marks; + + private int sp; // number of nodes on stack + private int mk; // current mark + private boolean node_created; + + JJTCSSParserState() { + nodes = new java.util.Stack<Node>(); + marks = new java.util.Stack<Integer>(); + sp = 0; + mk = 0; + } + + /* Determines whether the current node was actually closed and + pushed. This should only be called in the final user action of a + node scope. */ + boolean nodeCreated() { + return node_created; + } + + /* Call this to reinitialize the node stack. It is called +automatically by the parser's ReInit() method. */ + void reset() { + nodes.removeAllElements(); + marks.removeAllElements(); + sp = 0; + mk = 0; + } + + /* Returns the root node of the AST. It only makes sense to call +this after a successful parse. */ + Node rootNode() { + return nodes.elementAt(0); + } + + /* Pushes a node on to the stack. */ + void pushNode(Node n) { + nodes.push(n); + ++sp; + } + + /* Returns the node on the top of the stack, and remove it from the + stack. */ + Node popNode() { + if (--sp < mk) { + mk = marks.pop(); + } + return nodes.pop(); + } + + /* Returns the node currently on the top of the stack. */ + Node peekNode() { + return nodes.peek(); + } + + /* Returns the number of children on the stack in the current node + scope. */ + int nodeArity() { + return sp - mk; + } + + + void clearNodeScope(Node n) { + while (sp > mk) { + popNode(); + } + mk = marks.pop(); + } + + + void openNodeScope(Node n) { + marks.push(mk); + mk = sp; + n.jjtOpen(); + } + + + /* A definite node is constructed from a specified number of +children. That number of nodes are popped from the stack and +made the children of the definite node. Then the definite node +is pushed on to the stack. */ + void closeNodeScope(Node n, int num) { + mk = marks.pop(); + while (num-- > 0) { + Node c = popNode(); + c.jjtSetParent(n); + n.jjtAddChild(c, num); + } + n.jjtClose(); + pushNode(n); + node_created = true; + } + + + /* A conditional node is constructed if its condition is true. All +the nodes that have been pushed since the node was opened are +made children of the the conditional node, which is then pushed +on to the stack. If the condition is false the node is not +constructed and they are left on the stack. */ + void closeNodeScope(Node n, boolean condition) { + if (condition) { + int a = nodeArity(); + mk = marks.pop(); + while (a-- > 0) { + Node c = popNode(); + c.jjtSetParent(n); + n.jjtAddChild(c, a); + } + n.jjtClose(); + pushNode(n); + node_created = true; + } else { + mk = marks.pop(); + node_created = false; + } + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/Node.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/Node.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/Node.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,71 +0,0 @@ -/* Generated By:JJTree: Do not edit this line. Node.java */ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ - -package jaxx.compiler.css.parser; - -/* All AST nodes must implement this interface. It provides basic - machinery for constructing the parent and child relationships - between nodes. */ - -public interface Node { - - /** - * This method is called after the node has been made the current - * node. It indicates that child nodes can now be added to it. - */ - public void jjtOpen(); - - /** - * This method is called after all the child nodes have been - * added. - */ - public void jjtClose(); - - /** - * This pair of methods are used to inform the node of its - * parent. - * - * @param n node - */ - public void jjtSetParent(Node n); - - public Node jjtGetParent(); - - /** - * This method tells the node to add its argument to the node's - * list of children. - * - * @param n node - * @param i pos - */ - public void jjtAddChild(Node n, int i); - - /** - * @param i pos - * @return a child node. The children are numbered - * from zero, left to right. - */ - public Node jjtGetChild(int i); - - /** @return the number of children the node has. */ - public int jjtGetNumChildren(); -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/Node.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/Node.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/Node.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/Node.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,71 @@ +/* Generated By:JJTree: Do not edit this line. Node.java */ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ + +package jaxx.compiler.css.parser; + +/* All AST nodes must implement this interface. It provides basic + machinery for constructing the parent and child relationships + between nodes. */ + +public interface Node { + + /** + * This method is called after the node has been made the current + * node. It indicates that child nodes can now be added to it. + */ + public void jjtOpen(); + + /** + * This method is called after all the child nodes have been + * added. + */ + public void jjtClose(); + + /** + * This pair of methods are used to inform the node of its + * parent. + * + * @param n node + */ + public void jjtSetParent(Node n); + + public Node jjtGetParent(); + + /** + * This method tells the node to add its argument to the node's + * list of children. + * + * @param n node + * @param i pos + */ + public void jjtAddChild(Node n, int i); + + /** + * @param i pos + * @return a child node. The children are numbered + * from zero, left to right. + */ + public Node jjtGetChild(int i); + + /** @return the number of children the node has. */ + public int jjtGetNumChildren(); +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/ParseException.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/ParseException.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/ParseException.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,40 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 3.0 */ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.css.parser; - -public class ParseException extends jaxx.compiler.java.parser.ParseException { - private static final long serialVersionUID = 229575674880359031L; - - public ParseException() { - super(); - } - - - public ParseException(String message) { - super(message); - } - - - public ParseException(String message, int line, int column) { - super(message, line, column); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/ParseException.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/ParseException.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/ParseException.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/ParseException.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,40 @@ +/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 3.0 */ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.css.parser; + +public class ParseException extends jaxx.compiler.java.parser.ParseException { + private static final long serialVersionUID = 229575674880359031L; + + public ParseException() { + super(); + } + + + public ParseException(String message) { + super(message); + } + + + public ParseException(String message, int line, int column) { + super(message, line, column); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/SimpleCharStream.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/SimpleCharStream.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/SimpleCharStream.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,418 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 4.0 */ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.css.parser; - -/** - * An implementation of interface CharStream, where the stream is assumed to - * contain only ASCII characters (without unicode processing). - */ - -public class SimpleCharStream { - public static final boolean staticFlag = false; - int bufsize; - int available; - int tokenBegin; - public int bufpos = -1; - protected int bufline[]; - protected int bufcolumn[]; - - protected int column = 0; - protected int line = 1; - - protected boolean prevCharIsCR = false; - protected boolean prevCharIsLF = false; - - protected java.io.Reader inputStream; - - protected char[] buffer; - protected int maxNextCharInd = 0; - protected int inBuf = 0; - protected int tabSize = 8; - - protected void setTabSize(int i) { - tabSize = i; - } - - protected int getTabSize(int i) { - return tabSize; - } - - - protected void ExpandBuff(boolean wrapAround) { - char[] newbuffer = new char[bufsize + 2048]; - int newbufline[] = new int[bufsize + 2048]; - int newbufcolumn[] = new int[bufsize + 2048]; - - try { - if (wrapAround) { - System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); - System.arraycopy(buffer, 0, newbuffer, - bufsize - tokenBegin, bufpos); - buffer = newbuffer; - - System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); - System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); - bufline = newbufline; - - System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); - System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); - bufcolumn = newbufcolumn; - - maxNextCharInd = (bufpos += (bufsize - tokenBegin)); - } else { - System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); - buffer = newbuffer; - - System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); - bufline = newbufline; - - System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); - bufcolumn = newbufcolumn; - - maxNextCharInd = (bufpos -= tokenBegin); - } - } - catch (Throwable t) { - throw new Error(t.getMessage()); - } - - - bufsize += 2048; - available = bufsize; - tokenBegin = 0; - } - - protected void FillBuff() throws java.io.IOException { - if (maxNextCharInd == available) { - if (available == bufsize) { - if (tokenBegin > 2048) { - bufpos = maxNextCharInd = 0; - available = tokenBegin; - } else if (tokenBegin < 0) - bufpos = maxNextCharInd = 0; - else - ExpandBuff(false); - } else if (available > tokenBegin) - available = bufsize; - else if ((tokenBegin - available) < 2048) - ExpandBuff(true); - else - available = tokenBegin; - } - - int i; - try { - if ((i = inputStream.read(buffer, maxNextCharInd, - available - maxNextCharInd)) == -1) { - inputStream.close(); - throw new java.io.IOException(); - } else - maxNextCharInd += i; - } - catch (java.io.IOException e) { - --bufpos; - backup(0); - if (tokenBegin == -1) - tokenBegin = bufpos; - throw e; - } - } - - public char BeginToken() throws java.io.IOException { - tokenBegin = -1; - char c = readChar(); - tokenBegin = bufpos; - - return c; - } - - protected void UpdateLineColumn(char c) { - column++; - - if (prevCharIsLF) { - prevCharIsLF = false; - line += (column = 1); - } else if (prevCharIsCR) { - prevCharIsCR = false; - if (c == '\n') { - prevCharIsLF = true; - } else - line += (column = 1); - } - - switch (c) { - case '\r': - prevCharIsCR = true; - break; - case '\n': - prevCharIsLF = true; - break; - case '\t': - column--; - column += (tabSize - (column % tabSize)); - break; - default: - break; - } - - bufline[bufpos] = line; - bufcolumn[bufpos] = column; - } - - public char readChar() throws java.io.IOException { - if (inBuf > 0) { - --inBuf; - - if (++bufpos == bufsize) - bufpos = 0; - - return buffer[bufpos]; - } - - if (++bufpos >= maxNextCharInd) - FillBuff(); - - char c = buffer[bufpos]; - - UpdateLineColumn(c); - return (c); - } - - /** - * @return ??? - * @see #getEndColumn - * @deprecated - */ - - public int getColumn() { - return bufcolumn[bufpos]; - } - - /** - * @return ??? - * @see #getEndLine - * @deprecated - */ - - public int getLine() { - return bufline[bufpos]; - } - - public int getEndColumn() { - return bufcolumn[bufpos]; - } - - public int getEndLine() { - return bufline[bufpos]; - } - - public int getBeginColumn() { - return bufcolumn[tokenBegin]; - } - - public int getBeginLine() { - return bufline[tokenBegin]; - } - - public void backup(int amount) { - - inBuf += amount; - if ((bufpos -= amount) < 0) - bufpos += bufsize; - } - - public SimpleCharStream(java.io.Reader dstream, int startline, - int startcolumn, int buffersize) { - inputStream = dstream; - line = startline; - column = startcolumn - 1; - - available = bufsize = buffersize; - buffer = new char[buffersize]; - bufline = new int[buffersize]; - bufcolumn = new int[buffersize]; - } - - public SimpleCharStream(java.io.Reader dstream, int startline, - int startcolumn) { - this(dstream, startline, startcolumn, 4096); - } - - public SimpleCharStream(java.io.Reader dstream) { - this(dstream, 1, 1, 4096); - } - - public void ReInit(java.io.Reader dstream, int startline, - int startcolumn, int buffersize) { - inputStream = dstream; - line = startline; - column = startcolumn - 1; - - if (buffer == null || buffersize != buffer.length) { - available = bufsize = buffersize; - buffer = new char[buffersize]; - bufline = new int[buffersize]; - bufcolumn = new int[buffersize]; - } - prevCharIsLF = prevCharIsCR = false; - tokenBegin = inBuf = maxNextCharInd = 0; - bufpos = -1; - } - - public void ReInit(java.io.Reader dstream, int startline, - int startcolumn) { - ReInit(dstream, startline, startcolumn, 4096); - } - - public void ReInit(java.io.Reader dstream) { - ReInit(dstream, 1, 1, 4096); - } - - public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline, - int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException { - this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); - } - - public SimpleCharStream(java.io.InputStream dstream, int startline, - int startcolumn, int buffersize) { - this(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); - } - - public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline, - int startcolumn) throws java.io.UnsupportedEncodingException { - this(dstream, encoding, startline, startcolumn, 4096); - } - - public SimpleCharStream(java.io.InputStream dstream, int startline, - int startcolumn) { - this(dstream, startline, startcolumn, 4096); - } - - public SimpleCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException { - this(dstream, encoding, 1, 1, 4096); - } - - public SimpleCharStream(java.io.InputStream dstream) { - this(dstream, 1, 1, 4096); - } - - public void ReInit(java.io.InputStream dstream, String encoding, int startline, - int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException { - ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); - } - - public void ReInit(java.io.InputStream dstream, int startline, - int startcolumn, int buffersize) { - ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); - } - - public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException { - ReInit(dstream, encoding, 1, 1, 4096); - } - - public void ReInit(java.io.InputStream dstream) { - ReInit(dstream, 1, 1, 4096); - } - - public void ReInit(java.io.InputStream dstream, String encoding, int startline, - int startcolumn) throws java.io.UnsupportedEncodingException { - ReInit(dstream, encoding, startline, startcolumn, 4096); - } - - public void ReInit(java.io.InputStream dstream, int startline, - int startcolumn) { - ReInit(dstream, startline, startcolumn, 4096); - } - - public String GetImage() { - if (bufpos >= tokenBegin) - return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); - else - return new String(buffer, tokenBegin, bufsize - tokenBegin) + - new String(buffer, 0, bufpos + 1); - } - - public char[] GetSuffix(int len) { - char[] ret = new char[len]; - - if ((bufpos + 1) >= len) - System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); - else { - System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, - len - bufpos - 1); - System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); - } - - return ret; - } - - public void Done() { - buffer = null; - bufline = null; - bufcolumn = null; - } - - /** - * Method to adjust line and column numbers for the start of a token. - * - * @param newLine ? - * @param newCol ? - */ - public void adjustBeginLineColumn(int newLine, int newCol) { - int start = tokenBegin; - int len; - - if (bufpos >= tokenBegin) { - len = bufpos - tokenBegin + inBuf + 1; - } else { - len = bufsize - tokenBegin + bufpos + 1 + inBuf; - } - - int i = 0, j = 0, k; - int nextColDiff, columnDiff = 0; - - while (i < len && - bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) { - bufline[j] = newLine; - nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j]; - bufcolumn[j] = newCol + columnDiff; - columnDiff = nextColDiff; - i++; - } - - if (i < len) { - bufline[j] = newLine++; - bufcolumn[j] = newCol + columnDiff; - - while (i++ < len) { - if (bufline[j = start % bufsize] != bufline[++start % bufsize]) - bufline[j] = newLine++; - else - bufline[j] = newLine; - } - } - - line = bufline[j]; - column = bufcolumn[j]; - } - -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/SimpleCharStream.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/SimpleCharStream.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/SimpleCharStream.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/SimpleCharStream.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,418 @@ +/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 4.0 */ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.css.parser; + +/** + * An implementation of interface CharStream, where the stream is assumed to + * contain only ASCII characters (without unicode processing). + */ + +public class SimpleCharStream { + public static final boolean staticFlag = false; + int bufsize; + int available; + int tokenBegin; + public int bufpos = -1; + protected int bufline[]; + protected int bufcolumn[]; + + protected int column = 0; + protected int line = 1; + + protected boolean prevCharIsCR = false; + protected boolean prevCharIsLF = false; + + protected java.io.Reader inputStream; + + protected char[] buffer; + protected int maxNextCharInd = 0; + protected int inBuf = 0; + protected int tabSize = 8; + + protected void setTabSize(int i) { + tabSize = i; + } + + protected int getTabSize(int i) { + return tabSize; + } + + + protected void ExpandBuff(boolean wrapAround) { + char[] newbuffer = new char[bufsize + 2048]; + int newbufline[] = new int[bufsize + 2048]; + int newbufcolumn[] = new int[bufsize + 2048]; + + try { + if (wrapAround) { + System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); + System.arraycopy(buffer, 0, newbuffer, + bufsize - tokenBegin, bufpos); + buffer = newbuffer; + + System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); + System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); + bufline = newbufline; + + System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); + System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); + bufcolumn = newbufcolumn; + + maxNextCharInd = (bufpos += (bufsize - tokenBegin)); + } else { + System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); + buffer = newbuffer; + + System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); + bufline = newbufline; + + System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); + bufcolumn = newbufcolumn; + + maxNextCharInd = (bufpos -= tokenBegin); + } + } + catch (Throwable t) { + throw new Error(t.getMessage()); + } + + + bufsize += 2048; + available = bufsize; + tokenBegin = 0; + } + + protected void FillBuff() throws java.io.IOException { + if (maxNextCharInd == available) { + if (available == bufsize) { + if (tokenBegin > 2048) { + bufpos = maxNextCharInd = 0; + available = tokenBegin; + } else if (tokenBegin < 0) + bufpos = maxNextCharInd = 0; + else + ExpandBuff(false); + } else if (available > tokenBegin) + available = bufsize; + else if ((tokenBegin - available) < 2048) + ExpandBuff(true); + else + available = tokenBegin; + } + + int i; + try { + if ((i = inputStream.read(buffer, maxNextCharInd, + available - maxNextCharInd)) == -1) { + inputStream.close(); + throw new java.io.IOException(); + } else + maxNextCharInd += i; + } + catch (java.io.IOException e) { + --bufpos; + backup(0); + if (tokenBegin == -1) + tokenBegin = bufpos; + throw e; + } + } + + public char BeginToken() throws java.io.IOException { + tokenBegin = -1; + char c = readChar(); + tokenBegin = bufpos; + + return c; + } + + protected void UpdateLineColumn(char c) { + column++; + + if (prevCharIsLF) { + prevCharIsLF = false; + line += (column = 1); + } else if (prevCharIsCR) { + prevCharIsCR = false; + if (c == '\n') { + prevCharIsLF = true; + } else + line += (column = 1); + } + + switch (c) { + case '\r': + prevCharIsCR = true; + break; + case '\n': + prevCharIsLF = true; + break; + case '\t': + column--; + column += (tabSize - (column % tabSize)); + break; + default: + break; + } + + bufline[bufpos] = line; + bufcolumn[bufpos] = column; + } + + public char readChar() throws java.io.IOException { + if (inBuf > 0) { + --inBuf; + + if (++bufpos == bufsize) + bufpos = 0; + + return buffer[bufpos]; + } + + if (++bufpos >= maxNextCharInd) + FillBuff(); + + char c = buffer[bufpos]; + + UpdateLineColumn(c); + return (c); + } + + /** + * @return ??? + * @see #getEndColumn + * @deprecated + */ + + public int getColumn() { + return bufcolumn[bufpos]; + } + + /** + * @return ??? + * @see #getEndLine + * @deprecated + */ + + public int getLine() { + return bufline[bufpos]; + } + + public int getEndColumn() { + return bufcolumn[bufpos]; + } + + public int getEndLine() { + return bufline[bufpos]; + } + + public int getBeginColumn() { + return bufcolumn[tokenBegin]; + } + + public int getBeginLine() { + return bufline[tokenBegin]; + } + + public void backup(int amount) { + + inBuf += amount; + if ((bufpos -= amount) < 0) + bufpos += bufsize; + } + + public SimpleCharStream(java.io.Reader dstream, int startline, + int startcolumn, int buffersize) { + inputStream = dstream; + line = startline; + column = startcolumn - 1; + + available = bufsize = buffersize; + buffer = new char[buffersize]; + bufline = new int[buffersize]; + bufcolumn = new int[buffersize]; + } + + public SimpleCharStream(java.io.Reader dstream, int startline, + int startcolumn) { + this(dstream, startline, startcolumn, 4096); + } + + public SimpleCharStream(java.io.Reader dstream) { + this(dstream, 1, 1, 4096); + } + + public void ReInit(java.io.Reader dstream, int startline, + int startcolumn, int buffersize) { + inputStream = dstream; + line = startline; + column = startcolumn - 1; + + if (buffer == null || buffersize != buffer.length) { + available = bufsize = buffersize; + buffer = new char[buffersize]; + bufline = new int[buffersize]; + bufcolumn = new int[buffersize]; + } + prevCharIsLF = prevCharIsCR = false; + tokenBegin = inBuf = maxNextCharInd = 0; + bufpos = -1; + } + + public void ReInit(java.io.Reader dstream, int startline, + int startcolumn) { + ReInit(dstream, startline, startcolumn, 4096); + } + + public void ReInit(java.io.Reader dstream) { + ReInit(dstream, 1, 1, 4096); + } + + public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline, + int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException { + this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); + } + + public SimpleCharStream(java.io.InputStream dstream, int startline, + int startcolumn, int buffersize) { + this(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); + } + + public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline, + int startcolumn) throws java.io.UnsupportedEncodingException { + this(dstream, encoding, startline, startcolumn, 4096); + } + + public SimpleCharStream(java.io.InputStream dstream, int startline, + int startcolumn) { + this(dstream, startline, startcolumn, 4096); + } + + public SimpleCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException { + this(dstream, encoding, 1, 1, 4096); + } + + public SimpleCharStream(java.io.InputStream dstream) { + this(dstream, 1, 1, 4096); + } + + public void ReInit(java.io.InputStream dstream, String encoding, int startline, + int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException { + ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); + } + + public void ReInit(java.io.InputStream dstream, int startline, + int startcolumn, int buffersize) { + ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); + } + + public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException { + ReInit(dstream, encoding, 1, 1, 4096); + } + + public void ReInit(java.io.InputStream dstream) { + ReInit(dstream, 1, 1, 4096); + } + + public void ReInit(java.io.InputStream dstream, String encoding, int startline, + int startcolumn) throws java.io.UnsupportedEncodingException { + ReInit(dstream, encoding, startline, startcolumn, 4096); + } + + public void ReInit(java.io.InputStream dstream, int startline, + int startcolumn) { + ReInit(dstream, startline, startcolumn, 4096); + } + + public String GetImage() { + if (bufpos >= tokenBegin) + return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); + else + return new String(buffer, tokenBegin, bufsize - tokenBegin) + + new String(buffer, 0, bufpos + 1); + } + + public char[] GetSuffix(int len) { + char[] ret = new char[len]; + + if ((bufpos + 1) >= len) + System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); + else { + System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, + len - bufpos - 1); + System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); + } + + return ret; + } + + public void Done() { + buffer = null; + bufline = null; + bufcolumn = null; + } + + /** + * Method to adjust line and column numbers for the start of a token. + * + * @param newLine ? + * @param newCol ? + */ + public void adjustBeginLineColumn(int newLine, int newCol) { + int start = tokenBegin; + int len; + + if (bufpos >= tokenBegin) { + len = bufpos - tokenBegin + inBuf + 1; + } else { + len = bufsize - tokenBegin + bufpos + 1 + inBuf; + } + + int i = 0, j = 0, k; + int nextColDiff, columnDiff = 0; + + while (i < len && + bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) { + bufline[j] = newLine; + nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j]; + bufcolumn[j] = newCol + columnDiff; + columnDiff = nextColDiff; + i++; + } + + if (i < len) { + bufline[j] = newLine++; + bufcolumn[j] = newCol + columnDiff; + + while (i++ < len) { + if (bufline[j = start % bufsize] != bufline[++start % bufsize]) + bufline[j] = newLine++; + else + bufline[j] = newLine; + } + } + + line = bufline[j]; + column = bufcolumn[j]; + } + +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/SimpleNode.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/SimpleNode.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/SimpleNode.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,142 +0,0 @@ -/* Generated By:JJTree: Do not edit this line. SimpleNode.java */ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ - -package jaxx.compiler.css.parser; - -public class SimpleNode implements Node { - protected Node parent; - protected Node[] children; - protected int id; - protected CSSParser parser; - public Token firstToken; - public Token lastToken; - - - public SimpleNode(int i) { - id = i; - } - - public SimpleNode(CSSParser p, int i) { - this(i); - parser = p; - } - - - public int getId() { - return id; - } - - public void jjtOpen() { - } - - public void jjtClose() { - } - - public void jjtSetParent(Node n) { - parent = n; - } - - public Node jjtGetParent() { - return parent; - } - - public SimpleNode getParent() { - return (SimpleNode) parent; - } - - public void jjtAddChild(Node n, int i) { - if (children == null) { - children = new Node[i + 1]; - } else if (i >= children.length) { - Node c[] = new Node[i + 1]; - System.arraycopy(children, 0, c, 0, children.length); - children = c; - } - children[i] = n; - } - - public Node jjtGetChild(int i) { - return children[i]; - } - - public SimpleNode getChild(int i) { - return (SimpleNode) children[i]; - } - - public int jjtGetNumChildren() { - return (children == null) ? 0 : children.length; - } - - /* You can override these two methods in subclasses of SimpleNode to -customize the way the node appears when the tree is dumped. If -your output uses more than one line you should override -toString(String), otherwise overriding toString() is probably all -you need to do. */ - - @Override - public String toString() { - return getClass().getName() + "[" + getText() + "]"; - } - - public String toString(String prefix) { - return prefix + toString(); - } - - /* Override this method if you want to customize how the node dumps - out its children. */ - - public void dump(String prefix) { - System.out.println(toString(prefix)); - if (children != null) { - for (Node aChildren : children) { - SimpleNode n = (SimpleNode) aChildren; - if (n != null) { - n.dump(prefix + " "); - } - } - } - } - - private void appendSpecialTokens(StringBuffer s, Token st) { - if (st != null) { - appendSpecialTokens(s, st.specialToken); - s.append(st.image); - } - } - - - /** @return the text of the tokens comprising this node. */ - public String getText() { - StringBuffer text = new StringBuffer(); - Token t = firstToken; - while (t != null) { - appendSpecialTokens(text, t.specialToken); - text.append(t.image); - if (t == lastToken) - break; - t = t.next; - } - - return text.toString(); - } -} - Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/SimpleNode.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/SimpleNode.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/SimpleNode.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/SimpleNode.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,142 @@ +/* Generated By:JJTree: Do not edit this line. SimpleNode.java */ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ + +package jaxx.compiler.css.parser; + +public class SimpleNode implements Node { + protected Node parent; + protected Node[] children; + protected int id; + protected CSSParser parser; + public Token firstToken; + public Token lastToken; + + + public SimpleNode(int i) { + id = i; + } + + public SimpleNode(CSSParser p, int i) { + this(i); + parser = p; + } + + + public int getId() { + return id; + } + + public void jjtOpen() { + } + + public void jjtClose() { + } + + public void jjtSetParent(Node n) { + parent = n; + } + + public Node jjtGetParent() { + return parent; + } + + public SimpleNode getParent() { + return (SimpleNode) parent; + } + + public void jjtAddChild(Node n, int i) { + if (children == null) { + children = new Node[i + 1]; + } else if (i >= children.length) { + Node c[] = new Node[i + 1]; + System.arraycopy(children, 0, c, 0, children.length); + children = c; + } + children[i] = n; + } + + public Node jjtGetChild(int i) { + return children[i]; + } + + public SimpleNode getChild(int i) { + return (SimpleNode) children[i]; + } + + public int jjtGetNumChildren() { + return (children == null) ? 0 : children.length; + } + + /* You can override these two methods in subclasses of SimpleNode to +customize the way the node appears when the tree is dumped. If +your output uses more than one line you should override +toString(String), otherwise overriding toString() is probably all +you need to do. */ + + @Override + public String toString() { + return getClass().getName() + "[" + getText() + "]"; + } + + public String toString(String prefix) { + return prefix + toString(); + } + + /* Override this method if you want to customize how the node dumps + out its children. */ + + public void dump(String prefix) { + System.out.println(toString(prefix)); + if (children != null) { + for (Node aChildren : children) { + SimpleNode n = (SimpleNode) aChildren; + if (n != null) { + n.dump(prefix + " "); + } + } + } + } + + private void appendSpecialTokens(StringBuffer s, Token st) { + if (st != null) { + appendSpecialTokens(s, st.specialToken); + s.append(st.image); + } + } + + + /** @return the text of the tokens comprising this node. */ + public String getText() { + StringBuffer text = new StringBuffer(); + Token t = firstToken; + while (t != null) { + appendSpecialTokens(text, t.specialToken); + text.append(t.image); + if (t == lastToken) + break; + t = t.next; + } + + return text.toString(); + } +} + Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/Token.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/Token.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/Token.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,96 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.css.parser; - -/** Describes the input token stream. */ - -public class Token { - - /** - * An integer that describes the kind of this token. This numbering - * system is determined by JavaCCParser, and a table of these numbers is - * stored in the file ...Constants.java. - */ - public int kind; - - /** - * beginLine and beginColumn describe the position of the first character - * of this token; endLine and endColumn describe the position of the - * last character of this token. - */ - public int beginLine, beginColumn, endLine, endColumn; - - /** The string image of the token. */ - public String image; - - /** - * A reference to the next regular (non-special) token from the input - * stream. If this is the last token from the input stream, or if the - * token manager has not read tokens beyond this one, this field is - * set to null. This is true only if this token is also a regular - * token. Otherwise, see below for a description of the contents of - * this field. - */ - public Token next; - - /** - * This field is used to access special tokens that occur prior to this - * token, but after the immediately preceding regular (non-special) token. - * If there are no such special tokens, this field is set to null. - * When there are more than one such special token, this field refers - * to the last of these special tokens, which in turn refers to the next - * previous special token through its specialToken field, and so on - * until the first special token (whose specialToken field is null). - * The next fields of special tokens refer to other special tokens that - * immediately follow it (without an intervening regular token). If there - * is no such token, this field is null. - */ - public Token specialToken; - - /** Returns the image. */ - public String toString() { - return image; - } - - /** - * Returns a new Token object, by default. However, if you want, you - * can create and return subclass objects based on the value of ofKind. - * Simply add the cases to the switch for all those special cases. - * For example, if you have a subclass of Token called IDToken that - * you want to create if ofKind is ID, simlpy add something like : - * <p/> - * case MyParserConstants.ID : return new IDToken(); - * <p/> - * to the following switch statement. Then you can cast matchedToken - * variable to the appropriate type and use it in your lexical actions. - * - * @param ofKind kind of token - * @return the new token - */ - public static Token newToken(int ofKind) { - switch (ofKind) { - default: - return new Token(); - } - } - -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/Token.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/Token.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/Token.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/Token.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,96 @@ +/* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.css.parser; + +/** Describes the input token stream. */ + +public class Token { + + /** + * An integer that describes the kind of this token. This numbering + * system is determined by JavaCCParser, and a table of these numbers is + * stored in the file ...Constants.java. + */ + public int kind; + + /** + * beginLine and beginColumn describe the position of the first character + * of this token; endLine and endColumn describe the position of the + * last character of this token. + */ + public int beginLine, beginColumn, endLine, endColumn; + + /** The string image of the token. */ + public String image; + + /** + * A reference to the next regular (non-special) token from the input + * stream. If this is the last token from the input stream, or if the + * token manager has not read tokens beyond this one, this field is + * set to null. This is true only if this token is also a regular + * token. Otherwise, see below for a description of the contents of + * this field. + */ + public Token next; + + /** + * This field is used to access special tokens that occur prior to this + * token, but after the immediately preceding regular (non-special) token. + * If there are no such special tokens, this field is set to null. + * When there are more than one such special token, this field refers + * to the last of these special tokens, which in turn refers to the next + * previous special token through its specialToken field, and so on + * until the first special token (whose specialToken field is null). + * The next fields of special tokens refer to other special tokens that + * immediately follow it (without an intervening regular token). If there + * is no such token, this field is null. + */ + public Token specialToken; + + /** Returns the image. */ + public String toString() { + return image; + } + + /** + * Returns a new Token object, by default. However, if you want, you + * can create and return subclass objects based on the value of ofKind. + * Simply add the cases to the switch for all those special cases. + * For example, if you have a subclass of Token called IDToken that + * you want to create if ofKind is ID, simlpy add something like : + * <p/> + * case MyParserConstants.ID : return new IDToken(); + * <p/> + * to the following switch statement. Then you can cast matchedToken + * variable to the appropriate type and use it in your lexical actions. + * + * @param ofKind kind of token + * @return the new token + */ + public static Token newToken(int ofKind) { + switch (ofKind) { + default: + return new Token(); + } + } + +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/TokenMgrError.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/TokenMgrError.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/TokenMgrError.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,146 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 */ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.css.parser; - -public class TokenMgrError extends Error { - /* - * Ordinals for various reasons why an Error of this type can be thrown. - */ - - /** Lexical error occured. */ - static final int LEXICAL_ERROR = 0; - - /** An attempt wass made to create a second instance of a static token manager. */ - static final int STATIC_LEXER_ERROR = 1; - - /** Tried to change to an invalid lexical state. */ - static final int INVALID_LEXICAL_STATE = 2; - - /** Detected (and bailed out of) an infinite loop in the token manager. */ - static final int LOOP_DETECTED = 3; - - /** - * Indicates the reason why the exception is thrown. It will have - * one of the above 4 values. - */ - int errorCode; - private static final long serialVersionUID = -4308847190164230336L; - - /** - * Replaces unprintable characters by their espaced (or unicode escaped) - * equivalents in the given string - * - * @param str text to espace - * @return the espaced text - */ - protected static String addEscapes(String str) { - StringBuffer retval = new StringBuffer(); - char ch; - for (int i = 0; i < str.length(); i++) { - switch (str.charAt(i)) { - case 0: - continue; - case '\b': - retval.append("\\b"); - continue; - case '\t': - retval.append("\\t"); - continue; - case '\n': - retval.append("\\n"); - continue; - case '\f': - retval.append("\\f"); - continue; - case '\r': - retval.append("\\r"); - continue; - case '\"': - retval.append("\\\""); - continue; - case '\'': - retval.append("\\\'"); - continue; - case '\\': - retval.append("\\\\"); - continue; - default: - if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { - String s = "0000" + Integer.toString(ch, 16); - retval.append("\\u").append(s.substring(s.length() - 4, s.length())); - } else { - retval.append(ch); - } - } - } - return retval.toString(); - } - - /** - * @param EOFSeen : indicates if EOF caused the lexicl error - * @param lexState : lexical state in which this error occured - * @param errorLine : line number when the error occured - * @param errorColumn : column number when the error occured - * @param errorAfter : prefix that was seen before this error occured - * @param curChar : the offending character - * Note: You can customize the lexical error message by modifying this method. - * @return a detailed message for the Error when it is thrown by the - * token manager to indicate a lexical error. - */ - protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { - return ("Lexical error at line " + - errorLine + ", column " + - errorColumn + ". Encountered: " + - (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int) curChar + "), ") + - "after : \"" + addEscapes(errorAfter) + "\""); - } - - /** - * You can also modify the body of this method to customize your error messages. - * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not - * of end-users concern, so you can return something like : - * <p/> - * "Internal Error : Please file a bug report .... " - * <p/> - * from this method for such cases in the release version of your parser. - */ - @Override - public String getMessage() { - return super.getMessage(); - } - - /* - * Constructors of various flavors follow. - */ - - public TokenMgrError() { - } - - public TokenMgrError(String message, int reason) { - super(message); - errorCode = reason; - } - - public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { - this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/TokenMgrError.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/TokenMgrError.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/TokenMgrError.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/parser/TokenMgrError.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,146 @@ +/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 */ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.css.parser; + +public class TokenMgrError extends Error { + /* + * Ordinals for various reasons why an Error of this type can be thrown. + */ + + /** Lexical error occured. */ + static final int LEXICAL_ERROR = 0; + + /** An attempt wass made to create a second instance of a static token manager. */ + static final int STATIC_LEXER_ERROR = 1; + + /** Tried to change to an invalid lexical state. */ + static final int INVALID_LEXICAL_STATE = 2; + + /** Detected (and bailed out of) an infinite loop in the token manager. */ + static final int LOOP_DETECTED = 3; + + /** + * Indicates the reason why the exception is thrown. It will have + * one of the above 4 values. + */ + int errorCode; + private static final long serialVersionUID = -4308847190164230336L; + + /** + * Replaces unprintable characters by their espaced (or unicode escaped) + * equivalents in the given string + * + * @param str text to espace + * @return the espaced text + */ + protected static String addEscapes(String str) { + StringBuffer retval = new StringBuffer(); + char ch; + for (int i = 0; i < str.length(); i++) { + switch (str.charAt(i)) { + case 0: + continue; + case '\b': + retval.append("\\b"); + continue; + case '\t': + retval.append("\\t"); + continue; + case '\n': + retval.append("\\n"); + continue; + case '\f': + retval.append("\\f"); + continue; + case '\r': + retval.append("\\r"); + continue; + case '\"': + retval.append("\\\""); + continue; + case '\'': + retval.append("\\\'"); + continue; + case '\\': + retval.append("\\\\"); + continue; + default: + if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { + String s = "0000" + Integer.toString(ch, 16); + retval.append("\\u").append(s.substring(s.length() - 4, s.length())); + } else { + retval.append(ch); + } + } + } + return retval.toString(); + } + + /** + * @param EOFSeen : indicates if EOF caused the lexicl error + * @param lexState : lexical state in which this error occured + * @param errorLine : line number when the error occured + * @param errorColumn : column number when the error occured + * @param errorAfter : prefix that was seen before this error occured + * @param curChar : the offending character + * Note: You can customize the lexical error message by modifying this method. + * @return a detailed message for the Error when it is thrown by the + * token manager to indicate a lexical error. + */ + protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { + return ("Lexical error at line " + + errorLine + ", column " + + errorColumn + ". Encountered: " + + (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int) curChar + "), ") + + "after : \"" + addEscapes(errorAfter) + "\""); + } + + /** + * You can also modify the body of this method to customize your error messages. + * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not + * of end-users concern, so you can return something like : + * <p/> + * "Internal Error : Please file a bug report .... " + * <p/> + * from this method for such cases in the release version of your parser. + */ + @Override + public String getMessage() { + return super.getMessage(); + } + + /* + * Constructors of various flavors follow. + */ + + public TokenMgrError() { + } + + public TokenMgrError(String message, int reason) { + super(message); + errorCode = reason; + } + + public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { + this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/decorators/BoxedCompiledObjectDecorator.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/BoxedCompiledObjectDecorator.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/decorators/BoxedCompiledObjectDecorator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,58 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.decorators; - -import jaxx.compiler.CompiledObject; -import jaxx.compiler.CompiledObject.ChildRef; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.java.JavaFile; -import jaxx.runtime.SwingUtil; - -/** - * A decorator to surround a compiled object (should be a component at least) - * with a JXLayer. - * - * @author tony - * @since 1.2 - */ -public class BoxedCompiledObjectDecorator extends DefaultCompiledObjectDecorator { - - @Override - public String getName() { - return "boxed"; - } - - @Override - public void finalizeCompiler(JAXXCompiler compiler, CompiledObject root, CompiledObject object, JavaFile javaFile, String packageName, String className, String fullClassName) { - CompiledObject parent = object.getParent(); - if (parent == null) { - parent = root; - } - for (ChildRef child : parent.getChilds()) { - if (child.getChild() == object) { - String javaCode = child.getChildJavaCode(); - child.setChildJavaCode(SwingUtil.class.getSimpleName() + ".boxComponentWithJxLayer(" + javaCode + ")"); - break; - } - } - super.finalizeCompiler(compiler, root, object, javaFile, packageName, className, fullClassName); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/decorators/BoxedCompiledObjectDecorator.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/BoxedCompiledObjectDecorator.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/decorators/BoxedCompiledObjectDecorator.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/decorators/BoxedCompiledObjectDecorator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,58 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.decorators; + +import jaxx.compiler.CompiledObject; +import jaxx.compiler.CompiledObject.ChildRef; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.java.JavaFile; +import jaxx.runtime.SwingUtil; + +/** + * A decorator to surround a compiled object (should be a component at least) + * with a JXLayer. + * + * @author tony + * @since 1.2 + */ +public class BoxedCompiledObjectDecorator extends DefaultCompiledObjectDecorator { + + @Override + public String getName() { + return "boxed"; + } + + @Override + public void finalizeCompiler(JAXXCompiler compiler, CompiledObject root, CompiledObject object, JavaFile javaFile, String packageName, String className, String fullClassName) { + CompiledObject parent = object.getParent(); + if (parent == null) { + parent = root; + } + for (ChildRef child : parent.getChilds()) { + if (child.getChild() == object) { + String javaCode = child.getChildJavaCode(); + child.setChildJavaCode(SwingUtil.class.getSimpleName() + ".boxComponentWithJxLayer(" + javaCode + ")"); + break; + } + } + super.finalizeCompiler(compiler, root, object, javaFile, packageName, className, fullClassName); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/decorators/DefaultCompiledObjectDecorator.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/DefaultCompiledObjectDecorator.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/decorators/DefaultCompiledObjectDecorator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,180 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.decorators; - -import jaxx.compiler.CompiledObject; -import jaxx.compiler.CompiledObjectDecorator; -import jaxx.compiler.CompilerException; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.java.JavaFile; -import jaxx.compiler.java.JavaFileGenerator; -import jaxx.compiler.script.ScriptInitializer; -import jaxx.compiler.types.TypeManager; - -import java.lang.reflect.Modifier; -import java.util.Map.Entry; - -/** - * The default compiledObjectDecorator. - * - * @author tony - * @since 1.2 - */ -public class DefaultCompiledObjectDecorator implements CompiledObjectDecorator { - - @Override - public String getName() { - return "default"; - } - - @Override - public void finalizeCompiler(JAXXCompiler compiler, CompiledObject root, CompiledObject object, JavaFile javaFile, String packageName, String className, String fullClassName) { - - if (!object.isOverride() && !(object instanceof ScriptInitializer)) { - String id = object.getId(); - int access = id.startsWith("$") ? Modifier.PRIVATE : Modifier.PROTECTED; - if (object == root) { - javaFile.addSimpleField(JavaFileGenerator.newField(access, className, id, false, "this")); -// javaFile.addField(new JavaField(access, fullClassName, id, false, "this")); - } else { - //TC -20081017 can have generic on compiled Object - javaFile.addField(JavaFileGenerator.newField(access, JAXXCompiler.getCanonicalName(object), id, object.isOverride()), object.isJavaBean()); - } - } - - if (!compiler.inlineCreation(object) && object != root) { - javaFile.addMethod(JavaFileGenerator.newMethod(Modifier.PROTECTED, "void", object.getCreationMethodName(), getCreationCode(compiler, object), object.isOverride())); - } - } - - @Override - public String getCreationCode(JAXXCompiler compiler, CompiledObject object) throws CompilerException { - if (object instanceof ScriptInitializer) { - return object.getInitializationCode(compiler); - } - String eol = JAXXCompiler.getLineSeparator(); - StringBuffer result = new StringBuffer(); - if (compiler.getRootObject() == object || compiler.inlineCreation(object)) { - result.append("// inline creation of ").append(object.getId()); - } - if (object.isOverride() && object.getOverrideType() == object.getObjectClass()) { - //TC-20090309 on utilise le super code quand l'objet est de meme type - result.append("super.").append(object.getCreationMethodName()).append("();"); - } else { - String init = object.getId() + " = "; - if (object.isJavaBean() && object.getJavaBeanInitCode() != null) { - init += object.getJavaBeanInitCode(); - } else if (object.getInitializer() != null) { - init += object.getInitializer(); - } else { - //TC - 20081017 compiledObject can have generics - String canonicalName = JAXXCompiler.getCanonicalName(object); - init += "new " + canonicalName + "("; - String constructorParams = object.getConstructorParams(); - if (constructorParams != null) { - init += constructorParams; - } - init += ")"; - } - result.append(eol); - result.append("$objectMap.put(").append(TypeManager.getJavaCode(object.getId())).append(", ").append(init).append(");"); - } - result.append(eol); - String initCode = object.getInitializationCode(compiler); - if (initCode != null && initCode.length() > 0) { - result.append(initCode); - } - //TC-20091025 generate client properties at creation time (not at setup time) - // in some case can save to create a setup method (when there is only client properties - // to store) - addClientProperties(object, result, eol); - return result.toString(); - } - - @Override - public String createCompleteSetupMethod(JAXXCompiler compiler, CompiledObject object, JavaFile javaFile) { -// public String createCompleteSetupMethod(JAXXCompiler compiler, CompiledObject object, JavaFile javaFile, StringBuffer initDataBindings) { - StringBuffer code = new StringBuffer(); - String eol = JAXXCompiler.getLineSeparator(); - //TC-20091025 generate client properties at creation time (not at setup time) - // in some case can save to create a setup method (when there is only client properties - // to store) -// addClientProperties(object); - //TC-20091025 only generate the code if not empty - if (object.getId().startsWith("$")) { - String additionCode = object.getAdditionCode(); - if (!additionCode.isEmpty()) { - code.append("// inline complete setup of ").append(object.getId()).append(eol); - code.append(additionCode); - } - } else { - String additionCode = object.getAdditionCode(); - if (additionCode.length() > 0) { - code.append(object.getAdditionMethodName()).append("();").append(eol); - additionCode = "if (!allComponentsCreated) {" + eol + " return;" + eol + "}" + eol + additionCode; - javaFile.addMethod(JavaFileGenerator.newMethod(Modifier.PROTECTED, "void", object.getAdditionMethodName(), additionCode, false)); - } - } - String result = code.toString(); - return result; - } - - @Override - public boolean createInitializer(JAXXCompiler compiler, CompiledObject root, CompiledObject object, StringBuffer code, boolean lastWasMethodCall) { - String eol = JAXXCompiler.getLineSeparator(); - if (object == root) { - String rootCode = root.getInitializationCode(compiler); - if (rootCode != null && rootCode.length() > 0) { - code.append("// inline creation of ").append(object.getId()).append(eol); - code.append(rootCode); - //TC-20091025 generate client properties at creation time (not at setup time) - // in some case can save to create a setup method (when there is only client properties - // to store) - addClientProperties(object, code, eol); - code.append(eol); - } - } else { - if (!object.isOverride()) { - if (compiler.inlineCreation(object)) { - if (lastWasMethodCall) { - lastWasMethodCall = false; - } - code.append(getCreationCode(compiler, object)); - } else { - code.append(object.getCreationMethodName()).append("();"); - code.append(eol); - lastWasMethodCall = true; - } - } - } - return lastWasMethodCall; - } - - protected void addClientProperties(CompiledObject object, StringBuffer code, String eol) { - //TC-20090327 generate client properties - if (object.hasClientProperties()) { - // generate putClientProperty invocations - for (Entry<String, String> entry : object.getClientProperties().entrySet()) { - code.append(object.getJavaCode()).append(".putClientProperty(\"").append(entry.getKey()).append("\", ").append(entry.getValue()).append(");").append(eol); - } - } - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/decorators/DefaultCompiledObjectDecorator.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/DefaultCompiledObjectDecorator.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/decorators/DefaultCompiledObjectDecorator.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/decorators/DefaultCompiledObjectDecorator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,180 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.decorators; + +import jaxx.compiler.CompiledObject; +import jaxx.compiler.CompiledObjectDecorator; +import jaxx.compiler.CompilerException; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.java.JavaFile; +import jaxx.compiler.java.JavaFileGenerator; +import jaxx.compiler.script.ScriptInitializer; +import jaxx.compiler.types.TypeManager; + +import java.lang.reflect.Modifier; +import java.util.Map.Entry; + +/** + * The default compiledObjectDecorator. + * + * @author tony + * @since 1.2 + */ +public class DefaultCompiledObjectDecorator implements CompiledObjectDecorator { + + @Override + public String getName() { + return "default"; + } + + @Override + public void finalizeCompiler(JAXXCompiler compiler, CompiledObject root, CompiledObject object, JavaFile javaFile, String packageName, String className, String fullClassName) { + + if (!object.isOverride() && !(object instanceof ScriptInitializer)) { + String id = object.getId(); + int access = id.startsWith("$") ? Modifier.PRIVATE : Modifier.PROTECTED; + if (object == root) { + javaFile.addSimpleField(JavaFileGenerator.newField(access, className, id, false, "this")); +// javaFile.addField(new JavaField(access, fullClassName, id, false, "this")); + } else { + //TC -20081017 can have generic on compiled Object + javaFile.addField(JavaFileGenerator.newField(access, JAXXCompiler.getCanonicalName(object), id, object.isOverride()), object.isJavaBean()); + } + } + + if (!compiler.inlineCreation(object) && object != root) { + javaFile.addMethod(JavaFileGenerator.newMethod(Modifier.PROTECTED, "void", object.getCreationMethodName(), getCreationCode(compiler, object), object.isOverride())); + } + } + + @Override + public String getCreationCode(JAXXCompiler compiler, CompiledObject object) throws CompilerException { + if (object instanceof ScriptInitializer) { + return object.getInitializationCode(compiler); + } + String eol = JAXXCompiler.getLineSeparator(); + StringBuffer result = new StringBuffer(); + if (compiler.getRootObject() == object || compiler.inlineCreation(object)) { + result.append("// inline creation of ").append(object.getId()); + } + if (object.isOverride() && object.getOverrideType() == object.getObjectClass()) { + //TC-20090309 on utilise le super code quand l'objet est de meme type + result.append("super.").append(object.getCreationMethodName()).append("();"); + } else { + String init = object.getId() + " = "; + if (object.isJavaBean() && object.getJavaBeanInitCode() != null) { + init += object.getJavaBeanInitCode(); + } else if (object.getInitializer() != null) { + init += object.getInitializer(); + } else { + //TC - 20081017 compiledObject can have generics + String canonicalName = JAXXCompiler.getCanonicalName(object); + init += "new " + canonicalName + "("; + String constructorParams = object.getConstructorParams(); + if (constructorParams != null) { + init += constructorParams; + } + init += ")"; + } + result.append(eol); + result.append("$objectMap.put(").append(TypeManager.getJavaCode(object.getId())).append(", ").append(init).append(");"); + } + result.append(eol); + String initCode = object.getInitializationCode(compiler); + if (initCode != null && initCode.length() > 0) { + result.append(initCode); + } + //TC-20091025 generate client properties at creation time (not at setup time) + // in some case can save to create a setup method (when there is only client properties + // to store) + addClientProperties(object, result, eol); + return result.toString(); + } + + @Override + public String createCompleteSetupMethod(JAXXCompiler compiler, CompiledObject object, JavaFile javaFile) { +// public String createCompleteSetupMethod(JAXXCompiler compiler, CompiledObject object, JavaFile javaFile, StringBuffer initDataBindings) { + StringBuffer code = new StringBuffer(); + String eol = JAXXCompiler.getLineSeparator(); + //TC-20091025 generate client properties at creation time (not at setup time) + // in some case can save to create a setup method (when there is only client properties + // to store) +// addClientProperties(object); + //TC-20091025 only generate the code if not empty + if (object.getId().startsWith("$")) { + String additionCode = object.getAdditionCode(); + if (!additionCode.isEmpty()) { + code.append("// inline complete setup of ").append(object.getId()).append(eol); + code.append(additionCode); + } + } else { + String additionCode = object.getAdditionCode(); + if (additionCode.length() > 0) { + code.append(object.getAdditionMethodName()).append("();").append(eol); + additionCode = "if (!allComponentsCreated) {" + eol + " return;" + eol + "}" + eol + additionCode; + javaFile.addMethod(JavaFileGenerator.newMethod(Modifier.PROTECTED, "void", object.getAdditionMethodName(), additionCode, false)); + } + } + String result = code.toString(); + return result; + } + + @Override + public boolean createInitializer(JAXXCompiler compiler, CompiledObject root, CompiledObject object, StringBuffer code, boolean lastWasMethodCall) { + String eol = JAXXCompiler.getLineSeparator(); + if (object == root) { + String rootCode = root.getInitializationCode(compiler); + if (rootCode != null && rootCode.length() > 0) { + code.append("// inline creation of ").append(object.getId()).append(eol); + code.append(rootCode); + //TC-20091025 generate client properties at creation time (not at setup time) + // in some case can save to create a setup method (when there is only client properties + // to store) + addClientProperties(object, code, eol); + code.append(eol); + } + } else { + if (!object.isOverride()) { + if (compiler.inlineCreation(object)) { + if (lastWasMethodCall) { + lastWasMethodCall = false; + } + code.append(getCreationCode(compiler, object)); + } else { + code.append(object.getCreationMethodName()).append("();"); + code.append(eol); + lastWasMethodCall = true; + } + } + } + return lastWasMethodCall; + } + + protected void addClientProperties(CompiledObject object, StringBuffer code, String eol) { + //TC-20090327 generate client properties + if (object.hasClientProperties()) { + // generate putClientProperty invocations + for (Entry<String, String> entry : object.getClientProperties().entrySet()) { + code.append(object.getJavaCode()).append(".putClientProperty(\"").append(entry.getKey()).append("\", ").append(entry.getValue()).append(");").append(eol); + } + } + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,126 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.decorators; - -import jaxx.compiler.CompiledObject; -import jaxx.compiler.CompilerConfiguration; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.java.JavaArgument; -import jaxx.compiler.java.JavaFile; -import jaxx.compiler.java.JavaFileGenerator; - -import java.lang.reflect.Modifier; -import java.util.Iterator; -import java.util.Set; - -/** - * A decorator to place on a root compiled object to process javaHelp on the file. - * - * @author tony - * @since 1.2 - */ -public class HelpRootCompiledObjectDecorator extends DefaultCompiledObjectDecorator { - - /** - * the list of discovered helpId - */ - protected static Set<String> helpIds = new java.util.HashSet<String>(); - - @Override - public String getName() { - return "help"; - } - - protected String getBrokerFQN(JAXXCompiler compiler) { - String helpBrokerFQN = compiler.getConfiguration().getHelpBrokerFQN(); - return helpBrokerFQN; - } - - protected String getHelpId(CompiledObject o) { - String helpID = null; - if (o.hasClientProperties()) { - helpID = o.getClientProperty("help"); - } - return helpID; - } - - @Override - public void finalizeCompiler(JAXXCompiler compiler, CompiledObject root, CompiledObject object, JavaFile javaFile, String packageName, String className, String fullClassName) { - super.finalizeCompiler(compiler, root, object, javaFile, packageName, className, fullClassName); - CompilerConfiguration options = compiler.getConfiguration(); - - if (options.isGenerateHelp()) { - - // add JAXXHelpUI interface - Class<?> validatorInterface = jaxx.runtime.swing.help.JAXXHelpUI.class; - String helpBrokerFQN = getBrokerFQN(compiler); - javaFile.addInterface(JAXXCompiler.getCanonicalName(validatorInterface) + "<" + helpBrokerFQN + ">"); - - javaFile.addMethod(JavaFileGenerator.newMethod(Modifier.PUBLIC, "void", "registerHelpId", - "broker.installUI(component, helpId);", true, - new JavaArgument(helpBrokerFQN, "broker"), - new JavaArgument("Component", "component"), - new JavaArgument("String", "helpId"))); - - javaFile.addMethod(JavaFileGenerator.newMethod(Modifier.PUBLIC, "void", "showHelp", - "getBroker().showHelp(this, helpId);", true, - new JavaArgument("String", "helpId"))); - - StringBuilder buffer = new StringBuilder(); - - String eol = JAXXCompiler.getLineSeparator(); - -// if (options.isGenerateHelp()) { - - // add code to init javax help system - Iterator<CompiledObject> itr = compiler.getObjectCreationOrder(); - - for (; itr.hasNext();) { - CompiledObject o = itr.next(); - String helpID = getHelpId(o); - if (helpID != null) { - buffer.append(eol); - // detects a helpId to register - buffer.append("registerHelpId(_broker, ").append(o.getJavaCode()).append(", ").append(helpID).append(");"); - //keep the helpID for helpSet generation - helpIds.add(helpID); - } - } -// } - if (buffer.length() > 0) { - - StringBuilder extraCode = new StringBuilder(helpBrokerFQN).append(" _broker = getBroker();"); - - buffer.append(eol).append("_broker.prepareUI(this);"); - buffer.append(eol); - - // add the calls - compiler.appendLateInitializer("// help broker setup" + eol); - compiler.appendLateInitializer(extraCode.toString()); - compiler.appendLateInitializer(buffer.toString()); - } - } - } - - public static Set<String> getHelpIds() { - return helpIds; - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,126 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.decorators; + +import jaxx.compiler.CompiledObject; +import jaxx.compiler.CompilerConfiguration; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.java.JavaArgument; +import jaxx.compiler.java.JavaFile; +import jaxx.compiler.java.JavaFileGenerator; + +import java.lang.reflect.Modifier; +import java.util.Iterator; +import java.util.Set; + +/** + * A decorator to place on a root compiled object to process javaHelp on the file. + * + * @author tony + * @since 1.2 + */ +public class HelpRootCompiledObjectDecorator extends DefaultCompiledObjectDecorator { + + /** + * the list of discovered helpId + */ + protected static Set<String> helpIds = new java.util.HashSet<String>(); + + @Override + public String getName() { + return "help"; + } + + protected String getBrokerFQN(JAXXCompiler compiler) { + String helpBrokerFQN = compiler.getConfiguration().getHelpBrokerFQN(); + return helpBrokerFQN; + } + + protected String getHelpId(CompiledObject o) { + String helpID = null; + if (o.hasClientProperties()) { + helpID = o.getClientProperty("help"); + } + return helpID; + } + + @Override + public void finalizeCompiler(JAXXCompiler compiler, CompiledObject root, CompiledObject object, JavaFile javaFile, String packageName, String className, String fullClassName) { + super.finalizeCompiler(compiler, root, object, javaFile, packageName, className, fullClassName); + CompilerConfiguration options = compiler.getConfiguration(); + + if (options.isGenerateHelp()) { + + // add JAXXHelpUI interface + Class<?> validatorInterface = jaxx.runtime.swing.help.JAXXHelpUI.class; + String helpBrokerFQN = getBrokerFQN(compiler); + javaFile.addInterface(JAXXCompiler.getCanonicalName(validatorInterface) + "<" + helpBrokerFQN + ">"); + + javaFile.addMethod(JavaFileGenerator.newMethod(Modifier.PUBLIC, "void", "registerHelpId", + "broker.installUI(component, helpId);", true, + new JavaArgument(helpBrokerFQN, "broker"), + new JavaArgument("Component", "component"), + new JavaArgument("String", "helpId"))); + + javaFile.addMethod(JavaFileGenerator.newMethod(Modifier.PUBLIC, "void", "showHelp", + "getBroker().showHelp(this, helpId);", true, + new JavaArgument("String", "helpId"))); + + StringBuilder buffer = new StringBuilder(); + + String eol = JAXXCompiler.getLineSeparator(); + +// if (options.isGenerateHelp()) { + + // add code to init javax help system + Iterator<CompiledObject> itr = compiler.getObjectCreationOrder(); + + for (; itr.hasNext();) { + CompiledObject o = itr.next(); + String helpID = getHelpId(o); + if (helpID != null) { + buffer.append(eol); + // detects a helpId to register + buffer.append("registerHelpId(_broker, ").append(o.getJavaCode()).append(", ").append(helpID).append(");"); + //keep the helpID for helpSet generation + helpIds.add(helpID); + } + } +// } + if (buffer.length() > 0) { + + StringBuilder extraCode = new StringBuilder(helpBrokerFQN).append(" _broker = getBroker();"); + + buffer.append(eol).append("_broker.prepareUI(this);"); + buffer.append(eol); + + // add the calls + compiler.appendLateInitializer("// help broker setup" + eol); + compiler.appendLateInitializer(extraCode.toString()); + compiler.appendLateInitializer(buffer.toString()); + } + } + } + + public static Set<String> getHelpIds() { + return helpIds; + } +} Property changes on: trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers ___________________________________________________________________ Added: svn:mergeinfo + Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/DefaultFinalizer.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/DefaultFinalizer.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/DefaultFinalizer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,747 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.finalizers; - -import jaxx.compiler.*; -import jaxx.compiler.binding.DataBinding; -import jaxx.compiler.java.*; -import static jaxx.compiler.java.JavaFileGenerator.newField; -import static jaxx.compiler.java.JavaFileGenerator.newMethod; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.reflect.FieldDescriptor; -import jaxx.compiler.reflect.MethodDescriptor; -import jaxx.compiler.types.TypeManager; -import jaxx.runtime.*; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.io.IOException; -import static java.lang.reflect.Modifier.*; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -/** - * This class is a refactoring of the {@link jaxx.compiler.JAXXCompiler}. - * <p/> - * We delegate now the generation of a {@link jaxx.runtime.JAXXObject} to this class, the - * {@link jaxx.compiler.JAXXCompiler} now only deals with the compilation of files. - * - * @author chemit - */ -public class DefaultFinalizer implements JAXXCompilerFinalizer { - - /** - * Logger - */ - protected static final Log log = LogFactory.getLog(DefaultFinalizer.class); - /** - * serialVersionUID field - */ - protected static final JavaField SERIAL_VERSION_UID_FIELD = newField(PRIVATE | STATIC | FINAL, - "long", "serialVersionUID", false, "1L"); - /** - * $activeBindings field - */ - protected static final JavaField ACTIVE_BINDINGS_FIELD = newField(PROTECTED, - "java.util.List<Object>", "$activeBindings", false, "new ArrayList<Object>()"); - /** - * - */ - protected static final JavaField BINDING_SOURCES_FIELD = newField(PROTECTED, - "Map<String, Object>", "$bindingSources", false, "new HashMap<String, Object>()"); - /** - * - */ - protected static final JavaField OBJECT_MAP_FIELD = newField(PROTECTED, - "Map<String, Object>", "$objectMap", true, "new HashMap<String, Object>()"); - /** - * - */ - protected static final JavaField ALL_COMPONENTS_CREATED_FIELD = newField(PRIVATE, - "boolean", "allComponentsCreated", false); - /** - * - */ - protected static final JavaField CONTEXT_INITIALIZED = newField(PRIVATE, - "boolean", "contextInitialized", false, "true"); - /** - * - */ - protected static final JavaField PREVIOUS_VALUES_FIELD = newField(PROTECTED, - "Map<?,?>", "$previousValues", false, "new java.util.HashMap<Object, Object>()"); - /** - * - */ - protected static final JavaField BINDINGS_FIELD = newField(PRIVATE | FINAL, - "Map<String, JAXXBinding>", "$bindings", false, "new java.util.TreeMap<String, JAXXBinding>()"); - /** - * - */ - protected static final JavaField PROPERTY_CHANGE_SUPPORT_FIELD = newField(0, - "PropertyChangeSupport", "$propertyChangeSupport", false); - /** - * - */ - protected static final JavaMethod GET_CONTEXT_VALUE_METHOD = newMethod(PUBLIC, "<T> T", "getContextValue", - "return delegateContext.getContextValue(clazz, null);", true, - new JavaArgument("Class<T>", "clazz")); - /** - * - */ - protected static final JavaMethod GET_CONTEXT_VALUE_NAMED_METHOD = newMethod(PUBLIC, "<T> T", "getContextValue", - "return delegateContext.getContextValue(clazz, name);", true, - new JavaArgument("Class<T>", "clazz"), new JavaArgument("String", "name")); - /** - * - */ - protected static final JavaMethod SET_CONTEXT_VALUE_NAMED_METHOD = newMethod(PUBLIC, "<T> void", "setContextValue", - "delegateContext.setContextValue(o, name);", true, - new JavaArgument("T", "o"), new JavaArgument("String", "name")); - /** - * - */ - protected static final JavaMethod SET_CONTEXT_VALUE_METHOD = newMethod(PUBLIC, "<T> void", "setContextValue", - "delegateContext.setContextValue(o, null);", true, - new JavaArgument("T", "o")); - /** - * - */ - protected static final JavaMethod REMOVE_CONTEXT_VALUE_NAMED_METHOD = newMethod(PUBLIC, "<T> void", "removeContextValue", - "delegateContext.removeContextValue(clazz, name);", true, - new JavaArgument("Class<T>", "clazz"), new JavaArgument("String", "name")); - /** - * - */ - protected static final JavaMethod REMOVE_CONTEXT_VALUE_METHOD = newMethod(PUBLIC, "<T> void", "removeContextValue", - "delegateContext.removeContextValue(clazz, null);", true, - new JavaArgument("Class<T>", "clazz")); - /** - * - */ - protected static final JavaMethod GET_PARENT_CONTAINER_MORE_METHOD = newMethod(PUBLIC, "<O extends Container> O", "getParentContainer", - "return SwingUtil.getParentContainer(source, clazz);", true, - new JavaArgument("Object", "source"), new JavaArgument("Class<O>", "clazz")); - /** - * - */ - protected static final JavaMethod GET_PARENT_CONTAINER_METHOD = newMethod(PUBLIC, "<O extends Container> O", "getParentContainer", - "return SwingUtil.getParentContainer(this, clazz);", true, - new JavaArgument("Class<O>", "clazz")); - /** - * - */ - protected static final JavaMethod GET_OBJECT_BY_ID_METHOD = newMethod(PUBLIC, "Object", "getObjectById", - "return $objectMap.get(id);", true, - new JavaArgument("String", "id")); - /** - * - */ - protected static final JavaMethod GET_JAXX_OBJECT_DESCRIPTOR_METHOD = newMethod(PUBLIC | STATIC, "JAXXObjectDescriptor", "$getJAXXObjectDescriptor", - "return Util.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);", false); - /** - * - */ - protected static final JavaMethod PROCESS_DATA_BINDING_METHOD = newMethod(PUBLIC, "void", "processDataBinding", - "processDataBinding(binding, false);", true, - new JavaArgument("String", "binding")); - - protected static final JavaMethod REGISTER_DATA_BINDING_METHOD = newMethod(PRIVATE, "void", "registerDataBinding", - "$bindings.put(binding.getId(), binding);\n" + "applyDataBinding(binding.getId());", - false, - new JavaArgument(JAXXBinding.class.getSimpleName(), "binding")); - /** - * - */ - protected static final JavaMethod FIRE_PROPERTY_CHANGE_METHOD = newMethod(PUBLIC, "void", "firePropertyChange", - "super.firePropertyChange(propertyName, oldValue, newValue);", true, - new JavaArgument("String", "propertyName"), new JavaArgument("Object", "oldValue"), new JavaArgument("Object", "newValue")); - /** - * - */ - protected static final JavaMethod FIRE_PROPERTY_CHANGE_NAMED_METHOD = newMethod(PUBLIC, "void", "firePropertyChange", - "$getPropertyChangeSupport().firePropertyChange(propertyName, oldValue, newValue);", true, - new JavaArgument("String", "propertyName"), new JavaArgument("Object", "oldValue"), new JavaArgument("Object", "newValue")); - /** - * - */ - protected static final JavaMethod GET_PROPERTY_CHANGE_SUPPORT_METHOD = newMethod(0, "PropertyChangeSupport", "$getPropertyChangeSupport", - "if ($propertyChangeSupport == null)\n" + - " $propertyChangeSupport = new PropertyChangeSupport(this);\n" + - "return $propertyChangeSupport;", false); - /** - * - */ - protected static final JavaMethod ADD_PROPERTY_CHANGE_SUPPORT_METHOD = newMethod(PUBLIC, "void", "addPropertyChangeListener", - "$getPropertyChangeSupport().addPropertyChangeListener(listener);", true, - new JavaArgument("PropertyChangeListener", "listener")); - /** - * - */ - protected static final JavaMethod ADD_PROPERTY_CHANGE_SUPPORT_NAMED_METHOD = newMethod(PUBLIC, "void", "addPropertyChangeListener", - "$getPropertyChangeSupport().addPropertyChangeListener(property, listener);", true, - new JavaArgument("String", "property"), new JavaArgument("PropertyChangeListener", "listener")); - /** - * - */ - protected static final JavaMethod REMOVE_PROPERTY_CHANGE_SUPPORT_METHOD = newMethod(PUBLIC, "void", "removePropertyChangeListener", - "$getPropertyChangeSupport().removePropertyChangeListener(listener);", true, - new JavaArgument("PropertyChangeListener", "listener")); - /** - * - */ - protected static final JavaMethod REMOVE_PROPERTY_CHANGE_SUPPORT_NAMED_METHOD = newMethod(PUBLIC, "void", "removePropertyChangeListener", - "$getPropertyChangeSupport().removePropertyChangeListener(property, listener);", true, - new JavaArgument("String", "property"), new JavaArgument("PropertyChangeListener", "listener")); - - @Override - public void finalizeCompiler(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) { - - String fullClassName = packageName != null ? packageName + "." + className : className; - if (root == null) { - throw new CompilerException("root tag must be a class tag"); - } - ClassDescriptor superclass = root.getObjectClass(); - boolean superclassIsJAXXObject = ClassDescriptorLoader.getClassDescriptor(JAXXObject.class).isAssignableFrom(superclass); - javaFile.setModifiers(PUBLIC); - javaFile.setName(fullClassName); - javaFile.setSuperClass(JAXXCompiler.getCanonicalName(superclass)); - javaFile.setSuperclassIsJAXXObject(superclassIsJAXXObject); - - javaFile.addInterfaces(compiler.getExtraInterfaces()); - javaFile.setAbstractClass(compiler.isAbstractClass()); - javaFile.setGenericType(compiler.getGenericType()); - javaFile.setSuperGenericType(compiler.getSuperGenericType()); - - // finalize all objects via their decorator - for (CompiledObject object : compiler.getObjects().values()) { - CompiledObjectDecorator decorator = object.getDecorator(); - decorator.finalizeCompiler(compiler, root, object, javaFile, packageName, className, fullClassName); - } - - // compile bindings and fill the initDataBindings field of binding helper - compiler.getBindingHelper().finalizeBindings(); - - if (!superclassIsJAXXObject) { - javaFile.addInterface(JAXXObject.class.getSimpleName()); - } - } - - @Override - public void prepareJavaFile(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) throws ClassNotFoundException { - - String fullClassName = javaFile.getName(); - - String jaxxContextImplementorClass = compiler.getConfiguration().getJaxxContextClass().getName(); - boolean superclassIsJAXXObject = javaFile.isSuperclassIsJAXXObject(); - if (!superclassIsJAXXObject) { - javaFile.addImport(JAXXObject.class); - } - javaFile.addImport(JAXXContext.class); - javaFile.addImport(JAXXObjectDescriptor.class); - - if (!superclassIsJAXXObject) { - // add logger - if (compiler.getConfiguration().isAddLogger()) { - javaFile.addImport(Log.class); - javaFile.addImport(LogFactory.class); - //TC-20091127 : let the logger stays protected - javaFile.addSimpleField(newField(PROTECTED | STATIC | FINAL, "Log", "log", false, "LogFactory.getLog(" + fullClassName + ".class)")); - } - - // JAXXObject - javaFile.addField(OBJECT_MAP_FIELD); - javaFile.addMethod(GET_OBJECT_BY_ID_METHOD); - javaFile.addSimpleField(BINDING_SOURCES_FIELD); - javaFile.addSimpleField(ACTIVE_BINDINGS_FIELD); - // JAXXContext - javaFile.addField(newField(PROTECTED | FINAL, JAXXContext.class.getSimpleName(), "delegateContext", true, "new " + jaxxContextImplementorClass + "()")); -// javaFile.addField(newField(PROTECTED | FINAL, JAXXContext.class.getName(), "delegateContext", true, "new " + jaxxContextImplementorClass + "(this)")); - javaFile.addMethod(SET_CONTEXT_VALUE_METHOD); - javaFile.addMethod(SET_CONTEXT_VALUE_NAMED_METHOD); - javaFile.addMethod(GET_CONTEXT_VALUE_METHOD); - javaFile.addMethod(GET_CONTEXT_VALUE_NAMED_METHOD); - javaFile.addMethod(REMOVE_CONTEXT_VALUE_METHOD); - javaFile.addMethod(REMOVE_CONTEXT_VALUE_NAMED_METHOD); - javaFile.addMethod(GET_PARENT_CONTAINER_METHOD); - javaFile.addMethod(GET_PARENT_CONTAINER_MORE_METHOD); - - // PropertyChangeSupport - addPropertyChangeSupport(root, javaFile); - - // DataBinding - javaFile.addMethod(PROCESS_DATA_BINDING_METHOD); - } - javaFile.addSimpleField(SERIAL_VERSION_UID_FIELD); - javaFile.addSimpleField(ALL_COMPONENTS_CREATED_FIELD); - boolean overrideContextInitialized = false; - FieldDescriptor[] scriptFields = compiler.getScriptFields(); - for (FieldDescriptor f : scriptFields) { - if ("contextInitialized".equals(f.getName())) { - overrideContextInitialized = true; - break; - } - } - if (!overrideContextInitialized) { - javaFile.addSimpleField(CONTEXT_INITIALIZED); - } - javaFile.addSimpleField(createJAXXObjectDescriptorField(compiler, javaFile)); - - if (compiler.getStylesheet() != null) { - boolean needField = true; - if (superclassIsJAXXObject) { - // check alreay exists on parent - ClassDescriptor superclass = root.getObjectClass(); - if (log.isDebugEnabled()) { - log.debug("superclass : " + superclass); - } - JAXXCompiler parentCompiler = compiler.getEngine().getJAXXCompiler(superclass.getName()); - if (parentCompiler != null) { - needField = parentCompiler.getStylesheet() == null; - } else { - try { - superclass.getDeclaredFieldDescriptor(PREVIOUS_VALUES_FIELD.getName()); - needField = false; - } catch (NoSuchFieldException ex) { - // field not found - } - } - if (needField && log.isDebugEnabled()) { - log.debug("no " + PREVIOUS_VALUES_FIELD.getName() + " field in super class"); - } - } - if (needField) { - javaFile.addSimpleField(PREVIOUS_VALUES_FIELD); - } - } - //TC 20090228 - only generate constructors if not done in scripts - boolean constructorDetected = false; - MethodDescriptor[] methods = compiler.getScriptMethods(); - for (MethodDescriptor m : methods) { - try { - m.getReturnType(); - if (className.equals(m.getName())) { - constructorDetected = true; - break; - } - } catch (Exception e) { - log.warn("could not find return type " + m); - } - } - if (!constructorDetected) { - javaFile.addMethod(createConstructor(compiler, className, superclassIsJAXXObject)); - javaFile.addMethod(createConstructorWithInitialContext(compiler, className, superclassIsJAXXObject)); - } - - javaFile.addMethod(createInitializer(compiler)); - javaFile.addMethod(GET_JAXX_OBJECT_DESCRIPTOR_METHOD); - - javaFile.addBodyCode(compiler.getBodyCode().toString()); - - String dataBindingInitNode = null; - String simpleBindingInitNode = null; - - String eol = JAXXCompiler.getLineSeparator(); - JavaFileGenerator generator = new JavaFileGenerator(eol, true); - - DataBinding[] bindings; - - bindings = compiler.getBindingHelper().getSimpleBindings(); - if (bindings.length > 0) { - - // get data binding register code - - StringBuilder initCode = new StringBuilder(); - - for (DataBinding binding : bindings) { - - // ce n'est pas un binding, on enregistre le code d'init (si il existe) - - if (binding.getInitDataBinding() != null) { - initCode.append(binding.getInitDataBinding()); - } - } - - if (initCode.length() > 0) { - simpleBindingInitNode = "// apply " + bindings.length + " property setters " + eol + initCode.toString().trim(); - } - } - - bindings = compiler.getBindingHelper().getDataBindings(); - - boolean hasDataBindings = bindings.length > 0; - - if (hasDataBindings) { - - javaFile.addImport(JAXXBinding.class); - javaFile.addSimpleField(BINDINGS_FIELD); - javaFile.addMethod(REGISTER_DATA_BINDING_METHOD); - - // get data binding register code - - StringBuilder initCode = new StringBuilder(); - - for (DataBinding binding : bindings) { - - String constantId = binding.getConstantId(); - - // add the data binding constant Id - - compiler.addSimpleField(new JavaField((constantId.startsWith("BINDING_$") ? PRIVATE : PUBLIC) | FINAL | STATIC, String.class.getSimpleName(), constantId, false, TypeManager.getJavaCode(binding.getRealId()))); - - // register the binding - - List<JavaMethod> bMethods = binding.getMethods(); - - bMethods.add(0, new JavaMethod(PUBLIC, "void", "removeDataBinding", new JavaArgument[0], new String[0], binding.getRemoveListenerCode(), true)); - bMethods.add(0, new JavaMethod(PUBLIC, "void", "processDataBinding", new JavaArgument[0], new String[0], binding.getProcessDataBinding(), true)); - bMethods.add(0, new JavaMethod(PUBLIC, "void", "applyDataBinding", new JavaArgument[0], new String[0], binding.getAddListenerCode(), true)); - - initCode.append("registerDataBinding(new ").append(JAXXBinding.class.getSimpleName()).append("(").append(binding.getConstantId()).append(") {").append(eol); - for (JavaMethod m : bMethods) { - initCode.append(eol).append(JavaFileGenerator.indent(generator.generateMethod(m), 4, false, eol)).append(eol); - } - initCode.append("});").append(eol); - - if (binding.getInitDataBinding() != null) { - initCode.append(binding.getInitDataBinding()); - } - } - - dataBindingInitNode = "// registers " + bindings.length + " data bindings" + eol + initCode.toString().trim(); - } - - javaFile.addMethod(createCompleteSetupMethod(compiler, javaFile, simpleBindingInitNode, dataBindingInitNode)); - - javaFile.addMethod(createApplyDataBindingMethod(superclassIsJAXXObject, hasDataBindings)); - javaFile.addMethod(createProcessDataBindingMethod(superclassIsJAXXObject, hasDataBindings)); - javaFile.addMethod(createRemoveDataBindingMethod(superclassIsJAXXObject, hasDataBindings)); - - addEventHandlers(compiler, javaFile); - } - - /*---------------------------------------------------------------------------------*/ - /*-- Create fields ----------------------------------------------------------------*/ - /*---------------------------------------------------------------------------------*/ - protected JavaField createJAXXObjectDescriptorField(JAXXCompiler compiler, JavaFile javaFile) { - try { - JAXXObjectDescriptor descriptor = compiler.getJAXXObjectDescriptor(); - String data = Base64Coder.serialize(descriptor, true); - /*ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - ObjectOutputStream out = new ObjectOutputStream(new GZIPOutputStream(buffer)); - out.writeObject(descriptor); - out.close(); - // the use of the weird deprecated constructor is deliberate -- we need to store the data as a String - // in the compiled class file, since byte array initialization is horribly inefficient compared to - // String initialization. So we store the bytes in the String, and we quite explicitly want a 1:1 - // mapping between bytes and chars, with the high byte of the char set to zero. We can then safely - // reconstitute the original byte[] at a later date. This is unquestionably an abuse of the String - // type, but if we could efficiently store a byte[] we wouldn't have to do this. - String data = new String(buffer.toByteArray(), 0);*/ - - int sizeLimit = 65000; // constant strings are limited to 64K, and I'm not brave enough to push right up to the limit - if (data.length() < sizeLimit) { - return newField(PRIVATE | STATIC | FINAL, "String", "$jaxxObjectDescriptor", false, TypeManager.getJavaCode(data)); - } else { - StringBuffer initializer = new StringBuffer(); - for (int i = 0; i < data.length(); i += sizeLimit) { - String name = "$jaxxObjectDescriptor" + i; - javaFile.addField(new JavaField(PRIVATE | STATIC, "String", name, false, - TypeManager.getJavaCode(data.substring(i, Math.min(i + sizeLimit, data.length()))))); - if (initializer.length() > 0) { - initializer.append(" + "); - } - initializer.append("String.valueOf(").append(name).append(")"); - } - return newField(PRIVATE | STATIC | FINAL, "String", "$jaxxObjectDescriptor", false, initializer.toString()); - } - } catch (IOException e) { - throw new RuntimeException("Internal error: can't-happen error", e); - } - } - - /*---------------------------------------------------------------------------------*/ - /*-- Create methods ---------------------------------------------------------------*/ - /*---------------------------------------------------------------------------------*/ - protected void addPropertyChangeSupport(CompiledObject root, JavaFile javaFile) { - ClassDescriptor currentClass = root.getObjectClass(); - MethodDescriptor firePropertyChange = null; - while (firePropertyChange == null && currentClass != null) { - try { - firePropertyChange = currentClass.getDeclaredMethodDescriptor("firePropertyChange", ClassDescriptorLoader.getClassDescriptor(String.class), - ClassDescriptorLoader.getClassDescriptor(Object.class), - ClassDescriptorLoader.getClassDescriptor(Object.class)); - - } catch (NoSuchMethodException e) { - currentClass = currentClass.getSuperclass(); - } - } - - int modifiers = firePropertyChange != null ? firePropertyChange.getModifiers() : 0; - if (isPublic(modifiers)) { - // we have all the support we need - return; - } - if (isProtected(modifiers)) { - // there is property change support but the firePropertyChange method is protected - javaFile.addMethod(FIRE_PROPERTY_CHANGE_METHOD); - } else { - // either no support at all or firePropertyChange isn't accessible - javaFile.addImport(PropertyChangeListener.class); - javaFile.addImport(PropertyChangeSupport.class); - - javaFile.addField(PROPERTY_CHANGE_SUPPORT_FIELD); - javaFile.addMethod(GET_PROPERTY_CHANGE_SUPPORT_METHOD); - javaFile.addMethod(ADD_PROPERTY_CHANGE_SUPPORT_METHOD); - javaFile.addMethod(ADD_PROPERTY_CHANGE_SUPPORT_NAMED_METHOD); - javaFile.addMethod(REMOVE_PROPERTY_CHANGE_SUPPORT_METHOD); - javaFile.addMethod(REMOVE_PROPERTY_CHANGE_SUPPORT_NAMED_METHOD); - javaFile.addMethod(FIRE_PROPERTY_CHANGE_NAMED_METHOD); - } - } - - protected void addEventHandlers(JAXXCompiler compiler, JavaFile javaFile) { - for (Map.Entry<String, Map<ClassDescriptor, List<EventHandler>>> e1 : compiler.getEventHandlers().entrySet()) { - // outer loop is iterating over different objects (well, technically, different Java expressions) - for (Map.Entry<ClassDescriptor, List<EventHandler>> e2 : e1.getValue().entrySet()) { - // iterate over different types of listeners for this particular object (MouseListener, ComponentListener, etc.) - for (EventHandler handler : e2.getValue()) { - // iterate over individual event handlers of a single type - String methodName = compiler.getEventHandlerMethodName(handler); - MethodDescriptor listenerMethod = handler.getListenerMethod(); - if (listenerMethod.getParameterTypes().length != 1) { - throw new CompilerException("Expected event handler " + listenerMethod.getName() + " of class " + handler.getListenerClass() + " to have exactly one argument"); - } - javaFile.addMethod(newMethod(PUBLIC, "void", methodName, handler.getJavaCode(), false, - new JavaArgument(JAXXCompiler.getCanonicalName(listenerMethod.getParameterTypes()[0]), "event"))); - } - } - } - } - - protected JavaMethod createConstructor(JAXXCompiler compiler, String className, boolean superclassIsJAXXObject) throws CompilerException { - StringBuffer code = new StringBuffer(); - String constructorParams = compiler.getRootObject().getConstructorParams(); - String eol = JAXXCompiler.getLineSeparator(); - if (constructorParams != null) { - code.append(" super(").append(constructorParams).append(");").append(eol); - } else { - if (superclassIsJAXXObject) { - code.append(" super();").append(eol); - } - } - code.append("$initialize();"); - code.append(eol); - return newMethod(PUBLIC, null, className, code.toString(), false); - } - - protected JavaMethod createConstructorWithInitialContext(JAXXCompiler compiler, String className, boolean superclassIsJAXXObject) throws CompilerException { - StringBuffer code = new StringBuffer(); - String constructorParams = compiler.getRootObject().getConstructorParams(); - String eol = JAXXCompiler.getLineSeparator(); - if (constructorParams != null) { - if (superclassIsJAXXObject) { - //TODO-TC20091127 This MUST be a convention in JAXX : all specialized constructor must a second - //TODO constructor with extra first parameter as parentContext - constructorParams = "parentContext, " + constructorParams; - } - code.append(" super(").append(constructorParams).append(");").append(eol); - } else { - if (superclassIsJAXXObject) { - code.append(" super(parentContext);").append(eol); - } - } - if (!superclassIsJAXXObject) { - code.append(Util.class.getSimpleName()).append(".initContext(this, parentContext);"); - code.append(eol); - } - code.append("$initialize();"); - code.append(eol); - return newMethod(PUBLIC, null, className, code.toString(), false, new JavaArgument(JAXXContext.class.getSimpleName(), "parentContext")); - } - - public JavaMethod createInitializer(JAXXCompiler compiler) throws CompilerException { - String eol = JAXXCompiler.getLineSeparator(); - StringBuffer code = new StringBuffer(); - CompiledObject root = compiler.getRootObject(); - code.append("if (allComponentsCreated || !contextInitialized) {"); - code.append(eol); - code.append(" return;"); - code.append(eol); - code.append("}"); - code.append(eol); - //TODO-TC20091025 we should remove this if no used anywhere - code.append("$objectMap.put(").append(TypeManager.getJavaCode(root.getId())).append(", this);"); - code.append(eol); - - Iterator<CompiledObject> i = compiler.getObjectCreationOrder(); - boolean lastWasMethodCall = false; - //TODO-TC20091025 should do init of root first ? -// root.getDecorator().createInitializer(compiler, root, root, code, lastWasMethodCall); - while (i.hasNext()) { - CompiledObject object = i.next(); - if (object == root) { - continue; - } - CompiledObjectDecorator decorator = object.getDecorator(); - lastWasMethodCall = decorator.createInitializer(compiler, root, object, code, lastWasMethodCall); - } - root.getDecorator().createInitializer(compiler, root, root, code, lastWasMethodCall); - if (compiler.getInitializer().length() > 0) { - code.append(compiler.getInitializer()); - } - code.append("$completeSetup();"); - code.append(eol); - return newMethod(PRIVATE, "void", "$initialize", code.toString(), false); - } - - protected JavaMethod createCompleteSetupMethod(JAXXCompiler compiler, JavaFile javaFile, String simpleBindingInitNode, String dataBindingInitNode) { - StringBuffer code = new StringBuffer(); - code.append("allComponentsCreated = true;"); - String eol = JAXXCompiler.getLineSeparator(); - code.append(eol); - for (CompiledObject object : compiler.getObjects().values()) { - CompiledObjectDecorator decorator = object.getDecorator(); - code.append(decorator.createCompleteSetupMethod(compiler, object, javaFile)); - } - - if (simpleBindingInitNode != null && !simpleBindingInitNode.isEmpty()) { - code.append(simpleBindingInitNode).append(eol); - } - - if (dataBindingInitNode != null && !dataBindingInitNode.isEmpty()) { - code.append(dataBindingInitNode).append(eol); - } - - if (compiler.getLateInitializer().length() > 0) { - code.append("// late initializer").append(eol); - code.append(compiler.getLateInitializer()).append(eol); - } - //TC-20090313 add an extra method after complete setup - MethodDescriptor method = compiler.getScriptMethod("$afterCompleteSetup"); - if (method != null) { - code.append("$afterCompleteSetup();").append(eol); - } - return newMethod(PRIVATE, "void", "$completeSetup", code.toString(), false); - } - - protected JavaMethod createApplyDataBindingMethod(boolean superclassIsJAXXObject, boolean haveBinding) { - StringBuilder buffer = new StringBuilder(); - String eol = JAXXCompiler.getLineSeparator(); - - if (haveBinding) { - if (superclassIsJAXXObject) - buffer.append("if (allComponentsCreated && $bindings.containsKey($binding)) {").append(eol); - else { - buffer.append("if ($bindings.containsKey($binding)) {").append(eol); - } - buffer.append(" $bindings.get($binding).applyDataBinding();").append(eol); - buffer.append("}"); - - } - if (superclassIsJAXXObject) { - - if (haveBinding) { - buffer.append(" else {").append(eol).append(" "); - } - buffer.append("super.applyDataBinding($binding);").append(eol); - - if (haveBinding) { - buffer.append(" return;").append(eol).append("}"); - } - - } - buffer.append(eol).append("processDataBinding($binding);"); - return newMethod(PUBLIC, "void", "applyDataBinding", buffer.toString(), true, - new JavaArgument("String", "$binding")); - } - - protected JavaMethod createRemoveDataBindingMethod(boolean superclassIsJAXXObject, boolean haveBinding) { - StringBuilder buffer = new StringBuilder(); - String eol = JAXXCompiler.getLineSeparator(); - - if (haveBinding) { - - if (superclassIsJAXXObject) { - buffer.append("if (allComponentsCreated && $bindings.containsKey($binding)) {").append(eol); - } else { - buffer.append("if ($bindings.containsKey($binding)) {").append(eol); - } - buffer.append(" $bindings.get($binding).removeDataBinding();").append(eol); - buffer.append("}"); - - - } - if (superclassIsJAXXObject) { - - if (haveBinding) { - buffer.append(" else {").append(eol).append(" "); - } - buffer.append("super.removeDataBinding($binding);").append(eol); - - if (haveBinding) { - buffer.append("}"); - } - } - return newMethod(PUBLIC, "void", "removeDataBinding", buffer.toString(), true, - new JavaArgument("String", "$binding")); - } - - protected JavaMethod createProcessDataBindingMethod(boolean superclassIsJAXXObject, boolean haveBinding) { - StringBuffer code = new StringBuffer(); - String eol = JAXXCompiler.getLineSeparator(); - //boolean superclassIsJAXXObject = ClassDescriptorLoader.getClassDescriptor(JAXXObject.class).isAssignableFrom(compiler.getRootObject().getObjectClass()); - // the force parameter forces the update to happen even if it is already in activeBindings. This - // is used on superclass invocations b/c by the time the call gets to the superclass, it is already - // marked active and would otherwise be skipped - if (haveBinding) { - code.append(" if (!$force && $activeBindings.contains($binding)) { "); - code.append(eol); - code.append(" return;").append(eol); - code.append("}").append(eol); - code.append("$activeBindings.add($binding);").append(eol); - code.append("try {").append(eol); - if (superclassIsJAXXObject) { - code.append(" if (allComponentsCreated && $bindings.containsKey($binding)) {").append(eol); - } else { - code.append(" if ($bindings.containsKey($binding)) {").append(eol); - } - code.append(" $bindings.get($binding).processDataBinding();").append(eol); - code.append(" }"); - if (superclassIsJAXXObject) { - code.append(" else {").append(eol); - code.append(" super.processDataBinding($binding, true);").append(eol); - code.append(" }"); - } - code.append(eol); - code.append("} finally {").append(eol); - code.append(" $activeBindings.remove($binding);").append(eol); - code.append("}").append(eol); - } else if (superclassIsJAXXObject) { - code.append("super.processDataBinding($binding, true);").append(eol); - } - return newMethod(PUBLIC, "void", "processDataBinding", code.toString(), superclassIsJAXXObject, - new JavaArgument("String", "$binding"), new JavaArgument("boolean", "$force")); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/DefaultFinalizer.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/DefaultFinalizer.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/DefaultFinalizer.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/DefaultFinalizer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,747 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.finalizers; + +import jaxx.compiler.*; +import jaxx.compiler.binding.DataBinding; +import jaxx.compiler.java.*; +import static jaxx.compiler.java.JavaFileGenerator.newField; +import static jaxx.compiler.java.JavaFileGenerator.newMethod; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.reflect.FieldDescriptor; +import jaxx.compiler.reflect.MethodDescriptor; +import jaxx.compiler.types.TypeManager; +import jaxx.runtime.*; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.io.IOException; +import static java.lang.reflect.Modifier.*; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +/** + * This class is a refactoring of the {@link jaxx.compiler.JAXXCompiler}. + * <p/> + * We delegate now the generation of a {@link jaxx.runtime.JAXXObject} to this class, the + * {@link jaxx.compiler.JAXXCompiler} now only deals with the compilation of files. + * + * @author chemit + */ +public class DefaultFinalizer implements JAXXCompilerFinalizer { + + /** + * Logger + */ + protected static final Log log = LogFactory.getLog(DefaultFinalizer.class); + /** + * serialVersionUID field + */ + protected static final JavaField SERIAL_VERSION_UID_FIELD = newField(PRIVATE | STATIC | FINAL, + "long", "serialVersionUID", false, "1L"); + /** + * $activeBindings field + */ + protected static final JavaField ACTIVE_BINDINGS_FIELD = newField(PROTECTED, + "java.util.List<Object>", "$activeBindings", false, "new ArrayList<Object>()"); + /** + * + */ + protected static final JavaField BINDING_SOURCES_FIELD = newField(PROTECTED, + "Map<String, Object>", "$bindingSources", false, "new HashMap<String, Object>()"); + /** + * + */ + protected static final JavaField OBJECT_MAP_FIELD = newField(PROTECTED, + "Map<String, Object>", "$objectMap", true, "new HashMap<String, Object>()"); + /** + * + */ + protected static final JavaField ALL_COMPONENTS_CREATED_FIELD = newField(PRIVATE, + "boolean", "allComponentsCreated", false); + /** + * + */ + protected static final JavaField CONTEXT_INITIALIZED = newField(PRIVATE, + "boolean", "contextInitialized", false, "true"); + /** + * + */ + protected static final JavaField PREVIOUS_VALUES_FIELD = newField(PROTECTED, + "Map<?,?>", "$previousValues", false, "new java.util.HashMap<Object, Object>()"); + /** + * + */ + protected static final JavaField BINDINGS_FIELD = newField(PRIVATE | FINAL, + "Map<String, JAXXBinding>", "$bindings", false, "new java.util.TreeMap<String, JAXXBinding>()"); + /** + * + */ + protected static final JavaField PROPERTY_CHANGE_SUPPORT_FIELD = newField(0, + "PropertyChangeSupport", "$propertyChangeSupport", false); + /** + * + */ + protected static final JavaMethod GET_CONTEXT_VALUE_METHOD = newMethod(PUBLIC, "<T> T", "getContextValue", + "return delegateContext.getContextValue(clazz, null);", true, + new JavaArgument("Class<T>", "clazz")); + /** + * + */ + protected static final JavaMethod GET_CONTEXT_VALUE_NAMED_METHOD = newMethod(PUBLIC, "<T> T", "getContextValue", + "return delegateContext.getContextValue(clazz, name);", true, + new JavaArgument("Class<T>", "clazz"), new JavaArgument("String", "name")); + /** + * + */ + protected static final JavaMethod SET_CONTEXT_VALUE_NAMED_METHOD = newMethod(PUBLIC, "<T> void", "setContextValue", + "delegateContext.setContextValue(o, name);", true, + new JavaArgument("T", "o"), new JavaArgument("String", "name")); + /** + * + */ + protected static final JavaMethod SET_CONTEXT_VALUE_METHOD = newMethod(PUBLIC, "<T> void", "setContextValue", + "delegateContext.setContextValue(o, null);", true, + new JavaArgument("T", "o")); + /** + * + */ + protected static final JavaMethod REMOVE_CONTEXT_VALUE_NAMED_METHOD = newMethod(PUBLIC, "<T> void", "removeContextValue", + "delegateContext.removeContextValue(clazz, name);", true, + new JavaArgument("Class<T>", "clazz"), new JavaArgument("String", "name")); + /** + * + */ + protected static final JavaMethod REMOVE_CONTEXT_VALUE_METHOD = newMethod(PUBLIC, "<T> void", "removeContextValue", + "delegateContext.removeContextValue(clazz, null);", true, + new JavaArgument("Class<T>", "clazz")); + /** + * + */ + protected static final JavaMethod GET_PARENT_CONTAINER_MORE_METHOD = newMethod(PUBLIC, "<O extends Container> O", "getParentContainer", + "return SwingUtil.getParentContainer(source, clazz);", true, + new JavaArgument("Object", "source"), new JavaArgument("Class<O>", "clazz")); + /** + * + */ + protected static final JavaMethod GET_PARENT_CONTAINER_METHOD = newMethod(PUBLIC, "<O extends Container> O", "getParentContainer", + "return SwingUtil.getParentContainer(this, clazz);", true, + new JavaArgument("Class<O>", "clazz")); + /** + * + */ + protected static final JavaMethod GET_OBJECT_BY_ID_METHOD = newMethod(PUBLIC, "Object", "getObjectById", + "return $objectMap.get(id);", true, + new JavaArgument("String", "id")); + /** + * + */ + protected static final JavaMethod GET_JAXX_OBJECT_DESCRIPTOR_METHOD = newMethod(PUBLIC | STATIC, "JAXXObjectDescriptor", "$getJAXXObjectDescriptor", + "return Util.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);", false); + /** + * + */ + protected static final JavaMethod PROCESS_DATA_BINDING_METHOD = newMethod(PUBLIC, "void", "processDataBinding", + "processDataBinding(binding, false);", true, + new JavaArgument("String", "binding")); + + protected static final JavaMethod REGISTER_DATA_BINDING_METHOD = newMethod(PRIVATE, "void", "registerDataBinding", + "$bindings.put(binding.getId(), binding);\n" + "applyDataBinding(binding.getId());", + false, + new JavaArgument(JAXXBinding.class.getSimpleName(), "binding")); + /** + * + */ + protected static final JavaMethod FIRE_PROPERTY_CHANGE_METHOD = newMethod(PUBLIC, "void", "firePropertyChange", + "super.firePropertyChange(propertyName, oldValue, newValue);", true, + new JavaArgument("String", "propertyName"), new JavaArgument("Object", "oldValue"), new JavaArgument("Object", "newValue")); + /** + * + */ + protected static final JavaMethod FIRE_PROPERTY_CHANGE_NAMED_METHOD = newMethod(PUBLIC, "void", "firePropertyChange", + "$getPropertyChangeSupport().firePropertyChange(propertyName, oldValue, newValue);", true, + new JavaArgument("String", "propertyName"), new JavaArgument("Object", "oldValue"), new JavaArgument("Object", "newValue")); + /** + * + */ + protected static final JavaMethod GET_PROPERTY_CHANGE_SUPPORT_METHOD = newMethod(0, "PropertyChangeSupport", "$getPropertyChangeSupport", + "if ($propertyChangeSupport == null)\n" + + " $propertyChangeSupport = new PropertyChangeSupport(this);\n" + + "return $propertyChangeSupport;", false); + /** + * + */ + protected static final JavaMethod ADD_PROPERTY_CHANGE_SUPPORT_METHOD = newMethod(PUBLIC, "void", "addPropertyChangeListener", + "$getPropertyChangeSupport().addPropertyChangeListener(listener);", true, + new JavaArgument("PropertyChangeListener", "listener")); + /** + * + */ + protected static final JavaMethod ADD_PROPERTY_CHANGE_SUPPORT_NAMED_METHOD = newMethod(PUBLIC, "void", "addPropertyChangeListener", + "$getPropertyChangeSupport().addPropertyChangeListener(property, listener);", true, + new JavaArgument("String", "property"), new JavaArgument("PropertyChangeListener", "listener")); + /** + * + */ + protected static final JavaMethod REMOVE_PROPERTY_CHANGE_SUPPORT_METHOD = newMethod(PUBLIC, "void", "removePropertyChangeListener", + "$getPropertyChangeSupport().removePropertyChangeListener(listener);", true, + new JavaArgument("PropertyChangeListener", "listener")); + /** + * + */ + protected static final JavaMethod REMOVE_PROPERTY_CHANGE_SUPPORT_NAMED_METHOD = newMethod(PUBLIC, "void", "removePropertyChangeListener", + "$getPropertyChangeSupport().removePropertyChangeListener(property, listener);", true, + new JavaArgument("String", "property"), new JavaArgument("PropertyChangeListener", "listener")); + + @Override + public void finalizeCompiler(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) { + + String fullClassName = packageName != null ? packageName + "." + className : className; + if (root == null) { + throw new CompilerException("root tag must be a class tag"); + } + ClassDescriptor superclass = root.getObjectClass(); + boolean superclassIsJAXXObject = ClassDescriptorLoader.getClassDescriptor(JAXXObject.class).isAssignableFrom(superclass); + javaFile.setModifiers(PUBLIC); + javaFile.setName(fullClassName); + javaFile.setSuperClass(JAXXCompiler.getCanonicalName(superclass)); + javaFile.setSuperclassIsJAXXObject(superclassIsJAXXObject); + + javaFile.addInterfaces(compiler.getExtraInterfaces()); + javaFile.setAbstractClass(compiler.isAbstractClass()); + javaFile.setGenericType(compiler.getGenericType()); + javaFile.setSuperGenericType(compiler.getSuperGenericType()); + + // finalize all objects via their decorator + for (CompiledObject object : compiler.getObjects().values()) { + CompiledObjectDecorator decorator = object.getDecorator(); + decorator.finalizeCompiler(compiler, root, object, javaFile, packageName, className, fullClassName); + } + + // compile bindings and fill the initDataBindings field of binding helper + compiler.getBindingHelper().finalizeBindings(); + + if (!superclassIsJAXXObject) { + javaFile.addInterface(JAXXObject.class.getSimpleName()); + } + } + + @Override + public void prepareJavaFile(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) throws ClassNotFoundException { + + String fullClassName = javaFile.getName(); + + String jaxxContextImplementorClass = compiler.getConfiguration().getJaxxContextClass().getName(); + boolean superclassIsJAXXObject = javaFile.isSuperclassIsJAXXObject(); + if (!superclassIsJAXXObject) { + javaFile.addImport(JAXXObject.class); + } + javaFile.addImport(JAXXContext.class); + javaFile.addImport(JAXXObjectDescriptor.class); + + if (!superclassIsJAXXObject) { + // add logger + if (compiler.getConfiguration().isAddLogger()) { + javaFile.addImport(Log.class); + javaFile.addImport(LogFactory.class); + //TC-20091127 : let the logger stays protected + javaFile.addSimpleField(newField(PROTECTED | STATIC | FINAL, "Log", "log", false, "LogFactory.getLog(" + fullClassName + ".class)")); + } + + // JAXXObject + javaFile.addField(OBJECT_MAP_FIELD); + javaFile.addMethod(GET_OBJECT_BY_ID_METHOD); + javaFile.addSimpleField(BINDING_SOURCES_FIELD); + javaFile.addSimpleField(ACTIVE_BINDINGS_FIELD); + // JAXXContext + javaFile.addField(newField(PROTECTED | FINAL, JAXXContext.class.getSimpleName(), "delegateContext", true, "new " + jaxxContextImplementorClass + "()")); +// javaFile.addField(newField(PROTECTED | FINAL, JAXXContext.class.getName(), "delegateContext", true, "new " + jaxxContextImplementorClass + "(this)")); + javaFile.addMethod(SET_CONTEXT_VALUE_METHOD); + javaFile.addMethod(SET_CONTEXT_VALUE_NAMED_METHOD); + javaFile.addMethod(GET_CONTEXT_VALUE_METHOD); + javaFile.addMethod(GET_CONTEXT_VALUE_NAMED_METHOD); + javaFile.addMethod(REMOVE_CONTEXT_VALUE_METHOD); + javaFile.addMethod(REMOVE_CONTEXT_VALUE_NAMED_METHOD); + javaFile.addMethod(GET_PARENT_CONTAINER_METHOD); + javaFile.addMethod(GET_PARENT_CONTAINER_MORE_METHOD); + + // PropertyChangeSupport + addPropertyChangeSupport(root, javaFile); + + // DataBinding + javaFile.addMethod(PROCESS_DATA_BINDING_METHOD); + } + javaFile.addSimpleField(SERIAL_VERSION_UID_FIELD); + javaFile.addSimpleField(ALL_COMPONENTS_CREATED_FIELD); + boolean overrideContextInitialized = false; + FieldDescriptor[] scriptFields = compiler.getScriptFields(); + for (FieldDescriptor f : scriptFields) { + if ("contextInitialized".equals(f.getName())) { + overrideContextInitialized = true; + break; + } + } + if (!overrideContextInitialized) { + javaFile.addSimpleField(CONTEXT_INITIALIZED); + } + javaFile.addSimpleField(createJAXXObjectDescriptorField(compiler, javaFile)); + + if (compiler.getStylesheet() != null) { + boolean needField = true; + if (superclassIsJAXXObject) { + // check alreay exists on parent + ClassDescriptor superclass = root.getObjectClass(); + if (log.isDebugEnabled()) { + log.debug("superclass : " + superclass); + } + JAXXCompiler parentCompiler = compiler.getEngine().getJAXXCompiler(superclass.getName()); + if (parentCompiler != null) { + needField = parentCompiler.getStylesheet() == null; + } else { + try { + superclass.getDeclaredFieldDescriptor(PREVIOUS_VALUES_FIELD.getName()); + needField = false; + } catch (NoSuchFieldException ex) { + // field not found + } + } + if (needField && log.isDebugEnabled()) { + log.debug("no " + PREVIOUS_VALUES_FIELD.getName() + " field in super class"); + } + } + if (needField) { + javaFile.addSimpleField(PREVIOUS_VALUES_FIELD); + } + } + //TC 20090228 - only generate constructors if not done in scripts + boolean constructorDetected = false; + MethodDescriptor[] methods = compiler.getScriptMethods(); + for (MethodDescriptor m : methods) { + try { + m.getReturnType(); + if (className.equals(m.getName())) { + constructorDetected = true; + break; + } + } catch (Exception e) { + log.warn("could not find return type " + m); + } + } + if (!constructorDetected) { + javaFile.addMethod(createConstructor(compiler, className, superclassIsJAXXObject)); + javaFile.addMethod(createConstructorWithInitialContext(compiler, className, superclassIsJAXXObject)); + } + + javaFile.addMethod(createInitializer(compiler)); + javaFile.addMethod(GET_JAXX_OBJECT_DESCRIPTOR_METHOD); + + javaFile.addBodyCode(compiler.getBodyCode().toString()); + + String dataBindingInitNode = null; + String simpleBindingInitNode = null; + + String eol = JAXXCompiler.getLineSeparator(); + JavaFileGenerator generator = new JavaFileGenerator(eol, true); + + DataBinding[] bindings; + + bindings = compiler.getBindingHelper().getSimpleBindings(); + if (bindings.length > 0) { + + // get data binding register code + + StringBuilder initCode = new StringBuilder(); + + for (DataBinding binding : bindings) { + + // ce n'est pas un binding, on enregistre le code d'init (si il existe) + + if (binding.getInitDataBinding() != null) { + initCode.append(binding.getInitDataBinding()); + } + } + + if (initCode.length() > 0) { + simpleBindingInitNode = "// apply " + bindings.length + " property setters " + eol + initCode.toString().trim(); + } + } + + bindings = compiler.getBindingHelper().getDataBindings(); + + boolean hasDataBindings = bindings.length > 0; + + if (hasDataBindings) { + + javaFile.addImport(JAXXBinding.class); + javaFile.addSimpleField(BINDINGS_FIELD); + javaFile.addMethod(REGISTER_DATA_BINDING_METHOD); + + // get data binding register code + + StringBuilder initCode = new StringBuilder(); + + for (DataBinding binding : bindings) { + + String constantId = binding.getConstantId(); + + // add the data binding constant Id + + compiler.addSimpleField(new JavaField((constantId.startsWith("BINDING_$") ? PRIVATE : PUBLIC) | FINAL | STATIC, String.class.getSimpleName(), constantId, false, TypeManager.getJavaCode(binding.getRealId()))); + + // register the binding + + List<JavaMethod> bMethods = binding.getMethods(); + + bMethods.add(0, new JavaMethod(PUBLIC, "void", "removeDataBinding", new JavaArgument[0], new String[0], binding.getRemoveListenerCode(), true)); + bMethods.add(0, new JavaMethod(PUBLIC, "void", "processDataBinding", new JavaArgument[0], new String[0], binding.getProcessDataBinding(), true)); + bMethods.add(0, new JavaMethod(PUBLIC, "void", "applyDataBinding", new JavaArgument[0], new String[0], binding.getAddListenerCode(), true)); + + initCode.append("registerDataBinding(new ").append(JAXXBinding.class.getSimpleName()).append("(").append(binding.getConstantId()).append(") {").append(eol); + for (JavaMethod m : bMethods) { + initCode.append(eol).append(JavaFileGenerator.indent(generator.generateMethod(m), 4, false, eol)).append(eol); + } + initCode.append("});").append(eol); + + if (binding.getInitDataBinding() != null) { + initCode.append(binding.getInitDataBinding()); + } + } + + dataBindingInitNode = "// registers " + bindings.length + " data bindings" + eol + initCode.toString().trim(); + } + + javaFile.addMethod(createCompleteSetupMethod(compiler, javaFile, simpleBindingInitNode, dataBindingInitNode)); + + javaFile.addMethod(createApplyDataBindingMethod(superclassIsJAXXObject, hasDataBindings)); + javaFile.addMethod(createProcessDataBindingMethod(superclassIsJAXXObject, hasDataBindings)); + javaFile.addMethod(createRemoveDataBindingMethod(superclassIsJAXXObject, hasDataBindings)); + + addEventHandlers(compiler, javaFile); + } + + /*---------------------------------------------------------------------------------*/ + /*-- Create fields ----------------------------------------------------------------*/ + /*---------------------------------------------------------------------------------*/ + protected JavaField createJAXXObjectDescriptorField(JAXXCompiler compiler, JavaFile javaFile) { + try { + JAXXObjectDescriptor descriptor = compiler.getJAXXObjectDescriptor(); + String data = Base64Coder.serialize(descriptor, true); + /*ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + ObjectOutputStream out = new ObjectOutputStream(new GZIPOutputStream(buffer)); + out.writeObject(descriptor); + out.close(); + // the use of the weird deprecated constructor is deliberate -- we need to store the data as a String + // in the compiled class file, since byte array initialization is horribly inefficient compared to + // String initialization. So we store the bytes in the String, and we quite explicitly want a 1:1 + // mapping between bytes and chars, with the high byte of the char set to zero. We can then safely + // reconstitute the original byte[] at a later date. This is unquestionably an abuse of the String + // type, but if we could efficiently store a byte[] we wouldn't have to do this. + String data = new String(buffer.toByteArray(), 0);*/ + + int sizeLimit = 65000; // constant strings are limited to 64K, and I'm not brave enough to push right up to the limit + if (data.length() < sizeLimit) { + return newField(PRIVATE | STATIC | FINAL, "String", "$jaxxObjectDescriptor", false, TypeManager.getJavaCode(data)); + } else { + StringBuffer initializer = new StringBuffer(); + for (int i = 0; i < data.length(); i += sizeLimit) { + String name = "$jaxxObjectDescriptor" + i; + javaFile.addField(new JavaField(PRIVATE | STATIC, "String", name, false, + TypeManager.getJavaCode(data.substring(i, Math.min(i + sizeLimit, data.length()))))); + if (initializer.length() > 0) { + initializer.append(" + "); + } + initializer.append("String.valueOf(").append(name).append(")"); + } + return newField(PRIVATE | STATIC | FINAL, "String", "$jaxxObjectDescriptor", false, initializer.toString()); + } + } catch (IOException e) { + throw new RuntimeException("Internal error: can't-happen error", e); + } + } + + /*---------------------------------------------------------------------------------*/ + /*-- Create methods ---------------------------------------------------------------*/ + /*---------------------------------------------------------------------------------*/ + protected void addPropertyChangeSupport(CompiledObject root, JavaFile javaFile) { + ClassDescriptor currentClass = root.getObjectClass(); + MethodDescriptor firePropertyChange = null; + while (firePropertyChange == null && currentClass != null) { + try { + firePropertyChange = currentClass.getDeclaredMethodDescriptor("firePropertyChange", ClassDescriptorLoader.getClassDescriptor(String.class), + ClassDescriptorLoader.getClassDescriptor(Object.class), + ClassDescriptorLoader.getClassDescriptor(Object.class)); + + } catch (NoSuchMethodException e) { + currentClass = currentClass.getSuperclass(); + } + } + + int modifiers = firePropertyChange != null ? firePropertyChange.getModifiers() : 0; + if (isPublic(modifiers)) { + // we have all the support we need + return; + } + if (isProtected(modifiers)) { + // there is property change support but the firePropertyChange method is protected + javaFile.addMethod(FIRE_PROPERTY_CHANGE_METHOD); + } else { + // either no support at all or firePropertyChange isn't accessible + javaFile.addImport(PropertyChangeListener.class); + javaFile.addImport(PropertyChangeSupport.class); + + javaFile.addField(PROPERTY_CHANGE_SUPPORT_FIELD); + javaFile.addMethod(GET_PROPERTY_CHANGE_SUPPORT_METHOD); + javaFile.addMethod(ADD_PROPERTY_CHANGE_SUPPORT_METHOD); + javaFile.addMethod(ADD_PROPERTY_CHANGE_SUPPORT_NAMED_METHOD); + javaFile.addMethod(REMOVE_PROPERTY_CHANGE_SUPPORT_METHOD); + javaFile.addMethod(REMOVE_PROPERTY_CHANGE_SUPPORT_NAMED_METHOD); + javaFile.addMethod(FIRE_PROPERTY_CHANGE_NAMED_METHOD); + } + } + + protected void addEventHandlers(JAXXCompiler compiler, JavaFile javaFile) { + for (Map.Entry<String, Map<ClassDescriptor, List<EventHandler>>> e1 : compiler.getEventHandlers().entrySet()) { + // outer loop is iterating over different objects (well, technically, different Java expressions) + for (Map.Entry<ClassDescriptor, List<EventHandler>> e2 : e1.getValue().entrySet()) { + // iterate over different types of listeners for this particular object (MouseListener, ComponentListener, etc.) + for (EventHandler handler : e2.getValue()) { + // iterate over individual event handlers of a single type + String methodName = compiler.getEventHandlerMethodName(handler); + MethodDescriptor listenerMethod = handler.getListenerMethod(); + if (listenerMethod.getParameterTypes().length != 1) { + throw new CompilerException("Expected event handler " + listenerMethod.getName() + " of class " + handler.getListenerClass() + " to have exactly one argument"); + } + javaFile.addMethod(newMethod(PUBLIC, "void", methodName, handler.getJavaCode(), false, + new JavaArgument(JAXXCompiler.getCanonicalName(listenerMethod.getParameterTypes()[0]), "event"))); + } + } + } + } + + protected JavaMethod createConstructor(JAXXCompiler compiler, String className, boolean superclassIsJAXXObject) throws CompilerException { + StringBuffer code = new StringBuffer(); + String constructorParams = compiler.getRootObject().getConstructorParams(); + String eol = JAXXCompiler.getLineSeparator(); + if (constructorParams != null) { + code.append(" super(").append(constructorParams).append(");").append(eol); + } else { + if (superclassIsJAXXObject) { + code.append(" super();").append(eol); + } + } + code.append("$initialize();"); + code.append(eol); + return newMethod(PUBLIC, null, className, code.toString(), false); + } + + protected JavaMethod createConstructorWithInitialContext(JAXXCompiler compiler, String className, boolean superclassIsJAXXObject) throws CompilerException { + StringBuffer code = new StringBuffer(); + String constructorParams = compiler.getRootObject().getConstructorParams(); + String eol = JAXXCompiler.getLineSeparator(); + if (constructorParams != null) { + if (superclassIsJAXXObject) { + //TODO-TC20091127 This MUST be a convention in JAXX : all specialized constructor must a second + //TODO constructor with extra first parameter as parentContext + constructorParams = "parentContext, " + constructorParams; + } + code.append(" super(").append(constructorParams).append(");").append(eol); + } else { + if (superclassIsJAXXObject) { + code.append(" super(parentContext);").append(eol); + } + } + if (!superclassIsJAXXObject) { + code.append(Util.class.getSimpleName()).append(".initContext(this, parentContext);"); + code.append(eol); + } + code.append("$initialize();"); + code.append(eol); + return newMethod(PUBLIC, null, className, code.toString(), false, new JavaArgument(JAXXContext.class.getSimpleName(), "parentContext")); + } + + public JavaMethod createInitializer(JAXXCompiler compiler) throws CompilerException { + String eol = JAXXCompiler.getLineSeparator(); + StringBuffer code = new StringBuffer(); + CompiledObject root = compiler.getRootObject(); + code.append("if (allComponentsCreated || !contextInitialized) {"); + code.append(eol); + code.append(" return;"); + code.append(eol); + code.append("}"); + code.append(eol); + //TODO-TC20091025 we should remove this if no used anywhere + code.append("$objectMap.put(").append(TypeManager.getJavaCode(root.getId())).append(", this);"); + code.append(eol); + + Iterator<CompiledObject> i = compiler.getObjectCreationOrder(); + boolean lastWasMethodCall = false; + //TODO-TC20091025 should do init of root first ? +// root.getDecorator().createInitializer(compiler, root, root, code, lastWasMethodCall); + while (i.hasNext()) { + CompiledObject object = i.next(); + if (object == root) { + continue; + } + CompiledObjectDecorator decorator = object.getDecorator(); + lastWasMethodCall = decorator.createInitializer(compiler, root, object, code, lastWasMethodCall); + } + root.getDecorator().createInitializer(compiler, root, root, code, lastWasMethodCall); + if (compiler.getInitializer().length() > 0) { + code.append(compiler.getInitializer()); + } + code.append("$completeSetup();"); + code.append(eol); + return newMethod(PRIVATE, "void", "$initialize", code.toString(), false); + } + + protected JavaMethod createCompleteSetupMethod(JAXXCompiler compiler, JavaFile javaFile, String simpleBindingInitNode, String dataBindingInitNode) { + StringBuffer code = new StringBuffer(); + code.append("allComponentsCreated = true;"); + String eol = JAXXCompiler.getLineSeparator(); + code.append(eol); + for (CompiledObject object : compiler.getObjects().values()) { + CompiledObjectDecorator decorator = object.getDecorator(); + code.append(decorator.createCompleteSetupMethod(compiler, object, javaFile)); + } + + if (simpleBindingInitNode != null && !simpleBindingInitNode.isEmpty()) { + code.append(simpleBindingInitNode).append(eol); + } + + if (dataBindingInitNode != null && !dataBindingInitNode.isEmpty()) { + code.append(dataBindingInitNode).append(eol); + } + + if (compiler.getLateInitializer().length() > 0) { + code.append("// late initializer").append(eol); + code.append(compiler.getLateInitializer()).append(eol); + } + //TC-20090313 add an extra method after complete setup + MethodDescriptor method = compiler.getScriptMethod("$afterCompleteSetup"); + if (method != null) { + code.append("$afterCompleteSetup();").append(eol); + } + return newMethod(PRIVATE, "void", "$completeSetup", code.toString(), false); + } + + protected JavaMethod createApplyDataBindingMethod(boolean superclassIsJAXXObject, boolean haveBinding) { + StringBuilder buffer = new StringBuilder(); + String eol = JAXXCompiler.getLineSeparator(); + + if (haveBinding) { + if (superclassIsJAXXObject) + buffer.append("if (allComponentsCreated && $bindings.containsKey($binding)) {").append(eol); + else { + buffer.append("if ($bindings.containsKey($binding)) {").append(eol); + } + buffer.append(" $bindings.get($binding).applyDataBinding();").append(eol); + buffer.append("}"); + + } + if (superclassIsJAXXObject) { + + if (haveBinding) { + buffer.append(" else {").append(eol).append(" "); + } + buffer.append("super.applyDataBinding($binding);").append(eol); + + if (haveBinding) { + buffer.append(" return;").append(eol).append("}"); + } + + } + buffer.append(eol).append("processDataBinding($binding);"); + return newMethod(PUBLIC, "void", "applyDataBinding", buffer.toString(), true, + new JavaArgument("String", "$binding")); + } + + protected JavaMethod createRemoveDataBindingMethod(boolean superclassIsJAXXObject, boolean haveBinding) { + StringBuilder buffer = new StringBuilder(); + String eol = JAXXCompiler.getLineSeparator(); + + if (haveBinding) { + + if (superclassIsJAXXObject) { + buffer.append("if (allComponentsCreated && $bindings.containsKey($binding)) {").append(eol); + } else { + buffer.append("if ($bindings.containsKey($binding)) {").append(eol); + } + buffer.append(" $bindings.get($binding).removeDataBinding();").append(eol); + buffer.append("}"); + + + } + if (superclassIsJAXXObject) { + + if (haveBinding) { + buffer.append(" else {").append(eol).append(" "); + } + buffer.append("super.removeDataBinding($binding);").append(eol); + + if (haveBinding) { + buffer.append("}"); + } + } + return newMethod(PUBLIC, "void", "removeDataBinding", buffer.toString(), true, + new JavaArgument("String", "$binding")); + } + + protected JavaMethod createProcessDataBindingMethod(boolean superclassIsJAXXObject, boolean haveBinding) { + StringBuffer code = new StringBuffer(); + String eol = JAXXCompiler.getLineSeparator(); + //boolean superclassIsJAXXObject = ClassDescriptorLoader.getClassDescriptor(JAXXObject.class).isAssignableFrom(compiler.getRootObject().getObjectClass()); + // the force parameter forces the update to happen even if it is already in activeBindings. This + // is used on superclass invocations b/c by the time the call gets to the superclass, it is already + // marked active and would otherwise be skipped + if (haveBinding) { + code.append(" if (!$force && $activeBindings.contains($binding)) { "); + code.append(eol); + code.append(" return;").append(eol); + code.append("}").append(eol); + code.append("$activeBindings.add($binding);").append(eol); + code.append("try {").append(eol); + if (superclassIsJAXXObject) { + code.append(" if (allComponentsCreated && $bindings.containsKey($binding)) {").append(eol); + } else { + code.append(" if ($bindings.containsKey($binding)) {").append(eol); + } + code.append(" $bindings.get($binding).processDataBinding();").append(eol); + code.append(" }"); + if (superclassIsJAXXObject) { + code.append(" else {").append(eol); + code.append(" super.processDataBinding($binding, true);").append(eol); + code.append(" }"); + } + code.append(eol); + code.append("} finally {").append(eol); + code.append(" $activeBindings.remove($binding);").append(eol); + code.append("}").append(eol); + } else if (superclassIsJAXXObject) { + code.append("super.processDataBinding($binding, true);").append(eol); + } + return newMethod(PUBLIC, "void", "processDataBinding", code.toString(), superclassIsJAXXObject, + new JavaArgument("String", "$binding"), new JavaArgument("boolean", "$force")); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/SwingFinalizer.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/SwingFinalizer.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/SwingFinalizer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,53 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.finalizers; - -import jaxx.compiler.java.JavaArgument; -import jaxx.compiler.java.JavaFile; -import jaxx.compiler.java.JavaFileGenerator; -import jaxx.compiler.*; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.runtime.swing.Application; - -import java.lang.reflect.Modifier; - -/** @author chemit */ -public class SwingFinalizer implements JAXXCompilerFinalizer { - - @Override - public void finalizeCompiler(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) { - } - - @Override - public void prepareJavaFile(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) throws ClassNotFoundException { - - if (ClassDescriptorLoader.getClassDescriptor(Application.class.getName()).isAssignableFrom(root.getObjectClass()) && !compiler.isMainDeclared()) { - // TODO: check for existing main method first - javaFile.addMethod(JavaFileGenerator.newMethod( - Modifier.PUBLIC | Modifier.STATIC, - "void", - "main", - "SwingUtilities.invokeLater(new Runnable() { public void run() { new " + className + "().setVisible(true); } });", - false, - new JavaArgument("String[]", "arg"))); - } - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/SwingFinalizer.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/SwingFinalizer.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/SwingFinalizer.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/SwingFinalizer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,53 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.finalizers; + +import jaxx.compiler.java.JavaArgument; +import jaxx.compiler.java.JavaFile; +import jaxx.compiler.java.JavaFileGenerator; +import jaxx.compiler.*; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.runtime.swing.Application; + +import java.lang.reflect.Modifier; + +/** @author chemit */ +public class SwingFinalizer implements JAXXCompilerFinalizer { + + @Override + public void finalizeCompiler(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) { + } + + @Override + public void prepareJavaFile(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) throws ClassNotFoundException { + + if (ClassDescriptorLoader.getClassDescriptor(Application.class.getName()).isAssignableFrom(root.getObjectClass()) && !compiler.isMainDeclared()) { + // TODO: check for existing main method first + javaFile.addMethod(JavaFileGenerator.newMethod( + Modifier.PUBLIC | Modifier.STATIC, + "void", + "main", + "SwingUtilities.invokeLater(new Runnable() { public void run() { new " + className + "().setVisible(true); } });", + false, + new JavaArgument("String[]", "arg"))); + } + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/ValidatorFinalizer.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/ValidatorFinalizer.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/ValidatorFinalizer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,119 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.finalizers; - -import jaxx.compiler.java.JavaArgument; -import jaxx.compiler.java.JavaField; -import jaxx.compiler.java.JavaFile; -import jaxx.compiler.java.JavaFileGenerator; -import jaxx.compiler.*; -import jaxx.compiler.CompiledObject.ChildRef; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.tags.validator.BeanValidatorHandler; -import jaxx.compiler.tags.validator.BeanValidatorHandler.CompiledBeanValidator; - -import java.util.List; - -import jaxx.compiler.types.TypeManager; -import jaxx.runtime.SwingUtil; - -/** @author chemit */ -public class ValidatorFinalizer implements JAXXCompilerFinalizer { - - protected static final JavaField VALIDATOR_IDS_FIELD = JavaFileGenerator.newField(java.lang.reflect.Modifier.PROTECTED, - "java.util.List<String>", "validatorIds", true, "new ArrayList<String>()"); - - @Override - public void finalizeCompiler(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) { - - if (!BeanValidatorHandler.hasValidator(compiler)) { - return; - } - - for (CompiledObject object : compiler.getObjects().values()) { - List<ChildRef> childs = object.getChilds(); - if (childs == null || childs.isEmpty()) { - continue; - } - for (ChildRef child : childs) { - String javaCode = child.getChildJavaCode(); - // some validators are defined on this object - boolean found = BeanValidatorHandler.isComponentUsedByValidator(compiler, child.getChild().getId()); - if (found) { - // box the child component in a JxLayer - child.setChildJavaCode(SwingUtil.class.getSimpleName() + ".boxComponentWithJxLayer(" + javaCode + ")"); - } - } - } - String eol = JAXXCompiler.getLineSeparator(); - // register validator - compiler.appendLateInitializer("// validator setup" + eol); - for (CompiledBeanValidator validator : BeanValidatorHandler.getValidators(compiler)) { - String id = TypeManager.getJavaCode(validator.getId()); - compiler.appendLateInitializer("validatorIds.add(" + id + ");"); - compiler.appendLateInitializer(eol); - compiler.appendLateInitializer("getValidator(" + id + ").installUIs();"); - compiler.appendLateInitializer(eol); - compiler.appendLateInitializer("getValidator(" + id + ").reloadBean();"); - //compiler.appendLateInitializer("getValidator(" + id + ").validate();"); - compiler.appendLateInitializer(eol); - } - compiler.appendLateInitializer("validatorIds = java.util.Collections.unmodifiableList(validatorIds);"); - compiler.appendLateInitializer(eol); - } - - @Override - public void prepareJavaFile(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) throws ClassNotFoundException { - if (!BeanValidatorHandler.hasValidator(compiler)) { - return; - } - Class<?> validatorClass = compiler.getConfiguration().getValidatorClass(); - String validatorFQN = validatorClass.getName(); - javaFile.addImport(validatorFQN); - - //TODO use the specific JAXXValidator interface (swing, gwt,...) - Class<?> validatorInterface = jaxx.runtime.JAXXValidator.class; - - if (javaFile.isSuperclassIsJAXXObject()) { - ClassDescriptor superClass = ClassDescriptorLoader.getClassDescriptor(javaFile.getSuperClass()); - boolean parentIsValidator = ClassDescriptorLoader.getClassDescriptor(validatorInterface).isAssignableFrom(superClass); - - if (parentIsValidator) { - // nothing to generate (use the parent directly) - return; - } - } - - // add JAXXValidator interface - javaFile.addInterface(JAXXCompiler.getCanonicalName(validatorInterface)); - - // implements JAXXValidator - javaFile.addField(VALIDATOR_IDS_FIELD); - javaFile.addMethod(JavaFileGenerator.newMethod( - java.lang.reflect.Modifier.PUBLIC, - validatorFQN + "<?>", - "getValidator", - "return (" + validatorFQN + "<?>) (validatorIds.contains(validatorId) ? getObjectById(validatorId) : null);", - true, - new JavaArgument("String", "validatorId"))); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/ValidatorFinalizer.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/ValidatorFinalizer.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/ValidatorFinalizer.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/ValidatorFinalizer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,119 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.finalizers; + +import jaxx.compiler.java.JavaArgument; +import jaxx.compiler.java.JavaField; +import jaxx.compiler.java.JavaFile; +import jaxx.compiler.java.JavaFileGenerator; +import jaxx.compiler.*; +import jaxx.compiler.CompiledObject.ChildRef; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.tags.validator.BeanValidatorHandler; +import jaxx.compiler.tags.validator.BeanValidatorHandler.CompiledBeanValidator; + +import java.util.List; + +import jaxx.compiler.types.TypeManager; +import jaxx.runtime.SwingUtil; + +/** @author chemit */ +public class ValidatorFinalizer implements JAXXCompilerFinalizer { + + protected static final JavaField VALIDATOR_IDS_FIELD = JavaFileGenerator.newField(java.lang.reflect.Modifier.PROTECTED, + "java.util.List<String>", "validatorIds", true, "new ArrayList<String>()"); + + @Override + public void finalizeCompiler(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) { + + if (!BeanValidatorHandler.hasValidator(compiler)) { + return; + } + + for (CompiledObject object : compiler.getObjects().values()) { + List<ChildRef> childs = object.getChilds(); + if (childs == null || childs.isEmpty()) { + continue; + } + for (ChildRef child : childs) { + String javaCode = child.getChildJavaCode(); + // some validators are defined on this object + boolean found = BeanValidatorHandler.isComponentUsedByValidator(compiler, child.getChild().getId()); + if (found) { + // box the child component in a JxLayer + child.setChildJavaCode(SwingUtil.class.getSimpleName() + ".boxComponentWithJxLayer(" + javaCode + ")"); + } + } + } + String eol = JAXXCompiler.getLineSeparator(); + // register validator + compiler.appendLateInitializer("// validator setup" + eol); + for (CompiledBeanValidator validator : BeanValidatorHandler.getValidators(compiler)) { + String id = TypeManager.getJavaCode(validator.getId()); + compiler.appendLateInitializer("validatorIds.add(" + id + ");"); + compiler.appendLateInitializer(eol); + compiler.appendLateInitializer("getValidator(" + id + ").installUIs();"); + compiler.appendLateInitializer(eol); + compiler.appendLateInitializer("getValidator(" + id + ").reloadBean();"); + //compiler.appendLateInitializer("getValidator(" + id + ").validate();"); + compiler.appendLateInitializer(eol); + } + compiler.appendLateInitializer("validatorIds = java.util.Collections.unmodifiableList(validatorIds);"); + compiler.appendLateInitializer(eol); + } + + @Override + public void prepareJavaFile(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) throws ClassNotFoundException { + if (!BeanValidatorHandler.hasValidator(compiler)) { + return; + } + Class<?> validatorClass = compiler.getConfiguration().getValidatorClass(); + String validatorFQN = validatorClass.getName(); + javaFile.addImport(validatorFQN); + + //TODO use the specific JAXXValidator interface (swing, gwt,...) + Class<?> validatorInterface = jaxx.runtime.JAXXValidator.class; + + if (javaFile.isSuperclassIsJAXXObject()) { + ClassDescriptor superClass = ClassDescriptorLoader.getClassDescriptor(javaFile.getSuperClass()); + boolean parentIsValidator = ClassDescriptorLoader.getClassDescriptor(validatorInterface).isAssignableFrom(superClass); + + if (parentIsValidator) { + // nothing to generate (use the parent directly) + return; + } + } + + // add JAXXValidator interface + javaFile.addInterface(JAXXCompiler.getCanonicalName(validatorInterface)); + + // implements JAXXValidator + javaFile.addField(VALIDATOR_IDS_FIELD); + javaFile.addMethod(JavaFileGenerator.newMethod( + java.lang.reflect.Modifier.PUBLIC, + validatorFQN + "<?>", + "getValidator", + "return (" + validatorFQN + "<?>) (validatorIds.contains(validatorId) ? getObjectById(validatorId) : null);", + true, + new JavaArgument("String", "validatorId"))); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaArgument.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaArgument.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaArgument.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,76 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.java; - -/** - * Represents an argument to a <code>JavaMethod</code>. - * - * @see JavaMethod - */ -public class JavaArgument extends JavaElement { - - private String type; - private boolean isFinal; - - /** - * Creates a new <code>JavaArgument</code> with the specified name and type. For example, the method <code>main()</code> - * might have a <code>JavaArgument</code> with a name of <code>"arg"</code> and a type of <code>"java.lang.String[]"</code>. - * - * @param type the argument's type, as it would appear in Java source code - * @param name the argument's name - */ - public JavaArgument(String type, String name) { - this(type, name, false); - } - - /** - * Creates a new <code>JavaArgument</code> with the specified name, type, and finality. For example, the method <code>main()</code> - * might have a <code>JavaArgument</code> with a name of <code>"arg"</code> and a type of <code>"java.lang.String[]"</code>. The - * <code>isFinal</code> parameter allows the presence of the <code>final</code> keyword on the argument to be controlled. - * - * @param type the argument's type, as it would appear in Java source code - * @param name the argument's name - * @param isFinal <code>true</code> if the argument should be marked final - */ - public JavaArgument(String type, String name, boolean isFinal) { - super(0, name); - this.type = type; - this.isFinal = isFinal; - } - - /** - * Returns the argument's type as it would be represented in Java source code. - * - * @return the argument's type - */ - public String getType() { - return type; - } - - /** - * Returns <code>true</code> if the <code>final</code> keyword should appear before the argument. - * - * @return <code>true</code> if the argument is final - */ - public boolean isFinal() { - return isFinal; - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaArgument.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaArgument.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaArgument.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaArgument.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,76 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.java; + +/** + * Represents an argument to a <code>JavaMethod</code>. + * + * @see JavaMethod + */ +public class JavaArgument extends JavaElement { + + private String type; + private boolean isFinal; + + /** + * Creates a new <code>JavaArgument</code> with the specified name and type. For example, the method <code>main()</code> + * might have a <code>JavaArgument</code> with a name of <code>"arg"</code> and a type of <code>"java.lang.String[]"</code>. + * + * @param type the argument's type, as it would appear in Java source code + * @param name the argument's name + */ + public JavaArgument(String type, String name) { + this(type, name, false); + } + + /** + * Creates a new <code>JavaArgument</code> with the specified name, type, and finality. For example, the method <code>main()</code> + * might have a <code>JavaArgument</code> with a name of <code>"arg"</code> and a type of <code>"java.lang.String[]"</code>. The + * <code>isFinal</code> parameter allows the presence of the <code>final</code> keyword on the argument to be controlled. + * + * @param type the argument's type, as it would appear in Java source code + * @param name the argument's name + * @param isFinal <code>true</code> if the argument should be marked final + */ + public JavaArgument(String type, String name, boolean isFinal) { + super(0, name); + this.type = type; + this.isFinal = isFinal; + } + + /** + * Returns the argument's type as it would be represented in Java source code. + * + * @return the argument's type + */ + public String getType() { + return type; + } + + /** + * Returns <code>true</code> if the <code>final</code> keyword should appear before the argument. + * + * @return <code>true</code> if the argument is final + */ + public boolean isFinal() { + return isFinal; + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaElement.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaElement.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaElement.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,97 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.java; - -import java.lang.reflect.Modifier; - -/** - * Base Java element - * @author chemit - * @since 2.0.0 - */ -public abstract class JavaElement { - -// private String lineSeparator; - private String name; - private int modifiers; - - public JavaElement(int modifiers, String name) { - this.modifiers = modifiers; - this.name = name; - } - - public final int getModifiers() { - return modifiers; - } - - public final void setModifiers(int modifiers) { - this.modifiers = modifiers; - } - - public final String getName() { - return name; - } - - public final void setName(String className) { - this.name = className; - } - - public final String getModifiersText() { - if (modifiers == 0) { - return ""; - } else { - return Modifier.toString(modifiers) + ' '; - } - } - -// public final String getLineSeparator() { -// if (lineSeparator == null) { -// lineSeparator = JAXXCompiler.getLineSeparator(); -// } -// return lineSeparator; -// } -// -// public static String addIndentation(String source, int indentation, String lineSeparator) { -// return indent(source, indentation, false, lineSeparator); -// } -// -// public static String setIndentation(String source, int indentation, String lineSeparator) { -// return indent(source, indentation, true, lineSeparator); -// } -// -// public static String indent(String source, int indentation, boolean trim, String lineSeparator) { -// if (trim) { -// source = source.trim(); -// } -// char[] spaces = new char[indentation]; -// Arrays.fill(spaces, ' '); -// StringBuffer result = new StringBuffer(); -// String[] lines = source.split(System.getProperty("line.separator") + "|\n"); -// for (int i = 0; i < lines.length; i++) { -// if (i > 0) { -// result.append(lineSeparator); -// } -// result.append(spaces); -// result.append(trim ? lines[i].trim() : lines[i]); -// } -// return result.toString(); -// } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaElement.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaElement.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaElement.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaElement.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,97 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.java; + +import java.lang.reflect.Modifier; + +/** + * Base Java element + * @author chemit + * @since 2.0.0 + */ +public abstract class JavaElement { + +// private String lineSeparator; + private String name; + private int modifiers; + + public JavaElement(int modifiers, String name) { + this.modifiers = modifiers; + this.name = name; + } + + public final int getModifiers() { + return modifiers; + } + + public final void setModifiers(int modifiers) { + this.modifiers = modifiers; + } + + public final String getName() { + return name; + } + + public final void setName(String className) { + this.name = className; + } + + public final String getModifiersText() { + if (modifiers == 0) { + return ""; + } else { + return Modifier.toString(modifiers) + ' '; + } + } + +// public final String getLineSeparator() { +// if (lineSeparator == null) { +// lineSeparator = JAXXCompiler.getLineSeparator(); +// } +// return lineSeparator; +// } +// +// public static String addIndentation(String source, int indentation, String lineSeparator) { +// return indent(source, indentation, false, lineSeparator); +// } +// +// public static String setIndentation(String source, int indentation, String lineSeparator) { +// return indent(source, indentation, true, lineSeparator); +// } +// +// public static String indent(String source, int indentation, boolean trim, String lineSeparator) { +// if (trim) { +// source = source.trim(); +// } +// char[] spaces = new char[indentation]; +// Arrays.fill(spaces, ' '); +// StringBuffer result = new StringBuffer(); +// String[] lines = source.split(System.getProperty("line.separator") + "|\n"); +// for (int i = 0; i < lines.length; i++) { +// if (i > 0) { +// result.append(lineSeparator); +// } +// result.append(spaces); +// result.append(trim ? lines[i].trim() : lines[i]); +// } +// return result.toString(); +// } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaField.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaField.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaField.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,212 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.java; - -import java.lang.reflect.Modifier; -import java.util.Comparator; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Represents a field in a Java source file being generated for output. <code>JavaFields</code> are created - * and added to a {@link JavaFile}, which can then output Java source code. - */ -public class JavaField extends JavaElement implements Comparable<JavaField> { - - /** - * Field comparator - */ - static final JavaFieldComparator COMPARATOR = new JavaFieldComparator(); - /** - * type of field (fqn) - */ - private String type; - /** - * initializer of field (can be null) - */ - private String initializer; - /** - * flag to known where a field overrides a super-field - */ - private boolean override; - - /** - * Constructs a new <code>JavaField</code>. The <code>modifiers</code> parameter is a bit mask of the - * constants from {@link java.lang.reflect.Modifier}, and the <code>type</code> of the field should be - * represented as it would appear in Java source code. - * - * @param modifiers the modifier keywords that should appear as part of the field's declaration - * @param type the type of the field as it would appear in Java source code - * @param name the field's name - * @param override - */ - public JavaField(int modifiers, String type, String name, boolean override) { - this(modifiers, type, name, override, null); - } - - /** - * Constructs a new <code>JavaField</code>. The <code>modifiers</code> parameter is a bit mask of the - * constants from <code>java.lang.reflect.Modifier</code>, and the <code>type</code> of the field should be - * represented as it would appear in Java source code. The <code>initializer</code> is the initial - * value of the field as it would appear in Java source code, or <code>null</code> to leave it at the - * default value. - * - * @param modifiers the modifier keywords that should appear as part of the field's declaration - * @param type the type of the field as it would appear in Java source code - * @param name the field's name - * @param override {@code true} if method should be marked as overriden - * @param initializer the initial value of the field, as it would appear in Java source code - */ - public JavaField(int modifiers, String type, String name, boolean override, String initializer) { - super(modifiers, name); - this.type = type; - this.initializer = initializer; - this.override = override; - } - - /** - * Returns the field's type, as it would be represented in Java source code. - * - * @return the field's type - */ - public String getType() { - return type; - } - - public boolean isOverride() { - return override; - } - - public void setOverride(boolean override) { - this.override = override; - } - - public String getInitializer() { - return initializer; - } - - @Override - public int compareTo(JavaField o) { - return COMPARATOR.compare(this, o); - } - - static class JavaFieldComparator implements Comparator<JavaField> { - - @Override - public int compare(JavaField o1, JavaField o2) { - int result; - if ((result = compareStatic(o1, o2)) != 0) { - // les deux fields ne sont pas comparables sur static - return result; - } - // data sources must be on the last after all other fields - if ((result = compareDataSource(o1, o2)) != 0) { - // les deux fields ne sont pas comparables sur datasource - return result; - } - // same static - if ((result = compareVisibility(o1, o2)) != 0) { - // les deux fields ne sont pas de la même visibilité - return result; - } - // sort on return type - if ((result = compareReturnType(o1, o2)) != 0) { - // les deux fields ne sont pas du même type - return result; - } - // same visibility, test name - return compareName(o1.getName(), o2.getName()); - } - - public int compareStatic(JavaField o1, JavaField o2) { - // first comparator modifiers : static always before none static - if (Modifier.isStatic(o1.getModifiers()) && !Modifier.isStatic(o2.getModifiers())) { - return -1; - } - if (!Modifier.isStatic(o1.getModifiers()) && Modifier.isStatic(o2.getModifiers())) { - return 1; - } - return 0; - } - - public int compareReturnType(JavaField o1, JavaField o2) { - return o1.getType().compareTo(o2.getType()); - } - - public int compareDataSource(JavaField o1, JavaField o2) { - // first comparator modifiers : static always before none static - if (o1.getName().startsWith("$DataSource") && !o2.getName().startsWith("$DataSource")) { - return 1; - } - if (!o1.getName().startsWith("$DataSource") && o2.getName().startsWith("$DataSource")) { - return -1; - } - return 0; - } - - public int compareVisibility(JavaField o1, JavaField o2) { - // first comparator modifiers : static always before none static - if (!Modifier.isPublic(o1.getModifiers()) && Modifier.isPublic(o2.getModifiers())) { - return 1; - } - if (Modifier.isPublic(o1.getModifiers()) && !Modifier.isPublic(o2.getModifiers())) { - return -1; - } - if (Modifier.isProtected(o1.getModifiers()) && !Modifier.isProtected(o2.getModifiers())) { - return -1; - } - if (!Modifier.isProtected(o1.getModifiers()) && Modifier.isProtected(o2.getModifiers())) { - return 1; - } - if (Modifier.isPrivate(o1.getModifiers()) && !Modifier.isPrivate(o2.getModifiers())) { - return -1; - } - if (!Modifier.isPrivate(o1.getModifiers()) && Modifier.isPrivate(o2.getModifiers())) { - return 1; - } - return 0; - } - - static final Pattern NAME_PATTERN = Pattern.compile("(.+)([0-9]+)"); - - public int compareName(String n1, String n2) { - Matcher matcher1 = NAME_PATTERN.matcher(n1); - Matcher matcher2 = NAME_PATTERN.matcher(n2); - if (matcher1.matches() && matcher2.matches()) { - // les deux noms finissent par un nombre - String p1 = matcher1.group(1); - String p2 = matcher1.group(2); - int i = p1.compareTo(p2); - if (i != 0) { - // on est sur des noms de prefix différents, donc pas de tri sur les suffixes - return i; - } - // les deux noms doivent être triés sur les suffixes entiers - int i1 = Integer.valueOf(matcher1.group(2)); - int i2 = Integer.valueOf(matcher2.group(2)); - return i1 - i2; - } - - // les deux noms sont simplement comparé en alpha - return n1.compareTo(n2); - } - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaField.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaField.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaField.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaField.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,212 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.java; + +import java.lang.reflect.Modifier; +import java.util.Comparator; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Represents a field in a Java source file being generated for output. <code>JavaFields</code> are created + * and added to a {@link JavaFile}, which can then output Java source code. + */ +public class JavaField extends JavaElement implements Comparable<JavaField> { + + /** + * Field comparator + */ + static final JavaFieldComparator COMPARATOR = new JavaFieldComparator(); + /** + * type of field (fqn) + */ + private String type; + /** + * initializer of field (can be null) + */ + private String initializer; + /** + * flag to known where a field overrides a super-field + */ + private boolean override; + + /** + * Constructs a new <code>JavaField</code>. The <code>modifiers</code> parameter is a bit mask of the + * constants from {@link java.lang.reflect.Modifier}, and the <code>type</code> of the field should be + * represented as it would appear in Java source code. + * + * @param modifiers the modifier keywords that should appear as part of the field's declaration + * @param type the type of the field as it would appear in Java source code + * @param name the field's name + * @param override + */ + public JavaField(int modifiers, String type, String name, boolean override) { + this(modifiers, type, name, override, null); + } + + /** + * Constructs a new <code>JavaField</code>. The <code>modifiers</code> parameter is a bit mask of the + * constants from <code>java.lang.reflect.Modifier</code>, and the <code>type</code> of the field should be + * represented as it would appear in Java source code. The <code>initializer</code> is the initial + * value of the field as it would appear in Java source code, or <code>null</code> to leave it at the + * default value. + * + * @param modifiers the modifier keywords that should appear as part of the field's declaration + * @param type the type of the field as it would appear in Java source code + * @param name the field's name + * @param override {@code true} if method should be marked as overriden + * @param initializer the initial value of the field, as it would appear in Java source code + */ + public JavaField(int modifiers, String type, String name, boolean override, String initializer) { + super(modifiers, name); + this.type = type; + this.initializer = initializer; + this.override = override; + } + + /** + * Returns the field's type, as it would be represented in Java source code. + * + * @return the field's type + */ + public String getType() { + return type; + } + + public boolean isOverride() { + return override; + } + + public void setOverride(boolean override) { + this.override = override; + } + + public String getInitializer() { + return initializer; + } + + @Override + public int compareTo(JavaField o) { + return COMPARATOR.compare(this, o); + } + + static class JavaFieldComparator implements Comparator<JavaField> { + + @Override + public int compare(JavaField o1, JavaField o2) { + int result; + if ((result = compareStatic(o1, o2)) != 0) { + // les deux fields ne sont pas comparables sur static + return result; + } + // data sources must be on the last after all other fields + if ((result = compareDataSource(o1, o2)) != 0) { + // les deux fields ne sont pas comparables sur datasource + return result; + } + // same static + if ((result = compareVisibility(o1, o2)) != 0) { + // les deux fields ne sont pas de la même visibilité + return result; + } + // sort on return type + if ((result = compareReturnType(o1, o2)) != 0) { + // les deux fields ne sont pas du même type + return result; + } + // same visibility, test name + return compareName(o1.getName(), o2.getName()); + } + + public int compareStatic(JavaField o1, JavaField o2) { + // first comparator modifiers : static always before none static + if (Modifier.isStatic(o1.getModifiers()) && !Modifier.isStatic(o2.getModifiers())) { + return -1; + } + if (!Modifier.isStatic(o1.getModifiers()) && Modifier.isStatic(o2.getModifiers())) { + return 1; + } + return 0; + } + + public int compareReturnType(JavaField o1, JavaField o2) { + return o1.getType().compareTo(o2.getType()); + } + + public int compareDataSource(JavaField o1, JavaField o2) { + // first comparator modifiers : static always before none static + if (o1.getName().startsWith("$DataSource") && !o2.getName().startsWith("$DataSource")) { + return 1; + } + if (!o1.getName().startsWith("$DataSource") && o2.getName().startsWith("$DataSource")) { + return -1; + } + return 0; + } + + public int compareVisibility(JavaField o1, JavaField o2) { + // first comparator modifiers : static always before none static + if (!Modifier.isPublic(o1.getModifiers()) && Modifier.isPublic(o2.getModifiers())) { + return 1; + } + if (Modifier.isPublic(o1.getModifiers()) && !Modifier.isPublic(o2.getModifiers())) { + return -1; + } + if (Modifier.isProtected(o1.getModifiers()) && !Modifier.isProtected(o2.getModifiers())) { + return -1; + } + if (!Modifier.isProtected(o1.getModifiers()) && Modifier.isProtected(o2.getModifiers())) { + return 1; + } + if (Modifier.isPrivate(o1.getModifiers()) && !Modifier.isPrivate(o2.getModifiers())) { + return -1; + } + if (!Modifier.isPrivate(o1.getModifiers()) && Modifier.isPrivate(o2.getModifiers())) { + return 1; + } + return 0; + } + + static final Pattern NAME_PATTERN = Pattern.compile("(.+)([0-9]+)"); + + public int compareName(String n1, String n2) { + Matcher matcher1 = NAME_PATTERN.matcher(n1); + Matcher matcher2 = NAME_PATTERN.matcher(n2); + if (matcher1.matches() && matcher2.matches()) { + // les deux noms finissent par un nombre + String p1 = matcher1.group(1); + String p2 = matcher1.group(2); + int i = p1.compareTo(p2); + if (i != 0) { + // on est sur des noms de prefix différents, donc pas de tri sur les suffixes + return i; + } + // les deux noms doivent être triés sur les suffixes entiers + int i1 = Integer.valueOf(matcher1.group(2)); + int i2 = Integer.valueOf(matcher2.group(2)); + return i1 - i2; + } + + // les deux noms sont simplement comparé en alpha + return n1.compareTo(n2); + } + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaFile.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaFile.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaFile.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,204 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.java; - -import jaxx.compiler.types.TypeManager; - -import java.lang.reflect.Modifier; -import java.util.*; - -/** - * A Java source file being generated for output. Once the class is completely initialized, use the - * {@link #toString} method to generate source code for it. - */ -public class JavaFile extends JavaElement { - - protected static final String GETTER_PATTERN = "return %1$s;"; - protected static final String BOOLEAN_GETTER_PATTERN = "return %1$s !=null && %1$s;"; - protected static final String SETTER_PATTERN = "%1$s oldValue = this.%2$s;\nthis.%2$s = newValue;\nfirePropertyChange(%3$s, oldValue, newValue);"; - // protected static final String SETTER_PATTERN = "%1$s oldValue = this.%2$s;\nthis.%2$s = newValue;\nfirePropertyChange(\"%2$s\", oldValue, newValue);"; - private Set<String> imports = new HashSet<String>(); - private List<JavaField> fields = new ArrayList<JavaField>(); - private List<JavaMethod> methods = new ArrayList<JavaMethod>(); - private List<JavaFile> innerClasses = new ArrayList<JavaFile>(); - private String superClass; - private List<String> interfaces; - private StringBuffer rawBodyCode = new StringBuffer(); - private boolean superclassIsJAXXObject; - private boolean abstractClass; - private String genericType; - private String superGenericType; - - public JavaFile() { - super(0, ""); - } - - public JavaFile(int modifiers, String className, String superClass) { - this(modifiers, className, superClass, null); - } - - public JavaFile(int modifiers, String className, String superClass, List<String> interfaces) { - super(modifiers, className); - this.superClass = superClass; - this.interfaces = interfaces; - } - - public void addImport(String importString) { - imports.add(importString); - } - - public void addImport(Class<?> importString) { - addImport(importString.getName()); - } - - public String[] getImports() { - List<String> result = new ArrayList<String>(imports); - Collections.sort(result); - return result.toArray(new String[result.size()]); - } - - public String getSuperClass() { - return superClass; - } - - public void setSuperClass(String superClass) { - this.superClass = superClass; - } - - public List<String> getInterfaces() { - if (interfaces == null) { - interfaces = new ArrayList<String>(); - } - return interfaces; - } - - public void setInterfaces(List<String> interfaces) { - this.interfaces = interfaces; - } - - public void setGenericType(String genericType) { - this.genericType = genericType; - } - - public void addMethod(JavaMethod method) { - methods.add(method); - } - - public List<JavaMethod> getMethods() { - return methods; - } - - public void addField(JavaField field) { - addField(field, false); - } - - public void addField(JavaField field, boolean javaBean) { - addSimpleField(field); - String id = field.getName(); - String capitalizedName = org.apache.commons.lang.StringUtils.capitalize(id); - // add getter file - String content = String.format(GETTER_PATTERN, id); - addMethod(new JavaMethod( - Modifier.isProtected(field.getModifiers()) ? Modifier.PUBLIC : Modifier.PROTECTED, - field.getType(), "get" + capitalizedName, null, null, content, field.isOverride())); - - if (javaBean) { - // add full javabean support accessor + mutator + constante with name of property to make it easier to use - // compute the property constante - String constantId = TypeManager.convertVariableNameToConstantName("property" + capitalizedName); - addSimpleField(JavaFileGenerator.newField(Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL, String.class.getSimpleName(), constantId, false, "\"" + id + "\"")); - - if (Boolean.class.getName().equals(field.getType())) { - content = String.format(BOOLEAN_GETTER_PATTERN, id); - addMethod(new JavaMethod(Modifier.PUBLIC, field.getType(), "is" + capitalizedName, null, null, content, field.isOverride())); - } - content = String.format(SETTER_PATTERN, field.getType(), id, constantId); -// content = String.format(SETTER_PATTERN, field.getType(), id); - JavaArgument arg = new JavaArgument(field.getType(), "newValue"); - addMethod(new JavaMethod(Modifier.PUBLIC, "void", "set" + capitalizedName, new JavaArgument[]{arg}, null, content, field.isOverride())); - } - } - - public void addSimpleField(JavaField field) { - fields.add(field); - } - - public List<JavaField> getFields() { - return fields; - } - - public void addBodyCode(String bodyCode) { - rawBodyCode.append(bodyCode); - } - - public boolean isAbstractClass() { - return abstractClass; - } - - public String getGenericType() { - return genericType; - } - - public List<JavaFile> getInnerClasses() { - return innerClasses; - } - - public StringBuffer getRawBodyCode() { - return rawBodyCode; - } - - public String getSuperGenericType() { - return superGenericType; - } - - public void addInterface(String canonicalName) { - if (interfaces == null || !interfaces.contains(canonicalName)) { - getInterfaces().add(canonicalName); - } - } - - public void addInterfaces(String[] canonicalNames) { - if (canonicalNames == null) { - return; - } - for (String canonicalName : canonicalNames) { - if (interfaces == null || !interfaces.contains(canonicalName)) { - getInterfaces().add(canonicalName); - } - } - } - - public boolean isSuperclassIsJAXXObject() { - return superclassIsJAXXObject; - } - - public void setSuperclassIsJAXXObject(boolean superclassIsJAXXObject) { - this.superclassIsJAXXObject = superclassIsJAXXObject; - } - - public void setAbstractClass(boolean abstractClass) { - this.abstractClass = abstractClass; - } - - public void setSuperGenericType(String superGenericType) { - this.superGenericType = superGenericType; - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaFile.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaFile.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaFile.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaFile.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,204 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.java; + +import jaxx.compiler.types.TypeManager; + +import java.lang.reflect.Modifier; +import java.util.*; + +/** + * A Java source file being generated for output. Once the class is completely initialized, use the + * {@link #toString} method to generate source code for it. + */ +public class JavaFile extends JavaElement { + + protected static final String GETTER_PATTERN = "return %1$s;"; + protected static final String BOOLEAN_GETTER_PATTERN = "return %1$s !=null && %1$s;"; + protected static final String SETTER_PATTERN = "%1$s oldValue = this.%2$s;\nthis.%2$s = newValue;\nfirePropertyChange(%3$s, oldValue, newValue);"; + // protected static final String SETTER_PATTERN = "%1$s oldValue = this.%2$s;\nthis.%2$s = newValue;\nfirePropertyChange(\"%2$s\", oldValue, newValue);"; + private Set<String> imports = new HashSet<String>(); + private List<JavaField> fields = new ArrayList<JavaField>(); + private List<JavaMethod> methods = new ArrayList<JavaMethod>(); + private List<JavaFile> innerClasses = new ArrayList<JavaFile>(); + private String superClass; + private List<String> interfaces; + private StringBuffer rawBodyCode = new StringBuffer(); + private boolean superclassIsJAXXObject; + private boolean abstractClass; + private String genericType; + private String superGenericType; + + public JavaFile() { + super(0, ""); + } + + public JavaFile(int modifiers, String className, String superClass) { + this(modifiers, className, superClass, null); + } + + public JavaFile(int modifiers, String className, String superClass, List<String> interfaces) { + super(modifiers, className); + this.superClass = superClass; + this.interfaces = interfaces; + } + + public void addImport(String importString) { + imports.add(importString); + } + + public void addImport(Class<?> importString) { + addImport(importString.getName()); + } + + public String[] getImports() { + List<String> result = new ArrayList<String>(imports); + Collections.sort(result); + return result.toArray(new String[result.size()]); + } + + public String getSuperClass() { + return superClass; + } + + public void setSuperClass(String superClass) { + this.superClass = superClass; + } + + public List<String> getInterfaces() { + if (interfaces == null) { + interfaces = new ArrayList<String>(); + } + return interfaces; + } + + public void setInterfaces(List<String> interfaces) { + this.interfaces = interfaces; + } + + public void setGenericType(String genericType) { + this.genericType = genericType; + } + + public void addMethod(JavaMethod method) { + methods.add(method); + } + + public List<JavaMethod> getMethods() { + return methods; + } + + public void addField(JavaField field) { + addField(field, false); + } + + public void addField(JavaField field, boolean javaBean) { + addSimpleField(field); + String id = field.getName(); + String capitalizedName = org.apache.commons.lang.StringUtils.capitalize(id); + // add getter file + String content = String.format(GETTER_PATTERN, id); + addMethod(new JavaMethod( + Modifier.isProtected(field.getModifiers()) ? Modifier.PUBLIC : Modifier.PROTECTED, + field.getType(), "get" + capitalizedName, null, null, content, field.isOverride())); + + if (javaBean) { + // add full javabean support accessor + mutator + constante with name of property to make it easier to use + // compute the property constante + String constantId = TypeManager.convertVariableNameToConstantName("property" + capitalizedName); + addSimpleField(JavaFileGenerator.newField(Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL, String.class.getSimpleName(), constantId, false, "\"" + id + "\"")); + + if (Boolean.class.getName().equals(field.getType())) { + content = String.format(BOOLEAN_GETTER_PATTERN, id); + addMethod(new JavaMethod(Modifier.PUBLIC, field.getType(), "is" + capitalizedName, null, null, content, field.isOverride())); + } + content = String.format(SETTER_PATTERN, field.getType(), id, constantId); +// content = String.format(SETTER_PATTERN, field.getType(), id); + JavaArgument arg = new JavaArgument(field.getType(), "newValue"); + addMethod(new JavaMethod(Modifier.PUBLIC, "void", "set" + capitalizedName, new JavaArgument[]{arg}, null, content, field.isOverride())); + } + } + + public void addSimpleField(JavaField field) { + fields.add(field); + } + + public List<JavaField> getFields() { + return fields; + } + + public void addBodyCode(String bodyCode) { + rawBodyCode.append(bodyCode); + } + + public boolean isAbstractClass() { + return abstractClass; + } + + public String getGenericType() { + return genericType; + } + + public List<JavaFile> getInnerClasses() { + return innerClasses; + } + + public StringBuffer getRawBodyCode() { + return rawBodyCode; + } + + public String getSuperGenericType() { + return superGenericType; + } + + public void addInterface(String canonicalName) { + if (interfaces == null || !interfaces.contains(canonicalName)) { + getInterfaces().add(canonicalName); + } + } + + public void addInterfaces(String[] canonicalNames) { + if (canonicalNames == null) { + return; + } + for (String canonicalName : canonicalNames) { + if (interfaces == null || !interfaces.contains(canonicalName)) { + getInterfaces().add(canonicalName); + } + } + } + + public boolean isSuperclassIsJAXXObject() { + return superclassIsJAXXObject; + } + + public void setSuperclassIsJAXXObject(boolean superclassIsJAXXObject) { + this.superclassIsJAXXObject = superclassIsJAXXObject; + } + + public void setAbstractClass(boolean abstractClass) { + this.abstractClass = abstractClass; + } + + public void setSuperGenericType(String superGenericType) { + this.superGenericType = superGenericType; + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaFileGenerator.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaFileGenerator.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaFileGenerator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,289 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.java; - -import java.io.PrintWriter; -import java.util.Arrays; -import java.util.EnumMap; -import java.util.List; -import java.util.Map.Entry; -import jaxx.compiler.java.JavaMethod.MethodOrder; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Java file generator. - * - * @author chemit - * @since 2.0.0 - */ -public class JavaFileGenerator { - - /** - * Logger - */ - static private final Log log = LogFactory.getLog(JavaFileGenerator.class); - - public static JavaField newField(int modifiers, String returnType, String name, boolean override) { - return newField(modifiers, returnType, name, override, null); - } - - public static JavaField newField(int modifiers, String returnType, String name, boolean override, String initializer) { - return new JavaField(modifiers, returnType, name, override, initializer); - } - - public static JavaMethod newMethod(int modifiers, String returnType, String name, String initializer, boolean override, String[] exceptions, JavaArgument... arguments) { - return new JavaMethod(modifiers, returnType, name, arguments, exceptions, initializer, override); - } - - public static JavaMethod newMethod(int modifiers, String returnType, String name, String initializer, boolean override, JavaArgument... arguments) { - return newMethod(modifiers, returnType, name, initializer, override, new String[0], arguments); - } - /** - * End of line - */ - protected final String eol; - /** - * verbose flag when generates - */ - protected final boolean verbose; - /** - * current prefix indent size - */ - protected int indentationLevel = 0; - - public JavaFileGenerator(String eol, boolean verbose) { - this.eol = eol; - this.verbose = verbose && log.isDebugEnabled(); - } - - public String getEol() { - return eol; - } - - public String generateImport(String anImport) { - return "import " + anImport + ';' + eol; - } - - public void generateFile(JavaFile f, PrintWriter result) { - if (verbose) { - log.info(f.getName()); - } - indentationLevel = 0; - if (f.getName().indexOf(".") != -1) { - result.append("package ").append(f.getName().substring(0, f.getName().lastIndexOf("."))).append(";"); - result.append(eol).append(eol); - } - String[] imports = f.getImports(); - - if (imports.length > 0) { - for (String anImport : imports) { - result.append(generateImport(anImport)); - } - result.append(eol); - } - result.append(generateClass(f)); - } - - public String generateClass(JavaFile f) { - - if (verbose) { - log.info(f.getName()); - } - StringBuffer result = new StringBuffer(); - String genericType = f.getGenericType(); - - result.append(f.getModifiersText()); - if (f.isAbstractClass()) { - result.append("abstract "); - } - result.append("class "); - result.append(f.getName().substring(f.getName().lastIndexOf(".") + 1)); - if (genericType != null) { - result.append('<').append(genericType).append('>'); - } - result.append(" extends "); - result.append(f.getSuperClass()); - if (f.getSuperGenericType() != null) { - result.append('<').append(f.getSuperGenericType()).append('>'); - } - List<String> interfaces = f.getInterfaces(); - - if (interfaces != null && !interfaces.isEmpty()) { - result.append(" implements ").append(interfaces.get(0)); - for (int i = 1; i < interfaces.size(); i++) { - result.append(", ").append(interfaces.get(i)); - } - } - result.append(" {").append(eol); - - // generate fields - - List<JavaField> fields = f.getFields(); - - if (!fields.isEmpty()) { - java.util.Collections.sort(fields); // sort fields - - for (JavaField field : fields) { - if (log.isDebugEnabled()) { - log.debug("generate field " + field); - } - String txt = generateField(field); - result.append(addIndentation(txt, 4, eol)).append(eol); - } - result.append(eol); - } - - // generate raw body - - StringBuffer rawBodyCode = f.getRawBodyCode(); - - if (rawBodyCode.length() > 0) { - result.append(addIndentation("/* begin raw body code */\n", 4, eol)); - String s = rawBodyCode.toString(); - if (!s.startsWith(eol)) { - result.append(eol); - } - result.append(addIndentation(s, 4, eol)).append(eol); - result.append(addIndentation("/* end raw body code */", 4, eol)); - result.append(eol); - } - - // generate inner classes - - List<JavaFile> innerClasses = f.getInnerClasses(); - for (JavaFile innerClass : innerClasses) { - indentationLevel += 4; - try { - String txt = generateClass(innerClass); - result.append(addIndentation(txt, 4, eol)); - result.append(eol).append(eol); - } finally { - indentationLevel -= 4; - } - } - - // generate methods - - EnumMap<MethodOrder, List<JavaMethod>> map = JavaMethod.getSortedMethods(f.getMethods()); - for (Entry<MethodOrder, List<JavaMethod>> entry : map.entrySet()) { - List<JavaMethod> list = entry.getValue(); - if (!list.isEmpty()) { - result.append(addIndentation(entry.getKey().getHeader(), 4, eol)); - result.append(eol).append(eol); - for (JavaMethod method : list) { - String txt = generateMethod(method); - result.append(addIndentation(txt, 4, eol)); - result.append(eol).append(eol); - } - } - list.clear(); - } - map.clear(); - result.append("}"); - return result.toString(); - - } - - public String generateField(JavaField f) { - if (verbose) { - log.info(f.getName()); - } - StringBuffer result = new StringBuffer(); - result.append(f.getModifiersText()); - result.append(f.getType()).append(' ').append(f.getName()); - if (f.getInitializer() != null) { - result.append(" = ").append(f.getInitializer()); - } - result.append(';').append(eol); - return result.toString(); - } - - public String generateMethod(JavaMethod m) { - if (verbose) { - log.info(m.getName()); - } - - StringBuffer result = new StringBuffer(); - if (m.isOverride()) { - result.append("@Override").append(eol); - } - result.append(m.getModifiersText()); - if (m.getReturnType() != null) { - result.append(m.getReturnType()); - result.append(' '); - } - result.append(m.getName()); - result.append('('); - JavaArgument[] arguments = m.getArguments(); - - if (arguments != null && arguments.length > 0) { - result.append(generateArgument(arguments[0])); - for (int i = 1; i < arguments.length; i++) { - result.append(", ").append(generateArgument(arguments[i])); - } - } - result.append(") {"); - result.append(eol); - String body = m.getBody(); - - if (body != null) { - String formattedBodyCode = addIndentation(body.trim(), 4, eol); - if (formattedBodyCode.length() > 0) { - result.append(formattedBodyCode).append(eol); - } - } - result.append("}"); - return result.toString(); - - } - - public String generateArgument(JavaArgument argument) { - String result = argument.getType() + ' ' + argument.getName(); - return argument.isFinal() ? "final " + result : result; - } - - public String addIndentation(String source, int indentation, String lineSeparator) { - return indent(source, indentationLevel + indentation, false, lineSeparator); - } - - public String setIndentation(String source, int indentation, String lineSeparator) { - return indent(source, indentationLevel + indentation, true, lineSeparator); - } - - public static String indent(String source, int indentation, boolean trim, String lineSeparator) { - if (trim) { - source = source.trim(); - } - char[] spaces = new char[indentation]; - Arrays.fill(spaces, ' '); - StringBuffer result = new StringBuffer(); - String[] lines = source.split(lineSeparator + "|\n"); - for (int i = 0; i < lines.length; i++) { - if (i > 0) { - result.append(lineSeparator); - } - result.append(spaces); - result.append(trim ? lines[i].trim() : lines[i]); - } - return result.toString(); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaFileGenerator.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaFileGenerator.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaFileGenerator.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaFileGenerator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,289 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.java; + +import java.io.PrintWriter; +import java.util.Arrays; +import java.util.EnumMap; +import java.util.List; +import java.util.Map.Entry; +import jaxx.compiler.java.JavaMethod.MethodOrder; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Java file generator. + * + * @author chemit + * @since 2.0.0 + */ +public class JavaFileGenerator { + + /** + * Logger + */ + static private final Log log = LogFactory.getLog(JavaFileGenerator.class); + + public static JavaField newField(int modifiers, String returnType, String name, boolean override) { + return newField(modifiers, returnType, name, override, null); + } + + public static JavaField newField(int modifiers, String returnType, String name, boolean override, String initializer) { + return new JavaField(modifiers, returnType, name, override, initializer); + } + + public static JavaMethod newMethod(int modifiers, String returnType, String name, String initializer, boolean override, String[] exceptions, JavaArgument... arguments) { + return new JavaMethod(modifiers, returnType, name, arguments, exceptions, initializer, override); + } + + public static JavaMethod newMethod(int modifiers, String returnType, String name, String initializer, boolean override, JavaArgument... arguments) { + return newMethod(modifiers, returnType, name, initializer, override, new String[0], arguments); + } + /** + * End of line + */ + protected final String eol; + /** + * verbose flag when generates + */ + protected final boolean verbose; + /** + * current prefix indent size + */ + protected int indentationLevel = 0; + + public JavaFileGenerator(String eol, boolean verbose) { + this.eol = eol; + this.verbose = verbose && log.isDebugEnabled(); + } + + public String getEol() { + return eol; + } + + public String generateImport(String anImport) { + return "import " + anImport + ';' + eol; + } + + public void generateFile(JavaFile f, PrintWriter result) { + if (verbose) { + log.info(f.getName()); + } + indentationLevel = 0; + if (f.getName().indexOf(".") != -1) { + result.append("package ").append(f.getName().substring(0, f.getName().lastIndexOf("."))).append(";"); + result.append(eol).append(eol); + } + String[] imports = f.getImports(); + + if (imports.length > 0) { + for (String anImport : imports) { + result.append(generateImport(anImport)); + } + result.append(eol); + } + result.append(generateClass(f)); + } + + public String generateClass(JavaFile f) { + + if (verbose) { + log.info(f.getName()); + } + StringBuffer result = new StringBuffer(); + String genericType = f.getGenericType(); + + result.append(f.getModifiersText()); + if (f.isAbstractClass()) { + result.append("abstract "); + } + result.append("class "); + result.append(f.getName().substring(f.getName().lastIndexOf(".") + 1)); + if (genericType != null) { + result.append('<').append(genericType).append('>'); + } + result.append(" extends "); + result.append(f.getSuperClass()); + if (f.getSuperGenericType() != null) { + result.append('<').append(f.getSuperGenericType()).append('>'); + } + List<String> interfaces = f.getInterfaces(); + + if (interfaces != null && !interfaces.isEmpty()) { + result.append(" implements ").append(interfaces.get(0)); + for (int i = 1; i < interfaces.size(); i++) { + result.append(", ").append(interfaces.get(i)); + } + } + result.append(" {").append(eol); + + // generate fields + + List<JavaField> fields = f.getFields(); + + if (!fields.isEmpty()) { + java.util.Collections.sort(fields); // sort fields + + for (JavaField field : fields) { + if (log.isDebugEnabled()) { + log.debug("generate field " + field); + } + String txt = generateField(field); + result.append(addIndentation(txt, 4, eol)).append(eol); + } + result.append(eol); + } + + // generate raw body + + StringBuffer rawBodyCode = f.getRawBodyCode(); + + if (rawBodyCode.length() > 0) { + result.append(addIndentation("/* begin raw body code */\n", 4, eol)); + String s = rawBodyCode.toString(); + if (!s.startsWith(eol)) { + result.append(eol); + } + result.append(addIndentation(s, 4, eol)).append(eol); + result.append(addIndentation("/* end raw body code */", 4, eol)); + result.append(eol); + } + + // generate inner classes + + List<JavaFile> innerClasses = f.getInnerClasses(); + for (JavaFile innerClass : innerClasses) { + indentationLevel += 4; + try { + String txt = generateClass(innerClass); + result.append(addIndentation(txt, 4, eol)); + result.append(eol).append(eol); + } finally { + indentationLevel -= 4; + } + } + + // generate methods + + EnumMap<MethodOrder, List<JavaMethod>> map = JavaMethod.getSortedMethods(f.getMethods()); + for (Entry<MethodOrder, List<JavaMethod>> entry : map.entrySet()) { + List<JavaMethod> list = entry.getValue(); + if (!list.isEmpty()) { + result.append(addIndentation(entry.getKey().getHeader(), 4, eol)); + result.append(eol).append(eol); + for (JavaMethod method : list) { + String txt = generateMethod(method); + result.append(addIndentation(txt, 4, eol)); + result.append(eol).append(eol); + } + } + list.clear(); + } + map.clear(); + result.append("}"); + return result.toString(); + + } + + public String generateField(JavaField f) { + if (verbose) { + log.info(f.getName()); + } + StringBuffer result = new StringBuffer(); + result.append(f.getModifiersText()); + result.append(f.getType()).append(' ').append(f.getName()); + if (f.getInitializer() != null) { + result.append(" = ").append(f.getInitializer()); + } + result.append(';').append(eol); + return result.toString(); + } + + public String generateMethod(JavaMethod m) { + if (verbose) { + log.info(m.getName()); + } + + StringBuffer result = new StringBuffer(); + if (m.isOverride()) { + result.append("@Override").append(eol); + } + result.append(m.getModifiersText()); + if (m.getReturnType() != null) { + result.append(m.getReturnType()); + result.append(' '); + } + result.append(m.getName()); + result.append('('); + JavaArgument[] arguments = m.getArguments(); + + if (arguments != null && arguments.length > 0) { + result.append(generateArgument(arguments[0])); + for (int i = 1; i < arguments.length; i++) { + result.append(", ").append(generateArgument(arguments[i])); + } + } + result.append(") {"); + result.append(eol); + String body = m.getBody(); + + if (body != null) { + String formattedBodyCode = addIndentation(body.trim(), 4, eol); + if (formattedBodyCode.length() > 0) { + result.append(formattedBodyCode).append(eol); + } + } + result.append("}"); + return result.toString(); + + } + + public String generateArgument(JavaArgument argument) { + String result = argument.getType() + ' ' + argument.getName(); + return argument.isFinal() ? "final " + result : result; + } + + public String addIndentation(String source, int indentation, String lineSeparator) { + return indent(source, indentationLevel + indentation, false, lineSeparator); + } + + public String setIndentation(String source, int indentation, String lineSeparator) { + return indent(source, indentationLevel + indentation, true, lineSeparator); + } + + public static String indent(String source, int indentation, boolean trim, String lineSeparator) { + if (trim) { + source = source.trim(); + } + char[] spaces = new char[indentation]; + Arrays.fill(spaces, ' '); + StringBuffer result = new StringBuffer(); + String[] lines = source.split(lineSeparator + "|\n"); + for (int i = 0; i < lines.length; i++) { + if (i > 0) { + result.append(lineSeparator); + } + result.append(spaces); + result.append(trim ? lines[i].trim() : lines[i]); + } + return result.toString(); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaMethod.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaMethod.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaMethod.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,396 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.java; - -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.EnumMap; -import java.util.EnumSet; -import java.util.Iterator; -import java.util.List; - -/** - * Represents a method in a Java source file being generated for output. <code>JavaMethods</code> are created - * and added to a {@link JavaFile}, which can then output Java source code. In addition to normal methods, a - * <code>JavaMethod</code> can represent a constructor -- constructors should be named after their containing - * classes and have a return type of <code>null</code>. - */ -public class JavaMethod extends JavaElement implements Comparable<JavaMethod> { - - /** - * Method comparator - */ - static final JavaMethodComparator COMPARATOR = new JavaMethodComparator(); - /** - * return type of the method (null for constructors) - */ - private String returnType; - /** - * arguments of the method (can be empty) - */ - private JavaArgument[] arguments; - /** - * exceptions thrown by the method( can be empty) - */ - private String[] exceptions; - /** - * body of the mehotd (can be empty) - */ - private String body; - /** - * flag to known if the method overrids a super-method - */ - private boolean override; - - /** - * Constructs a new <code>JavaMethod</code> containing the specified body code. The <code>modifiers</code> parameter - * is a bit mask of the constants from {@link java.lang.reflect.Modifier}, and the <code>returnType</code> and - * <code>exceptions</code> of the method should be represented as they would appear in Java source code (<code>null</code> - * for a constructor). The method body is initially empty. - * - * @param modifiers the modifier keywords that should appear as part of the method's declaration - * @param returnType the return type of the method as it would appear in Java source code - * @param name the method's name - * @param arguments the method's arguments - * @param exceptions a list of exceptions the methods can throw, as they would be represented in Java source code - * @param bodyCode Java source code which should appear in the method body - * @param override flag with {@code true} value when the method overrides (or implements) a super class method - */ - public JavaMethod(int modifiers, String returnType, String name, JavaArgument[] arguments, String[] exceptions, String bodyCode, boolean override) { - super(modifiers, name); - this.returnType = returnType; - this.override = override; - this.arguments = arguments; - this.exceptions = exceptions; - this.body = bodyCode == null ? "" : bodyCode; - } - - /** - * Returns the method's return type, as it would be represented in Java source code. - * - * @return the method's return type - */ - public String getReturnType() { - return returnType; - } - - /** - * Returns a list of the method's arguments. - * - * @return the method's arguments - */ - public JavaArgument[] getArguments() { - return arguments; - } - - /** - * Returns a list of exceptions the method can throw. - * - * @return the method's exceptions - */ - public String[] getExceptions() { - return exceptions; - } - - public boolean isOverride() { - return override; - } - - public void setOverride(boolean override) { - this.override = override; - } - - public String getBody() { - return body; - } - - @Override - public int compareTo(JavaMethod o) { - return COMPARATOR.compare(this, o); - } - - public enum MethodOrder { - - statics(Modifier.STATIC, "/*---------------------------------------------------------------------------------*/\n" + - "/*-- Statics methods --------------------------------------------------------------*/\n" + - "/*---------------------------------------------------------------------------------*/") { - }, - constructors(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" + - "/*-- Constructors -----------------------------------------------------------------*/\n" + - "/*---------------------------------------------------------------------------------*/") { - - @Override - public boolean accept(JavaMethod method) { - return method.returnType == null; - } - }, - JAXXObject(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" + - "/*-- JAXXObject implementation ----------------------------------------------------*/\n" + - "/*---------------------------------------------------------------------------------*/") { - - private List<String> methods = Arrays.asList("applyDataBinding", "firePropertyChange", "getObjectById", "get$objectMap", "processDataBinding", "removeDataBinding"); - - @Override - public boolean accept(JavaMethod method) { - return methods.contains(method.getName()); - } - }, - JAXXContext(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" + - "/*-- JAXXContext implementation ---------------------------------------------------*/\n" + - "/*---------------------------------------------------------------------------------*/") { - - private List<String> methods = Arrays.asList("getContextValue", "getDelegateContext", "getParentContainer", "removeContextValue", "setContextValue"); - - @Override - public boolean accept(JavaMethod method) { - return methods.contains(method.getName()); - } - }, - JAXXValidation(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" + - "/*-- JAXXValidation implementation ------------------------------------------------*/\n" + - "/*---------------------------------------------------------------------------------*/") { - - private List<String> methods = Arrays.asList("getValidator", "getValidatorIds"); - - @Override - public boolean accept(JavaMethod method) { - return methods.contains(method.getName()); - } - }, - events(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" + - "/*-- Event methods ----------------------------------------------------------------*/\n" + - "/*---------------------------------------------------------------------------------*/") { - - @Override - public boolean accept(JavaMethod method) { - return (method.getName().startsWith("do") && method.getName().indexOf("__") > -1); - } - }, - publicGetters(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" + - "/*-- public acessor methods -------------------------------------------------------*/\n" + - "/*---------------------------------------------------------------------------------*/") { - - @Override - public boolean accept(JavaMethod method) { - return (method.getName().startsWith("get") || method.getName().startsWith("is")); - } - }, - publicSetters(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" + - "/*-- public mutator methods -------------------------------------------------------*/\n" + - "/*---------------------------------------------------------------------------------*/") { - - @Override - public boolean accept(JavaMethod method) { - return (method.getName().startsWith("set")); - } - }, - otherPublic(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" + - "/*-- public mutator methods -------------------------------------------------------*/\n" + - "/*---------------------------------------------------------------------------------*/") { - - @Override - public boolean accept(int mod) { - return super.accept(mod) && !Modifier.isStatic(mod); - } - }, - protectedGetters(Modifier.PROTECTED, "/*---------------------------------------------------------------------------------*/\n" + - "/*-- protected acessors methods ---------------------------------------------------*/\n" + - "/*---------------------------------------------------------------------------------*/") { - - @Override - public boolean accept(JavaMethod method) { - return (method.getName().startsWith("get") || method.getName().startsWith("is")); - } - }, - createMethod(Modifier.PROTECTED | Modifier.PRIVATE, "/*---------------------------------------------------------------------------------*/\n" + - "/*-- ui creation methods ----------------------------------------------------------*/\n" + - "/*---------------------------------------------------------------------------------*/") { - - @Override - public boolean accept(JavaMethod method) { - return method.getName().startsWith("create") || method.getName().startsWith("add") || - method.getName().equals("$completeSetup") || - method.getName().equals("$registerDataBinding") || - method.getName().equals("$initialize"); - } - }, - protecteds(Modifier.PROTECTED, "/*---------------------------------------------------------------------------------*/\n" + - "/*-- Other protected methods ------------------------------------------------------*/\n" + - "/*---------------------------------------------------------------------------------*/") { - }, - packageLocal(0, "/*---------------------------------------------------------------------------------*/\n" + - "/*-- Package methods --------------------------------------------------------------*/\n" + - "/*---------------------------------------------------------------------------------*/") { - - @Override - public boolean accept(int mod) { - return !Modifier.isStatic(mod) && !Modifier.isPublic(mod) && !Modifier.isProtected(mod); - } - }, - privates(Modifier.PRIVATE, "/*---------------------------------------------------------------------------------*/\n" + - "/*-- Private methods --------------------------------------------------------------*/\n" + - "/*---------------------------------------------------------------------------------*/") { - }; - private final String header; - private int modifier; - - MethodOrder(int modifier, String header) { - this.header = header; - this.modifier = modifier; - } - - public String getHeader() { - return header; - } - - public boolean accept(JavaMethod method) { - return true; - } - - public boolean accept(int mod) { - return (mod & modifier) != 0; - } - - public boolean accept(int mod, JavaMethod method) { - return accept(mod) && accept(method); - } - - public static MethodOrder valueOf(JavaMethod method, int scope) { - for (MethodOrder o : values()) { - if (o.accept(scope, method)) { - return o; - } - } - throw new IllegalArgumentException("could not find a " + MethodOrder.class + " for method " + method); - } - } - - public static EnumMap<MethodOrder, List<JavaMethod>> getSortedMethods(List<JavaMethod> methods) { - - EnumMap<MethodOrder, List<JavaMethod>> result = new EnumMap<MethodOrder, List<JavaMethod>>(MethodOrder.class); - for (MethodOrder methodOrder : MethodOrder.values()) { - result.put(methodOrder, new ArrayList<JavaMethod>()); - } - - EnumSet<MethodOrder> allConstants = EnumSet.allOf(MethodOrder.class); - List<JavaMethod> allMethods = new ArrayList<JavaMethod>(methods); - int[] scopes = new int[]{Modifier.STATIC, Modifier.PUBLIC, Modifier.PROTECTED, Modifier.PRIVATE}; - for (int scope : scopes) { - EnumSet<MethodOrder> constants = getMethodOrderScope(allConstants, scope); - - Iterator<JavaMethod> itMethods = allMethods.iterator(); - while (itMethods.hasNext()) { - JavaMethod method = itMethods.next(); - for (MethodOrder constant : constants) { - if (constant.accept(method.getModifiers(), method)) { - result.get(constant).add(method); - itMethods.remove(); - break; - } - } - } - constants.clear(); - } - - if (!allMethods.isEmpty()) { - throw new IllegalArgumentException("could not find a " + MethodOrder.class + " for method " + allMethods); - } - - for (MethodOrder methodOrder : MethodOrder.values()) { - // sort methods - java.util.Collections.sort(result.get(methodOrder)); - } - return result; - } - - public static EnumSet<MethodOrder> getMethodOrderScope(EnumSet<MethodOrder> allConstants, int scope) { - EnumSet<MethodOrder> constants = EnumSet.noneOf(MethodOrder.class); - for (MethodOrder order : allConstants) { - if (order.accept(scope)) { - constants.add(order); - } - } - return constants; - } - - static class JavaMethodComparator implements Comparator<JavaMethod> { - - @Override - public int compare(JavaMethod o1, JavaMethod o2) { - - /*int result; - if ((result = compareStatic(o1, o2)) != 0) { - return result; - } - if ((result = compareConstructor(o1, o2)) != 0) { - return result; - } - if ((result = compareVisibility(o1, o2)) != 0) { - return result; - }*/ - return o1.getName().compareTo(o2.getName()); - } - - public int compareStatic(JavaMethod o1, JavaMethod o2) { - if (Modifier.isStatic(o1.getModifiers()) && !Modifier.isStatic(o2.getModifiers())) { - return -1; - } - if (!Modifier.isStatic(o1.getModifiers()) && Modifier.isStatic(o2.getModifiers())) { - return 1; - } - return 0; - } - - public int compareConstructor(JavaMethod o1, JavaMethod o2) { - if (o1.getReturnType() == null && o2.getReturnType() != null) { - return -1; - } - if (o1.getReturnType() != null && o2.getReturnType() == null) { - return 1; - } - return 0; - } - - public int compareVisibility(JavaMethod o1, JavaMethod o2) { - if (Modifier.isPublic(o1.getModifiers()) && !Modifier.isPublic(o2.getModifiers())) { - return -1; - } - if (!Modifier.isPublic(o1.getModifiers()) && Modifier.isPublic(o2.getModifiers())) { - return 1; - } - if (Modifier.isProtected(o1.getModifiers()) && !Modifier.isProtected(o2.getModifiers())) { - return -1; - } - if (!Modifier.isProtected(o1.getModifiers()) && Modifier.isProtected(o2.getModifiers())) { - return 1; - } - if (Modifier.isPrivate(o1.getModifiers()) && !Modifier.isPrivate(o2.getModifiers())) { - return -1; - } - if (!Modifier.isPrivate(o1.getModifiers()) && Modifier.isPrivate(o2.getModifiers())) { - return 1; - } - return 0; - } - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaMethod.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaMethod.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaMethod.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaMethod.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,396 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.java; + +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.EnumMap; +import java.util.EnumSet; +import java.util.Iterator; +import java.util.List; + +/** + * Represents a method in a Java source file being generated for output. <code>JavaMethods</code> are created + * and added to a {@link JavaFile}, which can then output Java source code. In addition to normal methods, a + * <code>JavaMethod</code> can represent a constructor -- constructors should be named after their containing + * classes and have a return type of <code>null</code>. + */ +public class JavaMethod extends JavaElement implements Comparable<JavaMethod> { + + /** + * Method comparator + */ + static final JavaMethodComparator COMPARATOR = new JavaMethodComparator(); + /** + * return type of the method (null for constructors) + */ + private String returnType; + /** + * arguments of the method (can be empty) + */ + private JavaArgument[] arguments; + /** + * exceptions thrown by the method( can be empty) + */ + private String[] exceptions; + /** + * body of the mehotd (can be empty) + */ + private String body; + /** + * flag to known if the method overrids a super-method + */ + private boolean override; + + /** + * Constructs a new <code>JavaMethod</code> containing the specified body code. The <code>modifiers</code> parameter + * is a bit mask of the constants from {@link java.lang.reflect.Modifier}, and the <code>returnType</code> and + * <code>exceptions</code> of the method should be represented as they would appear in Java source code (<code>null</code> + * for a constructor). The method body is initially empty. + * + * @param modifiers the modifier keywords that should appear as part of the method's declaration + * @param returnType the return type of the method as it would appear in Java source code + * @param name the method's name + * @param arguments the method's arguments + * @param exceptions a list of exceptions the methods can throw, as they would be represented in Java source code + * @param bodyCode Java source code which should appear in the method body + * @param override flag with {@code true} value when the method overrides (or implements) a super class method + */ + public JavaMethod(int modifiers, String returnType, String name, JavaArgument[] arguments, String[] exceptions, String bodyCode, boolean override) { + super(modifiers, name); + this.returnType = returnType; + this.override = override; + this.arguments = arguments; + this.exceptions = exceptions; + this.body = bodyCode == null ? "" : bodyCode; + } + + /** + * Returns the method's return type, as it would be represented in Java source code. + * + * @return the method's return type + */ + public String getReturnType() { + return returnType; + } + + /** + * Returns a list of the method's arguments. + * + * @return the method's arguments + */ + public JavaArgument[] getArguments() { + return arguments; + } + + /** + * Returns a list of exceptions the method can throw. + * + * @return the method's exceptions + */ + public String[] getExceptions() { + return exceptions; + } + + public boolean isOverride() { + return override; + } + + public void setOverride(boolean override) { + this.override = override; + } + + public String getBody() { + return body; + } + + @Override + public int compareTo(JavaMethod o) { + return COMPARATOR.compare(this, o); + } + + public enum MethodOrder { + + statics(Modifier.STATIC, "/*---------------------------------------------------------------------------------*/\n" + + "/*-- Statics methods --------------------------------------------------------------*/\n" + + "/*---------------------------------------------------------------------------------*/") { + }, + constructors(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" + + "/*-- Constructors -----------------------------------------------------------------*/\n" + + "/*---------------------------------------------------------------------------------*/") { + + @Override + public boolean accept(JavaMethod method) { + return method.returnType == null; + } + }, + JAXXObject(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" + + "/*-- JAXXObject implementation ----------------------------------------------------*/\n" + + "/*---------------------------------------------------------------------------------*/") { + + private List<String> methods = Arrays.asList("applyDataBinding", "firePropertyChange", "getObjectById", "get$objectMap", "processDataBinding", "removeDataBinding"); + + @Override + public boolean accept(JavaMethod method) { + return methods.contains(method.getName()); + } + }, + JAXXContext(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" + + "/*-- JAXXContext implementation ---------------------------------------------------*/\n" + + "/*---------------------------------------------------------------------------------*/") { + + private List<String> methods = Arrays.asList("getContextValue", "getDelegateContext", "getParentContainer", "removeContextValue", "setContextValue"); + + @Override + public boolean accept(JavaMethod method) { + return methods.contains(method.getName()); + } + }, + JAXXValidation(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" + + "/*-- JAXXValidation implementation ------------------------------------------------*/\n" + + "/*---------------------------------------------------------------------------------*/") { + + private List<String> methods = Arrays.asList("getValidator", "getValidatorIds"); + + @Override + public boolean accept(JavaMethod method) { + return methods.contains(method.getName()); + } + }, + events(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" + + "/*-- Event methods ----------------------------------------------------------------*/\n" + + "/*---------------------------------------------------------------------------------*/") { + + @Override + public boolean accept(JavaMethod method) { + return (method.getName().startsWith("do") && method.getName().indexOf("__") > -1); + } + }, + publicGetters(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" + + "/*-- public acessor methods -------------------------------------------------------*/\n" + + "/*---------------------------------------------------------------------------------*/") { + + @Override + public boolean accept(JavaMethod method) { + return (method.getName().startsWith("get") || method.getName().startsWith("is")); + } + }, + publicSetters(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" + + "/*-- public mutator methods -------------------------------------------------------*/\n" + + "/*---------------------------------------------------------------------------------*/") { + + @Override + public boolean accept(JavaMethod method) { + return (method.getName().startsWith("set")); + } + }, + otherPublic(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" + + "/*-- public mutator methods -------------------------------------------------------*/\n" + + "/*---------------------------------------------------------------------------------*/") { + + @Override + public boolean accept(int mod) { + return super.accept(mod) && !Modifier.isStatic(mod); + } + }, + protectedGetters(Modifier.PROTECTED, "/*---------------------------------------------------------------------------------*/\n" + + "/*-- protected acessors methods ---------------------------------------------------*/\n" + + "/*---------------------------------------------------------------------------------*/") { + + @Override + public boolean accept(JavaMethod method) { + return (method.getName().startsWith("get") || method.getName().startsWith("is")); + } + }, + createMethod(Modifier.PROTECTED | Modifier.PRIVATE, "/*---------------------------------------------------------------------------------*/\n" + + "/*-- ui creation methods ----------------------------------------------------------*/\n" + + "/*---------------------------------------------------------------------------------*/") { + + @Override + public boolean accept(JavaMethod method) { + return method.getName().startsWith("create") || method.getName().startsWith("add") || + method.getName().equals("$completeSetup") || + method.getName().equals("$registerDataBinding") || + method.getName().equals("$initialize"); + } + }, + protecteds(Modifier.PROTECTED, "/*---------------------------------------------------------------------------------*/\n" + + "/*-- Other protected methods ------------------------------------------------------*/\n" + + "/*---------------------------------------------------------------------------------*/") { + }, + packageLocal(0, "/*---------------------------------------------------------------------------------*/\n" + + "/*-- Package methods --------------------------------------------------------------*/\n" + + "/*---------------------------------------------------------------------------------*/") { + + @Override + public boolean accept(int mod) { + return !Modifier.isStatic(mod) && !Modifier.isPublic(mod) && !Modifier.isProtected(mod); + } + }, + privates(Modifier.PRIVATE, "/*---------------------------------------------------------------------------------*/\n" + + "/*-- Private methods --------------------------------------------------------------*/\n" + + "/*---------------------------------------------------------------------------------*/") { + }; + private final String header; + private int modifier; + + MethodOrder(int modifier, String header) { + this.header = header; + this.modifier = modifier; + } + + public String getHeader() { + return header; + } + + public boolean accept(JavaMethod method) { + return true; + } + + public boolean accept(int mod) { + return (mod & modifier) != 0; + } + + public boolean accept(int mod, JavaMethod method) { + return accept(mod) && accept(method); + } + + public static MethodOrder valueOf(JavaMethod method, int scope) { + for (MethodOrder o : values()) { + if (o.accept(scope, method)) { + return o; + } + } + throw new IllegalArgumentException("could not find a " + MethodOrder.class + " for method " + method); + } + } + + public static EnumMap<MethodOrder, List<JavaMethod>> getSortedMethods(List<JavaMethod> methods) { + + EnumMap<MethodOrder, List<JavaMethod>> result = new EnumMap<MethodOrder, List<JavaMethod>>(MethodOrder.class); + for (MethodOrder methodOrder : MethodOrder.values()) { + result.put(methodOrder, new ArrayList<JavaMethod>()); + } + + EnumSet<MethodOrder> allConstants = EnumSet.allOf(MethodOrder.class); + List<JavaMethod> allMethods = new ArrayList<JavaMethod>(methods); + int[] scopes = new int[]{Modifier.STATIC, Modifier.PUBLIC, Modifier.PROTECTED, Modifier.PRIVATE}; + for (int scope : scopes) { + EnumSet<MethodOrder> constants = getMethodOrderScope(allConstants, scope); + + Iterator<JavaMethod> itMethods = allMethods.iterator(); + while (itMethods.hasNext()) { + JavaMethod method = itMethods.next(); + for (MethodOrder constant : constants) { + if (constant.accept(method.getModifiers(), method)) { + result.get(constant).add(method); + itMethods.remove(); + break; + } + } + } + constants.clear(); + } + + if (!allMethods.isEmpty()) { + throw new IllegalArgumentException("could not find a " + MethodOrder.class + " for method " + allMethods); + } + + for (MethodOrder methodOrder : MethodOrder.values()) { + // sort methods + java.util.Collections.sort(result.get(methodOrder)); + } + return result; + } + + public static EnumSet<MethodOrder> getMethodOrderScope(EnumSet<MethodOrder> allConstants, int scope) { + EnumSet<MethodOrder> constants = EnumSet.noneOf(MethodOrder.class); + for (MethodOrder order : allConstants) { + if (order.accept(scope)) { + constants.add(order); + } + } + return constants; + } + + static class JavaMethodComparator implements Comparator<JavaMethod> { + + @Override + public int compare(JavaMethod o1, JavaMethod o2) { + + /*int result; + if ((result = compareStatic(o1, o2)) != 0) { + return result; + } + if ((result = compareConstructor(o1, o2)) != 0) { + return result; + } + if ((result = compareVisibility(o1, o2)) != 0) { + return result; + }*/ + return o1.getName().compareTo(o2.getName()); + } + + public int compareStatic(JavaMethod o1, JavaMethod o2) { + if (Modifier.isStatic(o1.getModifiers()) && !Modifier.isStatic(o2.getModifiers())) { + return -1; + } + if (!Modifier.isStatic(o1.getModifiers()) && Modifier.isStatic(o2.getModifiers())) { + return 1; + } + return 0; + } + + public int compareConstructor(JavaMethod o1, JavaMethod o2) { + if (o1.getReturnType() == null && o2.getReturnType() != null) { + return -1; + } + if (o1.getReturnType() != null && o2.getReturnType() == null) { + return 1; + } + return 0; + } + + public int compareVisibility(JavaMethod o1, JavaMethod o2) { + if (Modifier.isPublic(o1.getModifiers()) && !Modifier.isPublic(o2.getModifiers())) { + return -1; + } + if (!Modifier.isPublic(o1.getModifiers()) && Modifier.isPublic(o2.getModifiers())) { + return 1; + } + if (Modifier.isProtected(o1.getModifiers()) && !Modifier.isProtected(o2.getModifiers())) { + return -1; + } + if (!Modifier.isProtected(o1.getModifiers()) && Modifier.isProtected(o2.getModifiers())) { + return 1; + } + if (Modifier.isPrivate(o1.getModifiers()) && !Modifier.isPrivate(o2.getModifiers())) { + return -1; + } + if (!Modifier.isPrivate(o1.getModifiers()) && Modifier.isPrivate(o2.getModifiers())) { + return 1; + } + return 0; + } + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JJTJavaParserState.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JJTJavaParserState.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JJTJavaParserState.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,143 +0,0 @@ -/* Generated By:JJTree: Do not edit this line. .\JJTJavaParserState.java */ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ - -package jaxx.compiler.java.parser; - -class JJTJavaParserState { - private java.util.Stack<Node> nodes; - private java.util.Stack<Integer> marks; - - private int sp; // number of nodes on stack - private int mk; // current mark - private boolean node_created; - - JJTJavaParserState() { - nodes = new java.util.Stack<Node>(); - marks = new java.util.Stack<Integer>(); - sp = 0; - mk = 0; - } - - /* Determines whether the current node was actually closed and - pushed. This should only be called in the final user action of a - node scope. */ - boolean nodeCreated() { - return node_created; - } - - /* Call this to reinitialize the node stack. It is called -automatically by the parser's ReInit() method. */ - void reset() { - nodes.removeAllElements(); - marks.removeAllElements(); - sp = 0; - mk = 0; - } - - /* Returns the root node of the AST. It only makes sense to call -this after a successful parse. */ - Node rootNode() { - return nodes.elementAt(0); - } - - /* Pushes a node on to the stack. */ - void pushNode(Node n) { - nodes.push(n); - ++sp; - } - - /* Returns the node on the top of the stack, and remove it from the - stack. */ - Node popNode() { - if (--sp < mk) { - mk = marks.pop(); - } - return nodes.pop(); - } - - /* Returns the node currently on the top of the stack. */ - Node peekNode() { - return nodes.peek(); - } - - /* Returns the number of children on the stack in the current node - scope. */ - int nodeArity() { - return sp - mk; - } - - - void clearNodeScope(Node n) { - while (sp > mk) { - popNode(); - } - mk = marks.pop(); - } - - - void openNodeScope(Node n) { - marks.push(mk); - mk = sp; - n.jjtOpen(); - } - - - /* A definite node is constructed from a specified number of -children. That number of nodes are popped from the stack and -made the children of the definite node. Then the definite node -is pushed on to the stack. */ - void closeNodeScope(Node n, int num) { - mk = marks.pop(); - while (num-- > 0) { - Node c = popNode(); - c.jjtSetParent(n); - n.jjtAddChild(c, num); - } - n.jjtClose(); - pushNode(n); - node_created = true; - } - - - /* A conditional node is constructed if its condition is true. All -the nodes that have been pushed since the node was opened are -made children of the the conditional node, which is then pushed -on to the stack. If the condition is false the node is not -constructed and they are left on the stack. */ - void closeNodeScope(Node n, boolean condition) { - if (condition) { - int a = nodeArity(); - mk = marks.pop(); - while (a-- > 0) { - Node c = popNode(); - c.jjtSetParent(n); - n.jjtAddChild(c, a); - } - n.jjtClose(); - pushNode(n); - node_created = true; - } else { - mk = marks.pop(); - node_created = false; - } - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JJTJavaParserState.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JJTJavaParserState.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JJTJavaParserState.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JJTJavaParserState.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,143 @@ +/* Generated By:JJTree: Do not edit this line. .\JJTJavaParserState.java */ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ + +package jaxx.compiler.java.parser; + +class JJTJavaParserState { + private java.util.Stack<Node> nodes; + private java.util.Stack<Integer> marks; + + private int sp; // number of nodes on stack + private int mk; // current mark + private boolean node_created; + + JJTJavaParserState() { + nodes = new java.util.Stack<Node>(); + marks = new java.util.Stack<Integer>(); + sp = 0; + mk = 0; + } + + /* Determines whether the current node was actually closed and + pushed. This should only be called in the final user action of a + node scope. */ + boolean nodeCreated() { + return node_created; + } + + /* Call this to reinitialize the node stack. It is called +automatically by the parser's ReInit() method. */ + void reset() { + nodes.removeAllElements(); + marks.removeAllElements(); + sp = 0; + mk = 0; + } + + /* Returns the root node of the AST. It only makes sense to call +this after a successful parse. */ + Node rootNode() { + return nodes.elementAt(0); + } + + /* Pushes a node on to the stack. */ + void pushNode(Node n) { + nodes.push(n); + ++sp; + } + + /* Returns the node on the top of the stack, and remove it from the + stack. */ + Node popNode() { + if (--sp < mk) { + mk = marks.pop(); + } + return nodes.pop(); + } + + /* Returns the node currently on the top of the stack. */ + Node peekNode() { + return nodes.peek(); + } + + /* Returns the number of children on the stack in the current node + scope. */ + int nodeArity() { + return sp - mk; + } + + + void clearNodeScope(Node n) { + while (sp > mk) { + popNode(); + } + mk = marks.pop(); + } + + + void openNodeScope(Node n) { + marks.push(mk); + mk = sp; + n.jjtOpen(); + } + + + /* A definite node is constructed from a specified number of +children. That number of nodes are popped from the stack and +made the children of the definite node. Then the definite node +is pushed on to the stack. */ + void closeNodeScope(Node n, int num) { + mk = marks.pop(); + while (num-- > 0) { + Node c = popNode(); + c.jjtSetParent(n); + n.jjtAddChild(c, num); + } + n.jjtClose(); + pushNode(n); + node_created = true; + } + + + /* A conditional node is constructed if its condition is true. All +the nodes that have been pushed since the node was opened are +made children of the the conditional node, which is then pushed +on to the stack. If the condition is false the node is not +constructed and they are left on the stack. */ + void closeNodeScope(Node n, boolean condition) { + if (condition) { + int a = nodeArity(); + mk = marks.pop(); + while (a-- > 0) { + Node c = popNode(); + c.jjtSetParent(n); + n.jjtAddChild(c, a); + } + n.jjtClose(); + pushNode(n); + node_created = true; + } else { + mk = marks.pop(); + node_created = false; + } + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Java1.5.jj =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Java1.5.jj 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Java1.5.jj 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,5125 +0,0 @@ -/*@bgen(jjtree) Generated By:JJTree: Do not edit this line. ./Java1.5.jj */ -/*@egen*/ -/* - * Copyright \u00a9 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has - * intellectual property rights relating to technology embodied in the product - * that is described in this document. In particular, and without limitation, - * these intellectual property rights may include one or more of the U.S. - * patents listed at http://www.sun.com/patents and one or more additional - * patents or pending patent applications in the U.S. and in other countries. - * U.S. Government Rights - Commercial software. Government users are subject - * to the Sun Microsystems, Inc. standard license agreement and applicable - * provisions of the FAR and its supplements. Use is subject to license terms. - * Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered - * trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This - * product is covered and controlled by U.S. Export Control laws and may be - * subject to the export or import laws in other countries. Nuclear, missile, - * chemical biological weapons or nuclear maritime end uses or end users, - * whether direct or indirect, are strictly prohibited. Export or reexport - * to countries subject to U.S. embargo or to entities identified on U.S. - * export exclusion lists, including, but not limited to, the denied persons - * and specially designated nationals lists is strictly prohibited. - */ - -// Slightly modified version of javacc's reference 1.5 grammar, tweaked for -// usage with JAXX. There are two main areas of changes: several new -// nonterminals were added to make identifying certain constructs easier, -// and the Line nonterminal was added to support JAXX's script tags. -// Several of the new changes are inefficient and require excess lookahead, -// but at this point I'd rather have inefficiency than risk breaking it during -// attempted optimizations. - -options { - JAVA_UNICODE_ESCAPE = true; - ERROR_REPORTING = false; - STATIC = false; - JDK_VERSION = "1.4"; -} - -PARSER_BEGIN(JavaParser) -package jaxx.parser; - -import java.io.*; - -/** - * Grammar to parse Java version 1.5 - * @author Sreenivasa Viswanadha - Simplified and enhanced for 1.5 - */ -public class JavaParser/*@bgen(jjtree)*/implements JavaParserTreeConstants/*@egen*/ -{/*@bgen(jjtree)*/ - protected JJTJavaParserState jjtree = new JJTJavaParserState(); - -/*@egen*/ - /** - * Class to hold modifiers. - */ - static public final class ModifierSet - { - /* Definitions of the bits in the modifiers field. */ - public static final int PUBLIC = 0x0001; - public static final int PROTECTED = 0x0002; - public static final int PRIVATE = 0x0004; - public static final int ABSTRACT = 0x0008; - public static final int STATIC = 0x0010; - public static final int FINAL = 0x0020; - public static final int SYNCHRONIZED = 0x0040; - public static final int NATIVE = 0x0080; - public static final int TRANSIENT = 0x0100; - public static final int VOLATILE = 0x0200; - public static final int STRICTFP = 0x1000; - - /** A set of accessors that indicate whether the specified modifier - is in the set. */ - - public boolean isPublic(int modifiers) - { - return (modifiers & PUBLIC) != 0; - } - - public boolean isProtected(int modifiers) - { - return (modifiers & PROTECTED) != 0; - } - - public boolean isPrivate(int modifiers) - { - return (modifiers & PRIVATE) != 0; - } - - public boolean isStatic(int modifiers) - { - return (modifiers & STATIC) != 0; - } - - public boolean isAbstract(int modifiers) - { - return (modifiers & ABSTRACT) != 0; - } - - public boolean isFinal(int modifiers) - { - return (modifiers & FINAL) != 0; - } - - public boolean isNative(int modifiers) - { - return (modifiers & NATIVE) != 0; - } - - public boolean isStrictfp(int modifiers) - { - return (modifiers & STRICTFP) != 0; - } - - public boolean isSynchronized(int modifiers) - { - return (modifiers & SYNCHRONIZED) != 0; - } - - public boolean isTransient(int modifiers) - { - return (modifiers & TRANSIENT) != 0; - } - - public boolean isVolatile(int modifiers) - { - return (modifiers & VOLATILE) != 0; - } - - /** - * Removes the given modifier. - */ - static int removeModifier(int modifiers, int mod) - { - return modifiers & ~mod; - } - } - - public JavaParser(String fileName) - { - this(System.in); - try { ReInit(new FileInputStream(new File(fileName))); } - catch(Exception e) { e.printStackTrace(); } - } - - void jjtreeOpenNodeScope(Node n) { - ((SimpleNode) n).firstToken = getToken(1); - } - - void jjtreeCloseNodeScope(Node n) { - ((SimpleNode) n).lastToken = getToken(0); - } - - public SimpleNode popNode() - { - if ( jjtree.nodeArity() > 0) // number of child nodes - return (SimpleNode)jjtree.popNode(); - else - return null; - } - public static void main(String args[]) { - JavaParser parser; - if (args.length == 0) { - System.out.println("Java Parser Version 1.1: Reading from standard input . . ."); - parser = new JavaParser(System.in); - } else if (args.length == 1) { - System.out.println("Java Parser Version 1.1: Reading from file " + args[0] + " . . ."); - try { - parser = new JavaParser(new java.io.FileInputStream(args[0])); - } catch (java.io.FileNotFoundException e) { - System.out.println("Java Parser Version 1.1: File " + args[0] + " not found."); - return; - } - } else { - System.out.println("Java Parser Version 1.1: Usage is one of:"); - System.out.println(" java JavaParser < inputfile"); - System.out.println("OR"); - System.out.println(" java JavaParser inputfile"); - return; - } - try { - parser.CompilationUnit(); - System.out.println("Java Parser Version 1.1: Java program parsed successfully."); - } catch (ParseException e) { - System.out.println(e.getMessage()); - System.out.println("Java Parser Version 1.1: Encountered errors during parse."); - } - } - -} - -PARSER_END(JavaParser) - -/* COMMENTS */ - -MORE : -{ - <"/**" ~["/"]> { input_stream.backup(1); } : IN_FORMAL_COMMENT -| - "/*" : IN_MULTI_LINE_COMMENT -} - -SPECIAL_TOKEN: -{ - <WHITE_SPACE: ([" ", "\n", "\r", "\t", "\f"])+> -} - -SPECIAL_TOKEN : -{ - <SINGLE_LINE_COMMENT: "//" (~["\n", "\r"])* ("\n" | "\r" | "\r\n")?> -} - -<IN_FORMAL_COMMENT> -SPECIAL_TOKEN : -{ - <FORMAL_COMMENT: "*/" > : DEFAULT -} - -<IN_MULTI_LINE_COMMENT> -SPECIAL_TOKEN : -{ - <MULTI_LINE_COMMENT: "*/" > : DEFAULT -} - -<IN_FORMAL_COMMENT,IN_MULTI_LINE_COMMENT> -MORE : -{ - < ~[] > -} - -/* RESERVED WORDS AND LITERALS */ - -TOKEN : -{ - < ABSTRACT: "abstract" > -| < ASSERT: "assert" > -| < BOOLEAN: "boolean" > -| < BREAK: "break" > -| < BYTE: "byte" > -| < CASE: "case" > -| < CATCH: "catch" > -| < CHAR: "char" > -| < CLASS: "class" > -| < CONST: "const" > -| < CONTINUE: "continue" > -| < _DEFAULT: "default" > -| < DO: "do" > -| < DOUBLE: "double" > -| < ELSE: "else" > -| < ENUM: "enum" > -| < EXTENDS: "extends" > -| < FALSE: "false" > -| < FINAL: "final" > -| < FINALLY: "finally" > -| < FLOAT: "float" > -| < FOR: "for" > -| < GOTO: "goto" > -| < IF: "if" > -| < IMPLEMENTS: "implements" > -| < IMPORT: "import" > -| < INSTANCEOF: "instanceof" > -| < INT: "int" > -| < INTERFACE: "interface" > -| < LONG: "long" > -| < NATIVE: "native" > -| < NEW: "new" > -| < NULL: "null" > -| < PACKAGE: "package"> -| < PRIVATE: "private" > -| < PROTECTED: "protected" > -| < PUBLIC: "public" > -| < RETURN: "return" > -| < SHORT: "short" > -| < STATIC: "static" > -| < STRICTFP: "strictfp" > -| < SUPER: "super" > -| < SWITCH: "switch" > -| < SYNCHRONIZED: "synchronized" > -| < THIS: "this" > -| < THROW: "throw" > -| < THROWS: "throws" > -| < TRANSIENT: "transient" > -| < TRUE: "true" > -| < TRY: "try" > -| < VOID: "void" > -| < VOLATILE: "volatile" > -| < WHILE: "while" > -} - -/* LITERALS */ - -TOKEN : -{ - < INTEGER_LITERAL: - <DECIMAL_LITERAL> (["l","L"])? - | <HEX_LITERAL> (["l","L"])? - | <OCTAL_LITERAL> (["l","L"])? - > -| - < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* > -| - < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ > -| - < #OCTAL_LITERAL: "0" (["0"-"7"])* > -| - < FLOATING_POINT_LITERAL: - <DECIMAL_FLOATING_POINT_LITERAL> - | <HEXADECIMAL_FLOATING_POINT_LITERAL> - > -| - < #DECIMAL_FLOATING_POINT_LITERAL: - (["0"-"9"])+ "." (["0"-"9"])* (<DECIMAL_EXPONENT>)? (["f","F","d","D"])? - | "." (["0"-"9"])+ (<DECIMAL_EXPONENT>)? (["f","F","d","D"])? - | (["0"-"9"])+ <DECIMAL_EXPONENT> (["f","F","d","D"])? - | (["0"-"9"])+ (<DECIMAL_EXPONENT>)? ["f","F","d","D"] - > -| - < #DECIMAL_EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ > -| - < #HEXADECIMAL_FLOATING_POINT_LITERAL: - "0" ["x", "X"] (["0"-"9","a"-"f","A"-"F"])+ (".")? <HEXADECIMAL_EXPONENT> (["f","F","d","D"])? - | "0" ["x", "X"] (["0"-"9","a"-"f","A"-"F"])* "." (["0"-"9","a"-"f","A"-"F"])+ <HEXADECIMAL_EXPONENT> (["f","F","d","D"])? - > -| - < #HEXADECIMAL_EXPONENT: ["p","P"] (["+","-"])? (["0"-"9"])+ > -| - < CHARACTER_LITERAL: - "'" - ( (~["'","\\","\n","\r"]) - | ("\\" - ( ["n","t","b","r","f","\\","'","\""] - | ["0"-"7"] ( ["0"-"7"] )? - | ["0"-"3"] ["0"-"7"] ["0"-"7"] - ) - ) - ) - "'" - > -| - < STRING_LITERAL: - "\"" - ( (~["\"","\\","\n","\r"]) - | ("\\" - ( ["n","t","b","r","f","\\","'","\""] - | ["0"-"7"] ( ["0"-"7"] )? - | ["0"-"3"] ["0"-"7"] ["0"-"7"] - ) - ) - )* - "\"" - > -} - -/* IDENTIFIERS */ - -TOKEN : -{ - < IDENTIFIER: <LETTER> (<PART_LETTER>)* > -| - < #LETTER: - [ // all chars for which Character.isIdentifierStart is true - "$", - "A"-"Z", - "_", - "a"-"z", - "\u00a2"-"\u00a5", - "\u00aa", - "\u00b5", - "\u00ba", - "\u00c0"-"\u00d6", - "\u00d8"-"\u00f6", - "\u00f8"-"\u021f", - "\u0222"-"\u0233", - "\u0250"-"\u02ad", - "\u02b0"-"\u02b8", - "\u02bb"-"\u02c1", - "\u02d0"-"\u02d1", - "\u02e0"-"\u02e4", - "\u02ee", - "\u037a", - "\u0386", - "\u0388"-"\u038a", - "\u038c", - "\u038e"-"\u03a1", - "\u03a3"-"\u03ce", - "\u03d0"-"\u03d7", - "\u03da"-"\u03f3", - "\u0400"-"\u0481", - "\u048c"-"\u04c4", - "\u04c7"-"\u04c8", - "\u04cb"-"\u04cc", - "\u04d0"-"\u04f5", - "\u04f8"-"\u04f9", - "\u0531"-"\u0556", - "\u0559", - "\u0561"-"\u0587", - "\u05d0"-"\u05ea", - "\u05f0"-"\u05f2", - "\u0621"-"\u063a", - "\u0640"-"\u064a", - "\u0671"-"\u06d3", - "\u06d5", - "\u06e5"-"\u06e6", - "\u06fa"-"\u06fc", - "\u0710", - "\u0712"-"\u072c", - "\u0780"-"\u07a5", - "\u0905"-"\u0939", - "\u093d", - "\u0950", - "\u0958"-"\u0961", - "\u0985"-"\u098c", - "\u098f"-"\u0990", - "\u0993"-"\u09a8", - "\u09aa"-"\u09b0", - "\u09b2", - "\u09b6"-"\u09b9", - "\u09dc"-"\u09dd", - "\u09df"-"\u09e1", - "\u09f0"-"\u09f3", - "\u0a05"-"\u0a0a", - "\u0a0f"-"\u0a10", - "\u0a13"-"\u0a28", - "\u0a2a"-"\u0a30", - "\u0a32"-"\u0a33", - "\u0a35"-"\u0a36", - "\u0a38"-"\u0a39", - "\u0a59"-"\u0a5c", - "\u0a5e", - "\u0a72"-"\u0a74", - "\u0a85"-"\u0a8b", - "\u0a8d", - "\u0a8f"-"\u0a91", - "\u0a93"-"\u0aa8", - "\u0aaa"-"\u0ab0", - "\u0ab2"-"\u0ab3", - "\u0ab5"-"\u0ab9", - "\u0abd", - "\u0ad0", - "\u0ae0", - "\u0b05"-"\u0b0c", - "\u0b0f"-"\u0b10", - "\u0b13"-"\u0b28", - "\u0b2a"-"\u0b30", - "\u0b32"-"\u0b33", - "\u0b36"-"\u0b39", - "\u0b3d", - "\u0b5c"-"\u0b5d", - "\u0b5f"-"\u0b61", - "\u0b85"-"\u0b8a", - "\u0b8e"-"\u0b90", - "\u0b92"-"\u0b95", - "\u0b99"-"\u0b9a", - "\u0b9c", - "\u0b9e"-"\u0b9f", - "\u0ba3"-"\u0ba4", - "\u0ba8"-"\u0baa", - "\u0bae"-"\u0bb5", - "\u0bb7"-"\u0bb9", - "\u0c05"-"\u0c0c", - "\u0c0e"-"\u0c10", - "\u0c12"-"\u0c28", - "\u0c2a"-"\u0c33", - "\u0c35"-"\u0c39", - "\u0c60"-"\u0c61", - "\u0c85"-"\u0c8c", - "\u0c8e"-"\u0c90", - "\u0c92"-"\u0ca8", - "\u0caa"-"\u0cb3", - "\u0cb5"-"\u0cb9", - "\u0cde", - "\u0ce0"-"\u0ce1", - "\u0d05"-"\u0d0c", - "\u0d0e"-"\u0d10", - "\u0d12"-"\u0d28", - "\u0d2a"-"\u0d39", - "\u0d60"-"\u0d61", - "\u0d85"-"\u0d96", - "\u0d9a"-"\u0db1", - "\u0db3"-"\u0dbb", - "\u0dbd", - "\u0dc0"-"\u0dc6", - "\u0e01"-"\u0e30", - "\u0e32"-"\u0e33", - "\u0e3f"-"\u0e46", - "\u0e81"-"\u0e82", - "\u0e84", - "\u0e87"-"\u0e88", - "\u0e8a", - "\u0e8d", - "\u0e94"-"\u0e97", - "\u0e99"-"\u0e9f", - "\u0ea1"-"\u0ea3", - "\u0ea5", - "\u0ea7", - "\u0eaa"-"\u0eab", - "\u0ead"-"\u0eb0", - "\u0eb2"-"\u0eb3", - "\u0ebd", - "\u0ec0"-"\u0ec4", - "\u0ec6", - "\u0edc"-"\u0edd", - "\u0f00", - "\u0f40"-"\u0f47", - "\u0f49"-"\u0f6a", - "\u0f88"-"\u0f8b", - "\u1000"-"\u1021", - "\u1023"-"\u1027", - "\u1029"-"\u102a", - "\u1050"-"\u1055", - "\u10a0"-"\u10c5", - "\u10d0"-"\u10f6", - "\u1100"-"\u1159", - "\u115f"-"\u11a2", - "\u11a8"-"\u11f9", - "\u1200"-"\u1206", - "\u1208"-"\u1246", - "\u1248", - "\u124a"-"\u124d", - "\u1250"-"\u1256", - "\u1258", - "\u125a"-"\u125d", - "\u1260"-"\u1286", - "\u1288", - "\u128a"-"\u128d", - "\u1290"-"\u12ae", - "\u12b0", - "\u12b2"-"\u12b5", - "\u12b8"-"\u12be", - "\u12c0", - "\u12c2"-"\u12c5", - "\u12c8"-"\u12ce", - "\u12d0"-"\u12d6", - "\u12d8"-"\u12ee", - "\u12f0"-"\u130e", - "\u1310", - "\u1312"-"\u1315", - "\u1318"-"\u131e", - "\u1320"-"\u1346", - "\u1348"-"\u135a", - "\u13a0"-"\u13f4", - "\u1401"-"\u166c", - "\u166f"-"\u1676", - "\u1681"-"\u169a", - "\u16a0"-"\u16ea", - "\u1780"-"\u17b3", - "\u17db", - "\u1820"-"\u1877", - "\u1880"-"\u18a8", - "\u1e00"-"\u1e9b", - "\u1ea0"-"\u1ef9", - "\u1f00"-"\u1f15", - "\u1f18"-"\u1f1d", - "\u1f20"-"\u1f45", - "\u1f48"-"\u1f4d", - "\u1f50"-"\u1f57", - "\u1f59", - "\u1f5b", - "\u1f5d", - "\u1f5f"-"\u1f7d", - "\u1f80"-"\u1fb4", - "\u1fb6"-"\u1fbc", - "\u1fbe", - "\u1fc2"-"\u1fc4", - "\u1fc6"-"\u1fcc", - "\u1fd0"-"\u1fd3", - "\u1fd6"-"\u1fdb", - "\u1fe0"-"\u1fec", - "\u1ff2"-"\u1ff4", - "\u1ff6"-"\u1ffc", - "\u203f"-"\u2040", - "\u207f", - "\u20a0"-"\u20af", - "\u2102", - "\u2107", - "\u210a"-"\u2113", - "\u2115", - "\u2119"-"\u211d", - "\u2124", - "\u2126", - "\u2128", - "\u212a"-"\u212d", - "\u212f"-"\u2131", - "\u2133"-"\u2139", - "\u2160"-"\u2183", - "\u3005"-"\u3007", - "\u3021"-"\u3029", - "\u3031"-"\u3035", - "\u3038"-"\u303a", - "\u3041"-"\u3094", - "\u309d"-"\u309e", - "\u30a1"-"\u30fe", - "\u3105"-"\u312c", - "\u3131"-"\u318e", - "\u31a0"-"\u31b7", - "\u3400"-"\u4db5", - "\u4e00"-"\u9fa5", - "\ua000"-"\ua48c", - "\uac00"-"\ud7a3", - "\uf900"-"\ufa2d", - "\ufb00"-"\ufb06", - "\ufb13"-"\ufb17", - "\ufb1d", - "\ufb1f"-"\ufb28", - "\ufb2a"-"\ufb36", - "\ufb38"-"\ufb3c", - "\ufb3e", - "\ufb40"-"\ufb41", - "\ufb43"-"\ufb44", - "\ufb46"-"\ufbb1", - "\ufbd3"-"\ufd3d", - "\ufd50"-"\ufd8f", - "\ufd92"-"\ufdc7", - "\ufdf0"-"\ufdfb", - "\ufe33"-"\ufe34", - "\ufe4d"-"\ufe4f", - "\ufe69", - "\ufe70"-"\ufe72", - "\ufe74", - "\ufe76"-"\ufefc", - "\uff04", - "\uff21"-"\uff3a", - "\uff3f", - "\uff41"-"\uff5a", - "\uff65"-"\uffbe", - "\uffc2"-"\uffc7", - "\uffca"-"\uffcf", - "\uffd2"-"\uffd7", - "\uffda"-"\uffdc", - "\uffe0"-"\uffe1", - "\uffe5"-"\uffe6" - ] - > -| - < #PART_LETTER: - [ // all chars for which Character.isIdentifierPart is true - "\u0000"-"\u0008", - "\u000e"-"\u001b", - "$", - "0"-"9", - "A"-"Z", - "_", - "a"-"z", - "\u007f"-"\u009f", - "\u00a2"-"\u00a5", - "\u00aa", - "\u00b5", - "\u00ba", - "\u00c0"-"\u00d6", - "\u00d8"-"\u00f6", - "\u00f8"-"\u021f", - "\u0222"-"\u0233", - "\u0250"-"\u02ad", - "\u02b0"-"\u02b8", - "\u02bb"-"\u02c1", - "\u02d0"-"\u02d1", - "\u02e0"-"\u02e4", - "\u02ee", - "\u0300"-"\u034e", - "\u0360"-"\u0362", - "\u037a", - "\u0386", - "\u0388"-"\u038a", - "\u038c", - "\u038e"-"\u03a1", - "\u03a3"-"\u03ce", - "\u03d0"-"\u03d7", - "\u03da"-"\u03f3", - "\u0400"-"\u0481", - "\u0483"-"\u0486", - "\u048c"-"\u04c4", - "\u04c7"-"\u04c8", - "\u04cb"-"\u04cc", - "\u04d0"-"\u04f5", - "\u04f8"-"\u04f9", - "\u0531"-"\u0556", - "\u0559", - "\u0561"-"\u0587", - "\u0591"-"\u05a1", - "\u05a3"-"\u05b9", - "\u05bb"-"\u05bd", - "\u05bf", - "\u05c1"-"\u05c2", - "\u05c4", - "\u05d0"-"\u05ea", - "\u05f0"-"\u05f2", - "\u0621"-"\u063a", - "\u0640"-"\u0655", - "\u0660"-"\u0669", - "\u0670"-"\u06d3", - "\u06d5"-"\u06dc", - "\u06df"-"\u06e8", - "\u06ea"-"\u06ed", - "\u06f0"-"\u06fc", - "\u070f"-"\u072c", - "\u0730"-"\u074a", - "\u0780"-"\u07b0", - "\u0901"-"\u0903", - "\u0905"-"\u0939", - "\u093c"-"\u094d", - "\u0950"-"\u0954", - "\u0958"-"\u0963", - "\u0966"-"\u096f", - "\u0981"-"\u0983", - "\u0985"-"\u098c", - "\u098f"-"\u0990", - "\u0993"-"\u09a8", - "\u09aa"-"\u09b0", - "\u09b2", - "\u09b6"-"\u09b9", - "\u09bc", - "\u09be"-"\u09c4", - "\u09c7"-"\u09c8", - "\u09cb"-"\u09cd", - "\u09d7", - "\u09dc"-"\u09dd", - "\u09df"-"\u09e3", - "\u09e6"-"\u09f3", - "\u0a02", - "\u0a05"-"\u0a0a", - "\u0a0f"-"\u0a10", - "\u0a13"-"\u0a28", - "\u0a2a"-"\u0a30", - "\u0a32"-"\u0a33", - "\u0a35"-"\u0a36", - "\u0a38"-"\u0a39", - "\u0a3c", - "\u0a3e"-"\u0a42", - "\u0a47"-"\u0a48", - "\u0a4b"-"\u0a4d", - "\u0a59"-"\u0a5c", - "\u0a5e", - "\u0a66"-"\u0a74", - "\u0a81"-"\u0a83", - "\u0a85"-"\u0a8b", - "\u0a8d", - "\u0a8f"-"\u0a91", - "\u0a93"-"\u0aa8", - "\u0aaa"-"\u0ab0", - "\u0ab2"-"\u0ab3", - "\u0ab5"-"\u0ab9", - "\u0abc"-"\u0ac5", - "\u0ac7"-"\u0ac9", - "\u0acb"-"\u0acd", - "\u0ad0", - "\u0ae0", - "\u0ae6"-"\u0aef", - "\u0b01"-"\u0b03", - "\u0b05"-"\u0b0c", - "\u0b0f"-"\u0b10", - "\u0b13"-"\u0b28", - "\u0b2a"-"\u0b30", - "\u0b32"-"\u0b33", - "\u0b36"-"\u0b39", - "\u0b3c"-"\u0b43", - "\u0b47"-"\u0b48", - "\u0b4b"-"\u0b4d", - "\u0b56"-"\u0b57", - "\u0b5c"-"\u0b5d", - "\u0b5f"-"\u0b61", - "\u0b66"-"\u0b6f", - "\u0b82"-"\u0b83", - "\u0b85"-"\u0b8a", - "\u0b8e"-"\u0b90", - "\u0b92"-"\u0b95", - "\u0b99"-"\u0b9a", - "\u0b9c", - "\u0b9e"-"\u0b9f", - "\u0ba3"-"\u0ba4", - "\u0ba8"-"\u0baa", - "\u0bae"-"\u0bb5", - "\u0bb7"-"\u0bb9", - "\u0bbe"-"\u0bc2", - "\u0bc6"-"\u0bc8", - "\u0bca"-"\u0bcd", - "\u0bd7", - "\u0be7"-"\u0bef", - "\u0c01"-"\u0c03", - "\u0c05"-"\u0c0c", - "\u0c0e"-"\u0c10", - "\u0c12"-"\u0c28", - "\u0c2a"-"\u0c33", - "\u0c35"-"\u0c39", - "\u0c3e"-"\u0c44", - "\u0c46"-"\u0c48", - "\u0c4a"-"\u0c4d", - "\u0c55"-"\u0c56", - "\u0c60"-"\u0c61", - "\u0c66"-"\u0c6f", - "\u0c82"-"\u0c83", - "\u0c85"-"\u0c8c", - "\u0c8e"-"\u0c90", - "\u0c92"-"\u0ca8", - "\u0caa"-"\u0cb3", - "\u0cb5"-"\u0cb9", - "\u0cbe"-"\u0cc4", - "\u0cc6"-"\u0cc8", - "\u0cca"-"\u0ccd", - "\u0cd5"-"\u0cd6", - "\u0cde", - "\u0ce0"-"\u0ce1", - "\u0ce6"-"\u0cef", - "\u0d02"-"\u0d03", - "\u0d05"-"\u0d0c", - "\u0d0e"-"\u0d10", - "\u0d12"-"\u0d28", - "\u0d2a"-"\u0d39", - "\u0d3e"-"\u0d43", - "\u0d46"-"\u0d48", - "\u0d4a"-"\u0d4d", - "\u0d57", - "\u0d60"-"\u0d61", - "\u0d66"-"\u0d6f", - "\u0d82"-"\u0d83", - "\u0d85"-"\u0d96", - "\u0d9a"-"\u0db1", - "\u0db3"-"\u0dbb", - "\u0dbd", - "\u0dc0"-"\u0dc6", - "\u0dca", - "\u0dcf"-"\u0dd4", - "\u0dd6", - "\u0dd8"-"\u0ddf", - "\u0df2"-"\u0df3", - "\u0e01"-"\u0e3a", - "\u0e3f"-"\u0e4e", - "\u0e50"-"\u0e59", - "\u0e81"-"\u0e82", - "\u0e84", - "\u0e87"-"\u0e88", - "\u0e8a", - "\u0e8d", - "\u0e94"-"\u0e97", - "\u0e99"-"\u0e9f", - "\u0ea1"-"\u0ea3", - "\u0ea5", - "\u0ea7", - "\u0eaa"-"\u0eab", - "\u0ead"-"\u0eb9", - "\u0ebb"-"\u0ebd", - "\u0ec0"-"\u0ec4", - "\u0ec6", - "\u0ec8"-"\u0ecd", - "\u0ed0"-"\u0ed9", - "\u0edc"-"\u0edd", - "\u0f00", - "\u0f18"-"\u0f19", - "\u0f20"-"\u0f29", - "\u0f35", - "\u0f37", - "\u0f39", - "\u0f3e"-"\u0f47", - "\u0f49"-"\u0f6a", - "\u0f71"-"\u0f84", - "\u0f86"-"\u0f8b", - "\u0f90"-"\u0f97", - "\u0f99"-"\u0fbc", - "\u0fc6", - "\u1000"-"\u1021", - "\u1023"-"\u1027", - "\u1029"-"\u102a", - "\u102c"-"\u1032", - "\u1036"-"\u1039", - "\u1040"-"\u1049", - "\u1050"-"\u1059", - "\u10a0"-"\u10c5", - "\u10d0"-"\u10f6", - "\u1100"-"\u1159", - "\u115f"-"\u11a2", - "\u11a8"-"\u11f9", - "\u1200"-"\u1206", - "\u1208"-"\u1246", - "\u1248", - "\u124a"-"\u124d", - "\u1250"-"\u1256", - "\u1258", - "\u125a"-"\u125d", - "\u1260"-"\u1286", - "\u1288", - "\u128a"-"\u128d", - "\u1290"-"\u12ae", - "\u12b0", - "\u12b2"-"\u12b5", - "\u12b8"-"\u12be", - "\u12c0", - "\u12c2"-"\u12c5", - "\u12c8"-"\u12ce", - "\u12d0"-"\u12d6", - "\u12d8"-"\u12ee", - "\u12f0"-"\u130e", - "\u1310", - "\u1312"-"\u1315", - "\u1318"-"\u131e", - "\u1320"-"\u1346", - "\u1348"-"\u135a", - "\u1369"-"\u1371", - "\u13a0"-"\u13f4", - "\u1401"-"\u166c", - "\u166f"-"\u1676", - "\u1681"-"\u169a", - "\u16a0"-"\u16ea", - "\u1780"-"\u17d3", - "\u17db", - "\u17e0"-"\u17e9", - "\u180b"-"\u180e", - "\u1810"-"\u1819", - "\u1820"-"\u1877", - "\u1880"-"\u18a9", - "\u1e00"-"\u1e9b", - "\u1ea0"-"\u1ef9", - "\u1f00"-"\u1f15", - "\u1f18"-"\u1f1d", - "\u1f20"-"\u1f45", - "\u1f48"-"\u1f4d", - "\u1f50"-"\u1f57", - "\u1f59", - "\u1f5b", - "\u1f5d", - "\u1f5f"-"\u1f7d", - "\u1f80"-"\u1fb4", - "\u1fb6"-"\u1fbc", - "\u1fbe", - "\u1fc2"-"\u1fc4", - "\u1fc6"-"\u1fcc", - "\u1fd0"-"\u1fd3", - "\u1fd6"-"\u1fdb", - "\u1fe0"-"\u1fec", - "\u1ff2"-"\u1ff4", - "\u1ff6"-"\u1ffc", - "\u200c"-"\u200f", - "\u202a"-"\u202e", - "\u203f"-"\u2040", - "\u206a"-"\u206f", - "\u207f", - "\u20a0"-"\u20af", - "\u20d0"-"\u20dc", - "\u20e1", - "\u2102", - "\u2107", - "\u210a"-"\u2113", - "\u2115", - "\u2119"-"\u211d", - "\u2124", - "\u2126", - "\u2128", - "\u212a"-"\u212d", - "\u212f"-"\u2131", - "\u2133"-"\u2139", - "\u2160"-"\u2183", - "\u3005"-"\u3007", - "\u3021"-"\u302f", - "\u3031"-"\u3035", - "\u3038"-"\u303a", - "\u3041"-"\u3094", - "\u3099"-"\u309a", - "\u309d"-"\u309e", - "\u30a1"-"\u30fe", - "\u3105"-"\u312c", - "\u3131"-"\u318e", - "\u31a0"-"\u31b7", - "\u3400"-"\u4db5", - "\u4e00"-"\u9fa5", - "\ua000"-"\ua48c", - "\uac00"-"\ud7a3", - "\uf900"-"\ufa2d", - "\ufb00"-"\ufb06", - "\ufb13"-"\ufb17", - "\ufb1d"-"\ufb28", - "\ufb2a"-"\ufb36", - "\ufb38"-"\ufb3c", - "\ufb3e", - "\ufb40"-"\ufb41", - "\ufb43"-"\ufb44", - "\ufb46"-"\ufbb1", - "\ufbd3"-"\ufd3d", - "\ufd50"-"\ufd8f", - "\ufd92"-"\ufdc7", - "\ufdf0"-"\ufdfb", - "\ufe20"-"\ufe23", - "\ufe33"-"\ufe34", - "\ufe4d"-"\ufe4f", - "\ufe69", - "\ufe70"-"\ufe72", - "\ufe74", - "\ufe76"-"\ufefc", - "\ufeff", - "\uff04", - "\uff10"-"\uff19", - "\uff21"-"\uff3a", - "\uff3f", - "\uff41"-"\uff5a", - "\uff65"-"\uffbe", - "\uffc2"-"\uffc7", - "\uffca"-"\uffcf", - "\uffd2"-"\uffd7", - "\uffda"-"\uffdc", - "\uffe0"-"\uffe1", - "\uffe5"-"\uffe6", - "\ufff9"-"\ufffb" - ] - > -} - -/* SEPARATORS */ - -TOKEN : -{ - < LPAREN: "(" > -| < RPAREN: ")" > -| < LBRACE: "{" > -| < RBRACE: "}" > -| < LBRACKET: "[" > -| < RBRACKET: "]" > -| < SEMICOLON: ";" > -| < COMMA: "," > -| < DOT: "." > -| < AT: "@" > -} - -/* OPERATORS */ - -TOKEN : -{ - < ASSIGN: "=" > -| < LT: "<" > -| < BANG: "!" > -| < TILDE: "~" > -| < HOOK: "?" > -| < COLON: ":" > -| < EQ: "==" > -| < LE: "<=" > -| < GE: ">=" > -| < NE: "!=" > -| < SC_OR: "||" > -| < SC_AND: "&&" > -| < INCR: "++" > -| < DECR: "--" > -| < PLUS: "+" > -| < MINUS: "-" > -| < STAR: "*" > -| < SLASH: "/" > -| < BIT_AND: "&" > -| < BIT_OR: "|" > -| < XOR: "^" > -| < REM: "%" > -| < LSHIFT: "<<" > -| < PLUSASSIGN: "+=" > -| < MINUSASSIGN: "-=" > -| < STARASSIGN: "*=" > -| < SLASHASSIGN: "/=" > -| < ANDASSIGN: "&=" > -| < ORASSIGN: "|=" > -| < XORASSIGN: "^=" > -| < REMASSIGN: "%=" > -| < LSHIFTASSIGN: "<<=" > -| < RSIGNEDSHIFTASSIGN: ">>=" > -| < RUNSIGNEDSHIFTASSIGN: ">>>=" > -| < ELLIPSIS: "..." > -} - -/* >'s need special attention due to generics syntax. */ -TOKEN : -{ - < RUNSIGNEDSHIFT: ">>>" > - { - matchedToken.kind = GT; - ((Token.GTToken)matchedToken).realKind = RUNSIGNEDSHIFT; - input_stream.backup(2); - matchedToken.image = ">"; - } -| < RSIGNEDSHIFT: ">>" > - { - matchedToken.kind = GT; - ((Token.GTToken)matchedToken).realKind = RSIGNEDSHIFT; - input_stream.backup(1); - matchedToken.image = ">"; - } -| < GT: ">" > -} - -boolean Line() : -{/*@bgen(jjtree) Line */ - SimpleNode jjtn000 = new SimpleNode(JJTLINE); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/ - int modifiers; -} -{/*@bgen(jjtree) Line */ - try { -/*@egen*/ - <EOF>/*@bgen(jjtree)*/ - { - jjtree.closeNodeScope(jjtn000, true); - jjtc000 = false; - jjtreeCloseNodeScope(jjtn000); - } -/*@egen*/ { - return true; - } -| - LOOKAHEAD(BlockStatement()) - BlockStatement()/*@bgen(jjtree)*/ - { - jjtree.closeNodeScope(jjtn000, true); - jjtc000 = false; - jjtreeCloseNodeScope(jjtn000); - } -/*@egen*/ { - return false; - } -| - LOOKAHEAD(Modifiers() [ TypeParameters() ] [ ResultType() ] <IDENTIFIER> FormalParameters() [ "throws" NameList() ] "{") - ClassOrInterfaceBodyDeclaration(false)/*@bgen(jjtree)*/ - { - jjtree.closeNodeScope(jjtn000, true); - jjtc000 = false; - jjtreeCloseNodeScope(jjtn000); - } -/*@egen*/ { - return false; - } -| - LOOKAHEAD(ClassOrInterfaceBodyDeclaration(false)) - ClassOrInterfaceBodyDeclaration(false)/*@bgen(jjtree)*/ - { - jjtree.closeNodeScope(jjtn000, true); - jjtc000 = false; - jjtreeCloseNodeScope(jjtn000); - } -/*@egen*/ { - return false; - } -| - LOOKAHEAD(Expression()) - Expression()/*@bgen(jjtree)*/ - { - jjtree.closeNodeScope(jjtn000, true); - jjtc000 = false; - jjtreeCloseNodeScope(jjtn000); - } -/*@egen*/ { - return false; - } -| - ImportDeclaration()/*@bgen(jjtree)*/ - { - jjtree.closeNodeScope(jjtn000, true); - jjtc000 = false; - jjtreeCloseNodeScope(jjtn000); - } -/*@egen*/ { - return false; - }/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -/***************************************** - * THE JAVA LANGUAGE GRAMMAR STARTS HERE * - *****************************************/ - -/* - * Program structuring syntax follows. - */ - -void CompilationUnit(): -{/*@bgen(jjtree) CompilationUnit */ - SimpleNode jjtn000 = new SimpleNode(JJTCOMPILATIONUNIT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) CompilationUnit */ - try { -/*@egen*/ - [ LOOKAHEAD( ( Annotation() )* "package" ) PackageDeclaration() ] - ( ImportDeclaration() )* - ( TypeDeclaration() )* - ( < "\u001a" > )? - ( <STUFF_TO_IGNORE: ~[]> )? - <EOF>/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void PackageDeclaration(): -{/*@bgen(jjtree) PackageDeclaration */ - SimpleNode jjtn000 = new SimpleNode(JJTPACKAGEDECLARATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) PackageDeclaration */ - try { -/*@egen*/ - Modifiers() "package" Name() ";"/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void ImportDeclaration(): -{/*@bgen(jjtree) ImportDeclaration */ - SimpleNode jjtn000 = new SimpleNode(JJTIMPORTDECLARATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) ImportDeclaration */ - try { -/*@egen*/ - "import" [ "static" ] Name() [ "." "*" ] ";"/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -/* - * Modifiers. We match all modifiers in a single rule to reduce the chances of - * syntax errors for simple modifier mistakes. It will also enable us to give - * better error messages. - */ - -int Modifiers(): -{/*@bgen(jjtree) Modifiers */ - SimpleNode jjtn000 = new SimpleNode(JJTMODIFIERS); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/ - int modifiers = 0; -} -{/*@bgen(jjtree) Modifiers */ - try { -/*@egen*/ - ( - LOOKAHEAD(2) - ( - "public" { modifiers |= ModifierSet.PUBLIC; } - | - "static" { modifiers |= ModifierSet.STATIC; } - | - "protected" { modifiers |= ModifierSet.PROTECTED; } - | - "private" { modifiers |= ModifierSet.PRIVATE; } - | - "final" { modifiers |= ModifierSet.FINAL; } - | - "abstract" { modifiers |= ModifierSet.ABSTRACT; } - | - "synchronized" { modifiers |= ModifierSet.SYNCHRONIZED; } - | - "native" { modifiers |= ModifierSet.NATIVE; } - | - "transient" { modifiers |= ModifierSet.TRANSIENT; } - | - "volatile" { modifiers |= ModifierSet.VOLATILE; } - | - "strictfp" { modifiers |= ModifierSet.STRICTFP; } - | - Annotation() - ) - )*/*@bgen(jjtree)*/ - { - jjtree.closeNodeScope(jjtn000, true); - jjtc000 = false; - jjtreeCloseNodeScope(jjtn000); - } -/*@egen*/ - - { - return modifiers; - }/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -/* - * Declaration syntax follows. - */ -void TypeDeclaration(): -{/*@bgen(jjtree) TypeDeclaration */ - SimpleNode jjtn000 = new SimpleNode(JJTTYPEDECLARATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/ - int modifiers; -} -{/*@bgen(jjtree) TypeDeclaration */ - try { -/*@egen*/ - ";" -| - modifiers = Modifiers() - ( - ClassOrInterfaceDeclaration(modifiers) - | - EnumDeclaration(modifiers) - | - AnnotationTypeDeclaration(modifiers) - )/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - - -void ClassOrInterfaceDeclaration(int modifiers): -{/*@bgen(jjtree) ClassOrInterfaceDeclaration */ - SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACEDECLARATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/ - boolean isInterface = false; -} -{/*@bgen(jjtree) ClassOrInterfaceDeclaration */ - try { -/*@egen*/ - ( "class" | "interface" { isInterface = true; } ) - <IDENTIFIER> - [ TypeParameters() ] - [ ExtendsList(isInterface) ] - [ ImplementsList(isInterface) ] - ClassOrInterfaceBody(isInterface)/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void ExtendsList(boolean isInterface): -{/*@bgen(jjtree) ExtendsList */ - SimpleNode jjtn000 = new SimpleNode(JJTEXTENDSLIST); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/ - boolean extendsMoreThanOne = false; -} -{/*@bgen(jjtree) ExtendsList */ - try { -/*@egen*/ - "extends" ClassOrInterfaceType() - ( "," ClassOrInterfaceType() { extendsMoreThanOne = true; } )*/*@bgen(jjtree)*/ - { - jjtree.closeNodeScope(jjtn000, true); - jjtc000 = false; - jjtreeCloseNodeScope(jjtn000); - } -/*@egen*/ - { - if (extendsMoreThanOne && !isInterface) - throw new ParseException("A class cannot extend more than one other class"); - }/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void ImplementsList(boolean isInterface): -{/*@bgen(jjtree) ImplementsList */ - SimpleNode jjtn000 = new SimpleNode(JJTIMPLEMENTSLIST); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) ImplementsList */ - try { -/*@egen*/ - "implements" ClassOrInterfaceType() - ( "," ClassOrInterfaceType() )*/*@bgen(jjtree)*/ - { - jjtree.closeNodeScope(jjtn000, true); - jjtc000 = false; - jjtreeCloseNodeScope(jjtn000); - } -/*@egen*/ - { - if (isInterface) - throw new ParseException("An interface cannot implement other interfaces"); - }/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void EnumDeclaration(int modifiers): -{/*@bgen(jjtree) EnumDeclaration */ - SimpleNode jjtn000 = new SimpleNode(JJTENUMDECLARATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) EnumDeclaration */ - try { -/*@egen*/ - "enum" <IDENTIFIER> - [ ImplementsList(false) ] - EnumBody()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void EnumBody(): -{/*@bgen(jjtree) EnumBody */ - SimpleNode jjtn000 = new SimpleNode(JJTENUMBODY); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) EnumBody */ - try { -/*@egen*/ - "{" - [ EnumConstant() ( LOOKAHEAD(2) "," EnumConstant() )* ] - [ "," ] - [ ";" ( ClassOrInterfaceBodyDeclaration(false) )* ] - "}"/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void EnumConstant(): -{/*@bgen(jjtree) EnumConstant */ - SimpleNode jjtn000 = new SimpleNode(JJTENUMCONSTANT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) EnumConstant */ - try { -/*@egen*/ - Modifiers() <IDENTIFIER> [ Arguments() ] [ ClassOrInterfaceBody(false) ]/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void TypeParameters(): -{/*@bgen(jjtree) TypeParameters */ - SimpleNode jjtn000 = new SimpleNode(JJTTYPEPARAMETERS); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) TypeParameters */ - try { -/*@egen*/ - "<" TypeParameter() ( "," TypeParameter() )* ">"/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void TypeParameter(): -{/*@bgen(jjtree) TypeParameter */ - SimpleNode jjtn000 = new SimpleNode(JJTTYPEPARAMETER); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) TypeParameter */ - try { -/*@egen*/ - <IDENTIFIER> [ TypeBound() ]/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void TypeBound(): -{/*@bgen(jjtree) TypeBound */ - SimpleNode jjtn000 = new SimpleNode(JJTTYPEBOUND); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) TypeBound */ - try { -/*@egen*/ - "extends" ClassOrInterfaceType() ( "&" ClassOrInterfaceType() )*/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void ClassOrInterfaceBody(boolean isInterface): -{/*@bgen(jjtree) ClassOrInterfaceBody */ - SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACEBODY); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) ClassOrInterfaceBody */ - try { -/*@egen*/ - "{" ( ClassOrInterfaceBodyDeclaration(isInterface) )* "}"/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void ClassOrInterfaceBodyDeclaration(boolean isInterface): -{/*@bgen(jjtree) ClassOrInterfaceBodyDeclaration */ - SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACEBODYDECLARATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/ - boolean isNestedInterface = false; - int modifiers; -} -{/*@bgen(jjtree) ClassOrInterfaceBodyDeclaration */ - try { -/*@egen*/ - LOOKAHEAD(2) - Initializer()/*@bgen(jjtree)*/ - { - jjtree.closeNodeScope(jjtn000, true); - jjtc000 = false; - jjtreeCloseNodeScope(jjtn000); - } -/*@egen*/ - { - if (isInterface) - throw new ParseException("An interface cannot have initializers"); - } -| - modifiers = Modifiers() // Just get all the modifiers out of the way. If you want to do - // more checks, pass the modifiers down to the member - ( - ClassOrInterfaceDeclaration(modifiers) - | - EnumDeclaration(modifiers) - | - LOOKAHEAD( [ TypeParameters() ] <IDENTIFIER> "(" ) - ConstructorDeclaration() - | - LOOKAHEAD( Type() <IDENTIFIER> ( "[" "]" )* ( "," | "=" | ";" ) ) - FieldDeclaration(modifiers) - | - MethodDeclaration(modifiers) - ) -| - ";"/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void FieldDeclaration(int modifiers): -{/*@bgen(jjtree) FieldDeclaration */ - SimpleNode jjtn000 = new SimpleNode(JJTFIELDDECLARATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) FieldDeclaration */ - try { -/*@egen*/ - // Modifiers are already matched in the caller - Type() VariableDeclarator() ( "," VariableDeclarator() )* ";"/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void VariableDeclarator(): -{/*@bgen(jjtree) VariableDeclarator */ - SimpleNode jjtn000 = new SimpleNode(JJTVARIABLEDECLARATOR); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) VariableDeclarator */ - try { -/*@egen*/ - VariableDeclaratorId() [ "=" VariableInitializer() ]/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void VariableDeclaratorId(): -{/*@bgen(jjtree) VariableDeclaratorId */ - SimpleNode jjtn000 = new SimpleNode(JJTVARIABLEDECLARATORID); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) VariableDeclaratorId */ - try { -/*@egen*/ - <IDENTIFIER> ( "[" "]" )*/*@bgen(jjtree)*/ - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void VariableInitializer(): -{/*@bgen(jjtree) VariableInitializer */ - SimpleNode jjtn000 = new SimpleNode(JJTVARIABLEINITIALIZER); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) VariableInitializer */ - try { -/*@egen*/ - ArrayInitializer() -| - Expression()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void ArrayInitializer(): -{/*@bgen(jjtree) ArrayInitializer */ - SimpleNode jjtn000 = new SimpleNode(JJTARRAYINITIALIZER); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) ArrayInitializer */ - try { -/*@egen*/ - "{" [ VariableInitializer() ( LOOKAHEAD(2) "," VariableInitializer() )* ] [ "," ] "}"/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void MethodDeclaration(int modifiers): -{/*@bgen(jjtree) MethodDeclaration */ - SimpleNode jjtn000 = new SimpleNode(JJTMETHODDECLARATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) MethodDeclaration */ - try { -/*@egen*/ - // Modifiers already matched in the caller! - [ TypeParameters() ] - ResultType() - MethodDeclarator() [ "throws" NameList() ] - ( Block() | ";" )/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void MethodDeclarator(): -{/*@bgen(jjtree) MethodDeclarator */ - SimpleNode jjtn000 = new SimpleNode(JJTMETHODDECLARATOR); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) MethodDeclarator */ - try { -/*@egen*/ - <IDENTIFIER> FormalParameters() ( "[" "]" )*/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void FormalParameters(): -{/*@bgen(jjtree) FormalParameters */ - SimpleNode jjtn000 = new SimpleNode(JJTFORMALPARAMETERS); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) FormalParameters */ - try { -/*@egen*/ - "(" [ FormalParameter() ( "," FormalParameter() )* ] ")"/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void FormalParameter(): -{/*@bgen(jjtree) FormalParameter */ - SimpleNode jjtn000 = new SimpleNode(JJTFORMALPARAMETER); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) FormalParameter */ - try { -/*@egen*/ - Modifiers() Type() [ "..." ] VariableDeclaratorId()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void ConstructorDeclaration(): -{/*@bgen(jjtree) ConstructorDeclaration */ - SimpleNode jjtn000 = new SimpleNode(JJTCONSTRUCTORDECLARATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) ConstructorDeclaration */ - try { -/*@egen*/ - [ TypeParameters() ] - // Modifiers matched in the caller - <IDENTIFIER> FormalParameters() [ "throws" NameList() ] - "{" - [ LOOKAHEAD(ExplicitConstructorInvocation()) - ExplicitConstructorInvocation() - ] - ( BlockStatement() )* - "}"/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void ExplicitConstructorInvocation(): -{/*@bgen(jjtree) ExplicitConstructorInvocation */ - SimpleNode jjtn000 = new SimpleNode(JJTEXPLICITCONSTRUCTORINVOCATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) ExplicitConstructorInvocation */ - try { -/*@egen*/ - ( <IDENTIFIER> "." )* [ LOOKAHEAD(2) "this" "." ] - [ TypeArguments() ] ("this"|"super") Arguments() ";"/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void Initializer(): -{/*@bgen(jjtree) Initializer */ - SimpleNode jjtn000 = new SimpleNode(JJTINITIALIZER); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) Initializer */ - try { -/*@egen*/ - [ "static" ] Block()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - - -/* - * Type, name and expression syntax follows. - */ - -void Type(): -{/*@bgen(jjtree) Type */ - SimpleNode jjtn000 = new SimpleNode(JJTTYPE); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) Type */ - try { -/*@egen*/ - LOOKAHEAD(2) ReferenceType() - | - PrimitiveType()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void ReferenceType(): -{/*@bgen(jjtree) ReferenceType */ - SimpleNode jjtn000 = new SimpleNode(JJTREFERENCETYPE); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) ReferenceType */ - try { -/*@egen*/ - PrimitiveType() ( LOOKAHEAD(2) "[" "]" )+ - | - ( ClassOrInterfaceType() ) ( LOOKAHEAD(2) "[" "]" )*/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void ClassOrInterfaceType(): -{/*@bgen(jjtree) ClassOrInterfaceType */ - SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACETYPE); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) ClassOrInterfaceType */ - try { -/*@egen*/ - <IDENTIFIER> [ LOOKAHEAD(2) TypeArguments() ] - ( LOOKAHEAD(2) "." <IDENTIFIER> [ LOOKAHEAD(2) TypeArguments() ] )*/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void TypeArguments(): -{/*@bgen(jjtree) TypeArguments */ - SimpleNode jjtn000 = new SimpleNode(JJTTYPEARGUMENTS); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) TypeArguments */ - try { -/*@egen*/ - "<" TypeArgument() ( "," TypeArgument() )* ">"/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void TypeArgument(): -{/*@bgen(jjtree) TypeArgument */ - SimpleNode jjtn000 = new SimpleNode(JJTTYPEARGUMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) TypeArgument */ - try { -/*@egen*/ - ReferenceType() - | - "?" [ WildcardBounds() ]/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void WildcardBounds(): -{/*@bgen(jjtree) WildcardBounds */ - SimpleNode jjtn000 = new SimpleNode(JJTWILDCARDBOUNDS); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) WildcardBounds */ - try { -/*@egen*/ - "extends" ReferenceType() - | - "super" ReferenceType()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - - -void PrimitiveType(): -{/*@bgen(jjtree) PrimitiveType */ - SimpleNode jjtn000 = new SimpleNode(JJTPRIMITIVETYPE); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) PrimitiveType */ - try { -/*@egen*/ - "boolean" -| - "char" -| - "byte" -| - "short" -| - "int" -| - "long" -| - "float" -| - "double"/*@bgen(jjtree)*/ - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void ResultType(): -{/*@bgen(jjtree) ResultType */ - SimpleNode jjtn000 = new SimpleNode(JJTRESULTTYPE); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) ResultType */ - try { -/*@egen*/ - "void" -| - Type()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void Name(): -/* - * A lookahead of 2 is required below since "Name" can be followed - * by a ".*" when used in the context of an "ImportDeclaration". - */ -{/*@bgen(jjtree) Name */ - SimpleNode jjtn000 = new SimpleNode(JJTNAME); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) Name */ - try { -/*@egen*/ - <IDENTIFIER> - ( LOOKAHEAD(2) "." <IDENTIFIER> - )*/*@bgen(jjtree)*/ - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void NameList(): -{/*@bgen(jjtree) NameList */ - SimpleNode jjtn000 = new SimpleNode(JJTNAMELIST); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) NameList */ - try { -/*@egen*/ - Name() ( "," Name() )*/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - - -/* - * Expression syntax follows. - */ - -void Expression(): -/* - * This expansion has been written this way instead of: - * Assignment() | ConditionalExpression() - * for performance reasons. - * However, it is a weakening of the grammar for it allows the LHS of - * assignments to be any conditional expression whereas it can only be - * a primary expression. Consider adding a semantic predicate to work - * around this. - */ -{/*@bgen(jjtree) Expression */ - SimpleNode jjtn000 = new SimpleNode(JJTEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) Expression */ - try { -/*@egen*/ - ConditionalExpression() - [ - LOOKAHEAD(2) - AssignmentOperator() Expression() - ]/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void AssignmentOperator(): -{/*@bgen(jjtree) AssignmentOperator */ - SimpleNode jjtn000 = new SimpleNode(JJTASSIGNMENTOPERATOR); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) AssignmentOperator */ - try { -/*@egen*/ - "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | ">>>=" | "&=" | "^=" | "|="/*@bgen(jjtree)*/ - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void AssignmentExpression(): -{/*@bgen(jjtree) AssignmentExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTASSIGNMENTEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) AssignmentExpression */ - try { -/*@egen*/ - PrimaryExpression() AssignmentOperator() Expression()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void ConditionalExpression(): -{/*@bgen(jjtree) ConditionalExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTCONDITIONALEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) ConditionalExpression */ - try { -/*@egen*/ - ConditionalOrExpression() [ "?" Expression() ":" Expression() ]/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void ConditionalOrExpression(): -{/*@bgen(jjtree) ConditionalOrExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTCONDITIONALOREXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) ConditionalOrExpression */ - try { -/*@egen*/ - ConditionalAndExpression() ( "||" ConditionalAndExpression() )*/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void ConditionalAndExpression(): -{/*@bgen(jjtree) ConditionalAndExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTCONDITIONALANDEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) ConditionalAndExpression */ - try { -/*@egen*/ - InclusiveOrExpression() ( "&&" InclusiveOrExpression() )*/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void InclusiveOrExpression(): -{/*@bgen(jjtree) InclusiveOrExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTINCLUSIVEOREXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) InclusiveOrExpression */ - try { -/*@egen*/ - ExclusiveOrExpression() ( "|" ExclusiveOrExpression() )*/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void ExclusiveOrExpression(): -{/*@bgen(jjtree) ExclusiveOrExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTEXCLUSIVEOREXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) ExclusiveOrExpression */ - try { -/*@egen*/ - AndExpression() ( "^" AndExpression() )*/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void AndExpression(): -{/*@bgen(jjtree) AndExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTANDEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) AndExpression */ - try { -/*@egen*/ - EqualityExpression() ( "&" EqualityExpression() )*/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void EqualityExpression(): -{/*@bgen(jjtree) EqualityExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTEQUALITYEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) EqualityExpression */ - try { -/*@egen*/ - InstanceOfExpression() ( ( "==" | "!=" ) InstanceOfExpression() )*/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void InstanceOfExpression(): -{/*@bgen(jjtree) InstanceOfExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTINSTANCEOFEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) InstanceOfExpression */ - try { -/*@egen*/ - RelationalExpression() [ "instanceof" Type() ]/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void RelationalExpression(): -{/*@bgen(jjtree) RelationalExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTRELATIONALEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) RelationalExpression */ - try { -/*@egen*/ - ShiftExpression() ( ( "<" | ">" | "<=" | ">=" ) ShiftExpression() )*/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void ShiftExpression(): -{/*@bgen(jjtree) ShiftExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTSHIFTEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) ShiftExpression */ - try { -/*@egen*/ - AdditiveExpression() ( ( "<<" | RSIGNEDSHIFT() | RUNSIGNEDSHIFT() ) AdditiveExpression() )*/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void AdditiveExpression(): -{/*@bgen(jjtree) AdditiveExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTADDITIVEEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) AdditiveExpression */ - try { -/*@egen*/ - MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )*/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void MultiplicativeExpression(): -{/*@bgen(jjtree) MultiplicativeExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTMULTIPLICATIVEEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) MultiplicativeExpression */ - try { -/*@egen*/ - UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )*/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void UnaryExpression(): -{/*@bgen(jjtree) UnaryExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTUNARYEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) UnaryExpression */ - try { -/*@egen*/ - ( "+" | "-" ) UnaryExpression() -| - PreIncrementExpression() -| - PreDecrementExpression() -| - UnaryExpressionNotPlusMinus()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void PreIncrementExpression(): -{/*@bgen(jjtree) PreIncrementExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTPREINCREMENTEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) PreIncrementExpression */ - try { -/*@egen*/ - "++" PrimaryExpression()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void PreDecrementExpression(): -{/*@bgen(jjtree) PreDecrementExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTPREDECREMENTEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) PreDecrementExpression */ - try { -/*@egen*/ - "--" PrimaryExpression()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void UnaryExpressionNotPlusMinus(): -{/*@bgen(jjtree) UnaryExpressionNotPlusMinus */ - SimpleNode jjtn000 = new SimpleNode(JJTUNARYEXPRESSIONNOTPLUSMINUS); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) UnaryExpressionNotPlusMinus */ - try { -/*@egen*/ - ( "~" | "!" ) UnaryExpression() -| - LOOKAHEAD( CastLookahead() ) - CastExpression() -| - PostfixExpression()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -// This production is to determine lookahead only. The LOOKAHEAD specifications -// below are not used, but they are there just to indicate that we know about -// this. -void CastLookahead(): -{/*@bgen(jjtree) CastLookahead */ - SimpleNode jjtn000 = new SimpleNode(JJTCASTLOOKAHEAD); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) CastLookahead */ - try { -/*@egen*/ - LOOKAHEAD(2) - "(" PrimitiveType() -| - LOOKAHEAD("(" Type() "[") - "(" Type() "[" "]" -| - "(" Type() ")" ( "~" | "!" | "(" | <IDENTIFIER> | "this" | "super" | "new" | Literal() )/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void PostfixExpression(): -{/*@bgen(jjtree) PostfixExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTPOSTFIXEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) PostfixExpression */ - try { -/*@egen*/ - PrimaryExpression() [ PostfixOperator() ]/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void PostfixOperator(): -{/*@bgen(jjtree) PostfixOperator */ - SimpleNode jjtn000 = new SimpleNode(JJTPOSTFIXOPERATOR); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) PostfixOperator */ - try { -/*@egen*/ - "++" | "--"/*@bgen(jjtree)*/ - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void CastExpression(): -{/*@bgen(jjtree) CastExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTCASTEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) CastExpression */ - try { -/*@egen*/ - LOOKAHEAD("(" PrimitiveType()) - "(" Type() ")" UnaryExpression() -| - "(" Type() ")" UnaryExpressionNotPlusMinus()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void PrimaryExpression(): -{/*@bgen(jjtree) PrimaryExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTPRIMARYEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) PrimaryExpression */ - try { -/*@egen*/ - PrimaryPrefix() ( LOOKAHEAD(2) PrimarySuffix() )*/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void MemberSelector(): -{/*@bgen(jjtree) MemberSelector */ - SimpleNode jjtn000 = new SimpleNode(JJTMEMBERSELECTOR); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) MemberSelector */ - try { -/*@egen*/ - "." TypeArguments() <IDENTIFIER>/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void PrimaryPrefix(): -{/*@bgen(jjtree) PrimaryPrefix */ - SimpleNode jjtn000 = new SimpleNode(JJTPRIMARYPREFIX); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) PrimaryPrefix */ - try { -/*@egen*/ - Literal() -| - LOOKAHEAD( ( <IDENTIFIER> "." )* "this" ) - ( <IDENTIFIER> "." )* - "this" -| - "super" "." <IDENTIFIER> -| - "(" Expression() ")" -| - AllocationExpression() -| - LOOKAHEAD( ResultType() "." "class" ) - ResultType() "." "class" -| - Name()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void PrimarySuffix(): -{/*@bgen(jjtree) PrimarySuffix */ - SimpleNode jjtn000 = new SimpleNode(JJTPRIMARYSUFFIX); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) PrimarySuffix */ - try { -/*@egen*/ - LOOKAHEAD("." "super" ".") - "." "super" -| - LOOKAHEAD("." "this") - "." "this" -| - LOOKAHEAD(2) - "." AllocationExpression() -| - LOOKAHEAD(3) - MemberSelector() -| - "[" Expression() "]" -| - "." <IDENTIFIER> -| - Arguments()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void Literal(): -{/*@bgen(jjtree) Literal */ - SimpleNode jjtn000 = new SimpleNode(JJTLITERAL); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) Literal */ - try { -/*@egen*/ - <INTEGER_LITERAL> -| - <FLOATING_POINT_LITERAL> -| - <CHARACTER_LITERAL> -| - <STRING_LITERAL> -| - BooleanLiteral() -| - NullLiteral()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void BooleanLiteral(): -{/*@bgen(jjtree) BooleanLiteral */ - SimpleNode jjtn000 = new SimpleNode(JJTBOOLEANLITERAL); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) BooleanLiteral */ - try { -/*@egen*/ - "true" -| - "false"/*@bgen(jjtree)*/ - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void NullLiteral(): -{/*@bgen(jjtree) NullLiteral */ - SimpleNode jjtn000 = new SimpleNode(JJTNULLLITERAL); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) NullLiteral */ - try { -/*@egen*/ - "null"/*@bgen(jjtree)*/ - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void Arguments(): -{/*@bgen(jjtree) Arguments */ - SimpleNode jjtn000 = new SimpleNode(JJTARGUMENTS); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) Arguments */ - try { -/*@egen*/ - "(" [ ArgumentList() ] ")"/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void ArgumentList(): -{/*@bgen(jjtree) ArgumentList */ - SimpleNode jjtn000 = new SimpleNode(JJTARGUMENTLIST); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) ArgumentList */ - try { -/*@egen*/ - Expression() ( "," Expression() )*/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void AllocationExpression(): -{/*@bgen(jjtree) AllocationExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTALLOCATIONEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) AllocationExpression */ - try { -/*@egen*/ - LOOKAHEAD(2) - "new" PrimitiveType() ArrayDimsAndInits() -| - "new" ClassOrInterfaceType() [ TypeArguments() ] - ( - ArrayDimsAndInits() - | - Arguments() [ ClassOrInterfaceBody(false) ] - )/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -/* - * The third LOOKAHEAD specification below is to parse to PrimarySuffix - * if there is an expression between the "[...]". - */ -void ArrayDimsAndInits(): -{/*@bgen(jjtree) ArrayDimsAndInits */ - SimpleNode jjtn000 = new SimpleNode(JJTARRAYDIMSANDINITS); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) ArrayDimsAndInits */ - try { -/*@egen*/ - LOOKAHEAD(2) - ( LOOKAHEAD(2) "[" Expression() "]" )+ ( LOOKAHEAD(2) "[" "]" )* -| - ( "[" "]" )+ ArrayInitializer()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - - -/* - * Statement syntax follows. - */ - -void Statement(): -{/*@bgen(jjtree) Statement */ - SimpleNode jjtn000 = new SimpleNode(JJTSTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) Statement */ - try { -/*@egen*/ - LOOKAHEAD(2) - LabeledStatement() -| - AssertStatement() -| - Block() -| - EmptyStatement() -| - StatementExpression() ";" -| - SwitchStatement() -| - IfStatement() -| - WhileStatement() -| - DoStatement() -| - ForStatement() -| - BreakStatement() -| - ContinueStatement() -| - ReturnStatement() -| - ThrowStatement() -| - SynchronizedStatement() -| - TryStatement()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void AssertStatement(): -{/*@bgen(jjtree) AssertStatement */ - SimpleNode jjtn000 = new SimpleNode(JJTASSERTSTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) AssertStatement */ - try { -/*@egen*/ - "assert" Expression() [ ":" Expression() ] ";"/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void LabeledStatement(): -{/*@bgen(jjtree) LabeledStatement */ - SimpleNode jjtn000 = new SimpleNode(JJTLABELEDSTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) LabeledStatement */ - try { -/*@egen*/ - <IDENTIFIER> ":" Statement()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void Block(): -{/*@bgen(jjtree) Block */ - SimpleNode jjtn000 = new SimpleNode(JJTBLOCK); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) Block */ - try { -/*@egen*/ - "{" ( BlockStatement() )* "}"/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void BlockStatement(): -{/*@bgen(jjtree) BlockStatement */ - SimpleNode jjtn000 = new SimpleNode(JJTBLOCKSTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) BlockStatement */ - try { -/*@egen*/ - LOOKAHEAD( Modifiers() Type() <IDENTIFIER> ) - LocalVariableDeclaration() ";" -| - Statement() -| - ClassOrInterfaceDeclaration(0)/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void LocalVariableDeclaration(): -{/*@bgen(jjtree) LocalVariableDeclaration */ - SimpleNode jjtn000 = new SimpleNode(JJTLOCALVARIABLEDECLARATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) LocalVariableDeclaration */ - try { -/*@egen*/ - Modifiers() Type() VariableDeclarator() ( "," VariableDeclarator() )*/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void EmptyStatement(): -{/*@bgen(jjtree) EmptyStatement */ - SimpleNode jjtn000 = new SimpleNode(JJTEMPTYSTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) EmptyStatement */ - try { -/*@egen*/ - ";"/*@bgen(jjtree)*/ - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void StatementExpression(): -{/*@bgen(jjtree) StatementExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTSTATEMENTEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) StatementExpression */ - try { -/*@egen*/ - PreIncrementExpression() -| - PreDecrementExpression() -| - LOOKAHEAD(PrimaryExpression() AssignmentOperator()) - AssignmentExpression() -| - PostfixExpression()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void SwitchStatement(): -{/*@bgen(jjtree) SwitchStatement */ - SimpleNode jjtn000 = new SimpleNode(JJTSWITCHSTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) SwitchStatement */ - try { -/*@egen*/ - "switch" "(" Expression() ")" "{" - ( SwitchLabel() ( BlockStatement() )* )* - "}"/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void SwitchLabel(): -{/*@bgen(jjtree) SwitchLabel */ - SimpleNode jjtn000 = new SimpleNode(JJTSWITCHLABEL); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) SwitchLabel */ - try { -/*@egen*/ - "case" Expression() ":" -| - "default" ":"/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void IfStatement(): -/* - * The disambiguating algorithm of JavaCC automatically binds dangling - * else's to the innermost if statement. The LOOKAHEAD specification - * is to tell JavaCC that we know what we are doing. - */ -{/*@bgen(jjtree) IfStatement */ - SimpleNode jjtn000 = new SimpleNode(JJTIFSTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) IfStatement */ - try { -/*@egen*/ - "if" "(" Expression() ")" Statement() [ LOOKAHEAD(1) "else" Statement() ]/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void WhileStatement(): -{/*@bgen(jjtree) WhileStatement */ - SimpleNode jjtn000 = new SimpleNode(JJTWHILESTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) WhileStatement */ - try { -/*@egen*/ - "while" "(" Expression() ")" Statement()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void DoStatement(): -{/*@bgen(jjtree) DoStatement */ - SimpleNode jjtn000 = new SimpleNode(JJTDOSTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) DoStatement */ - try { -/*@egen*/ - "do" Statement() "while" "(" Expression() ")" ";"/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void ForStatement(): -{/*@bgen(jjtree) ForStatement */ - SimpleNode jjtn000 = new SimpleNode(JJTFORSTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) ForStatement */ - try { -/*@egen*/ - "for" "(" - - ( - LOOKAHEAD(Modifiers() Type() <IDENTIFIER> ":") - Modifiers() Type() <IDENTIFIER> ":" Expression() - | - [ ForInit() ] ";" [ Expression() ] ";" [ ForUpdate() ] - ) - - ")" Statement()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void ForInit(): -{/*@bgen(jjtree) ForInit */ - SimpleNode jjtn000 = new SimpleNode(JJTFORINIT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) ForInit */ - try { -/*@egen*/ - LOOKAHEAD( Modifiers() Type() <IDENTIFIER> ) - LocalVariableDeclaration() -| - StatementExpressionList()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void StatementExpressionList(): -{/*@bgen(jjtree) StatementExpressionList */ - SimpleNode jjtn000 = new SimpleNode(JJTSTATEMENTEXPRESSIONLIST); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) StatementExpressionList */ - try { -/*@egen*/ - StatementExpression() ( "," StatementExpression() )*/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void ForUpdate(): -{/*@bgen(jjtree) ForUpdate */ - SimpleNode jjtn000 = new SimpleNode(JJTFORUPDATE); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) ForUpdate */ - try { -/*@egen*/ - StatementExpressionList()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void BreakStatement(): -{/*@bgen(jjtree) BreakStatement */ - SimpleNode jjtn000 = new SimpleNode(JJTBREAKSTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) BreakStatement */ - try { -/*@egen*/ - "break" [ <IDENTIFIER> ] ";"/*@bgen(jjtree)*/ - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void ContinueStatement(): -{/*@bgen(jjtree) ContinueStatement */ - SimpleNode jjtn000 = new SimpleNode(JJTCONTINUESTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) ContinueStatement */ - try { -/*@egen*/ - "continue" [ <IDENTIFIER> ] ";"/*@bgen(jjtree)*/ - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void ReturnStatement(): -{/*@bgen(jjtree) ReturnStatement */ - SimpleNode jjtn000 = new SimpleNode(JJTRETURNSTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) ReturnStatement */ - try { -/*@egen*/ - "return" [ Expression() ] ";"/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void ThrowStatement(): -{/*@bgen(jjtree) ThrowStatement */ - SimpleNode jjtn000 = new SimpleNode(JJTTHROWSTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) ThrowStatement */ - try { -/*@egen*/ - "throw" Expression() ";"/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void SynchronizedStatement(): -{/*@bgen(jjtree) SynchronizedStatement */ - SimpleNode jjtn000 = new SimpleNode(JJTSYNCHRONIZEDSTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) SynchronizedStatement */ - try { -/*@egen*/ - "synchronized" "(" Expression() ")" Block()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void TryStatement(): -/* - * Semantic check required here to make sure that at least one - * finally/catch is present. - */ -{/*@bgen(jjtree) TryStatement */ - SimpleNode jjtn000 = new SimpleNode(JJTTRYSTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) TryStatement */ - try { -/*@egen*/ - "try" Block() - ( "catch" "(" FormalParameter() ")" Block() )* - [ "finally" Block() ]/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -/* We use productions to match >>>, >> and > so that we can keep the - * type declaration syntax with generics clean - */ - -void RUNSIGNEDSHIFT(): -{/*@bgen(jjtree) RUNSIGNEDSHIFT */ - SimpleNode jjtn000 = new SimpleNode(JJTRUNSIGNEDSHIFT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) RUNSIGNEDSHIFT */ - try { -/*@egen*/ - ( LOOKAHEAD({ getToken(1).kind == GT && - ((Token.GTToken)getToken(1)).realKind == RUNSIGNEDSHIFT} ) - ">" ">" ">" - )/*@bgen(jjtree)*/ - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void RSIGNEDSHIFT(): -{/*@bgen(jjtree) RSIGNEDSHIFT */ - SimpleNode jjtn000 = new SimpleNode(JJTRSIGNEDSHIFT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) RSIGNEDSHIFT */ - try { -/*@egen*/ - ( LOOKAHEAD({ getToken(1).kind == GT && - ((Token.GTToken)getToken(1)).realKind == RSIGNEDSHIFT} ) - ">" ">" - )/*@bgen(jjtree)*/ - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -/* Annotation syntax follows. */ - -void Annotation(): -{/*@bgen(jjtree) Annotation */ - SimpleNode jjtn000 = new SimpleNode(JJTANNOTATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) Annotation */ - try { -/*@egen*/ - LOOKAHEAD( "@" Name() "(" ( <IDENTIFIER> "=" | ")" )) - NormalAnnotation() - | - LOOKAHEAD( "@" Name() "(" ) - SingleMemberAnnotation() - | - MarkerAnnotation()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void NormalAnnotation(): -{/*@bgen(jjtree) NormalAnnotation */ - SimpleNode jjtn000 = new SimpleNode(JJTNORMALANNOTATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) NormalAnnotation */ - try { -/*@egen*/ - "@" Name() "(" [ MemberValuePairs() ] ")"/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void MarkerAnnotation(): -{/*@bgen(jjtree) MarkerAnnotation */ - SimpleNode jjtn000 = new SimpleNode(JJTMARKERANNOTATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) MarkerAnnotation */ - try { -/*@egen*/ - "@" Name()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void SingleMemberAnnotation(): -{/*@bgen(jjtree) SingleMemberAnnotation */ - SimpleNode jjtn000 = new SimpleNode(JJTSINGLEMEMBERANNOTATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) SingleMemberAnnotation */ - try { -/*@egen*/ - "@" Name() "(" MemberValue() ")"/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void MemberValuePairs(): -{/*@bgen(jjtree) MemberValuePairs */ - SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUEPAIRS); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) MemberValuePairs */ - try { -/*@egen*/ - MemberValuePair() ( "," MemberValuePair() )*/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void MemberValuePair(): -{/*@bgen(jjtree) MemberValuePair */ - SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUEPAIR); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) MemberValuePair */ - try { -/*@egen*/ - <IDENTIFIER> "=" MemberValue()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void MemberValue(): -{/*@bgen(jjtree) MemberValue */ - SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUE); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) MemberValue */ - try { -/*@egen*/ - Annotation() - | - MemberValueArrayInitializer() - | - ConditionalExpression()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void MemberValueArrayInitializer(): -{/*@bgen(jjtree) MemberValueArrayInitializer */ - SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUEARRAYINITIALIZER); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) MemberValueArrayInitializer */ - try { -/*@egen*/ - "{" MemberValue() ( LOOKAHEAD(2) "," MemberValue() )* [ "," ] "}"/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - - -/* Annotation Types. */ - -void AnnotationTypeDeclaration(int modifiers): -{/*@bgen(jjtree) AnnotationTypeDeclaration */ - SimpleNode jjtn000 = new SimpleNode(JJTANNOTATIONTYPEDECLARATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) AnnotationTypeDeclaration */ - try { -/*@egen*/ - "@" "interface" <IDENTIFIER> AnnotationTypeBody()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void AnnotationTypeBody(): -{/*@bgen(jjtree) AnnotationTypeBody */ - SimpleNode jjtn000 = new SimpleNode(JJTANNOTATIONTYPEBODY); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) AnnotationTypeBody */ - try { -/*@egen*/ - "{" ( AnnotationTypeMemberDeclaration() )* "}"/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void AnnotationTypeMemberDeclaration(): -{/*@bgen(jjtree) AnnotationTypeMemberDeclaration */ - SimpleNode jjtn000 = new SimpleNode(JJTANNOTATIONTYPEMEMBERDECLARATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/ - int modifiers; -} -{/*@bgen(jjtree) AnnotationTypeMemberDeclaration */ - try { -/*@egen*/ - modifiers = Modifiers() - ( - LOOKAHEAD(Type() <IDENTIFIER> "(") - Type() <IDENTIFIER> "(" ")" [ DefaultValue() ] ";" - | - ClassOrInterfaceDeclaration(modifiers) - | - EnumDeclaration(modifiers) - | - AnnotationTypeDeclaration(modifiers) - | - FieldDeclaration(modifiers) - ) - | - ( ";" )/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} - -void DefaultValue(): -{/*@bgen(jjtree) DefaultValue */ - SimpleNode jjtn000 = new SimpleNode(JJTDEFAULTVALUE); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); -/*@egen*/} -{/*@bgen(jjtree) DefaultValue */ - try { -/*@egen*/ - "default" MemberValue()/*@bgen(jjtree)*/ - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - throw (RuntimeException)jjte000; - } - if (jjte000 instanceof ParseException) { - throw (ParseException)jjte000; - } - throw (Error)jjte000; - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } -/*@egen*/ -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Java1.5.jj (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Java1.5.jj) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Java1.5.jj (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Java1.5.jj 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,5125 @@ +/*@bgen(jjtree) Generated By:JJTree: Do not edit this line. ./Java1.5.jj */ +/*@egen*/ +/* + * Copyright \u00a9 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has + * intellectual property rights relating to technology embodied in the product + * that is described in this document. In particular, and without limitation, + * these intellectual property rights may include one or more of the U.S. + * patents listed at http://www.sun.com/patents and one or more additional + * patents or pending patent applications in the U.S. and in other countries. + * U.S. Government Rights - Commercial software. Government users are subject + * to the Sun Microsystems, Inc. standard license agreement and applicable + * provisions of the FAR and its supplements. Use is subject to license terms. + * Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This + * product is covered and controlled by U.S. Export Control laws and may be + * subject to the export or import laws in other countries. Nuclear, missile, + * chemical biological weapons or nuclear maritime end uses or end users, + * whether direct or indirect, are strictly prohibited. Export or reexport + * to countries subject to U.S. embargo or to entities identified on U.S. + * export exclusion lists, including, but not limited to, the denied persons + * and specially designated nationals lists is strictly prohibited. + */ + +// Slightly modified version of javacc's reference 1.5 grammar, tweaked for +// usage with JAXX. There are two main areas of changes: several new +// nonterminals were added to make identifying certain constructs easier, +// and the Line nonterminal was added to support JAXX's script tags. +// Several of the new changes are inefficient and require excess lookahead, +// but at this point I'd rather have inefficiency than risk breaking it during +// attempted optimizations. + +options { + JAVA_UNICODE_ESCAPE = true; + ERROR_REPORTING = false; + STATIC = false; + JDK_VERSION = "1.4"; +} + +PARSER_BEGIN(JavaParser) +package jaxx.parser; + +import java.io.*; + +/** + * Grammar to parse Java version 1.5 + * @author Sreenivasa Viswanadha - Simplified and enhanced for 1.5 + */ +public class JavaParser/*@bgen(jjtree)*/implements JavaParserTreeConstants/*@egen*/ +{/*@bgen(jjtree)*/ + protected JJTJavaParserState jjtree = new JJTJavaParserState(); + +/*@egen*/ + /** + * Class to hold modifiers. + */ + static public final class ModifierSet + { + /* Definitions of the bits in the modifiers field. */ + public static final int PUBLIC = 0x0001; + public static final int PROTECTED = 0x0002; + public static final int PRIVATE = 0x0004; + public static final int ABSTRACT = 0x0008; + public static final int STATIC = 0x0010; + public static final int FINAL = 0x0020; + public static final int SYNCHRONIZED = 0x0040; + public static final int NATIVE = 0x0080; + public static final int TRANSIENT = 0x0100; + public static final int VOLATILE = 0x0200; + public static final int STRICTFP = 0x1000; + + /** A set of accessors that indicate whether the specified modifier + is in the set. */ + + public boolean isPublic(int modifiers) + { + return (modifiers & PUBLIC) != 0; + } + + public boolean isProtected(int modifiers) + { + return (modifiers & PROTECTED) != 0; + } + + public boolean isPrivate(int modifiers) + { + return (modifiers & PRIVATE) != 0; + } + + public boolean isStatic(int modifiers) + { + return (modifiers & STATIC) != 0; + } + + public boolean isAbstract(int modifiers) + { + return (modifiers & ABSTRACT) != 0; + } + + public boolean isFinal(int modifiers) + { + return (modifiers & FINAL) != 0; + } + + public boolean isNative(int modifiers) + { + return (modifiers & NATIVE) != 0; + } + + public boolean isStrictfp(int modifiers) + { + return (modifiers & STRICTFP) != 0; + } + + public boolean isSynchronized(int modifiers) + { + return (modifiers & SYNCHRONIZED) != 0; + } + + public boolean isTransient(int modifiers) + { + return (modifiers & TRANSIENT) != 0; + } + + public boolean isVolatile(int modifiers) + { + return (modifiers & VOLATILE) != 0; + } + + /** + * Removes the given modifier. + */ + static int removeModifier(int modifiers, int mod) + { + return modifiers & ~mod; + } + } + + public JavaParser(String fileName) + { + this(System.in); + try { ReInit(new FileInputStream(new File(fileName))); } + catch(Exception e) { e.printStackTrace(); } + } + + void jjtreeOpenNodeScope(Node n) { + ((SimpleNode) n).firstToken = getToken(1); + } + + void jjtreeCloseNodeScope(Node n) { + ((SimpleNode) n).lastToken = getToken(0); + } + + public SimpleNode popNode() + { + if ( jjtree.nodeArity() > 0) // number of child nodes + return (SimpleNode)jjtree.popNode(); + else + return null; + } + public static void main(String args[]) { + JavaParser parser; + if (args.length == 0) { + System.out.println("Java Parser Version 1.1: Reading from standard input . . ."); + parser = new JavaParser(System.in); + } else if (args.length == 1) { + System.out.println("Java Parser Version 1.1: Reading from file " + args[0] + " . . ."); + try { + parser = new JavaParser(new java.io.FileInputStream(args[0])); + } catch (java.io.FileNotFoundException e) { + System.out.println("Java Parser Version 1.1: File " + args[0] + " not found."); + return; + } + } else { + System.out.println("Java Parser Version 1.1: Usage is one of:"); + System.out.println(" java JavaParser < inputfile"); + System.out.println("OR"); + System.out.println(" java JavaParser inputfile"); + return; + } + try { + parser.CompilationUnit(); + System.out.println("Java Parser Version 1.1: Java program parsed successfully."); + } catch (ParseException e) { + System.out.println(e.getMessage()); + System.out.println("Java Parser Version 1.1: Encountered errors during parse."); + } + } + +} + +PARSER_END(JavaParser) + +/* COMMENTS */ + +MORE : +{ + <"/**" ~["/"]> { input_stream.backup(1); } : IN_FORMAL_COMMENT +| + "/*" : IN_MULTI_LINE_COMMENT +} + +SPECIAL_TOKEN: +{ + <WHITE_SPACE: ([" ", "\n", "\r", "\t", "\f"])+> +} + +SPECIAL_TOKEN : +{ + <SINGLE_LINE_COMMENT: "//" (~["\n", "\r"])* ("\n" | "\r" | "\r\n")?> +} + +<IN_FORMAL_COMMENT> +SPECIAL_TOKEN : +{ + <FORMAL_COMMENT: "*/" > : DEFAULT +} + +<IN_MULTI_LINE_COMMENT> +SPECIAL_TOKEN : +{ + <MULTI_LINE_COMMENT: "*/" > : DEFAULT +} + +<IN_FORMAL_COMMENT,IN_MULTI_LINE_COMMENT> +MORE : +{ + < ~[] > +} + +/* RESERVED WORDS AND LITERALS */ + +TOKEN : +{ + < ABSTRACT: "abstract" > +| < ASSERT: "assert" > +| < BOOLEAN: "boolean" > +| < BREAK: "break" > +| < BYTE: "byte" > +| < CASE: "case" > +| < CATCH: "catch" > +| < CHAR: "char" > +| < CLASS: "class" > +| < CONST: "const" > +| < CONTINUE: "continue" > +| < _DEFAULT: "default" > +| < DO: "do" > +| < DOUBLE: "double" > +| < ELSE: "else" > +| < ENUM: "enum" > +| < EXTENDS: "extends" > +| < FALSE: "false" > +| < FINAL: "final" > +| < FINALLY: "finally" > +| < FLOAT: "float" > +| < FOR: "for" > +| < GOTO: "goto" > +| < IF: "if" > +| < IMPLEMENTS: "implements" > +| < IMPORT: "import" > +| < INSTANCEOF: "instanceof" > +| < INT: "int" > +| < INTERFACE: "interface" > +| < LONG: "long" > +| < NATIVE: "native" > +| < NEW: "new" > +| < NULL: "null" > +| < PACKAGE: "package"> +| < PRIVATE: "private" > +| < PROTECTED: "protected" > +| < PUBLIC: "public" > +| < RETURN: "return" > +| < SHORT: "short" > +| < STATIC: "static" > +| < STRICTFP: "strictfp" > +| < SUPER: "super" > +| < SWITCH: "switch" > +| < SYNCHRONIZED: "synchronized" > +| < THIS: "this" > +| < THROW: "throw" > +| < THROWS: "throws" > +| < TRANSIENT: "transient" > +| < TRUE: "true" > +| < TRY: "try" > +| < VOID: "void" > +| < VOLATILE: "volatile" > +| < WHILE: "while" > +} + +/* LITERALS */ + +TOKEN : +{ + < INTEGER_LITERAL: + <DECIMAL_LITERAL> (["l","L"])? + | <HEX_LITERAL> (["l","L"])? + | <OCTAL_LITERAL> (["l","L"])? + > +| + < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* > +| + < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ > +| + < #OCTAL_LITERAL: "0" (["0"-"7"])* > +| + < FLOATING_POINT_LITERAL: + <DECIMAL_FLOATING_POINT_LITERAL> + | <HEXADECIMAL_FLOATING_POINT_LITERAL> + > +| + < #DECIMAL_FLOATING_POINT_LITERAL: + (["0"-"9"])+ "." (["0"-"9"])* (<DECIMAL_EXPONENT>)? (["f","F","d","D"])? + | "." (["0"-"9"])+ (<DECIMAL_EXPONENT>)? (["f","F","d","D"])? + | (["0"-"9"])+ <DECIMAL_EXPONENT> (["f","F","d","D"])? + | (["0"-"9"])+ (<DECIMAL_EXPONENT>)? ["f","F","d","D"] + > +| + < #DECIMAL_EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ > +| + < #HEXADECIMAL_FLOATING_POINT_LITERAL: + "0" ["x", "X"] (["0"-"9","a"-"f","A"-"F"])+ (".")? <HEXADECIMAL_EXPONENT> (["f","F","d","D"])? + | "0" ["x", "X"] (["0"-"9","a"-"f","A"-"F"])* "." (["0"-"9","a"-"f","A"-"F"])+ <HEXADECIMAL_EXPONENT> (["f","F","d","D"])? + > +| + < #HEXADECIMAL_EXPONENT: ["p","P"] (["+","-"])? (["0"-"9"])+ > +| + < CHARACTER_LITERAL: + "'" + ( (~["'","\\","\n","\r"]) + | ("\\" + ( ["n","t","b","r","f","\\","'","\""] + | ["0"-"7"] ( ["0"-"7"] )? + | ["0"-"3"] ["0"-"7"] ["0"-"7"] + ) + ) + ) + "'" + > +| + < STRING_LITERAL: + "\"" + ( (~["\"","\\","\n","\r"]) + | ("\\" + ( ["n","t","b","r","f","\\","'","\""] + | ["0"-"7"] ( ["0"-"7"] )? + | ["0"-"3"] ["0"-"7"] ["0"-"7"] + ) + ) + )* + "\"" + > +} + +/* IDENTIFIERS */ + +TOKEN : +{ + < IDENTIFIER: <LETTER> (<PART_LETTER>)* > +| + < #LETTER: + [ // all chars for which Character.isIdentifierStart is true + "$", + "A"-"Z", + "_", + "a"-"z", + "\u00a2"-"\u00a5", + "\u00aa", + "\u00b5", + "\u00ba", + "\u00c0"-"\u00d6", + "\u00d8"-"\u00f6", + "\u00f8"-"\u021f", + "\u0222"-"\u0233", + "\u0250"-"\u02ad", + "\u02b0"-"\u02b8", + "\u02bb"-"\u02c1", + "\u02d0"-"\u02d1", + "\u02e0"-"\u02e4", + "\u02ee", + "\u037a", + "\u0386", + "\u0388"-"\u038a", + "\u038c", + "\u038e"-"\u03a1", + "\u03a3"-"\u03ce", + "\u03d0"-"\u03d7", + "\u03da"-"\u03f3", + "\u0400"-"\u0481", + "\u048c"-"\u04c4", + "\u04c7"-"\u04c8", + "\u04cb"-"\u04cc", + "\u04d0"-"\u04f5", + "\u04f8"-"\u04f9", + "\u0531"-"\u0556", + "\u0559", + "\u0561"-"\u0587", + "\u05d0"-"\u05ea", + "\u05f0"-"\u05f2", + "\u0621"-"\u063a", + "\u0640"-"\u064a", + "\u0671"-"\u06d3", + "\u06d5", + "\u06e5"-"\u06e6", + "\u06fa"-"\u06fc", + "\u0710", + "\u0712"-"\u072c", + "\u0780"-"\u07a5", + "\u0905"-"\u0939", + "\u093d", + "\u0950", + "\u0958"-"\u0961", + "\u0985"-"\u098c", + "\u098f"-"\u0990", + "\u0993"-"\u09a8", + "\u09aa"-"\u09b0", + "\u09b2", + "\u09b6"-"\u09b9", + "\u09dc"-"\u09dd", + "\u09df"-"\u09e1", + "\u09f0"-"\u09f3", + "\u0a05"-"\u0a0a", + "\u0a0f"-"\u0a10", + "\u0a13"-"\u0a28", + "\u0a2a"-"\u0a30", + "\u0a32"-"\u0a33", + "\u0a35"-"\u0a36", + "\u0a38"-"\u0a39", + "\u0a59"-"\u0a5c", + "\u0a5e", + "\u0a72"-"\u0a74", + "\u0a85"-"\u0a8b", + "\u0a8d", + "\u0a8f"-"\u0a91", + "\u0a93"-"\u0aa8", + "\u0aaa"-"\u0ab0", + "\u0ab2"-"\u0ab3", + "\u0ab5"-"\u0ab9", + "\u0abd", + "\u0ad0", + "\u0ae0", + "\u0b05"-"\u0b0c", + "\u0b0f"-"\u0b10", + "\u0b13"-"\u0b28", + "\u0b2a"-"\u0b30", + "\u0b32"-"\u0b33", + "\u0b36"-"\u0b39", + "\u0b3d", + "\u0b5c"-"\u0b5d", + "\u0b5f"-"\u0b61", + "\u0b85"-"\u0b8a", + "\u0b8e"-"\u0b90", + "\u0b92"-"\u0b95", + "\u0b99"-"\u0b9a", + "\u0b9c", + "\u0b9e"-"\u0b9f", + "\u0ba3"-"\u0ba4", + "\u0ba8"-"\u0baa", + "\u0bae"-"\u0bb5", + "\u0bb7"-"\u0bb9", + "\u0c05"-"\u0c0c", + "\u0c0e"-"\u0c10", + "\u0c12"-"\u0c28", + "\u0c2a"-"\u0c33", + "\u0c35"-"\u0c39", + "\u0c60"-"\u0c61", + "\u0c85"-"\u0c8c", + "\u0c8e"-"\u0c90", + "\u0c92"-"\u0ca8", + "\u0caa"-"\u0cb3", + "\u0cb5"-"\u0cb9", + "\u0cde", + "\u0ce0"-"\u0ce1", + "\u0d05"-"\u0d0c", + "\u0d0e"-"\u0d10", + "\u0d12"-"\u0d28", + "\u0d2a"-"\u0d39", + "\u0d60"-"\u0d61", + "\u0d85"-"\u0d96", + "\u0d9a"-"\u0db1", + "\u0db3"-"\u0dbb", + "\u0dbd", + "\u0dc0"-"\u0dc6", + "\u0e01"-"\u0e30", + "\u0e32"-"\u0e33", + "\u0e3f"-"\u0e46", + "\u0e81"-"\u0e82", + "\u0e84", + "\u0e87"-"\u0e88", + "\u0e8a", + "\u0e8d", + "\u0e94"-"\u0e97", + "\u0e99"-"\u0e9f", + "\u0ea1"-"\u0ea3", + "\u0ea5", + "\u0ea7", + "\u0eaa"-"\u0eab", + "\u0ead"-"\u0eb0", + "\u0eb2"-"\u0eb3", + "\u0ebd", + "\u0ec0"-"\u0ec4", + "\u0ec6", + "\u0edc"-"\u0edd", + "\u0f00", + "\u0f40"-"\u0f47", + "\u0f49"-"\u0f6a", + "\u0f88"-"\u0f8b", + "\u1000"-"\u1021", + "\u1023"-"\u1027", + "\u1029"-"\u102a", + "\u1050"-"\u1055", + "\u10a0"-"\u10c5", + "\u10d0"-"\u10f6", + "\u1100"-"\u1159", + "\u115f"-"\u11a2", + "\u11a8"-"\u11f9", + "\u1200"-"\u1206", + "\u1208"-"\u1246", + "\u1248", + "\u124a"-"\u124d", + "\u1250"-"\u1256", + "\u1258", + "\u125a"-"\u125d", + "\u1260"-"\u1286", + "\u1288", + "\u128a"-"\u128d", + "\u1290"-"\u12ae", + "\u12b0", + "\u12b2"-"\u12b5", + "\u12b8"-"\u12be", + "\u12c0", + "\u12c2"-"\u12c5", + "\u12c8"-"\u12ce", + "\u12d0"-"\u12d6", + "\u12d8"-"\u12ee", + "\u12f0"-"\u130e", + "\u1310", + "\u1312"-"\u1315", + "\u1318"-"\u131e", + "\u1320"-"\u1346", + "\u1348"-"\u135a", + "\u13a0"-"\u13f4", + "\u1401"-"\u166c", + "\u166f"-"\u1676", + "\u1681"-"\u169a", + "\u16a0"-"\u16ea", + "\u1780"-"\u17b3", + "\u17db", + "\u1820"-"\u1877", + "\u1880"-"\u18a8", + "\u1e00"-"\u1e9b", + "\u1ea0"-"\u1ef9", + "\u1f00"-"\u1f15", + "\u1f18"-"\u1f1d", + "\u1f20"-"\u1f45", + "\u1f48"-"\u1f4d", + "\u1f50"-"\u1f57", + "\u1f59", + "\u1f5b", + "\u1f5d", + "\u1f5f"-"\u1f7d", + "\u1f80"-"\u1fb4", + "\u1fb6"-"\u1fbc", + "\u1fbe", + "\u1fc2"-"\u1fc4", + "\u1fc6"-"\u1fcc", + "\u1fd0"-"\u1fd3", + "\u1fd6"-"\u1fdb", + "\u1fe0"-"\u1fec", + "\u1ff2"-"\u1ff4", + "\u1ff6"-"\u1ffc", + "\u203f"-"\u2040", + "\u207f", + "\u20a0"-"\u20af", + "\u2102", + "\u2107", + "\u210a"-"\u2113", + "\u2115", + "\u2119"-"\u211d", + "\u2124", + "\u2126", + "\u2128", + "\u212a"-"\u212d", + "\u212f"-"\u2131", + "\u2133"-"\u2139", + "\u2160"-"\u2183", + "\u3005"-"\u3007", + "\u3021"-"\u3029", + "\u3031"-"\u3035", + "\u3038"-"\u303a", + "\u3041"-"\u3094", + "\u309d"-"\u309e", + "\u30a1"-"\u30fe", + "\u3105"-"\u312c", + "\u3131"-"\u318e", + "\u31a0"-"\u31b7", + "\u3400"-"\u4db5", + "\u4e00"-"\u9fa5", + "\ua000"-"\ua48c", + "\uac00"-"\ud7a3", + "\uf900"-"\ufa2d", + "\ufb00"-"\ufb06", + "\ufb13"-"\ufb17", + "\ufb1d", + "\ufb1f"-"\ufb28", + "\ufb2a"-"\ufb36", + "\ufb38"-"\ufb3c", + "\ufb3e", + "\ufb40"-"\ufb41", + "\ufb43"-"\ufb44", + "\ufb46"-"\ufbb1", + "\ufbd3"-"\ufd3d", + "\ufd50"-"\ufd8f", + "\ufd92"-"\ufdc7", + "\ufdf0"-"\ufdfb", + "\ufe33"-"\ufe34", + "\ufe4d"-"\ufe4f", + "\ufe69", + "\ufe70"-"\ufe72", + "\ufe74", + "\ufe76"-"\ufefc", + "\uff04", + "\uff21"-"\uff3a", + "\uff3f", + "\uff41"-"\uff5a", + "\uff65"-"\uffbe", + "\uffc2"-"\uffc7", + "\uffca"-"\uffcf", + "\uffd2"-"\uffd7", + "\uffda"-"\uffdc", + "\uffe0"-"\uffe1", + "\uffe5"-"\uffe6" + ] + > +| + < #PART_LETTER: + [ // all chars for which Character.isIdentifierPart is true + "\u0000"-"\u0008", + "\u000e"-"\u001b", + "$", + "0"-"9", + "A"-"Z", + "_", + "a"-"z", + "\u007f"-"\u009f", + "\u00a2"-"\u00a5", + "\u00aa", + "\u00b5", + "\u00ba", + "\u00c0"-"\u00d6", + "\u00d8"-"\u00f6", + "\u00f8"-"\u021f", + "\u0222"-"\u0233", + "\u0250"-"\u02ad", + "\u02b0"-"\u02b8", + "\u02bb"-"\u02c1", + "\u02d0"-"\u02d1", + "\u02e0"-"\u02e4", + "\u02ee", + "\u0300"-"\u034e", + "\u0360"-"\u0362", + "\u037a", + "\u0386", + "\u0388"-"\u038a", + "\u038c", + "\u038e"-"\u03a1", + "\u03a3"-"\u03ce", + "\u03d0"-"\u03d7", + "\u03da"-"\u03f3", + "\u0400"-"\u0481", + "\u0483"-"\u0486", + "\u048c"-"\u04c4", + "\u04c7"-"\u04c8", + "\u04cb"-"\u04cc", + "\u04d0"-"\u04f5", + "\u04f8"-"\u04f9", + "\u0531"-"\u0556", + "\u0559", + "\u0561"-"\u0587", + "\u0591"-"\u05a1", + "\u05a3"-"\u05b9", + "\u05bb"-"\u05bd", + "\u05bf", + "\u05c1"-"\u05c2", + "\u05c4", + "\u05d0"-"\u05ea", + "\u05f0"-"\u05f2", + "\u0621"-"\u063a", + "\u0640"-"\u0655", + "\u0660"-"\u0669", + "\u0670"-"\u06d3", + "\u06d5"-"\u06dc", + "\u06df"-"\u06e8", + "\u06ea"-"\u06ed", + "\u06f0"-"\u06fc", + "\u070f"-"\u072c", + "\u0730"-"\u074a", + "\u0780"-"\u07b0", + "\u0901"-"\u0903", + "\u0905"-"\u0939", + "\u093c"-"\u094d", + "\u0950"-"\u0954", + "\u0958"-"\u0963", + "\u0966"-"\u096f", + "\u0981"-"\u0983", + "\u0985"-"\u098c", + "\u098f"-"\u0990", + "\u0993"-"\u09a8", + "\u09aa"-"\u09b0", + "\u09b2", + "\u09b6"-"\u09b9", + "\u09bc", + "\u09be"-"\u09c4", + "\u09c7"-"\u09c8", + "\u09cb"-"\u09cd", + "\u09d7", + "\u09dc"-"\u09dd", + "\u09df"-"\u09e3", + "\u09e6"-"\u09f3", + "\u0a02", + "\u0a05"-"\u0a0a", + "\u0a0f"-"\u0a10", + "\u0a13"-"\u0a28", + "\u0a2a"-"\u0a30", + "\u0a32"-"\u0a33", + "\u0a35"-"\u0a36", + "\u0a38"-"\u0a39", + "\u0a3c", + "\u0a3e"-"\u0a42", + "\u0a47"-"\u0a48", + "\u0a4b"-"\u0a4d", + "\u0a59"-"\u0a5c", + "\u0a5e", + "\u0a66"-"\u0a74", + "\u0a81"-"\u0a83", + "\u0a85"-"\u0a8b", + "\u0a8d", + "\u0a8f"-"\u0a91", + "\u0a93"-"\u0aa8", + "\u0aaa"-"\u0ab0", + "\u0ab2"-"\u0ab3", + "\u0ab5"-"\u0ab9", + "\u0abc"-"\u0ac5", + "\u0ac7"-"\u0ac9", + "\u0acb"-"\u0acd", + "\u0ad0", + "\u0ae0", + "\u0ae6"-"\u0aef", + "\u0b01"-"\u0b03", + "\u0b05"-"\u0b0c", + "\u0b0f"-"\u0b10", + "\u0b13"-"\u0b28", + "\u0b2a"-"\u0b30", + "\u0b32"-"\u0b33", + "\u0b36"-"\u0b39", + "\u0b3c"-"\u0b43", + "\u0b47"-"\u0b48", + "\u0b4b"-"\u0b4d", + "\u0b56"-"\u0b57", + "\u0b5c"-"\u0b5d", + "\u0b5f"-"\u0b61", + "\u0b66"-"\u0b6f", + "\u0b82"-"\u0b83", + "\u0b85"-"\u0b8a", + "\u0b8e"-"\u0b90", + "\u0b92"-"\u0b95", + "\u0b99"-"\u0b9a", + "\u0b9c", + "\u0b9e"-"\u0b9f", + "\u0ba3"-"\u0ba4", + "\u0ba8"-"\u0baa", + "\u0bae"-"\u0bb5", + "\u0bb7"-"\u0bb9", + "\u0bbe"-"\u0bc2", + "\u0bc6"-"\u0bc8", + "\u0bca"-"\u0bcd", + "\u0bd7", + "\u0be7"-"\u0bef", + "\u0c01"-"\u0c03", + "\u0c05"-"\u0c0c", + "\u0c0e"-"\u0c10", + "\u0c12"-"\u0c28", + "\u0c2a"-"\u0c33", + "\u0c35"-"\u0c39", + "\u0c3e"-"\u0c44", + "\u0c46"-"\u0c48", + "\u0c4a"-"\u0c4d", + "\u0c55"-"\u0c56", + "\u0c60"-"\u0c61", + "\u0c66"-"\u0c6f", + "\u0c82"-"\u0c83", + "\u0c85"-"\u0c8c", + "\u0c8e"-"\u0c90", + "\u0c92"-"\u0ca8", + "\u0caa"-"\u0cb3", + "\u0cb5"-"\u0cb9", + "\u0cbe"-"\u0cc4", + "\u0cc6"-"\u0cc8", + "\u0cca"-"\u0ccd", + "\u0cd5"-"\u0cd6", + "\u0cde", + "\u0ce0"-"\u0ce1", + "\u0ce6"-"\u0cef", + "\u0d02"-"\u0d03", + "\u0d05"-"\u0d0c", + "\u0d0e"-"\u0d10", + "\u0d12"-"\u0d28", + "\u0d2a"-"\u0d39", + "\u0d3e"-"\u0d43", + "\u0d46"-"\u0d48", + "\u0d4a"-"\u0d4d", + "\u0d57", + "\u0d60"-"\u0d61", + "\u0d66"-"\u0d6f", + "\u0d82"-"\u0d83", + "\u0d85"-"\u0d96", + "\u0d9a"-"\u0db1", + "\u0db3"-"\u0dbb", + "\u0dbd", + "\u0dc0"-"\u0dc6", + "\u0dca", + "\u0dcf"-"\u0dd4", + "\u0dd6", + "\u0dd8"-"\u0ddf", + "\u0df2"-"\u0df3", + "\u0e01"-"\u0e3a", + "\u0e3f"-"\u0e4e", + "\u0e50"-"\u0e59", + "\u0e81"-"\u0e82", + "\u0e84", + "\u0e87"-"\u0e88", + "\u0e8a", + "\u0e8d", + "\u0e94"-"\u0e97", + "\u0e99"-"\u0e9f", + "\u0ea1"-"\u0ea3", + "\u0ea5", + "\u0ea7", + "\u0eaa"-"\u0eab", + "\u0ead"-"\u0eb9", + "\u0ebb"-"\u0ebd", + "\u0ec0"-"\u0ec4", + "\u0ec6", + "\u0ec8"-"\u0ecd", + "\u0ed0"-"\u0ed9", + "\u0edc"-"\u0edd", + "\u0f00", + "\u0f18"-"\u0f19", + "\u0f20"-"\u0f29", + "\u0f35", + "\u0f37", + "\u0f39", + "\u0f3e"-"\u0f47", + "\u0f49"-"\u0f6a", + "\u0f71"-"\u0f84", + "\u0f86"-"\u0f8b", + "\u0f90"-"\u0f97", + "\u0f99"-"\u0fbc", + "\u0fc6", + "\u1000"-"\u1021", + "\u1023"-"\u1027", + "\u1029"-"\u102a", + "\u102c"-"\u1032", + "\u1036"-"\u1039", + "\u1040"-"\u1049", + "\u1050"-"\u1059", + "\u10a0"-"\u10c5", + "\u10d0"-"\u10f6", + "\u1100"-"\u1159", + "\u115f"-"\u11a2", + "\u11a8"-"\u11f9", + "\u1200"-"\u1206", + "\u1208"-"\u1246", + "\u1248", + "\u124a"-"\u124d", + "\u1250"-"\u1256", + "\u1258", + "\u125a"-"\u125d", + "\u1260"-"\u1286", + "\u1288", + "\u128a"-"\u128d", + "\u1290"-"\u12ae", + "\u12b0", + "\u12b2"-"\u12b5", + "\u12b8"-"\u12be", + "\u12c0", + "\u12c2"-"\u12c5", + "\u12c8"-"\u12ce", + "\u12d0"-"\u12d6", + "\u12d8"-"\u12ee", + "\u12f0"-"\u130e", + "\u1310", + "\u1312"-"\u1315", + "\u1318"-"\u131e", + "\u1320"-"\u1346", + "\u1348"-"\u135a", + "\u1369"-"\u1371", + "\u13a0"-"\u13f4", + "\u1401"-"\u166c", + "\u166f"-"\u1676", + "\u1681"-"\u169a", + "\u16a0"-"\u16ea", + "\u1780"-"\u17d3", + "\u17db", + "\u17e0"-"\u17e9", + "\u180b"-"\u180e", + "\u1810"-"\u1819", + "\u1820"-"\u1877", + "\u1880"-"\u18a9", + "\u1e00"-"\u1e9b", + "\u1ea0"-"\u1ef9", + "\u1f00"-"\u1f15", + "\u1f18"-"\u1f1d", + "\u1f20"-"\u1f45", + "\u1f48"-"\u1f4d", + "\u1f50"-"\u1f57", + "\u1f59", + "\u1f5b", + "\u1f5d", + "\u1f5f"-"\u1f7d", + "\u1f80"-"\u1fb4", + "\u1fb6"-"\u1fbc", + "\u1fbe", + "\u1fc2"-"\u1fc4", + "\u1fc6"-"\u1fcc", + "\u1fd0"-"\u1fd3", + "\u1fd6"-"\u1fdb", + "\u1fe0"-"\u1fec", + "\u1ff2"-"\u1ff4", + "\u1ff6"-"\u1ffc", + "\u200c"-"\u200f", + "\u202a"-"\u202e", + "\u203f"-"\u2040", + "\u206a"-"\u206f", + "\u207f", + "\u20a0"-"\u20af", + "\u20d0"-"\u20dc", + "\u20e1", + "\u2102", + "\u2107", + "\u210a"-"\u2113", + "\u2115", + "\u2119"-"\u211d", + "\u2124", + "\u2126", + "\u2128", + "\u212a"-"\u212d", + "\u212f"-"\u2131", + "\u2133"-"\u2139", + "\u2160"-"\u2183", + "\u3005"-"\u3007", + "\u3021"-"\u302f", + "\u3031"-"\u3035", + "\u3038"-"\u303a", + "\u3041"-"\u3094", + "\u3099"-"\u309a", + "\u309d"-"\u309e", + "\u30a1"-"\u30fe", + "\u3105"-"\u312c", + "\u3131"-"\u318e", + "\u31a0"-"\u31b7", + "\u3400"-"\u4db5", + "\u4e00"-"\u9fa5", + "\ua000"-"\ua48c", + "\uac00"-"\ud7a3", + "\uf900"-"\ufa2d", + "\ufb00"-"\ufb06", + "\ufb13"-"\ufb17", + "\ufb1d"-"\ufb28", + "\ufb2a"-"\ufb36", + "\ufb38"-"\ufb3c", + "\ufb3e", + "\ufb40"-"\ufb41", + "\ufb43"-"\ufb44", + "\ufb46"-"\ufbb1", + "\ufbd3"-"\ufd3d", + "\ufd50"-"\ufd8f", + "\ufd92"-"\ufdc7", + "\ufdf0"-"\ufdfb", + "\ufe20"-"\ufe23", + "\ufe33"-"\ufe34", + "\ufe4d"-"\ufe4f", + "\ufe69", + "\ufe70"-"\ufe72", + "\ufe74", + "\ufe76"-"\ufefc", + "\ufeff", + "\uff04", + "\uff10"-"\uff19", + "\uff21"-"\uff3a", + "\uff3f", + "\uff41"-"\uff5a", + "\uff65"-"\uffbe", + "\uffc2"-"\uffc7", + "\uffca"-"\uffcf", + "\uffd2"-"\uffd7", + "\uffda"-"\uffdc", + "\uffe0"-"\uffe1", + "\uffe5"-"\uffe6", + "\ufff9"-"\ufffb" + ] + > +} + +/* SEPARATORS */ + +TOKEN : +{ + < LPAREN: "(" > +| < RPAREN: ")" > +| < LBRACE: "{" > +| < RBRACE: "}" > +| < LBRACKET: "[" > +| < RBRACKET: "]" > +| < SEMICOLON: ";" > +| < COMMA: "," > +| < DOT: "." > +| < AT: "@" > +} + +/* OPERATORS */ + +TOKEN : +{ + < ASSIGN: "=" > +| < LT: "<" > +| < BANG: "!" > +| < TILDE: "~" > +| < HOOK: "?" > +| < COLON: ":" > +| < EQ: "==" > +| < LE: "<=" > +| < GE: ">=" > +| < NE: "!=" > +| < SC_OR: "||" > +| < SC_AND: "&&" > +| < INCR: "++" > +| < DECR: "--" > +| < PLUS: "+" > +| < MINUS: "-" > +| < STAR: "*" > +| < SLASH: "/" > +| < BIT_AND: "&" > +| < BIT_OR: "|" > +| < XOR: "^" > +| < REM: "%" > +| < LSHIFT: "<<" > +| < PLUSASSIGN: "+=" > +| < MINUSASSIGN: "-=" > +| < STARASSIGN: "*=" > +| < SLASHASSIGN: "/=" > +| < ANDASSIGN: "&=" > +| < ORASSIGN: "|=" > +| < XORASSIGN: "^=" > +| < REMASSIGN: "%=" > +| < LSHIFTASSIGN: "<<=" > +| < RSIGNEDSHIFTASSIGN: ">>=" > +| < RUNSIGNEDSHIFTASSIGN: ">>>=" > +| < ELLIPSIS: "..." > +} + +/* >'s need special attention due to generics syntax. */ +TOKEN : +{ + < RUNSIGNEDSHIFT: ">>>" > + { + matchedToken.kind = GT; + ((Token.GTToken)matchedToken).realKind = RUNSIGNEDSHIFT; + input_stream.backup(2); + matchedToken.image = ">"; + } +| < RSIGNEDSHIFT: ">>" > + { + matchedToken.kind = GT; + ((Token.GTToken)matchedToken).realKind = RSIGNEDSHIFT; + input_stream.backup(1); + matchedToken.image = ">"; + } +| < GT: ">" > +} + +boolean Line() : +{/*@bgen(jjtree) Line */ + SimpleNode jjtn000 = new SimpleNode(JJTLINE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/ + int modifiers; +} +{/*@bgen(jjtree) Line */ + try { +/*@egen*/ + <EOF>/*@bgen(jjtree)*/ + { + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtreeCloseNodeScope(jjtn000); + } +/*@egen*/ { + return true; + } +| + LOOKAHEAD(BlockStatement()) + BlockStatement()/*@bgen(jjtree)*/ + { + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtreeCloseNodeScope(jjtn000); + } +/*@egen*/ { + return false; + } +| + LOOKAHEAD(Modifiers() [ TypeParameters() ] [ ResultType() ] <IDENTIFIER> FormalParameters() [ "throws" NameList() ] "{") + ClassOrInterfaceBodyDeclaration(false)/*@bgen(jjtree)*/ + { + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtreeCloseNodeScope(jjtn000); + } +/*@egen*/ { + return false; + } +| + LOOKAHEAD(ClassOrInterfaceBodyDeclaration(false)) + ClassOrInterfaceBodyDeclaration(false)/*@bgen(jjtree)*/ + { + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtreeCloseNodeScope(jjtn000); + } +/*@egen*/ { + return false; + } +| + LOOKAHEAD(Expression()) + Expression()/*@bgen(jjtree)*/ + { + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtreeCloseNodeScope(jjtn000); + } +/*@egen*/ { + return false; + } +| + ImportDeclaration()/*@bgen(jjtree)*/ + { + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtreeCloseNodeScope(jjtn000); + } +/*@egen*/ { + return false; + }/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +/***************************************** + * THE JAVA LANGUAGE GRAMMAR STARTS HERE * + *****************************************/ + +/* + * Program structuring syntax follows. + */ + +void CompilationUnit(): +{/*@bgen(jjtree) CompilationUnit */ + SimpleNode jjtn000 = new SimpleNode(JJTCOMPILATIONUNIT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) CompilationUnit */ + try { +/*@egen*/ + [ LOOKAHEAD( ( Annotation() )* "package" ) PackageDeclaration() ] + ( ImportDeclaration() )* + ( TypeDeclaration() )* + ( < "\u001a" > )? + ( <STUFF_TO_IGNORE: ~[]> )? + <EOF>/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void PackageDeclaration(): +{/*@bgen(jjtree) PackageDeclaration */ + SimpleNode jjtn000 = new SimpleNode(JJTPACKAGEDECLARATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) PackageDeclaration */ + try { +/*@egen*/ + Modifiers() "package" Name() ";"/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void ImportDeclaration(): +{/*@bgen(jjtree) ImportDeclaration */ + SimpleNode jjtn000 = new SimpleNode(JJTIMPORTDECLARATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) ImportDeclaration */ + try { +/*@egen*/ + "import" [ "static" ] Name() [ "." "*" ] ";"/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +/* + * Modifiers. We match all modifiers in a single rule to reduce the chances of + * syntax errors for simple modifier mistakes. It will also enable us to give + * better error messages. + */ + +int Modifiers(): +{/*@bgen(jjtree) Modifiers */ + SimpleNode jjtn000 = new SimpleNode(JJTMODIFIERS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/ + int modifiers = 0; +} +{/*@bgen(jjtree) Modifiers */ + try { +/*@egen*/ + ( + LOOKAHEAD(2) + ( + "public" { modifiers |= ModifierSet.PUBLIC; } + | + "static" { modifiers |= ModifierSet.STATIC; } + | + "protected" { modifiers |= ModifierSet.PROTECTED; } + | + "private" { modifiers |= ModifierSet.PRIVATE; } + | + "final" { modifiers |= ModifierSet.FINAL; } + | + "abstract" { modifiers |= ModifierSet.ABSTRACT; } + | + "synchronized" { modifiers |= ModifierSet.SYNCHRONIZED; } + | + "native" { modifiers |= ModifierSet.NATIVE; } + | + "transient" { modifiers |= ModifierSet.TRANSIENT; } + | + "volatile" { modifiers |= ModifierSet.VOLATILE; } + | + "strictfp" { modifiers |= ModifierSet.STRICTFP; } + | + Annotation() + ) + )*/*@bgen(jjtree)*/ + { + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtreeCloseNodeScope(jjtn000); + } +/*@egen*/ + + { + return modifiers; + }/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +/* + * Declaration syntax follows. + */ +void TypeDeclaration(): +{/*@bgen(jjtree) TypeDeclaration */ + SimpleNode jjtn000 = new SimpleNode(JJTTYPEDECLARATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/ + int modifiers; +} +{/*@bgen(jjtree) TypeDeclaration */ + try { +/*@egen*/ + ";" +| + modifiers = Modifiers() + ( + ClassOrInterfaceDeclaration(modifiers) + | + EnumDeclaration(modifiers) + | + AnnotationTypeDeclaration(modifiers) + )/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + + +void ClassOrInterfaceDeclaration(int modifiers): +{/*@bgen(jjtree) ClassOrInterfaceDeclaration */ + SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACEDECLARATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/ + boolean isInterface = false; +} +{/*@bgen(jjtree) ClassOrInterfaceDeclaration */ + try { +/*@egen*/ + ( "class" | "interface" { isInterface = true; } ) + <IDENTIFIER> + [ TypeParameters() ] + [ ExtendsList(isInterface) ] + [ ImplementsList(isInterface) ] + ClassOrInterfaceBody(isInterface)/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void ExtendsList(boolean isInterface): +{/*@bgen(jjtree) ExtendsList */ + SimpleNode jjtn000 = new SimpleNode(JJTEXTENDSLIST); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/ + boolean extendsMoreThanOne = false; +} +{/*@bgen(jjtree) ExtendsList */ + try { +/*@egen*/ + "extends" ClassOrInterfaceType() + ( "," ClassOrInterfaceType() { extendsMoreThanOne = true; } )*/*@bgen(jjtree)*/ + { + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtreeCloseNodeScope(jjtn000); + } +/*@egen*/ + { + if (extendsMoreThanOne && !isInterface) + throw new ParseException("A class cannot extend more than one other class"); + }/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void ImplementsList(boolean isInterface): +{/*@bgen(jjtree) ImplementsList */ + SimpleNode jjtn000 = new SimpleNode(JJTIMPLEMENTSLIST); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) ImplementsList */ + try { +/*@egen*/ + "implements" ClassOrInterfaceType() + ( "," ClassOrInterfaceType() )*/*@bgen(jjtree)*/ + { + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtreeCloseNodeScope(jjtn000); + } +/*@egen*/ + { + if (isInterface) + throw new ParseException("An interface cannot implement other interfaces"); + }/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void EnumDeclaration(int modifiers): +{/*@bgen(jjtree) EnumDeclaration */ + SimpleNode jjtn000 = new SimpleNode(JJTENUMDECLARATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) EnumDeclaration */ + try { +/*@egen*/ + "enum" <IDENTIFIER> + [ ImplementsList(false) ] + EnumBody()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void EnumBody(): +{/*@bgen(jjtree) EnumBody */ + SimpleNode jjtn000 = new SimpleNode(JJTENUMBODY); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) EnumBody */ + try { +/*@egen*/ + "{" + [ EnumConstant() ( LOOKAHEAD(2) "," EnumConstant() )* ] + [ "," ] + [ ";" ( ClassOrInterfaceBodyDeclaration(false) )* ] + "}"/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void EnumConstant(): +{/*@bgen(jjtree) EnumConstant */ + SimpleNode jjtn000 = new SimpleNode(JJTENUMCONSTANT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) EnumConstant */ + try { +/*@egen*/ + Modifiers() <IDENTIFIER> [ Arguments() ] [ ClassOrInterfaceBody(false) ]/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void TypeParameters(): +{/*@bgen(jjtree) TypeParameters */ + SimpleNode jjtn000 = new SimpleNode(JJTTYPEPARAMETERS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) TypeParameters */ + try { +/*@egen*/ + "<" TypeParameter() ( "," TypeParameter() )* ">"/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void TypeParameter(): +{/*@bgen(jjtree) TypeParameter */ + SimpleNode jjtn000 = new SimpleNode(JJTTYPEPARAMETER); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) TypeParameter */ + try { +/*@egen*/ + <IDENTIFIER> [ TypeBound() ]/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void TypeBound(): +{/*@bgen(jjtree) TypeBound */ + SimpleNode jjtn000 = new SimpleNode(JJTTYPEBOUND); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) TypeBound */ + try { +/*@egen*/ + "extends" ClassOrInterfaceType() ( "&" ClassOrInterfaceType() )*/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void ClassOrInterfaceBody(boolean isInterface): +{/*@bgen(jjtree) ClassOrInterfaceBody */ + SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACEBODY); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) ClassOrInterfaceBody */ + try { +/*@egen*/ + "{" ( ClassOrInterfaceBodyDeclaration(isInterface) )* "}"/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void ClassOrInterfaceBodyDeclaration(boolean isInterface): +{/*@bgen(jjtree) ClassOrInterfaceBodyDeclaration */ + SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACEBODYDECLARATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/ + boolean isNestedInterface = false; + int modifiers; +} +{/*@bgen(jjtree) ClassOrInterfaceBodyDeclaration */ + try { +/*@egen*/ + LOOKAHEAD(2) + Initializer()/*@bgen(jjtree)*/ + { + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtreeCloseNodeScope(jjtn000); + } +/*@egen*/ + { + if (isInterface) + throw new ParseException("An interface cannot have initializers"); + } +| + modifiers = Modifiers() // Just get all the modifiers out of the way. If you want to do + // more checks, pass the modifiers down to the member + ( + ClassOrInterfaceDeclaration(modifiers) + | + EnumDeclaration(modifiers) + | + LOOKAHEAD( [ TypeParameters() ] <IDENTIFIER> "(" ) + ConstructorDeclaration() + | + LOOKAHEAD( Type() <IDENTIFIER> ( "[" "]" )* ( "," | "=" | ";" ) ) + FieldDeclaration(modifiers) + | + MethodDeclaration(modifiers) + ) +| + ";"/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void FieldDeclaration(int modifiers): +{/*@bgen(jjtree) FieldDeclaration */ + SimpleNode jjtn000 = new SimpleNode(JJTFIELDDECLARATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) FieldDeclaration */ + try { +/*@egen*/ + // Modifiers are already matched in the caller + Type() VariableDeclarator() ( "," VariableDeclarator() )* ";"/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void VariableDeclarator(): +{/*@bgen(jjtree) VariableDeclarator */ + SimpleNode jjtn000 = new SimpleNode(JJTVARIABLEDECLARATOR); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) VariableDeclarator */ + try { +/*@egen*/ + VariableDeclaratorId() [ "=" VariableInitializer() ]/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void VariableDeclaratorId(): +{/*@bgen(jjtree) VariableDeclaratorId */ + SimpleNode jjtn000 = new SimpleNode(JJTVARIABLEDECLARATORID); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) VariableDeclaratorId */ + try { +/*@egen*/ + <IDENTIFIER> ( "[" "]" )*/*@bgen(jjtree)*/ + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void VariableInitializer(): +{/*@bgen(jjtree) VariableInitializer */ + SimpleNode jjtn000 = new SimpleNode(JJTVARIABLEINITIALIZER); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) VariableInitializer */ + try { +/*@egen*/ + ArrayInitializer() +| + Expression()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void ArrayInitializer(): +{/*@bgen(jjtree) ArrayInitializer */ + SimpleNode jjtn000 = new SimpleNode(JJTARRAYINITIALIZER); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) ArrayInitializer */ + try { +/*@egen*/ + "{" [ VariableInitializer() ( LOOKAHEAD(2) "," VariableInitializer() )* ] [ "," ] "}"/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void MethodDeclaration(int modifiers): +{/*@bgen(jjtree) MethodDeclaration */ + SimpleNode jjtn000 = new SimpleNode(JJTMETHODDECLARATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) MethodDeclaration */ + try { +/*@egen*/ + // Modifiers already matched in the caller! + [ TypeParameters() ] + ResultType() + MethodDeclarator() [ "throws" NameList() ] + ( Block() | ";" )/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void MethodDeclarator(): +{/*@bgen(jjtree) MethodDeclarator */ + SimpleNode jjtn000 = new SimpleNode(JJTMETHODDECLARATOR); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) MethodDeclarator */ + try { +/*@egen*/ + <IDENTIFIER> FormalParameters() ( "[" "]" )*/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void FormalParameters(): +{/*@bgen(jjtree) FormalParameters */ + SimpleNode jjtn000 = new SimpleNode(JJTFORMALPARAMETERS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) FormalParameters */ + try { +/*@egen*/ + "(" [ FormalParameter() ( "," FormalParameter() )* ] ")"/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void FormalParameter(): +{/*@bgen(jjtree) FormalParameter */ + SimpleNode jjtn000 = new SimpleNode(JJTFORMALPARAMETER); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) FormalParameter */ + try { +/*@egen*/ + Modifiers() Type() [ "..." ] VariableDeclaratorId()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void ConstructorDeclaration(): +{/*@bgen(jjtree) ConstructorDeclaration */ + SimpleNode jjtn000 = new SimpleNode(JJTCONSTRUCTORDECLARATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) ConstructorDeclaration */ + try { +/*@egen*/ + [ TypeParameters() ] + // Modifiers matched in the caller + <IDENTIFIER> FormalParameters() [ "throws" NameList() ] + "{" + [ LOOKAHEAD(ExplicitConstructorInvocation()) + ExplicitConstructorInvocation() + ] + ( BlockStatement() )* + "}"/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void ExplicitConstructorInvocation(): +{/*@bgen(jjtree) ExplicitConstructorInvocation */ + SimpleNode jjtn000 = new SimpleNode(JJTEXPLICITCONSTRUCTORINVOCATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) ExplicitConstructorInvocation */ + try { +/*@egen*/ + ( <IDENTIFIER> "." )* [ LOOKAHEAD(2) "this" "." ] + [ TypeArguments() ] ("this"|"super") Arguments() ";"/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void Initializer(): +{/*@bgen(jjtree) Initializer */ + SimpleNode jjtn000 = new SimpleNode(JJTINITIALIZER); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) Initializer */ + try { +/*@egen*/ + [ "static" ] Block()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + + +/* + * Type, name and expression syntax follows. + */ + +void Type(): +{/*@bgen(jjtree) Type */ + SimpleNode jjtn000 = new SimpleNode(JJTTYPE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) Type */ + try { +/*@egen*/ + LOOKAHEAD(2) ReferenceType() + | + PrimitiveType()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void ReferenceType(): +{/*@bgen(jjtree) ReferenceType */ + SimpleNode jjtn000 = new SimpleNode(JJTREFERENCETYPE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) ReferenceType */ + try { +/*@egen*/ + PrimitiveType() ( LOOKAHEAD(2) "[" "]" )+ + | + ( ClassOrInterfaceType() ) ( LOOKAHEAD(2) "[" "]" )*/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void ClassOrInterfaceType(): +{/*@bgen(jjtree) ClassOrInterfaceType */ + SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACETYPE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) ClassOrInterfaceType */ + try { +/*@egen*/ + <IDENTIFIER> [ LOOKAHEAD(2) TypeArguments() ] + ( LOOKAHEAD(2) "." <IDENTIFIER> [ LOOKAHEAD(2) TypeArguments() ] )*/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void TypeArguments(): +{/*@bgen(jjtree) TypeArguments */ + SimpleNode jjtn000 = new SimpleNode(JJTTYPEARGUMENTS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) TypeArguments */ + try { +/*@egen*/ + "<" TypeArgument() ( "," TypeArgument() )* ">"/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void TypeArgument(): +{/*@bgen(jjtree) TypeArgument */ + SimpleNode jjtn000 = new SimpleNode(JJTTYPEARGUMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) TypeArgument */ + try { +/*@egen*/ + ReferenceType() + | + "?" [ WildcardBounds() ]/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void WildcardBounds(): +{/*@bgen(jjtree) WildcardBounds */ + SimpleNode jjtn000 = new SimpleNode(JJTWILDCARDBOUNDS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) WildcardBounds */ + try { +/*@egen*/ + "extends" ReferenceType() + | + "super" ReferenceType()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + + +void PrimitiveType(): +{/*@bgen(jjtree) PrimitiveType */ + SimpleNode jjtn000 = new SimpleNode(JJTPRIMITIVETYPE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) PrimitiveType */ + try { +/*@egen*/ + "boolean" +| + "char" +| + "byte" +| + "short" +| + "int" +| + "long" +| + "float" +| + "double"/*@bgen(jjtree)*/ + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void ResultType(): +{/*@bgen(jjtree) ResultType */ + SimpleNode jjtn000 = new SimpleNode(JJTRESULTTYPE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) ResultType */ + try { +/*@egen*/ + "void" +| + Type()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void Name(): +/* + * A lookahead of 2 is required below since "Name" can be followed + * by a ".*" when used in the context of an "ImportDeclaration". + */ +{/*@bgen(jjtree) Name */ + SimpleNode jjtn000 = new SimpleNode(JJTNAME); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) Name */ + try { +/*@egen*/ + <IDENTIFIER> + ( LOOKAHEAD(2) "." <IDENTIFIER> + )*/*@bgen(jjtree)*/ + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void NameList(): +{/*@bgen(jjtree) NameList */ + SimpleNode jjtn000 = new SimpleNode(JJTNAMELIST); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) NameList */ + try { +/*@egen*/ + Name() ( "," Name() )*/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + + +/* + * Expression syntax follows. + */ + +void Expression(): +/* + * This expansion has been written this way instead of: + * Assignment() | ConditionalExpression() + * for performance reasons. + * However, it is a weakening of the grammar for it allows the LHS of + * assignments to be any conditional expression whereas it can only be + * a primary expression. Consider adding a semantic predicate to work + * around this. + */ +{/*@bgen(jjtree) Expression */ + SimpleNode jjtn000 = new SimpleNode(JJTEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) Expression */ + try { +/*@egen*/ + ConditionalExpression() + [ + LOOKAHEAD(2) + AssignmentOperator() Expression() + ]/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void AssignmentOperator(): +{/*@bgen(jjtree) AssignmentOperator */ + SimpleNode jjtn000 = new SimpleNode(JJTASSIGNMENTOPERATOR); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) AssignmentOperator */ + try { +/*@egen*/ + "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | ">>>=" | "&=" | "^=" | "|="/*@bgen(jjtree)*/ + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void AssignmentExpression(): +{/*@bgen(jjtree) AssignmentExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTASSIGNMENTEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) AssignmentExpression */ + try { +/*@egen*/ + PrimaryExpression() AssignmentOperator() Expression()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void ConditionalExpression(): +{/*@bgen(jjtree) ConditionalExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTCONDITIONALEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) ConditionalExpression */ + try { +/*@egen*/ + ConditionalOrExpression() [ "?" Expression() ":" Expression() ]/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void ConditionalOrExpression(): +{/*@bgen(jjtree) ConditionalOrExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTCONDITIONALOREXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) ConditionalOrExpression */ + try { +/*@egen*/ + ConditionalAndExpression() ( "||" ConditionalAndExpression() )*/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void ConditionalAndExpression(): +{/*@bgen(jjtree) ConditionalAndExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTCONDITIONALANDEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) ConditionalAndExpression */ + try { +/*@egen*/ + InclusiveOrExpression() ( "&&" InclusiveOrExpression() )*/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void InclusiveOrExpression(): +{/*@bgen(jjtree) InclusiveOrExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTINCLUSIVEOREXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) InclusiveOrExpression */ + try { +/*@egen*/ + ExclusiveOrExpression() ( "|" ExclusiveOrExpression() )*/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void ExclusiveOrExpression(): +{/*@bgen(jjtree) ExclusiveOrExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTEXCLUSIVEOREXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) ExclusiveOrExpression */ + try { +/*@egen*/ + AndExpression() ( "^" AndExpression() )*/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void AndExpression(): +{/*@bgen(jjtree) AndExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTANDEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) AndExpression */ + try { +/*@egen*/ + EqualityExpression() ( "&" EqualityExpression() )*/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void EqualityExpression(): +{/*@bgen(jjtree) EqualityExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTEQUALITYEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) EqualityExpression */ + try { +/*@egen*/ + InstanceOfExpression() ( ( "==" | "!=" ) InstanceOfExpression() )*/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void InstanceOfExpression(): +{/*@bgen(jjtree) InstanceOfExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTINSTANCEOFEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) InstanceOfExpression */ + try { +/*@egen*/ + RelationalExpression() [ "instanceof" Type() ]/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void RelationalExpression(): +{/*@bgen(jjtree) RelationalExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTRELATIONALEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) RelationalExpression */ + try { +/*@egen*/ + ShiftExpression() ( ( "<" | ">" | "<=" | ">=" ) ShiftExpression() )*/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void ShiftExpression(): +{/*@bgen(jjtree) ShiftExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTSHIFTEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) ShiftExpression */ + try { +/*@egen*/ + AdditiveExpression() ( ( "<<" | RSIGNEDSHIFT() | RUNSIGNEDSHIFT() ) AdditiveExpression() )*/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void AdditiveExpression(): +{/*@bgen(jjtree) AdditiveExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTADDITIVEEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) AdditiveExpression */ + try { +/*@egen*/ + MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )*/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void MultiplicativeExpression(): +{/*@bgen(jjtree) MultiplicativeExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTMULTIPLICATIVEEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) MultiplicativeExpression */ + try { +/*@egen*/ + UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )*/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void UnaryExpression(): +{/*@bgen(jjtree) UnaryExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTUNARYEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) UnaryExpression */ + try { +/*@egen*/ + ( "+" | "-" ) UnaryExpression() +| + PreIncrementExpression() +| + PreDecrementExpression() +| + UnaryExpressionNotPlusMinus()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void PreIncrementExpression(): +{/*@bgen(jjtree) PreIncrementExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTPREINCREMENTEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) PreIncrementExpression */ + try { +/*@egen*/ + "++" PrimaryExpression()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void PreDecrementExpression(): +{/*@bgen(jjtree) PreDecrementExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTPREDECREMENTEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) PreDecrementExpression */ + try { +/*@egen*/ + "--" PrimaryExpression()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void UnaryExpressionNotPlusMinus(): +{/*@bgen(jjtree) UnaryExpressionNotPlusMinus */ + SimpleNode jjtn000 = new SimpleNode(JJTUNARYEXPRESSIONNOTPLUSMINUS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) UnaryExpressionNotPlusMinus */ + try { +/*@egen*/ + ( "~" | "!" ) UnaryExpression() +| + LOOKAHEAD( CastLookahead() ) + CastExpression() +| + PostfixExpression()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +// This production is to determine lookahead only. The LOOKAHEAD specifications +// below are not used, but they are there just to indicate that we know about +// this. +void CastLookahead(): +{/*@bgen(jjtree) CastLookahead */ + SimpleNode jjtn000 = new SimpleNode(JJTCASTLOOKAHEAD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) CastLookahead */ + try { +/*@egen*/ + LOOKAHEAD(2) + "(" PrimitiveType() +| + LOOKAHEAD("(" Type() "[") + "(" Type() "[" "]" +| + "(" Type() ")" ( "~" | "!" | "(" | <IDENTIFIER> | "this" | "super" | "new" | Literal() )/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void PostfixExpression(): +{/*@bgen(jjtree) PostfixExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTPOSTFIXEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) PostfixExpression */ + try { +/*@egen*/ + PrimaryExpression() [ PostfixOperator() ]/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void PostfixOperator(): +{/*@bgen(jjtree) PostfixOperator */ + SimpleNode jjtn000 = new SimpleNode(JJTPOSTFIXOPERATOR); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) PostfixOperator */ + try { +/*@egen*/ + "++" | "--"/*@bgen(jjtree)*/ + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void CastExpression(): +{/*@bgen(jjtree) CastExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTCASTEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) CastExpression */ + try { +/*@egen*/ + LOOKAHEAD("(" PrimitiveType()) + "(" Type() ")" UnaryExpression() +| + "(" Type() ")" UnaryExpressionNotPlusMinus()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void PrimaryExpression(): +{/*@bgen(jjtree) PrimaryExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTPRIMARYEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) PrimaryExpression */ + try { +/*@egen*/ + PrimaryPrefix() ( LOOKAHEAD(2) PrimarySuffix() )*/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void MemberSelector(): +{/*@bgen(jjtree) MemberSelector */ + SimpleNode jjtn000 = new SimpleNode(JJTMEMBERSELECTOR); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) MemberSelector */ + try { +/*@egen*/ + "." TypeArguments() <IDENTIFIER>/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void PrimaryPrefix(): +{/*@bgen(jjtree) PrimaryPrefix */ + SimpleNode jjtn000 = new SimpleNode(JJTPRIMARYPREFIX); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) PrimaryPrefix */ + try { +/*@egen*/ + Literal() +| + LOOKAHEAD( ( <IDENTIFIER> "." )* "this" ) + ( <IDENTIFIER> "." )* + "this" +| + "super" "." <IDENTIFIER> +| + "(" Expression() ")" +| + AllocationExpression() +| + LOOKAHEAD( ResultType() "." "class" ) + ResultType() "." "class" +| + Name()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void PrimarySuffix(): +{/*@bgen(jjtree) PrimarySuffix */ + SimpleNode jjtn000 = new SimpleNode(JJTPRIMARYSUFFIX); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) PrimarySuffix */ + try { +/*@egen*/ + LOOKAHEAD("." "super" ".") + "." "super" +| + LOOKAHEAD("." "this") + "." "this" +| + LOOKAHEAD(2) + "." AllocationExpression() +| + LOOKAHEAD(3) + MemberSelector() +| + "[" Expression() "]" +| + "." <IDENTIFIER> +| + Arguments()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void Literal(): +{/*@bgen(jjtree) Literal */ + SimpleNode jjtn000 = new SimpleNode(JJTLITERAL); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) Literal */ + try { +/*@egen*/ + <INTEGER_LITERAL> +| + <FLOATING_POINT_LITERAL> +| + <CHARACTER_LITERAL> +| + <STRING_LITERAL> +| + BooleanLiteral() +| + NullLiteral()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void BooleanLiteral(): +{/*@bgen(jjtree) BooleanLiteral */ + SimpleNode jjtn000 = new SimpleNode(JJTBOOLEANLITERAL); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) BooleanLiteral */ + try { +/*@egen*/ + "true" +| + "false"/*@bgen(jjtree)*/ + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void NullLiteral(): +{/*@bgen(jjtree) NullLiteral */ + SimpleNode jjtn000 = new SimpleNode(JJTNULLLITERAL); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) NullLiteral */ + try { +/*@egen*/ + "null"/*@bgen(jjtree)*/ + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void Arguments(): +{/*@bgen(jjtree) Arguments */ + SimpleNode jjtn000 = new SimpleNode(JJTARGUMENTS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) Arguments */ + try { +/*@egen*/ + "(" [ ArgumentList() ] ")"/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void ArgumentList(): +{/*@bgen(jjtree) ArgumentList */ + SimpleNode jjtn000 = new SimpleNode(JJTARGUMENTLIST); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) ArgumentList */ + try { +/*@egen*/ + Expression() ( "," Expression() )*/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void AllocationExpression(): +{/*@bgen(jjtree) AllocationExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTALLOCATIONEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) AllocationExpression */ + try { +/*@egen*/ + LOOKAHEAD(2) + "new" PrimitiveType() ArrayDimsAndInits() +| + "new" ClassOrInterfaceType() [ TypeArguments() ] + ( + ArrayDimsAndInits() + | + Arguments() [ ClassOrInterfaceBody(false) ] + )/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +/* + * The third LOOKAHEAD specification below is to parse to PrimarySuffix + * if there is an expression between the "[...]". + */ +void ArrayDimsAndInits(): +{/*@bgen(jjtree) ArrayDimsAndInits */ + SimpleNode jjtn000 = new SimpleNode(JJTARRAYDIMSANDINITS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) ArrayDimsAndInits */ + try { +/*@egen*/ + LOOKAHEAD(2) + ( LOOKAHEAD(2) "[" Expression() "]" )+ ( LOOKAHEAD(2) "[" "]" )* +| + ( "[" "]" )+ ArrayInitializer()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + + +/* + * Statement syntax follows. + */ + +void Statement(): +{/*@bgen(jjtree) Statement */ + SimpleNode jjtn000 = new SimpleNode(JJTSTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) Statement */ + try { +/*@egen*/ + LOOKAHEAD(2) + LabeledStatement() +| + AssertStatement() +| + Block() +| + EmptyStatement() +| + StatementExpression() ";" +| + SwitchStatement() +| + IfStatement() +| + WhileStatement() +| + DoStatement() +| + ForStatement() +| + BreakStatement() +| + ContinueStatement() +| + ReturnStatement() +| + ThrowStatement() +| + SynchronizedStatement() +| + TryStatement()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void AssertStatement(): +{/*@bgen(jjtree) AssertStatement */ + SimpleNode jjtn000 = new SimpleNode(JJTASSERTSTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) AssertStatement */ + try { +/*@egen*/ + "assert" Expression() [ ":" Expression() ] ";"/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void LabeledStatement(): +{/*@bgen(jjtree) LabeledStatement */ + SimpleNode jjtn000 = new SimpleNode(JJTLABELEDSTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) LabeledStatement */ + try { +/*@egen*/ + <IDENTIFIER> ":" Statement()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void Block(): +{/*@bgen(jjtree) Block */ + SimpleNode jjtn000 = new SimpleNode(JJTBLOCK); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) Block */ + try { +/*@egen*/ + "{" ( BlockStatement() )* "}"/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void BlockStatement(): +{/*@bgen(jjtree) BlockStatement */ + SimpleNode jjtn000 = new SimpleNode(JJTBLOCKSTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) BlockStatement */ + try { +/*@egen*/ + LOOKAHEAD( Modifiers() Type() <IDENTIFIER> ) + LocalVariableDeclaration() ";" +| + Statement() +| + ClassOrInterfaceDeclaration(0)/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void LocalVariableDeclaration(): +{/*@bgen(jjtree) LocalVariableDeclaration */ + SimpleNode jjtn000 = new SimpleNode(JJTLOCALVARIABLEDECLARATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) LocalVariableDeclaration */ + try { +/*@egen*/ + Modifiers() Type() VariableDeclarator() ( "," VariableDeclarator() )*/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void EmptyStatement(): +{/*@bgen(jjtree) EmptyStatement */ + SimpleNode jjtn000 = new SimpleNode(JJTEMPTYSTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) EmptyStatement */ + try { +/*@egen*/ + ";"/*@bgen(jjtree)*/ + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void StatementExpression(): +{/*@bgen(jjtree) StatementExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTSTATEMENTEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) StatementExpression */ + try { +/*@egen*/ + PreIncrementExpression() +| + PreDecrementExpression() +| + LOOKAHEAD(PrimaryExpression() AssignmentOperator()) + AssignmentExpression() +| + PostfixExpression()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void SwitchStatement(): +{/*@bgen(jjtree) SwitchStatement */ + SimpleNode jjtn000 = new SimpleNode(JJTSWITCHSTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) SwitchStatement */ + try { +/*@egen*/ + "switch" "(" Expression() ")" "{" + ( SwitchLabel() ( BlockStatement() )* )* + "}"/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void SwitchLabel(): +{/*@bgen(jjtree) SwitchLabel */ + SimpleNode jjtn000 = new SimpleNode(JJTSWITCHLABEL); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) SwitchLabel */ + try { +/*@egen*/ + "case" Expression() ":" +| + "default" ":"/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void IfStatement(): +/* + * The disambiguating algorithm of JavaCC automatically binds dangling + * else's to the innermost if statement. The LOOKAHEAD specification + * is to tell JavaCC that we know what we are doing. + */ +{/*@bgen(jjtree) IfStatement */ + SimpleNode jjtn000 = new SimpleNode(JJTIFSTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) IfStatement */ + try { +/*@egen*/ + "if" "(" Expression() ")" Statement() [ LOOKAHEAD(1) "else" Statement() ]/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void WhileStatement(): +{/*@bgen(jjtree) WhileStatement */ + SimpleNode jjtn000 = new SimpleNode(JJTWHILESTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) WhileStatement */ + try { +/*@egen*/ + "while" "(" Expression() ")" Statement()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void DoStatement(): +{/*@bgen(jjtree) DoStatement */ + SimpleNode jjtn000 = new SimpleNode(JJTDOSTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) DoStatement */ + try { +/*@egen*/ + "do" Statement() "while" "(" Expression() ")" ";"/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void ForStatement(): +{/*@bgen(jjtree) ForStatement */ + SimpleNode jjtn000 = new SimpleNode(JJTFORSTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) ForStatement */ + try { +/*@egen*/ + "for" "(" + + ( + LOOKAHEAD(Modifiers() Type() <IDENTIFIER> ":") + Modifiers() Type() <IDENTIFIER> ":" Expression() + | + [ ForInit() ] ";" [ Expression() ] ";" [ ForUpdate() ] + ) + + ")" Statement()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void ForInit(): +{/*@bgen(jjtree) ForInit */ + SimpleNode jjtn000 = new SimpleNode(JJTFORINIT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) ForInit */ + try { +/*@egen*/ + LOOKAHEAD( Modifiers() Type() <IDENTIFIER> ) + LocalVariableDeclaration() +| + StatementExpressionList()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void StatementExpressionList(): +{/*@bgen(jjtree) StatementExpressionList */ + SimpleNode jjtn000 = new SimpleNode(JJTSTATEMENTEXPRESSIONLIST); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) StatementExpressionList */ + try { +/*@egen*/ + StatementExpression() ( "," StatementExpression() )*/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void ForUpdate(): +{/*@bgen(jjtree) ForUpdate */ + SimpleNode jjtn000 = new SimpleNode(JJTFORUPDATE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) ForUpdate */ + try { +/*@egen*/ + StatementExpressionList()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void BreakStatement(): +{/*@bgen(jjtree) BreakStatement */ + SimpleNode jjtn000 = new SimpleNode(JJTBREAKSTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) BreakStatement */ + try { +/*@egen*/ + "break" [ <IDENTIFIER> ] ";"/*@bgen(jjtree)*/ + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void ContinueStatement(): +{/*@bgen(jjtree) ContinueStatement */ + SimpleNode jjtn000 = new SimpleNode(JJTCONTINUESTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) ContinueStatement */ + try { +/*@egen*/ + "continue" [ <IDENTIFIER> ] ";"/*@bgen(jjtree)*/ + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void ReturnStatement(): +{/*@bgen(jjtree) ReturnStatement */ + SimpleNode jjtn000 = new SimpleNode(JJTRETURNSTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) ReturnStatement */ + try { +/*@egen*/ + "return" [ Expression() ] ";"/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void ThrowStatement(): +{/*@bgen(jjtree) ThrowStatement */ + SimpleNode jjtn000 = new SimpleNode(JJTTHROWSTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) ThrowStatement */ + try { +/*@egen*/ + "throw" Expression() ";"/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void SynchronizedStatement(): +{/*@bgen(jjtree) SynchronizedStatement */ + SimpleNode jjtn000 = new SimpleNode(JJTSYNCHRONIZEDSTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) SynchronizedStatement */ + try { +/*@egen*/ + "synchronized" "(" Expression() ")" Block()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void TryStatement(): +/* + * Semantic check required here to make sure that at least one + * finally/catch is present. + */ +{/*@bgen(jjtree) TryStatement */ + SimpleNode jjtn000 = new SimpleNode(JJTTRYSTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) TryStatement */ + try { +/*@egen*/ + "try" Block() + ( "catch" "(" FormalParameter() ")" Block() )* + [ "finally" Block() ]/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +/* We use productions to match >>>, >> and > so that we can keep the + * type declaration syntax with generics clean + */ + +void RUNSIGNEDSHIFT(): +{/*@bgen(jjtree) RUNSIGNEDSHIFT */ + SimpleNode jjtn000 = new SimpleNode(JJTRUNSIGNEDSHIFT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) RUNSIGNEDSHIFT */ + try { +/*@egen*/ + ( LOOKAHEAD({ getToken(1).kind == GT && + ((Token.GTToken)getToken(1)).realKind == RUNSIGNEDSHIFT} ) + ">" ">" ">" + )/*@bgen(jjtree)*/ + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void RSIGNEDSHIFT(): +{/*@bgen(jjtree) RSIGNEDSHIFT */ + SimpleNode jjtn000 = new SimpleNode(JJTRSIGNEDSHIFT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) RSIGNEDSHIFT */ + try { +/*@egen*/ + ( LOOKAHEAD({ getToken(1).kind == GT && + ((Token.GTToken)getToken(1)).realKind == RSIGNEDSHIFT} ) + ">" ">" + )/*@bgen(jjtree)*/ + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +/* Annotation syntax follows. */ + +void Annotation(): +{/*@bgen(jjtree) Annotation */ + SimpleNode jjtn000 = new SimpleNode(JJTANNOTATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) Annotation */ + try { +/*@egen*/ + LOOKAHEAD( "@" Name() "(" ( <IDENTIFIER> "=" | ")" )) + NormalAnnotation() + | + LOOKAHEAD( "@" Name() "(" ) + SingleMemberAnnotation() + | + MarkerAnnotation()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void NormalAnnotation(): +{/*@bgen(jjtree) NormalAnnotation */ + SimpleNode jjtn000 = new SimpleNode(JJTNORMALANNOTATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) NormalAnnotation */ + try { +/*@egen*/ + "@" Name() "(" [ MemberValuePairs() ] ")"/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void MarkerAnnotation(): +{/*@bgen(jjtree) MarkerAnnotation */ + SimpleNode jjtn000 = new SimpleNode(JJTMARKERANNOTATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) MarkerAnnotation */ + try { +/*@egen*/ + "@" Name()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void SingleMemberAnnotation(): +{/*@bgen(jjtree) SingleMemberAnnotation */ + SimpleNode jjtn000 = new SimpleNode(JJTSINGLEMEMBERANNOTATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) SingleMemberAnnotation */ + try { +/*@egen*/ + "@" Name() "(" MemberValue() ")"/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void MemberValuePairs(): +{/*@bgen(jjtree) MemberValuePairs */ + SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUEPAIRS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) MemberValuePairs */ + try { +/*@egen*/ + MemberValuePair() ( "," MemberValuePair() )*/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void MemberValuePair(): +{/*@bgen(jjtree) MemberValuePair */ + SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUEPAIR); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) MemberValuePair */ + try { +/*@egen*/ + <IDENTIFIER> "=" MemberValue()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void MemberValue(): +{/*@bgen(jjtree) MemberValue */ + SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) MemberValue */ + try { +/*@egen*/ + Annotation() + | + MemberValueArrayInitializer() + | + ConditionalExpression()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void MemberValueArrayInitializer(): +{/*@bgen(jjtree) MemberValueArrayInitializer */ + SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUEARRAYINITIALIZER); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) MemberValueArrayInitializer */ + try { +/*@egen*/ + "{" MemberValue() ( LOOKAHEAD(2) "," MemberValue() )* [ "," ] "}"/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + + +/* Annotation Types. */ + +void AnnotationTypeDeclaration(int modifiers): +{/*@bgen(jjtree) AnnotationTypeDeclaration */ + SimpleNode jjtn000 = new SimpleNode(JJTANNOTATIONTYPEDECLARATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) AnnotationTypeDeclaration */ + try { +/*@egen*/ + "@" "interface" <IDENTIFIER> AnnotationTypeBody()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void AnnotationTypeBody(): +{/*@bgen(jjtree) AnnotationTypeBody */ + SimpleNode jjtn000 = new SimpleNode(JJTANNOTATIONTYPEBODY); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) AnnotationTypeBody */ + try { +/*@egen*/ + "{" ( AnnotationTypeMemberDeclaration() )* "}"/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void AnnotationTypeMemberDeclaration(): +{/*@bgen(jjtree) AnnotationTypeMemberDeclaration */ + SimpleNode jjtn000 = new SimpleNode(JJTANNOTATIONTYPEMEMBERDECLARATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/ + int modifiers; +} +{/*@bgen(jjtree) AnnotationTypeMemberDeclaration */ + try { +/*@egen*/ + modifiers = Modifiers() + ( + LOOKAHEAD(Type() <IDENTIFIER> "(") + Type() <IDENTIFIER> "(" ")" [ DefaultValue() ] ";" + | + ClassOrInterfaceDeclaration(modifiers) + | + EnumDeclaration(modifiers) + | + AnnotationTypeDeclaration(modifiers) + | + FieldDeclaration(modifiers) + ) + | + ( ";" )/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} + +void DefaultValue(): +{/*@bgen(jjtree) DefaultValue */ + SimpleNode jjtn000 = new SimpleNode(JJTDEFAULTVALUE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); +/*@egen*/} +{/*@bgen(jjtree) DefaultValue */ + try { +/*@egen*/ + "default" MemberValue()/*@bgen(jjtree)*/ + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + throw (Error)jjte000; + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } +/*@egen*/ +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Java1.5.jjt =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Java1.5.jjt 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Java1.5.jjt 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,2150 +0,0 @@ - -/* - * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has - * intellectual property rights relating to technology embodied in the product - * that is described in this document. In particular, and without limitation, - * these intellectual property rights may include one or more of the U.S. - * patents listed at http://www.sun.com/patents and one or more additional - * patents or pending patent applications in the U.S. and in other countries. - * U.S. Government Rights - Commercial software. Government users are subject - * to the Sun Microsystems, Inc. standard license agreement and applicable - * provisions of the FAR and its supplements. Use is subject to license terms. - * Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered - * trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This - * product is covered and controlled by U.S. Export Control laws and may be - * subject to the export or import laws in other countries. Nuclear, missile, - * chemical biological weapons or nuclear maritime end uses or end users, - * whether direct or indirect, are strictly prohibited. Export or reexport - * to countries subject to U.S. embargo or to entities identified on U.S. - * export exclusion lists, including, but not limited to, the denied persons - * and specially designated nationals lists is strictly prohibited. - */ - -// Slightly modified version of javacc's reference 1.5 grammar, tweaked for -// usage with JAXX. There are two main areas of changes: several new -// nonterminals were added to make identifying certain constructs easier, -// and the Line nonterminal was added to support JAXX's script tags. -// Several of the new changes are inefficient and require excess lookahead, -// but at this point I'd rather have inefficiency than risk breaking it during -// attempted optimizations. - -options { - JAVA_UNICODE_ESCAPE = true; - ERROR_REPORTING = false; - STATIC = false; - JDK_VERSION = "1.4"; - NODE_SCOPE_HOOK=true; -} - -PARSER_BEGIN(JavaParser) -package jaxx.parser; - -import java.io.*; - -/** - * Grammar to parse Java version 1.5 - * @author Sreenivasa Viswanadha - Simplified and enhanced for 1.5 - */ -public class JavaParser -{ - /** - * Class to hold modifiers. - */ - static public final class ModifierSet - { - /* Definitions of the bits in the modifiers field. */ - public static final int PUBLIC = 0x0001; - public static final int PROTECTED = 0x0002; - public static final int PRIVATE = 0x0004; - public static final int ABSTRACT = 0x0008; - public static final int STATIC = 0x0010; - public static final int FINAL = 0x0020; - public static final int SYNCHRONIZED = 0x0040; - public static final int NATIVE = 0x0080; - public static final int TRANSIENT = 0x0100; - public static final int VOLATILE = 0x0200; - public static final int STRICTFP = 0x1000; - - /** A set of accessors that indicate whether the specified modifier - is in the set. */ - - public boolean isPublic(int modifiers) - { - return (modifiers & PUBLIC) != 0; - } - - public boolean isProtected(int modifiers) - { - return (modifiers & PROTECTED) != 0; - } - - public boolean isPrivate(int modifiers) - { - return (modifiers & PRIVATE) != 0; - } - - public boolean isStatic(int modifiers) - { - return (modifiers & STATIC) != 0; - } - - public boolean isAbstract(int modifiers) - { - return (modifiers & ABSTRACT) != 0; - } - - public boolean isFinal(int modifiers) - { - return (modifiers & FINAL) != 0; - } - - public boolean isNative(int modifiers) - { - return (modifiers & NATIVE) != 0; - } - - public boolean isStrictfp(int modifiers) - { - return (modifiers & STRICTFP) != 0; - } - - public boolean isSynchronized(int modifiers) - { - return (modifiers & SYNCHRONIZED) != 0; - } - - public boolean isTransient(int modifiers) - { - return (modifiers & TRANSIENT) != 0; - } - - public boolean isVolatile(int modifiers) - { - return (modifiers & VOLATILE) != 0; - } - - /** - * Removes the given modifier. - */ - static int removeModifier(int modifiers, int mod) - { - return modifiers & ~mod; - } - } - - public JavaParser(String fileName) - { - this(System.in); - try { ReInit(new FileInputStream(new File(fileName))); } - catch(Exception e) { e.printStackTrace(); } - } - - void jjtreeOpenNodeScope(Node n) { - ((SimpleNode) n).firstToken = getToken(1); - } - - void jjtreeCloseNodeScope(Node n) { - ((SimpleNode) n).lastToken = getToken(0); - } - - public SimpleNode popNode() - { - if ( jjtree.nodeArity() > 0) // number of child nodes - return (SimpleNode)jjtree.popNode(); - else - return null; - } - public static void main(String args[]) { - JavaParser parser; - if (args.length == 0) { - System.out.println("Java Parser Version 1.1: Reading from standard input . . ."); - parser = new JavaParser(System.in); - } else if (args.length == 1) { - System.out.println("Java Parser Version 1.1: Reading from file " + args[0] + " . . ."); - try { - parser = new JavaParser(new java.io.FileInputStream(args[0])); - } catch (java.io.FileNotFoundException e) { - System.out.println("Java Parser Version 1.1: File " + args[0] + " not found."); - return; - } - } else { - System.out.println("Java Parser Version 1.1: Usage is one of:"); - System.out.println(" java JavaParser < inputfile"); - System.out.println("OR"); - System.out.println(" java JavaParser inputfile"); - return; - } - try { - parser.CompilationUnit(); - System.out.println("Java Parser Version 1.1: Java program parsed successfully."); - } catch (ParseException e) { - System.out.println(e.getMessage()); - System.out.println("Java Parser Version 1.1: Encountered errors during parse."); - } - } - -} - -PARSER_END(JavaParser) - -/* COMMENTS */ - -MORE : -{ - <"/**" ~["/"]> { input_stream.backup(1); } : IN_FORMAL_COMMENT -| - "/*" : IN_MULTI_LINE_COMMENT -} - -SPECIAL_TOKEN: -{ - <WHITE_SPACE: ([" ", "\n", "\r", "\t", "\f"])+> -} - -SPECIAL_TOKEN : -{ - <SINGLE_LINE_COMMENT: "//" (~["\n", "\r"])* ("\n" | "\r" | "\r\n")?> -} - -<IN_FORMAL_COMMENT> -SPECIAL_TOKEN : -{ - <FORMAL_COMMENT: "*/" > : DEFAULT -} - -<IN_MULTI_LINE_COMMENT> -SPECIAL_TOKEN : -{ - <MULTI_LINE_COMMENT: "*/" > : DEFAULT -} - -<IN_FORMAL_COMMENT,IN_MULTI_LINE_COMMENT> -MORE : -{ - < ~[] > -} - -/* RESERVED WORDS AND LITERALS */ - -TOKEN : -{ - < ABSTRACT: "abstract" > -| < ASSERT: "assert" > -| < BOOLEAN: "boolean" > -| < BREAK: "break" > -| < BYTE: "byte" > -| < CASE: "case" > -| < CATCH: "catch" > -| < CHAR: "char" > -| < CLASS: "class" > -| < CONST: "const" > -| < CONTINUE: "continue" > -| < _DEFAULT: "default" > -| < DO: "do" > -| < DOUBLE: "double" > -| < ELSE: "else" > -| < ENUM: "enum" > -| < EXTENDS: "extends" > -| < FALSE: "false" > -| < FINAL: "final" > -| < FINALLY: "finally" > -| < FLOAT: "float" > -| < FOR: "for" > -| < GOTO: "goto" > -| < IF: "if" > -| < IMPLEMENTS: "implements" > -| < IMPORT: "import" > -| < INSTANCEOF: "instanceof" > -| < INT: "int" > -| < INTERFACE: "interface" > -| < LONG: "long" > -| < NATIVE: "native" > -| < NEW: "new" > -| < NULL: "null" > -| < PACKAGE: "package"> -| < PRIVATE: "private" > -| < PROTECTED: "protected" > -| < PUBLIC: "public" > -| < RETURN: "return" > -| < SHORT: "short" > -| < STATIC: "static" > -| < STRICTFP: "strictfp" > -| < SUPER: "super" > -| < SWITCH: "switch" > -| < SYNCHRONIZED: "synchronized" > -| < THIS: "this" > -| < THROW: "throw" > -| < THROWS: "throws" > -| < TRANSIENT: "transient" > -| < TRUE: "true" > -| < TRY: "try" > -| < VOID: "void" > -| < VOLATILE: "volatile" > -| < WHILE: "while" > -} - -/* LITERALS */ - -TOKEN : -{ - < INTEGER_LITERAL: - <DECIMAL_LITERAL> (["l","L"])? - | <HEX_LITERAL> (["l","L"])? - | <OCTAL_LITERAL> (["l","L"])? - > -| - < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* > -| - < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ > -| - < #OCTAL_LITERAL: "0" (["0"-"7"])* > -| - < FLOATING_POINT_LITERAL: - <DECIMAL_FLOATING_POINT_LITERAL> - | <HEXADECIMAL_FLOATING_POINT_LITERAL> - > -| - < #DECIMAL_FLOATING_POINT_LITERAL: - (["0"-"9"])+ "." (["0"-"9"])* (<DECIMAL_EXPONENT>)? (["f","F","d","D"])? - | "." (["0"-"9"])+ (<DECIMAL_EXPONENT>)? (["f","F","d","D"])? - | (["0"-"9"])+ <DECIMAL_EXPONENT> (["f","F","d","D"])? - | (["0"-"9"])+ (<DECIMAL_EXPONENT>)? ["f","F","d","D"] - > -| - < #DECIMAL_EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ > -| - < #HEXADECIMAL_FLOATING_POINT_LITERAL: - "0" ["x", "X"] (["0"-"9","a"-"f","A"-"F"])+ (".")? <HEXADECIMAL_EXPONENT> (["f","F","d","D"])? - | "0" ["x", "X"] (["0"-"9","a"-"f","A"-"F"])* "." (["0"-"9","a"-"f","A"-"F"])+ <HEXADECIMAL_EXPONENT> (["f","F","d","D"])? - > -| - < #HEXADECIMAL_EXPONENT: ["p","P"] (["+","-"])? (["0"-"9"])+ > -| - < CHARACTER_LITERAL: - "'" - ( (~["'","\\","\n","\r"]) - | ("\\" - ( ["n","t","b","r","f","\\","'","\""] - | ["0"-"7"] ( ["0"-"7"] )? - | ["0"-"3"] ["0"-"7"] ["0"-"7"] - ) - ) - ) - "'" - > -| - < STRING_LITERAL: - "\"" - ( (~["\"","\\","\n","\r"]) - | ("\\" - ( ["n","t","b","r","f","\\","'","\""] - | ["0"-"7"] ( ["0"-"7"] )? - | ["0"-"3"] ["0"-"7"] ["0"-"7"] - ) - ) - )* - "\"" - > -} - -/* IDENTIFIERS */ - -TOKEN : -{ - < IDENTIFIER: <LETTER> (<PART_LETTER>)* > -| - < #LETTER: - [ // all chars for which Character.isIdentifierStart is true - "$", - "A"-"Z", - "_", - "a"-"z", - "\u00a2"-"\u00a5", - "\u00aa", - "\u00b5", - "\u00ba", - "\u00c0"-"\u00d6", - "\u00d8"-"\u00f6", - "\u00f8"-"\u021f", - "\u0222"-"\u0233", - "\u0250"-"\u02ad", - "\u02b0"-"\u02b8", - "\u02bb"-"\u02c1", - "\u02d0"-"\u02d1", - "\u02e0"-"\u02e4", - "\u02ee", - "\u037a", - "\u0386", - "\u0388"-"\u038a", - "\u038c", - "\u038e"-"\u03a1", - "\u03a3"-"\u03ce", - "\u03d0"-"\u03d7", - "\u03da"-"\u03f3", - "\u0400"-"\u0481", - "\u048c"-"\u04c4", - "\u04c7"-"\u04c8", - "\u04cb"-"\u04cc", - "\u04d0"-"\u04f5", - "\u04f8"-"\u04f9", - "\u0531"-"\u0556", - "\u0559", - "\u0561"-"\u0587", - "\u05d0"-"\u05ea", - "\u05f0"-"\u05f2", - "\u0621"-"\u063a", - "\u0640"-"\u064a", - "\u0671"-"\u06d3", - "\u06d5", - "\u06e5"-"\u06e6", - "\u06fa"-"\u06fc", - "\u0710", - "\u0712"-"\u072c", - "\u0780"-"\u07a5", - "\u0905"-"\u0939", - "\u093d", - "\u0950", - "\u0958"-"\u0961", - "\u0985"-"\u098c", - "\u098f"-"\u0990", - "\u0993"-"\u09a8", - "\u09aa"-"\u09b0", - "\u09b2", - "\u09b6"-"\u09b9", - "\u09dc"-"\u09dd", - "\u09df"-"\u09e1", - "\u09f0"-"\u09f3", - "\u0a05"-"\u0a0a", - "\u0a0f"-"\u0a10", - "\u0a13"-"\u0a28", - "\u0a2a"-"\u0a30", - "\u0a32"-"\u0a33", - "\u0a35"-"\u0a36", - "\u0a38"-"\u0a39", - "\u0a59"-"\u0a5c", - "\u0a5e", - "\u0a72"-"\u0a74", - "\u0a85"-"\u0a8b", - "\u0a8d", - "\u0a8f"-"\u0a91", - "\u0a93"-"\u0aa8", - "\u0aaa"-"\u0ab0", - "\u0ab2"-"\u0ab3", - "\u0ab5"-"\u0ab9", - "\u0abd", - "\u0ad0", - "\u0ae0", - "\u0b05"-"\u0b0c", - "\u0b0f"-"\u0b10", - "\u0b13"-"\u0b28", - "\u0b2a"-"\u0b30", - "\u0b32"-"\u0b33", - "\u0b36"-"\u0b39", - "\u0b3d", - "\u0b5c"-"\u0b5d", - "\u0b5f"-"\u0b61", - "\u0b85"-"\u0b8a", - "\u0b8e"-"\u0b90", - "\u0b92"-"\u0b95", - "\u0b99"-"\u0b9a", - "\u0b9c", - "\u0b9e"-"\u0b9f", - "\u0ba3"-"\u0ba4", - "\u0ba8"-"\u0baa", - "\u0bae"-"\u0bb5", - "\u0bb7"-"\u0bb9", - "\u0c05"-"\u0c0c", - "\u0c0e"-"\u0c10", - "\u0c12"-"\u0c28", - "\u0c2a"-"\u0c33", - "\u0c35"-"\u0c39", - "\u0c60"-"\u0c61", - "\u0c85"-"\u0c8c", - "\u0c8e"-"\u0c90", - "\u0c92"-"\u0ca8", - "\u0caa"-"\u0cb3", - "\u0cb5"-"\u0cb9", - "\u0cde", - "\u0ce0"-"\u0ce1", - "\u0d05"-"\u0d0c", - "\u0d0e"-"\u0d10", - "\u0d12"-"\u0d28", - "\u0d2a"-"\u0d39", - "\u0d60"-"\u0d61", - "\u0d85"-"\u0d96", - "\u0d9a"-"\u0db1", - "\u0db3"-"\u0dbb", - "\u0dbd", - "\u0dc0"-"\u0dc6", - "\u0e01"-"\u0e30", - "\u0e32"-"\u0e33", - "\u0e3f"-"\u0e46", - "\u0e81"-"\u0e82", - "\u0e84", - "\u0e87"-"\u0e88", - "\u0e8a", - "\u0e8d", - "\u0e94"-"\u0e97", - "\u0e99"-"\u0e9f", - "\u0ea1"-"\u0ea3", - "\u0ea5", - "\u0ea7", - "\u0eaa"-"\u0eab", - "\u0ead"-"\u0eb0", - "\u0eb2"-"\u0eb3", - "\u0ebd", - "\u0ec0"-"\u0ec4", - "\u0ec6", - "\u0edc"-"\u0edd", - "\u0f00", - "\u0f40"-"\u0f47", - "\u0f49"-"\u0f6a", - "\u0f88"-"\u0f8b", - "\u1000"-"\u1021", - "\u1023"-"\u1027", - "\u1029"-"\u102a", - "\u1050"-"\u1055", - "\u10a0"-"\u10c5", - "\u10d0"-"\u10f6", - "\u1100"-"\u1159", - "\u115f"-"\u11a2", - "\u11a8"-"\u11f9", - "\u1200"-"\u1206", - "\u1208"-"\u1246", - "\u1248", - "\u124a"-"\u124d", - "\u1250"-"\u1256", - "\u1258", - "\u125a"-"\u125d", - "\u1260"-"\u1286", - "\u1288", - "\u128a"-"\u128d", - "\u1290"-"\u12ae", - "\u12b0", - "\u12b2"-"\u12b5", - "\u12b8"-"\u12be", - "\u12c0", - "\u12c2"-"\u12c5", - "\u12c8"-"\u12ce", - "\u12d0"-"\u12d6", - "\u12d8"-"\u12ee", - "\u12f0"-"\u130e", - "\u1310", - "\u1312"-"\u1315", - "\u1318"-"\u131e", - "\u1320"-"\u1346", - "\u1348"-"\u135a", - "\u13a0"-"\u13f4", - "\u1401"-"\u166c", - "\u166f"-"\u1676", - "\u1681"-"\u169a", - "\u16a0"-"\u16ea", - "\u1780"-"\u17b3", - "\u17db", - "\u1820"-"\u1877", - "\u1880"-"\u18a8", - "\u1e00"-"\u1e9b", - "\u1ea0"-"\u1ef9", - "\u1f00"-"\u1f15", - "\u1f18"-"\u1f1d", - "\u1f20"-"\u1f45", - "\u1f48"-"\u1f4d", - "\u1f50"-"\u1f57", - "\u1f59", - "\u1f5b", - "\u1f5d", - "\u1f5f"-"\u1f7d", - "\u1f80"-"\u1fb4", - "\u1fb6"-"\u1fbc", - "\u1fbe", - "\u1fc2"-"\u1fc4", - "\u1fc6"-"\u1fcc", - "\u1fd0"-"\u1fd3", - "\u1fd6"-"\u1fdb", - "\u1fe0"-"\u1fec", - "\u1ff2"-"\u1ff4", - "\u1ff6"-"\u1ffc", - "\u203f"-"\u2040", - "\u207f", - "\u20a0"-"\u20af", - "\u2102", - "\u2107", - "\u210a"-"\u2113", - "\u2115", - "\u2119"-"\u211d", - "\u2124", - "\u2126", - "\u2128", - "\u212a"-"\u212d", - "\u212f"-"\u2131", - "\u2133"-"\u2139", - "\u2160"-"\u2183", - "\u3005"-"\u3007", - "\u3021"-"\u3029", - "\u3031"-"\u3035", - "\u3038"-"\u303a", - "\u3041"-"\u3094", - "\u309d"-"\u309e", - "\u30a1"-"\u30fe", - "\u3105"-"\u312c", - "\u3131"-"\u318e", - "\u31a0"-"\u31b7", - "\u3400"-"\u4db5", - "\u4e00"-"\u9fa5", - "\ua000"-"\ua48c", - "\uac00"-"\ud7a3", - "\uf900"-"\ufa2d", - "\ufb00"-"\ufb06", - "\ufb13"-"\ufb17", - "\ufb1d", - "\ufb1f"-"\ufb28", - "\ufb2a"-"\ufb36", - "\ufb38"-"\ufb3c", - "\ufb3e", - "\ufb40"-"\ufb41", - "\ufb43"-"\ufb44", - "\ufb46"-"\ufbb1", - "\ufbd3"-"\ufd3d", - "\ufd50"-"\ufd8f", - "\ufd92"-"\ufdc7", - "\ufdf0"-"\ufdfb", - "\ufe33"-"\ufe34", - "\ufe4d"-"\ufe4f", - "\ufe69", - "\ufe70"-"\ufe72", - "\ufe74", - "\ufe76"-"\ufefc", - "\uff04", - "\uff21"-"\uff3a", - "\uff3f", - "\uff41"-"\uff5a", - "\uff65"-"\uffbe", - "\uffc2"-"\uffc7", - "\uffca"-"\uffcf", - "\uffd2"-"\uffd7", - "\uffda"-"\uffdc", - "\uffe0"-"\uffe1", - "\uffe5"-"\uffe6" - ] - > -| - < #PART_LETTER: - [ // all chars for which Character.isIdentifierPart is true - "\u0000"-"\u0008", - "\u000e"-"\u001b", - "$", - "0"-"9", - "A"-"Z", - "_", - "a"-"z", - "\u007f"-"\u009f", - "\u00a2"-"\u00a5", - "\u00aa", - "\u00b5", - "\u00ba", - "\u00c0"-"\u00d6", - "\u00d8"-"\u00f6", - "\u00f8"-"\u021f", - "\u0222"-"\u0233", - "\u0250"-"\u02ad", - "\u02b0"-"\u02b8", - "\u02bb"-"\u02c1", - "\u02d0"-"\u02d1", - "\u02e0"-"\u02e4", - "\u02ee", - "\u0300"-"\u034e", - "\u0360"-"\u0362", - "\u037a", - "\u0386", - "\u0388"-"\u038a", - "\u038c", - "\u038e"-"\u03a1", - "\u03a3"-"\u03ce", - "\u03d0"-"\u03d7", - "\u03da"-"\u03f3", - "\u0400"-"\u0481", - "\u0483"-"\u0486", - "\u048c"-"\u04c4", - "\u04c7"-"\u04c8", - "\u04cb"-"\u04cc", - "\u04d0"-"\u04f5", - "\u04f8"-"\u04f9", - "\u0531"-"\u0556", - "\u0559", - "\u0561"-"\u0587", - "\u0591"-"\u05a1", - "\u05a3"-"\u05b9", - "\u05bb"-"\u05bd", - "\u05bf", - "\u05c1"-"\u05c2", - "\u05c4", - "\u05d0"-"\u05ea", - "\u05f0"-"\u05f2", - "\u0621"-"\u063a", - "\u0640"-"\u0655", - "\u0660"-"\u0669", - "\u0670"-"\u06d3", - "\u06d5"-"\u06dc", - "\u06df"-"\u06e8", - "\u06ea"-"\u06ed", - "\u06f0"-"\u06fc", - "\u070f"-"\u072c", - "\u0730"-"\u074a", - "\u0780"-"\u07b0", - "\u0901"-"\u0903", - "\u0905"-"\u0939", - "\u093c"-"\u094d", - "\u0950"-"\u0954", - "\u0958"-"\u0963", - "\u0966"-"\u096f", - "\u0981"-"\u0983", - "\u0985"-"\u098c", - "\u098f"-"\u0990", - "\u0993"-"\u09a8", - "\u09aa"-"\u09b0", - "\u09b2", - "\u09b6"-"\u09b9", - "\u09bc", - "\u09be"-"\u09c4", - "\u09c7"-"\u09c8", - "\u09cb"-"\u09cd", - "\u09d7", - "\u09dc"-"\u09dd", - "\u09df"-"\u09e3", - "\u09e6"-"\u09f3", - "\u0a02", - "\u0a05"-"\u0a0a", - "\u0a0f"-"\u0a10", - "\u0a13"-"\u0a28", - "\u0a2a"-"\u0a30", - "\u0a32"-"\u0a33", - "\u0a35"-"\u0a36", - "\u0a38"-"\u0a39", - "\u0a3c", - "\u0a3e"-"\u0a42", - "\u0a47"-"\u0a48", - "\u0a4b"-"\u0a4d", - "\u0a59"-"\u0a5c", - "\u0a5e", - "\u0a66"-"\u0a74", - "\u0a81"-"\u0a83", - "\u0a85"-"\u0a8b", - "\u0a8d", - "\u0a8f"-"\u0a91", - "\u0a93"-"\u0aa8", - "\u0aaa"-"\u0ab0", - "\u0ab2"-"\u0ab3", - "\u0ab5"-"\u0ab9", - "\u0abc"-"\u0ac5", - "\u0ac7"-"\u0ac9", - "\u0acb"-"\u0acd", - "\u0ad0", - "\u0ae0", - "\u0ae6"-"\u0aef", - "\u0b01"-"\u0b03", - "\u0b05"-"\u0b0c", - "\u0b0f"-"\u0b10", - "\u0b13"-"\u0b28", - "\u0b2a"-"\u0b30", - "\u0b32"-"\u0b33", - "\u0b36"-"\u0b39", - "\u0b3c"-"\u0b43", - "\u0b47"-"\u0b48", - "\u0b4b"-"\u0b4d", - "\u0b56"-"\u0b57", - "\u0b5c"-"\u0b5d", - "\u0b5f"-"\u0b61", - "\u0b66"-"\u0b6f", - "\u0b82"-"\u0b83", - "\u0b85"-"\u0b8a", - "\u0b8e"-"\u0b90", - "\u0b92"-"\u0b95", - "\u0b99"-"\u0b9a", - "\u0b9c", - "\u0b9e"-"\u0b9f", - "\u0ba3"-"\u0ba4", - "\u0ba8"-"\u0baa", - "\u0bae"-"\u0bb5", - "\u0bb7"-"\u0bb9", - "\u0bbe"-"\u0bc2", - "\u0bc6"-"\u0bc8", - "\u0bca"-"\u0bcd", - "\u0bd7", - "\u0be7"-"\u0bef", - "\u0c01"-"\u0c03", - "\u0c05"-"\u0c0c", - "\u0c0e"-"\u0c10", - "\u0c12"-"\u0c28", - "\u0c2a"-"\u0c33", - "\u0c35"-"\u0c39", - "\u0c3e"-"\u0c44", - "\u0c46"-"\u0c48", - "\u0c4a"-"\u0c4d", - "\u0c55"-"\u0c56", - "\u0c60"-"\u0c61", - "\u0c66"-"\u0c6f", - "\u0c82"-"\u0c83", - "\u0c85"-"\u0c8c", - "\u0c8e"-"\u0c90", - "\u0c92"-"\u0ca8", - "\u0caa"-"\u0cb3", - "\u0cb5"-"\u0cb9", - "\u0cbe"-"\u0cc4", - "\u0cc6"-"\u0cc8", - "\u0cca"-"\u0ccd", - "\u0cd5"-"\u0cd6", - "\u0cde", - "\u0ce0"-"\u0ce1", - "\u0ce6"-"\u0cef", - "\u0d02"-"\u0d03", - "\u0d05"-"\u0d0c", - "\u0d0e"-"\u0d10", - "\u0d12"-"\u0d28", - "\u0d2a"-"\u0d39", - "\u0d3e"-"\u0d43", - "\u0d46"-"\u0d48", - "\u0d4a"-"\u0d4d", - "\u0d57", - "\u0d60"-"\u0d61", - "\u0d66"-"\u0d6f", - "\u0d82"-"\u0d83", - "\u0d85"-"\u0d96", - "\u0d9a"-"\u0db1", - "\u0db3"-"\u0dbb", - "\u0dbd", - "\u0dc0"-"\u0dc6", - "\u0dca", - "\u0dcf"-"\u0dd4", - "\u0dd6", - "\u0dd8"-"\u0ddf", - "\u0df2"-"\u0df3", - "\u0e01"-"\u0e3a", - "\u0e3f"-"\u0e4e", - "\u0e50"-"\u0e59", - "\u0e81"-"\u0e82", - "\u0e84", - "\u0e87"-"\u0e88", - "\u0e8a", - "\u0e8d", - "\u0e94"-"\u0e97", - "\u0e99"-"\u0e9f", - "\u0ea1"-"\u0ea3", - "\u0ea5", - "\u0ea7", - "\u0eaa"-"\u0eab", - "\u0ead"-"\u0eb9", - "\u0ebb"-"\u0ebd", - "\u0ec0"-"\u0ec4", - "\u0ec6", - "\u0ec8"-"\u0ecd", - "\u0ed0"-"\u0ed9", - "\u0edc"-"\u0edd", - "\u0f00", - "\u0f18"-"\u0f19", - "\u0f20"-"\u0f29", - "\u0f35", - "\u0f37", - "\u0f39", - "\u0f3e"-"\u0f47", - "\u0f49"-"\u0f6a", - "\u0f71"-"\u0f84", - "\u0f86"-"\u0f8b", - "\u0f90"-"\u0f97", - "\u0f99"-"\u0fbc", - "\u0fc6", - "\u1000"-"\u1021", - "\u1023"-"\u1027", - "\u1029"-"\u102a", - "\u102c"-"\u1032", - "\u1036"-"\u1039", - "\u1040"-"\u1049", - "\u1050"-"\u1059", - "\u10a0"-"\u10c5", - "\u10d0"-"\u10f6", - "\u1100"-"\u1159", - "\u115f"-"\u11a2", - "\u11a8"-"\u11f9", - "\u1200"-"\u1206", - "\u1208"-"\u1246", - "\u1248", - "\u124a"-"\u124d", - "\u1250"-"\u1256", - "\u1258", - "\u125a"-"\u125d", - "\u1260"-"\u1286", - "\u1288", - "\u128a"-"\u128d", - "\u1290"-"\u12ae", - "\u12b0", - "\u12b2"-"\u12b5", - "\u12b8"-"\u12be", - "\u12c0", - "\u12c2"-"\u12c5", - "\u12c8"-"\u12ce", - "\u12d0"-"\u12d6", - "\u12d8"-"\u12ee", - "\u12f0"-"\u130e", - "\u1310", - "\u1312"-"\u1315", - "\u1318"-"\u131e", - "\u1320"-"\u1346", - "\u1348"-"\u135a", - "\u1369"-"\u1371", - "\u13a0"-"\u13f4", - "\u1401"-"\u166c", - "\u166f"-"\u1676", - "\u1681"-"\u169a", - "\u16a0"-"\u16ea", - "\u1780"-"\u17d3", - "\u17db", - "\u17e0"-"\u17e9", - "\u180b"-"\u180e", - "\u1810"-"\u1819", - "\u1820"-"\u1877", - "\u1880"-"\u18a9", - "\u1e00"-"\u1e9b", - "\u1ea0"-"\u1ef9", - "\u1f00"-"\u1f15", - "\u1f18"-"\u1f1d", - "\u1f20"-"\u1f45", - "\u1f48"-"\u1f4d", - "\u1f50"-"\u1f57", - "\u1f59", - "\u1f5b", - "\u1f5d", - "\u1f5f"-"\u1f7d", - "\u1f80"-"\u1fb4", - "\u1fb6"-"\u1fbc", - "\u1fbe", - "\u1fc2"-"\u1fc4", - "\u1fc6"-"\u1fcc", - "\u1fd0"-"\u1fd3", - "\u1fd6"-"\u1fdb", - "\u1fe0"-"\u1fec", - "\u1ff2"-"\u1ff4", - "\u1ff6"-"\u1ffc", - "\u200c"-"\u200f", - "\u202a"-"\u202e", - "\u203f"-"\u2040", - "\u206a"-"\u206f", - "\u207f", - "\u20a0"-"\u20af", - "\u20d0"-"\u20dc", - "\u20e1", - "\u2102", - "\u2107", - "\u210a"-"\u2113", - "\u2115", - "\u2119"-"\u211d", - "\u2124", - "\u2126", - "\u2128", - "\u212a"-"\u212d", - "\u212f"-"\u2131", - "\u2133"-"\u2139", - "\u2160"-"\u2183", - "\u3005"-"\u3007", - "\u3021"-"\u302f", - "\u3031"-"\u3035", - "\u3038"-"\u303a", - "\u3041"-"\u3094", - "\u3099"-"\u309a", - "\u309d"-"\u309e", - "\u30a1"-"\u30fe", - "\u3105"-"\u312c", - "\u3131"-"\u318e", - "\u31a0"-"\u31b7", - "\u3400"-"\u4db5", - "\u4e00"-"\u9fa5", - "\ua000"-"\ua48c", - "\uac00"-"\ud7a3", - "\uf900"-"\ufa2d", - "\ufb00"-"\ufb06", - "\ufb13"-"\ufb17", - "\ufb1d"-"\ufb28", - "\ufb2a"-"\ufb36", - "\ufb38"-"\ufb3c", - "\ufb3e", - "\ufb40"-"\ufb41", - "\ufb43"-"\ufb44", - "\ufb46"-"\ufbb1", - "\ufbd3"-"\ufd3d", - "\ufd50"-"\ufd8f", - "\ufd92"-"\ufdc7", - "\ufdf0"-"\ufdfb", - "\ufe20"-"\ufe23", - "\ufe33"-"\ufe34", - "\ufe4d"-"\ufe4f", - "\ufe69", - "\ufe70"-"\ufe72", - "\ufe74", - "\ufe76"-"\ufefc", - "\ufeff", - "\uff04", - "\uff10"-"\uff19", - "\uff21"-"\uff3a", - "\uff3f", - "\uff41"-"\uff5a", - "\uff65"-"\uffbe", - "\uffc2"-"\uffc7", - "\uffca"-"\uffcf", - "\uffd2"-"\uffd7", - "\uffda"-"\uffdc", - "\uffe0"-"\uffe1", - "\uffe5"-"\uffe6", - "\ufff9"-"\ufffb" - ] - > -} - -/* SEPARATORS */ - -TOKEN : -{ - < LPAREN: "(" > -| < RPAREN: ")" > -| < LBRACE: "{" > -| < RBRACE: "}" > -| < LBRACKET: "[" > -| < RBRACKET: "]" > -| < SEMICOLON: ";" > -| < COMMA: "," > -| < DOT: "." > -| < AT: "@" > -} - -/* OPERATORS */ - -TOKEN : -{ - < ASSIGN: "=" > -| < LT: "<" > -| < BANG: "!" > -| < TILDE: "~" > -| < HOOK: "?" > -| < COLON: ":" > -| < EQ: "==" > -| < LE: "<=" > -| < GE: ">=" > -| < NE: "!=" > -| < SC_OR: "||" > -| < SC_AND: "&&" > -| < INCR: "++" > -| < DECR: "--" > -| < PLUS: "+" > -| < MINUS: "-" > -| < STAR: "*" > -| < SLASH: "/" > -| < BIT_AND: "&" > -| < BIT_OR: "|" > -| < XOR: "^" > -| < REM: "%" > -| < LSHIFT: "<<" > -| < PLUSASSIGN: "+=" > -| < MINUSASSIGN: "-=" > -| < STARASSIGN: "*=" > -| < SLASHASSIGN: "/=" > -| < ANDASSIGN: "&=" > -| < ORASSIGN: "|=" > -| < XORASSIGN: "^=" > -| < REMASSIGN: "%=" > -| < LSHIFTASSIGN: "<<=" > -| < RSIGNEDSHIFTASSIGN: ">>=" > -| < RUNSIGNEDSHIFTASSIGN: ">>>=" > -| < ELLIPSIS: "..." > -} - -/* >'s need special attention due to generics syntax. */ -TOKEN : -{ - < RUNSIGNEDSHIFT: ">>>" > - { - matchedToken.kind = GT; - ((Token.GTToken)matchedToken).realKind = RUNSIGNEDSHIFT; - input_stream.backup(2); - matchedToken.image = ">"; - } -| < RSIGNEDSHIFT: ">>" > - { - matchedToken.kind = GT; - ((Token.GTToken)matchedToken).realKind = RSIGNEDSHIFT; - input_stream.backup(1); - matchedToken.image = ">"; - } -| < GT: ">" > -} - -boolean Line() : -{ - int modifiers; -} -{ - <EOF> { - return true; - } -| - LOOKAHEAD(BlockStatement()) - BlockStatement() { - return false; - } -| - LOOKAHEAD(Modifiers() [ TypeParameters() ] [ ResultType() ] <IDENTIFIER> FormalParameters() [ "throws" NameList() ] "{") - ClassOrInterfaceBodyDeclaration(false) { - return false; - } -| - LOOKAHEAD(ClassOrInterfaceBodyDeclaration(false)) - ClassOrInterfaceBodyDeclaration(false) { - return false; - } -| - LOOKAHEAD(Expression()) - Expression() { - return false; - } -| - ImportDeclaration() { - return false; - } -} - -/***************************************** - * THE JAVA LANGUAGE GRAMMAR STARTS HERE * - *****************************************/ - -/* - * Program structuring syntax follows. - */ - -void CompilationUnit(): -{} -{ - [ LOOKAHEAD( ( Annotation() )* "package" ) PackageDeclaration() ] - ( ImportDeclaration() )* - ( TypeDeclaration() )* - ( < "\u001a" > )? - ( <STUFF_TO_IGNORE: ~[]> )? - <EOF> -} - -void PackageDeclaration(): -{} -{ - Modifiers() "package" Name() ";" -} - -void ImportDeclaration(): -{} -{ - "import" [ "static" ] Name() [ "." "*" ] ";" -} - -/* - * Modifiers. We match all modifiers in a single rule to reduce the chances of - * syntax errors for simple modifier mistakes. It will also enable us to give - * better error messages. - */ - -int Modifiers(): -{ - int modifiers = 0; -} -{ - ( - LOOKAHEAD(2) - ( - "public" { modifiers |= ModifierSet.PUBLIC; } - | - "static" { modifiers |= ModifierSet.STATIC; } - | - "protected" { modifiers |= ModifierSet.PROTECTED; } - | - "private" { modifiers |= ModifierSet.PRIVATE; } - | - "final" { modifiers |= ModifierSet.FINAL; } - | - "abstract" { modifiers |= ModifierSet.ABSTRACT; } - | - "synchronized" { modifiers |= ModifierSet.SYNCHRONIZED; } - | - "native" { modifiers |= ModifierSet.NATIVE; } - | - "transient" { modifiers |= ModifierSet.TRANSIENT; } - | - "volatile" { modifiers |= ModifierSet.VOLATILE; } - | - "strictfp" { modifiers |= ModifierSet.STRICTFP; } - | - Annotation() - ) - )* - - { - return modifiers; - } -} - -/* - * Declaration syntax follows. - */ -void TypeDeclaration(): -{ - int modifiers; -} -{ - ";" -| - modifiers = Modifiers() - ( - ClassOrInterfaceDeclaration(modifiers) - | - EnumDeclaration(modifiers) - | - AnnotationTypeDeclaration(modifiers) - ) -} - - -void ClassOrInterfaceDeclaration(int modifiers): -{ - boolean isInterface = false; -} -{ - ( "class" | "interface" { isInterface = true; } ) - <IDENTIFIER> - [ TypeParameters() ] - [ ExtendsList(isInterface) ] - [ ImplementsList(isInterface) ] - ClassOrInterfaceBody(isInterface) -} - -void ExtendsList(boolean isInterface): -{ - boolean extendsMoreThanOne = false; -} -{ - "extends" ClassOrInterfaceType() - ( "," ClassOrInterfaceType() { extendsMoreThanOne = true; } )* - { - if (extendsMoreThanOne && !isInterface) - throw new ParseException("A class cannot extend more than one other class"); - } -} - -void ImplementsList(boolean isInterface): -{} -{ - "implements" ClassOrInterfaceType() - ( "," ClassOrInterfaceType() )* - { - if (isInterface) - throw new ParseException("An interface cannot implement other interfaces"); - } -} - -void EnumDeclaration(int modifiers): -{} -{ - "enum" <IDENTIFIER> - [ ImplementsList(false) ] - EnumBody() -} - -void EnumBody(): -{} -{ - "{" - [ EnumConstant() ( LOOKAHEAD(2) "," EnumConstant() )* ] - [ "," ] - [ ";" ( ClassOrInterfaceBodyDeclaration(false) )* ] - "}" -} - -void EnumConstant(): -{} -{ - Modifiers() <IDENTIFIER> [ Arguments() ] [ ClassOrInterfaceBody(false) ] -} - -void TypeParameters(): -{} -{ - "<" TypeParameter() ( "," TypeParameter() )* ">" -} - -void TypeParameter(): -{} -{ - <IDENTIFIER> [ TypeBound() ] -} - -void TypeBound(): -{} -{ - "extends" ClassOrInterfaceType() ( "&" ClassOrInterfaceType() )* -} - -void ClassOrInterfaceBody(boolean isInterface): -{} -{ - "{" ( ClassOrInterfaceBodyDeclaration(isInterface) )* "}" -} - -void ClassOrInterfaceBodyDeclaration(boolean isInterface): -{ - boolean isNestedInterface = false; - int modifiers; -} -{ - LOOKAHEAD(2) - Initializer() - { - if (isInterface) - throw new ParseException("An interface cannot have initializers"); - } -| - modifiers = Modifiers() // Just get all the modifiers out of the way. If you want to do - // more checks, pass the modifiers down to the member - ( - ClassOrInterfaceDeclaration(modifiers) - | - EnumDeclaration(modifiers) - | - LOOKAHEAD( [ TypeParameters() ] <IDENTIFIER> "(" ) - ConstructorDeclaration() - | - LOOKAHEAD( Type() <IDENTIFIER> ( "[" "]" )* ( "," | "=" | ";" ) ) - FieldDeclaration(modifiers) - | - MethodDeclaration(modifiers) - ) -| - ";" -} - -void FieldDeclaration(int modifiers): -{} -{ - // Modifiers are already matched in the caller - Type() VariableDeclarator() ( "," VariableDeclarator() )* ";" -} - -void VariableDeclarator(): -{} -{ - VariableDeclaratorId() [ "=" VariableInitializer() ] -} - -void VariableDeclaratorId(): -{} -{ - <IDENTIFIER> ( "[" "]" )* -} - -void VariableInitializer(): -{} -{ - ArrayInitializer() -| - Expression() -} - -void ArrayInitializer(): -{} -{ - "{" [ VariableInitializer() ( LOOKAHEAD(2) "," VariableInitializer() )* ] [ "," ] "}" -} - -void MethodDeclaration(int modifiers): -{} -{ - // Modifiers already matched in the caller! - [ TypeParameters() ] - ResultType() - MethodDeclarator() [ "throws" NameList() ] - ( Block() | ";" ) -} - -void MethodDeclarator(): -{} -{ - <IDENTIFIER> FormalParameters() ( "[" "]" )* -} - -void FormalParameters(): -{} -{ - "(" [ FormalParameter() ( "," FormalParameter() )* ] ")" -} - -void FormalParameter(): -{} -{ - Modifiers() Type() [ "..." ] VariableDeclaratorId() -} - -void ConstructorDeclaration(): -{} -{ - [ TypeParameters() ] - // Modifiers matched in the caller - <IDENTIFIER> FormalParameters() [ "throws" NameList() ] - "{" - [ LOOKAHEAD(ExplicitConstructorInvocation()) - ExplicitConstructorInvocation() - ] - ( BlockStatement() )* - "}" -} - -void ExplicitConstructorInvocation(): -{} -{ - ( <IDENTIFIER> "." )* [ LOOKAHEAD(2) "this" "." ] - [ TypeArguments() ] ("this"|"super") Arguments() ";" -} - -void Initializer(): -{} -{ - [ "static" ] Block() -} - - -/* - * Type, name and expression syntax follows. - */ - -void Type(): -{} -{ - LOOKAHEAD(2) ReferenceType() - | - PrimitiveType() -} - -void ReferenceType(): -{} -{ - PrimitiveType() ( LOOKAHEAD(2) "[" "]" )+ - | - ( ClassOrInterfaceType() ) ( LOOKAHEAD(2) "[" "]" )* -} - -void ClassOrInterfaceType(): -{} -{ - <IDENTIFIER> [ LOOKAHEAD(2) TypeArguments() ] - ( LOOKAHEAD(2) "." <IDENTIFIER> [ LOOKAHEAD(2) TypeArguments() ] )* -} - -void TypeArguments(): -{} -{ - "<" TypeArgument() ( "," TypeArgument() )* ">" -} - -void TypeArgument(): -{} -{ - ReferenceType() - | - "?" [ WildcardBounds() ] -} - -void WildcardBounds(): -{} -{ - "extends" ReferenceType() - | - "super" ReferenceType() -} - - -void PrimitiveType(): -{} -{ - "boolean" -| - "char" -| - "byte" -| - "short" -| - "int" -| - "long" -| - "float" -| - "double" -} - -void ResultType(): -{} -{ - "void" -| - Type() -} - -void Name(): -/* - * A lookahead of 2 is required below since "Name" can be followed - * by a ".*" when used in the context of an "ImportDeclaration". - */ -{} -{ - <IDENTIFIER> - ( LOOKAHEAD(2) "." <IDENTIFIER> - )* -} - -void NameList(): -{} -{ - Name() ( "," Name() )* -} - - -/* - * Expression syntax follows. - */ - -void Expression(): -/* - * This expansion has been written this way instead of: - * Assignment() | ConditionalExpression() - * for performance reasons. - * However, it is a weakening of the grammar for it allows the LHS of - * assignments to be any conditional expression whereas it can only be - * a primary expression. Consider adding a semantic predicate to work - * around this. - */ -{} -{ - ConditionalExpression() - [ - LOOKAHEAD(2) - AssignmentOperator() Expression() - ] -} - -void AssignmentOperator(): -{} -{ - "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | ">>>=" | "&=" | "^=" | "|=" -} - -void AssignmentExpression(): -{} -{ - PrimaryExpression() AssignmentOperator() Expression() -} - -void ConditionalExpression(): -{} -{ - ConditionalOrExpression() [ "?" Expression() ":" Expression() ] -} - -void ConditionalOrExpression(): -{} -{ - ConditionalAndExpression() ( "||" ConditionalAndExpression() )* -} - -void ConditionalAndExpression(): -{} -{ - InclusiveOrExpression() ( "&&" InclusiveOrExpression() )* -} - -void InclusiveOrExpression(): -{} -{ - ExclusiveOrExpression() ( "|" ExclusiveOrExpression() )* -} - -void ExclusiveOrExpression(): -{} -{ - AndExpression() ( "^" AndExpression() )* -} - -void AndExpression(): -{} -{ - EqualityExpression() ( "&" EqualityExpression() )* -} - -void EqualityExpression(): -{} -{ - InstanceOfExpression() ( ( "==" | "!=" ) InstanceOfExpression() )* -} - -void InstanceOfExpression(): -{} -{ - RelationalExpression() [ "instanceof" Type() ] -} - -void RelationalExpression(): -{} -{ - ShiftExpression() ( ( "<" | ">" | "<=" | ">=" ) ShiftExpression() )* -} - -void ShiftExpression(): -{} -{ - AdditiveExpression() ( ( "<<" | RSIGNEDSHIFT() | RUNSIGNEDSHIFT() ) AdditiveExpression() )* -} - -void AdditiveExpression(): -{} -{ - MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )* -} - -void MultiplicativeExpression(): -{} -{ - UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )* -} - -void UnaryExpression(): -{} -{ - ( "+" | "-" ) UnaryExpression() -| - PreIncrementExpression() -| - PreDecrementExpression() -| - UnaryExpressionNotPlusMinus() -} - -void PreIncrementExpression(): -{} -{ - "++" PrimaryExpression() -} - -void PreDecrementExpression(): -{} -{ - "--" PrimaryExpression() -} - -void UnaryExpressionNotPlusMinus(): -{} -{ - ( "~" | "!" ) UnaryExpression() -| - LOOKAHEAD( CastLookahead() ) - CastExpression() -| - PostfixExpression() -} - -// This production is to determine lookahead only. The LOOKAHEAD specifications -// below are not used, but they are there just to indicate that we know about -// this. -void CastLookahead(): -{} -{ - LOOKAHEAD(2) - "(" PrimitiveType() -| - LOOKAHEAD("(" Type() "[") - "(" Type() "[" "]" -| - "(" Type() ")" ( "~" | "!" | "(" | <IDENTIFIER> | "this" | "super" | "new" | Literal() ) -} - -void PostfixExpression(): -{} -{ - PrimaryExpression() [ PostfixOperator() ] -} - -void PostfixOperator(): -{} -{ - "++" | "--" -} - -void CastExpression(): -{} -{ - LOOKAHEAD("(" PrimitiveType()) - "(" Type() ")" UnaryExpression() -| - "(" Type() ")" UnaryExpressionNotPlusMinus() -} - -void PrimaryExpression(): -{} -{ - PrimaryPrefix() ( LOOKAHEAD(2) PrimarySuffix() )* -} - -void MemberSelector(): -{} -{ - "." TypeArguments() <IDENTIFIER> -} - -void PrimaryPrefix(): -{} -{ - Literal() -| - LOOKAHEAD( ( <IDENTIFIER> "." )* "this" ) - ( <IDENTIFIER> "." )* - "this" -| - "super" "." <IDENTIFIER> -| - "(" Expression() ")" -| - AllocationExpression() -| - LOOKAHEAD( ResultType() "." "class" ) - ResultType() "." "class" -| - Name() -} - -void PrimarySuffix(): -{} -{ - LOOKAHEAD("." "super" ".") - "." "super" -| - LOOKAHEAD("." "this") - "." "this" -| - LOOKAHEAD(2) - "." AllocationExpression() -| - LOOKAHEAD(3) - MemberSelector() -| - "[" Expression() "]" -| - "." <IDENTIFIER> -| - Arguments() -} - -void Literal(): -{} -{ - <INTEGER_LITERAL> -| - <FLOATING_POINT_LITERAL> -| - <CHARACTER_LITERAL> -| - <STRING_LITERAL> -| - BooleanLiteral() -| - NullLiteral() -} - -void BooleanLiteral(): -{} -{ - "true" -| - "false" -} - -void NullLiteral(): -{} -{ - "null" -} - -void Arguments(): -{} -{ - "(" [ ArgumentList() ] ")" -} - -void ArgumentList(): -{} -{ - Expression() ( "," Expression() )* -} - -void AllocationExpression(): -{} -{ - LOOKAHEAD(2) - "new" PrimitiveType() ArrayDimsAndInits() -| - "new" ClassOrInterfaceType() [ TypeArguments() ] - ( - ArrayDimsAndInits() - | - Arguments() [ ClassOrInterfaceBody(false) ] - ) -} - -/* - * The third LOOKAHEAD specification below is to parse to PrimarySuffix - * if there is an expression between the "[...]". - */ -void ArrayDimsAndInits(): -{} -{ - LOOKAHEAD(2) - ( LOOKAHEAD(2) "[" Expression() "]" )+ ( LOOKAHEAD(2) "[" "]" )* -| - ( "[" "]" )+ ArrayInitializer() -} - - -/* - * Statement syntax follows. - */ - -void Statement(): -{} -{ - LOOKAHEAD(2) - LabeledStatement() -| - AssertStatement() -| - Block() -| - EmptyStatement() -| - StatementExpression() ";" -| - SwitchStatement() -| - IfStatement() -| - WhileStatement() -| - DoStatement() -| - ForStatement() -| - BreakStatement() -| - ContinueStatement() -| - ReturnStatement() -| - ThrowStatement() -| - SynchronizedStatement() -| - TryStatement() -} - -void AssertStatement(): -{} -{ - "assert" Expression() [ ":" Expression() ] ";" -} - -void LabeledStatement(): -{} -{ - <IDENTIFIER> ":" Statement() -} - -void Block(): -{} -{ - "{" ( BlockStatement() )* "}" -} - -void BlockStatement(): -{} -{ - LOOKAHEAD( Modifiers() Type() <IDENTIFIER> ) - LocalVariableDeclaration() ";" -| - Statement() -| - ClassOrInterfaceDeclaration(0) -} - -void LocalVariableDeclaration(): -{} -{ - Modifiers() Type() VariableDeclarator() ( "," VariableDeclarator() )* -} - -void EmptyStatement(): -{} -{ - ";" -} - -void StatementExpression(): -{} -{ - PreIncrementExpression() -| - PreDecrementExpression() -| - LOOKAHEAD(PrimaryExpression() AssignmentOperator()) - AssignmentExpression() -| - PostfixExpression() -} - -void SwitchStatement(): -{} -{ - "switch" "(" Expression() ")" "{" - ( SwitchLabel() ( BlockStatement() )* )* - "}" -} - -void SwitchLabel(): -{} -{ - "case" Expression() ":" -| - "default" ":" -} - -void IfStatement(): -/* - * The disambiguating algorithm of JavaCC automatically binds dangling - * else's to the innermost if statement. The LOOKAHEAD specification - * is to tell JavaCC that we know what we are doing. - */ -{} -{ - "if" "(" Expression() ")" Statement() [ LOOKAHEAD(1) "else" Statement() ] -} - -void WhileStatement(): -{} -{ - "while" "(" Expression() ")" Statement() -} - -void DoStatement(): -{} -{ - "do" Statement() "while" "(" Expression() ")" ";" -} - -void ForStatement(): -{} -{ - "for" "(" - - ( - LOOKAHEAD(Modifiers() Type() <IDENTIFIER> ":") - Modifiers() Type() <IDENTIFIER> ":" Expression() - | - [ ForInit() ] ";" [ Expression() ] ";" [ ForUpdate() ] - ) - - ")" Statement() -} - -void ForInit(): -{} -{ - LOOKAHEAD( Modifiers() Type() <IDENTIFIER> ) - LocalVariableDeclaration() -| - StatementExpressionList() -} - -void StatementExpressionList(): -{} -{ - StatementExpression() ( "," StatementExpression() )* -} - -void ForUpdate(): -{} -{ - StatementExpressionList() -} - -void BreakStatement(): -{} -{ - "break" [ <IDENTIFIER> ] ";" -} - -void ContinueStatement(): -{} -{ - "continue" [ <IDENTIFIER> ] ";" -} - -void ReturnStatement(): -{} -{ - "return" [ Expression() ] ";" -} - -void ThrowStatement(): -{} -{ - "throw" Expression() ";" -} - -void SynchronizedStatement(): -{} -{ - "synchronized" "(" Expression() ")" Block() -} - -void TryStatement(): -/* - * Semantic check required here to make sure that at least one - * finally/catch is present. - */ -{} -{ - "try" Block() - ( "catch" "(" FormalParameter() ")" Block() )* - [ "finally" Block() ] -} - -/* We use productions to match >>>, >> and > so that we can keep the - * type declaration syntax with generics clean - */ - -void RUNSIGNEDSHIFT(): -{} -{ - ( LOOKAHEAD({ getToken(1).kind == GT && - ((Token.GTToken)getToken(1)).realKind == RUNSIGNEDSHIFT} ) - ">" ">" ">" - ) -} - -void RSIGNEDSHIFT(): -{} -{ - ( LOOKAHEAD({ getToken(1).kind == GT && - ((Token.GTToken)getToken(1)).realKind == RSIGNEDSHIFT} ) - ">" ">" - ) -} - -/* Annotation syntax follows. */ - -void Annotation(): -{} -{ - LOOKAHEAD( "@" Name() "(" ( <IDENTIFIER> "=" | ")" )) - NormalAnnotation() - | - LOOKAHEAD( "@" Name() "(" ) - SingleMemberAnnotation() - | - MarkerAnnotation() -} - -void NormalAnnotation(): -{} -{ - "@" Name() "(" [ MemberValuePairs() ] ")" -} - -void MarkerAnnotation(): -{} -{ - "@" Name() -} - -void SingleMemberAnnotation(): -{} -{ - "@" Name() "(" MemberValue() ")" -} - -void MemberValuePairs(): -{} -{ - MemberValuePair() ( "," MemberValuePair() )* -} - -void MemberValuePair(): -{} -{ - <IDENTIFIER> "=" MemberValue() -} - -void MemberValue(): -{} -{ - Annotation() - | - MemberValueArrayInitializer() - | - ConditionalExpression() -} - -void MemberValueArrayInitializer(): -{} -{ - "{" MemberValue() ( LOOKAHEAD(2) "," MemberValue() )* [ "," ] "}" -} - - -/* Annotation Types. */ - -void AnnotationTypeDeclaration(int modifiers): -{} -{ - "@" "interface" <IDENTIFIER> AnnotationTypeBody() -} - -void AnnotationTypeBody(): -{} -{ - "{" ( AnnotationTypeMemberDeclaration() )* "}" -} - -void AnnotationTypeMemberDeclaration(): -{ - int modifiers; -} -{ - modifiers = Modifiers() - ( - LOOKAHEAD(Type() <IDENTIFIER> "(") - Type() <IDENTIFIER> "(" ")" [ DefaultValue() ] ";" - | - ClassOrInterfaceDeclaration(modifiers) - | - EnumDeclaration(modifiers) - | - AnnotationTypeDeclaration(modifiers) - | - FieldDeclaration(modifiers) - ) - | - ( ";" ) -} - -void DefaultValue(): -{} -{ - "default" MemberValue() -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Java1.5.jjt (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Java1.5.jjt) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Java1.5.jjt (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Java1.5.jjt 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,2150 @@ + +/* + * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has + * intellectual property rights relating to technology embodied in the product + * that is described in this document. In particular, and without limitation, + * these intellectual property rights may include one or more of the U.S. + * patents listed at http://www.sun.com/patents and one or more additional + * patents or pending patent applications in the U.S. and in other countries. + * U.S. Government Rights - Commercial software. Government users are subject + * to the Sun Microsystems, Inc. standard license agreement and applicable + * provisions of the FAR and its supplements. Use is subject to license terms. + * Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This + * product is covered and controlled by U.S. Export Control laws and may be + * subject to the export or import laws in other countries. Nuclear, missile, + * chemical biological weapons or nuclear maritime end uses or end users, + * whether direct or indirect, are strictly prohibited. Export or reexport + * to countries subject to U.S. embargo or to entities identified on U.S. + * export exclusion lists, including, but not limited to, the denied persons + * and specially designated nationals lists is strictly prohibited. + */ + +// Slightly modified version of javacc's reference 1.5 grammar, tweaked for +// usage with JAXX. There are two main areas of changes: several new +// nonterminals were added to make identifying certain constructs easier, +// and the Line nonterminal was added to support JAXX's script tags. +// Several of the new changes are inefficient and require excess lookahead, +// but at this point I'd rather have inefficiency than risk breaking it during +// attempted optimizations. + +options { + JAVA_UNICODE_ESCAPE = true; + ERROR_REPORTING = false; + STATIC = false; + JDK_VERSION = "1.4"; + NODE_SCOPE_HOOK=true; +} + +PARSER_BEGIN(JavaParser) +package jaxx.parser; + +import java.io.*; + +/** + * Grammar to parse Java version 1.5 + * @author Sreenivasa Viswanadha - Simplified and enhanced for 1.5 + */ +public class JavaParser +{ + /** + * Class to hold modifiers. + */ + static public final class ModifierSet + { + /* Definitions of the bits in the modifiers field. */ + public static final int PUBLIC = 0x0001; + public static final int PROTECTED = 0x0002; + public static final int PRIVATE = 0x0004; + public static final int ABSTRACT = 0x0008; + public static final int STATIC = 0x0010; + public static final int FINAL = 0x0020; + public static final int SYNCHRONIZED = 0x0040; + public static final int NATIVE = 0x0080; + public static final int TRANSIENT = 0x0100; + public static final int VOLATILE = 0x0200; + public static final int STRICTFP = 0x1000; + + /** A set of accessors that indicate whether the specified modifier + is in the set. */ + + public boolean isPublic(int modifiers) + { + return (modifiers & PUBLIC) != 0; + } + + public boolean isProtected(int modifiers) + { + return (modifiers & PROTECTED) != 0; + } + + public boolean isPrivate(int modifiers) + { + return (modifiers & PRIVATE) != 0; + } + + public boolean isStatic(int modifiers) + { + return (modifiers & STATIC) != 0; + } + + public boolean isAbstract(int modifiers) + { + return (modifiers & ABSTRACT) != 0; + } + + public boolean isFinal(int modifiers) + { + return (modifiers & FINAL) != 0; + } + + public boolean isNative(int modifiers) + { + return (modifiers & NATIVE) != 0; + } + + public boolean isStrictfp(int modifiers) + { + return (modifiers & STRICTFP) != 0; + } + + public boolean isSynchronized(int modifiers) + { + return (modifiers & SYNCHRONIZED) != 0; + } + + public boolean isTransient(int modifiers) + { + return (modifiers & TRANSIENT) != 0; + } + + public boolean isVolatile(int modifiers) + { + return (modifiers & VOLATILE) != 0; + } + + /** + * Removes the given modifier. + */ + static int removeModifier(int modifiers, int mod) + { + return modifiers & ~mod; + } + } + + public JavaParser(String fileName) + { + this(System.in); + try { ReInit(new FileInputStream(new File(fileName))); } + catch(Exception e) { e.printStackTrace(); } + } + + void jjtreeOpenNodeScope(Node n) { + ((SimpleNode) n).firstToken = getToken(1); + } + + void jjtreeCloseNodeScope(Node n) { + ((SimpleNode) n).lastToken = getToken(0); + } + + public SimpleNode popNode() + { + if ( jjtree.nodeArity() > 0) // number of child nodes + return (SimpleNode)jjtree.popNode(); + else + return null; + } + public static void main(String args[]) { + JavaParser parser; + if (args.length == 0) { + System.out.println("Java Parser Version 1.1: Reading from standard input . . ."); + parser = new JavaParser(System.in); + } else if (args.length == 1) { + System.out.println("Java Parser Version 1.1: Reading from file " + args[0] + " . . ."); + try { + parser = new JavaParser(new java.io.FileInputStream(args[0])); + } catch (java.io.FileNotFoundException e) { + System.out.println("Java Parser Version 1.1: File " + args[0] + " not found."); + return; + } + } else { + System.out.println("Java Parser Version 1.1: Usage is one of:"); + System.out.println(" java JavaParser < inputfile"); + System.out.println("OR"); + System.out.println(" java JavaParser inputfile"); + return; + } + try { + parser.CompilationUnit(); + System.out.println("Java Parser Version 1.1: Java program parsed successfully."); + } catch (ParseException e) { + System.out.println(e.getMessage()); + System.out.println("Java Parser Version 1.1: Encountered errors during parse."); + } + } + +} + +PARSER_END(JavaParser) + +/* COMMENTS */ + +MORE : +{ + <"/**" ~["/"]> { input_stream.backup(1); } : IN_FORMAL_COMMENT +| + "/*" : IN_MULTI_LINE_COMMENT +} + +SPECIAL_TOKEN: +{ + <WHITE_SPACE: ([" ", "\n", "\r", "\t", "\f"])+> +} + +SPECIAL_TOKEN : +{ + <SINGLE_LINE_COMMENT: "//" (~["\n", "\r"])* ("\n" | "\r" | "\r\n")?> +} + +<IN_FORMAL_COMMENT> +SPECIAL_TOKEN : +{ + <FORMAL_COMMENT: "*/" > : DEFAULT +} + +<IN_MULTI_LINE_COMMENT> +SPECIAL_TOKEN : +{ + <MULTI_LINE_COMMENT: "*/" > : DEFAULT +} + +<IN_FORMAL_COMMENT,IN_MULTI_LINE_COMMENT> +MORE : +{ + < ~[] > +} + +/* RESERVED WORDS AND LITERALS */ + +TOKEN : +{ + < ABSTRACT: "abstract" > +| < ASSERT: "assert" > +| < BOOLEAN: "boolean" > +| < BREAK: "break" > +| < BYTE: "byte" > +| < CASE: "case" > +| < CATCH: "catch" > +| < CHAR: "char" > +| < CLASS: "class" > +| < CONST: "const" > +| < CONTINUE: "continue" > +| < _DEFAULT: "default" > +| < DO: "do" > +| < DOUBLE: "double" > +| < ELSE: "else" > +| < ENUM: "enum" > +| < EXTENDS: "extends" > +| < FALSE: "false" > +| < FINAL: "final" > +| < FINALLY: "finally" > +| < FLOAT: "float" > +| < FOR: "for" > +| < GOTO: "goto" > +| < IF: "if" > +| < IMPLEMENTS: "implements" > +| < IMPORT: "import" > +| < INSTANCEOF: "instanceof" > +| < INT: "int" > +| < INTERFACE: "interface" > +| < LONG: "long" > +| < NATIVE: "native" > +| < NEW: "new" > +| < NULL: "null" > +| < PACKAGE: "package"> +| < PRIVATE: "private" > +| < PROTECTED: "protected" > +| < PUBLIC: "public" > +| < RETURN: "return" > +| < SHORT: "short" > +| < STATIC: "static" > +| < STRICTFP: "strictfp" > +| < SUPER: "super" > +| < SWITCH: "switch" > +| < SYNCHRONIZED: "synchronized" > +| < THIS: "this" > +| < THROW: "throw" > +| < THROWS: "throws" > +| < TRANSIENT: "transient" > +| < TRUE: "true" > +| < TRY: "try" > +| < VOID: "void" > +| < VOLATILE: "volatile" > +| < WHILE: "while" > +} + +/* LITERALS */ + +TOKEN : +{ + < INTEGER_LITERAL: + <DECIMAL_LITERAL> (["l","L"])? + | <HEX_LITERAL> (["l","L"])? + | <OCTAL_LITERAL> (["l","L"])? + > +| + < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* > +| + < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ > +| + < #OCTAL_LITERAL: "0" (["0"-"7"])* > +| + < FLOATING_POINT_LITERAL: + <DECIMAL_FLOATING_POINT_LITERAL> + | <HEXADECIMAL_FLOATING_POINT_LITERAL> + > +| + < #DECIMAL_FLOATING_POINT_LITERAL: + (["0"-"9"])+ "." (["0"-"9"])* (<DECIMAL_EXPONENT>)? (["f","F","d","D"])? + | "." (["0"-"9"])+ (<DECIMAL_EXPONENT>)? (["f","F","d","D"])? + | (["0"-"9"])+ <DECIMAL_EXPONENT> (["f","F","d","D"])? + | (["0"-"9"])+ (<DECIMAL_EXPONENT>)? ["f","F","d","D"] + > +| + < #DECIMAL_EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ > +| + < #HEXADECIMAL_FLOATING_POINT_LITERAL: + "0" ["x", "X"] (["0"-"9","a"-"f","A"-"F"])+ (".")? <HEXADECIMAL_EXPONENT> (["f","F","d","D"])? + | "0" ["x", "X"] (["0"-"9","a"-"f","A"-"F"])* "." (["0"-"9","a"-"f","A"-"F"])+ <HEXADECIMAL_EXPONENT> (["f","F","d","D"])? + > +| + < #HEXADECIMAL_EXPONENT: ["p","P"] (["+","-"])? (["0"-"9"])+ > +| + < CHARACTER_LITERAL: + "'" + ( (~["'","\\","\n","\r"]) + | ("\\" + ( ["n","t","b","r","f","\\","'","\""] + | ["0"-"7"] ( ["0"-"7"] )? + | ["0"-"3"] ["0"-"7"] ["0"-"7"] + ) + ) + ) + "'" + > +| + < STRING_LITERAL: + "\"" + ( (~["\"","\\","\n","\r"]) + | ("\\" + ( ["n","t","b","r","f","\\","'","\""] + | ["0"-"7"] ( ["0"-"7"] )? + | ["0"-"3"] ["0"-"7"] ["0"-"7"] + ) + ) + )* + "\"" + > +} + +/* IDENTIFIERS */ + +TOKEN : +{ + < IDENTIFIER: <LETTER> (<PART_LETTER>)* > +| + < #LETTER: + [ // all chars for which Character.isIdentifierStart is true + "$", + "A"-"Z", + "_", + "a"-"z", + "\u00a2"-"\u00a5", + "\u00aa", + "\u00b5", + "\u00ba", + "\u00c0"-"\u00d6", + "\u00d8"-"\u00f6", + "\u00f8"-"\u021f", + "\u0222"-"\u0233", + "\u0250"-"\u02ad", + "\u02b0"-"\u02b8", + "\u02bb"-"\u02c1", + "\u02d0"-"\u02d1", + "\u02e0"-"\u02e4", + "\u02ee", + "\u037a", + "\u0386", + "\u0388"-"\u038a", + "\u038c", + "\u038e"-"\u03a1", + "\u03a3"-"\u03ce", + "\u03d0"-"\u03d7", + "\u03da"-"\u03f3", + "\u0400"-"\u0481", + "\u048c"-"\u04c4", + "\u04c7"-"\u04c8", + "\u04cb"-"\u04cc", + "\u04d0"-"\u04f5", + "\u04f8"-"\u04f9", + "\u0531"-"\u0556", + "\u0559", + "\u0561"-"\u0587", + "\u05d0"-"\u05ea", + "\u05f0"-"\u05f2", + "\u0621"-"\u063a", + "\u0640"-"\u064a", + "\u0671"-"\u06d3", + "\u06d5", + "\u06e5"-"\u06e6", + "\u06fa"-"\u06fc", + "\u0710", + "\u0712"-"\u072c", + "\u0780"-"\u07a5", + "\u0905"-"\u0939", + "\u093d", + "\u0950", + "\u0958"-"\u0961", + "\u0985"-"\u098c", + "\u098f"-"\u0990", + "\u0993"-"\u09a8", + "\u09aa"-"\u09b0", + "\u09b2", + "\u09b6"-"\u09b9", + "\u09dc"-"\u09dd", + "\u09df"-"\u09e1", + "\u09f0"-"\u09f3", + "\u0a05"-"\u0a0a", + "\u0a0f"-"\u0a10", + "\u0a13"-"\u0a28", + "\u0a2a"-"\u0a30", + "\u0a32"-"\u0a33", + "\u0a35"-"\u0a36", + "\u0a38"-"\u0a39", + "\u0a59"-"\u0a5c", + "\u0a5e", + "\u0a72"-"\u0a74", + "\u0a85"-"\u0a8b", + "\u0a8d", + "\u0a8f"-"\u0a91", + "\u0a93"-"\u0aa8", + "\u0aaa"-"\u0ab0", + "\u0ab2"-"\u0ab3", + "\u0ab5"-"\u0ab9", + "\u0abd", + "\u0ad0", + "\u0ae0", + "\u0b05"-"\u0b0c", + "\u0b0f"-"\u0b10", + "\u0b13"-"\u0b28", + "\u0b2a"-"\u0b30", + "\u0b32"-"\u0b33", + "\u0b36"-"\u0b39", + "\u0b3d", + "\u0b5c"-"\u0b5d", + "\u0b5f"-"\u0b61", + "\u0b85"-"\u0b8a", + "\u0b8e"-"\u0b90", + "\u0b92"-"\u0b95", + "\u0b99"-"\u0b9a", + "\u0b9c", + "\u0b9e"-"\u0b9f", + "\u0ba3"-"\u0ba4", + "\u0ba8"-"\u0baa", + "\u0bae"-"\u0bb5", + "\u0bb7"-"\u0bb9", + "\u0c05"-"\u0c0c", + "\u0c0e"-"\u0c10", + "\u0c12"-"\u0c28", + "\u0c2a"-"\u0c33", + "\u0c35"-"\u0c39", + "\u0c60"-"\u0c61", + "\u0c85"-"\u0c8c", + "\u0c8e"-"\u0c90", + "\u0c92"-"\u0ca8", + "\u0caa"-"\u0cb3", + "\u0cb5"-"\u0cb9", + "\u0cde", + "\u0ce0"-"\u0ce1", + "\u0d05"-"\u0d0c", + "\u0d0e"-"\u0d10", + "\u0d12"-"\u0d28", + "\u0d2a"-"\u0d39", + "\u0d60"-"\u0d61", + "\u0d85"-"\u0d96", + "\u0d9a"-"\u0db1", + "\u0db3"-"\u0dbb", + "\u0dbd", + "\u0dc0"-"\u0dc6", + "\u0e01"-"\u0e30", + "\u0e32"-"\u0e33", + "\u0e3f"-"\u0e46", + "\u0e81"-"\u0e82", + "\u0e84", + "\u0e87"-"\u0e88", + "\u0e8a", + "\u0e8d", + "\u0e94"-"\u0e97", + "\u0e99"-"\u0e9f", + "\u0ea1"-"\u0ea3", + "\u0ea5", + "\u0ea7", + "\u0eaa"-"\u0eab", + "\u0ead"-"\u0eb0", + "\u0eb2"-"\u0eb3", + "\u0ebd", + "\u0ec0"-"\u0ec4", + "\u0ec6", + "\u0edc"-"\u0edd", + "\u0f00", + "\u0f40"-"\u0f47", + "\u0f49"-"\u0f6a", + "\u0f88"-"\u0f8b", + "\u1000"-"\u1021", + "\u1023"-"\u1027", + "\u1029"-"\u102a", + "\u1050"-"\u1055", + "\u10a0"-"\u10c5", + "\u10d0"-"\u10f6", + "\u1100"-"\u1159", + "\u115f"-"\u11a2", + "\u11a8"-"\u11f9", + "\u1200"-"\u1206", + "\u1208"-"\u1246", + "\u1248", + "\u124a"-"\u124d", + "\u1250"-"\u1256", + "\u1258", + "\u125a"-"\u125d", + "\u1260"-"\u1286", + "\u1288", + "\u128a"-"\u128d", + "\u1290"-"\u12ae", + "\u12b0", + "\u12b2"-"\u12b5", + "\u12b8"-"\u12be", + "\u12c0", + "\u12c2"-"\u12c5", + "\u12c8"-"\u12ce", + "\u12d0"-"\u12d6", + "\u12d8"-"\u12ee", + "\u12f0"-"\u130e", + "\u1310", + "\u1312"-"\u1315", + "\u1318"-"\u131e", + "\u1320"-"\u1346", + "\u1348"-"\u135a", + "\u13a0"-"\u13f4", + "\u1401"-"\u166c", + "\u166f"-"\u1676", + "\u1681"-"\u169a", + "\u16a0"-"\u16ea", + "\u1780"-"\u17b3", + "\u17db", + "\u1820"-"\u1877", + "\u1880"-"\u18a8", + "\u1e00"-"\u1e9b", + "\u1ea0"-"\u1ef9", + "\u1f00"-"\u1f15", + "\u1f18"-"\u1f1d", + "\u1f20"-"\u1f45", + "\u1f48"-"\u1f4d", + "\u1f50"-"\u1f57", + "\u1f59", + "\u1f5b", + "\u1f5d", + "\u1f5f"-"\u1f7d", + "\u1f80"-"\u1fb4", + "\u1fb6"-"\u1fbc", + "\u1fbe", + "\u1fc2"-"\u1fc4", + "\u1fc6"-"\u1fcc", + "\u1fd0"-"\u1fd3", + "\u1fd6"-"\u1fdb", + "\u1fe0"-"\u1fec", + "\u1ff2"-"\u1ff4", + "\u1ff6"-"\u1ffc", + "\u203f"-"\u2040", + "\u207f", + "\u20a0"-"\u20af", + "\u2102", + "\u2107", + "\u210a"-"\u2113", + "\u2115", + "\u2119"-"\u211d", + "\u2124", + "\u2126", + "\u2128", + "\u212a"-"\u212d", + "\u212f"-"\u2131", + "\u2133"-"\u2139", + "\u2160"-"\u2183", + "\u3005"-"\u3007", + "\u3021"-"\u3029", + "\u3031"-"\u3035", + "\u3038"-"\u303a", + "\u3041"-"\u3094", + "\u309d"-"\u309e", + "\u30a1"-"\u30fe", + "\u3105"-"\u312c", + "\u3131"-"\u318e", + "\u31a0"-"\u31b7", + "\u3400"-"\u4db5", + "\u4e00"-"\u9fa5", + "\ua000"-"\ua48c", + "\uac00"-"\ud7a3", + "\uf900"-"\ufa2d", + "\ufb00"-"\ufb06", + "\ufb13"-"\ufb17", + "\ufb1d", + "\ufb1f"-"\ufb28", + "\ufb2a"-"\ufb36", + "\ufb38"-"\ufb3c", + "\ufb3e", + "\ufb40"-"\ufb41", + "\ufb43"-"\ufb44", + "\ufb46"-"\ufbb1", + "\ufbd3"-"\ufd3d", + "\ufd50"-"\ufd8f", + "\ufd92"-"\ufdc7", + "\ufdf0"-"\ufdfb", + "\ufe33"-"\ufe34", + "\ufe4d"-"\ufe4f", + "\ufe69", + "\ufe70"-"\ufe72", + "\ufe74", + "\ufe76"-"\ufefc", + "\uff04", + "\uff21"-"\uff3a", + "\uff3f", + "\uff41"-"\uff5a", + "\uff65"-"\uffbe", + "\uffc2"-"\uffc7", + "\uffca"-"\uffcf", + "\uffd2"-"\uffd7", + "\uffda"-"\uffdc", + "\uffe0"-"\uffe1", + "\uffe5"-"\uffe6" + ] + > +| + < #PART_LETTER: + [ // all chars for which Character.isIdentifierPart is true + "\u0000"-"\u0008", + "\u000e"-"\u001b", + "$", + "0"-"9", + "A"-"Z", + "_", + "a"-"z", + "\u007f"-"\u009f", + "\u00a2"-"\u00a5", + "\u00aa", + "\u00b5", + "\u00ba", + "\u00c0"-"\u00d6", + "\u00d8"-"\u00f6", + "\u00f8"-"\u021f", + "\u0222"-"\u0233", + "\u0250"-"\u02ad", + "\u02b0"-"\u02b8", + "\u02bb"-"\u02c1", + "\u02d0"-"\u02d1", + "\u02e0"-"\u02e4", + "\u02ee", + "\u0300"-"\u034e", + "\u0360"-"\u0362", + "\u037a", + "\u0386", + "\u0388"-"\u038a", + "\u038c", + "\u038e"-"\u03a1", + "\u03a3"-"\u03ce", + "\u03d0"-"\u03d7", + "\u03da"-"\u03f3", + "\u0400"-"\u0481", + "\u0483"-"\u0486", + "\u048c"-"\u04c4", + "\u04c7"-"\u04c8", + "\u04cb"-"\u04cc", + "\u04d0"-"\u04f5", + "\u04f8"-"\u04f9", + "\u0531"-"\u0556", + "\u0559", + "\u0561"-"\u0587", + "\u0591"-"\u05a1", + "\u05a3"-"\u05b9", + "\u05bb"-"\u05bd", + "\u05bf", + "\u05c1"-"\u05c2", + "\u05c4", + "\u05d0"-"\u05ea", + "\u05f0"-"\u05f2", + "\u0621"-"\u063a", + "\u0640"-"\u0655", + "\u0660"-"\u0669", + "\u0670"-"\u06d3", + "\u06d5"-"\u06dc", + "\u06df"-"\u06e8", + "\u06ea"-"\u06ed", + "\u06f0"-"\u06fc", + "\u070f"-"\u072c", + "\u0730"-"\u074a", + "\u0780"-"\u07b0", + "\u0901"-"\u0903", + "\u0905"-"\u0939", + "\u093c"-"\u094d", + "\u0950"-"\u0954", + "\u0958"-"\u0963", + "\u0966"-"\u096f", + "\u0981"-"\u0983", + "\u0985"-"\u098c", + "\u098f"-"\u0990", + "\u0993"-"\u09a8", + "\u09aa"-"\u09b0", + "\u09b2", + "\u09b6"-"\u09b9", + "\u09bc", + "\u09be"-"\u09c4", + "\u09c7"-"\u09c8", + "\u09cb"-"\u09cd", + "\u09d7", + "\u09dc"-"\u09dd", + "\u09df"-"\u09e3", + "\u09e6"-"\u09f3", + "\u0a02", + "\u0a05"-"\u0a0a", + "\u0a0f"-"\u0a10", + "\u0a13"-"\u0a28", + "\u0a2a"-"\u0a30", + "\u0a32"-"\u0a33", + "\u0a35"-"\u0a36", + "\u0a38"-"\u0a39", + "\u0a3c", + "\u0a3e"-"\u0a42", + "\u0a47"-"\u0a48", + "\u0a4b"-"\u0a4d", + "\u0a59"-"\u0a5c", + "\u0a5e", + "\u0a66"-"\u0a74", + "\u0a81"-"\u0a83", + "\u0a85"-"\u0a8b", + "\u0a8d", + "\u0a8f"-"\u0a91", + "\u0a93"-"\u0aa8", + "\u0aaa"-"\u0ab0", + "\u0ab2"-"\u0ab3", + "\u0ab5"-"\u0ab9", + "\u0abc"-"\u0ac5", + "\u0ac7"-"\u0ac9", + "\u0acb"-"\u0acd", + "\u0ad0", + "\u0ae0", + "\u0ae6"-"\u0aef", + "\u0b01"-"\u0b03", + "\u0b05"-"\u0b0c", + "\u0b0f"-"\u0b10", + "\u0b13"-"\u0b28", + "\u0b2a"-"\u0b30", + "\u0b32"-"\u0b33", + "\u0b36"-"\u0b39", + "\u0b3c"-"\u0b43", + "\u0b47"-"\u0b48", + "\u0b4b"-"\u0b4d", + "\u0b56"-"\u0b57", + "\u0b5c"-"\u0b5d", + "\u0b5f"-"\u0b61", + "\u0b66"-"\u0b6f", + "\u0b82"-"\u0b83", + "\u0b85"-"\u0b8a", + "\u0b8e"-"\u0b90", + "\u0b92"-"\u0b95", + "\u0b99"-"\u0b9a", + "\u0b9c", + "\u0b9e"-"\u0b9f", + "\u0ba3"-"\u0ba4", + "\u0ba8"-"\u0baa", + "\u0bae"-"\u0bb5", + "\u0bb7"-"\u0bb9", + "\u0bbe"-"\u0bc2", + "\u0bc6"-"\u0bc8", + "\u0bca"-"\u0bcd", + "\u0bd7", + "\u0be7"-"\u0bef", + "\u0c01"-"\u0c03", + "\u0c05"-"\u0c0c", + "\u0c0e"-"\u0c10", + "\u0c12"-"\u0c28", + "\u0c2a"-"\u0c33", + "\u0c35"-"\u0c39", + "\u0c3e"-"\u0c44", + "\u0c46"-"\u0c48", + "\u0c4a"-"\u0c4d", + "\u0c55"-"\u0c56", + "\u0c60"-"\u0c61", + "\u0c66"-"\u0c6f", + "\u0c82"-"\u0c83", + "\u0c85"-"\u0c8c", + "\u0c8e"-"\u0c90", + "\u0c92"-"\u0ca8", + "\u0caa"-"\u0cb3", + "\u0cb5"-"\u0cb9", + "\u0cbe"-"\u0cc4", + "\u0cc6"-"\u0cc8", + "\u0cca"-"\u0ccd", + "\u0cd5"-"\u0cd6", + "\u0cde", + "\u0ce0"-"\u0ce1", + "\u0ce6"-"\u0cef", + "\u0d02"-"\u0d03", + "\u0d05"-"\u0d0c", + "\u0d0e"-"\u0d10", + "\u0d12"-"\u0d28", + "\u0d2a"-"\u0d39", + "\u0d3e"-"\u0d43", + "\u0d46"-"\u0d48", + "\u0d4a"-"\u0d4d", + "\u0d57", + "\u0d60"-"\u0d61", + "\u0d66"-"\u0d6f", + "\u0d82"-"\u0d83", + "\u0d85"-"\u0d96", + "\u0d9a"-"\u0db1", + "\u0db3"-"\u0dbb", + "\u0dbd", + "\u0dc0"-"\u0dc6", + "\u0dca", + "\u0dcf"-"\u0dd4", + "\u0dd6", + "\u0dd8"-"\u0ddf", + "\u0df2"-"\u0df3", + "\u0e01"-"\u0e3a", + "\u0e3f"-"\u0e4e", + "\u0e50"-"\u0e59", + "\u0e81"-"\u0e82", + "\u0e84", + "\u0e87"-"\u0e88", + "\u0e8a", + "\u0e8d", + "\u0e94"-"\u0e97", + "\u0e99"-"\u0e9f", + "\u0ea1"-"\u0ea3", + "\u0ea5", + "\u0ea7", + "\u0eaa"-"\u0eab", + "\u0ead"-"\u0eb9", + "\u0ebb"-"\u0ebd", + "\u0ec0"-"\u0ec4", + "\u0ec6", + "\u0ec8"-"\u0ecd", + "\u0ed0"-"\u0ed9", + "\u0edc"-"\u0edd", + "\u0f00", + "\u0f18"-"\u0f19", + "\u0f20"-"\u0f29", + "\u0f35", + "\u0f37", + "\u0f39", + "\u0f3e"-"\u0f47", + "\u0f49"-"\u0f6a", + "\u0f71"-"\u0f84", + "\u0f86"-"\u0f8b", + "\u0f90"-"\u0f97", + "\u0f99"-"\u0fbc", + "\u0fc6", + "\u1000"-"\u1021", + "\u1023"-"\u1027", + "\u1029"-"\u102a", + "\u102c"-"\u1032", + "\u1036"-"\u1039", + "\u1040"-"\u1049", + "\u1050"-"\u1059", + "\u10a0"-"\u10c5", + "\u10d0"-"\u10f6", + "\u1100"-"\u1159", + "\u115f"-"\u11a2", + "\u11a8"-"\u11f9", + "\u1200"-"\u1206", + "\u1208"-"\u1246", + "\u1248", + "\u124a"-"\u124d", + "\u1250"-"\u1256", + "\u1258", + "\u125a"-"\u125d", + "\u1260"-"\u1286", + "\u1288", + "\u128a"-"\u128d", + "\u1290"-"\u12ae", + "\u12b0", + "\u12b2"-"\u12b5", + "\u12b8"-"\u12be", + "\u12c0", + "\u12c2"-"\u12c5", + "\u12c8"-"\u12ce", + "\u12d0"-"\u12d6", + "\u12d8"-"\u12ee", + "\u12f0"-"\u130e", + "\u1310", + "\u1312"-"\u1315", + "\u1318"-"\u131e", + "\u1320"-"\u1346", + "\u1348"-"\u135a", + "\u1369"-"\u1371", + "\u13a0"-"\u13f4", + "\u1401"-"\u166c", + "\u166f"-"\u1676", + "\u1681"-"\u169a", + "\u16a0"-"\u16ea", + "\u1780"-"\u17d3", + "\u17db", + "\u17e0"-"\u17e9", + "\u180b"-"\u180e", + "\u1810"-"\u1819", + "\u1820"-"\u1877", + "\u1880"-"\u18a9", + "\u1e00"-"\u1e9b", + "\u1ea0"-"\u1ef9", + "\u1f00"-"\u1f15", + "\u1f18"-"\u1f1d", + "\u1f20"-"\u1f45", + "\u1f48"-"\u1f4d", + "\u1f50"-"\u1f57", + "\u1f59", + "\u1f5b", + "\u1f5d", + "\u1f5f"-"\u1f7d", + "\u1f80"-"\u1fb4", + "\u1fb6"-"\u1fbc", + "\u1fbe", + "\u1fc2"-"\u1fc4", + "\u1fc6"-"\u1fcc", + "\u1fd0"-"\u1fd3", + "\u1fd6"-"\u1fdb", + "\u1fe0"-"\u1fec", + "\u1ff2"-"\u1ff4", + "\u1ff6"-"\u1ffc", + "\u200c"-"\u200f", + "\u202a"-"\u202e", + "\u203f"-"\u2040", + "\u206a"-"\u206f", + "\u207f", + "\u20a0"-"\u20af", + "\u20d0"-"\u20dc", + "\u20e1", + "\u2102", + "\u2107", + "\u210a"-"\u2113", + "\u2115", + "\u2119"-"\u211d", + "\u2124", + "\u2126", + "\u2128", + "\u212a"-"\u212d", + "\u212f"-"\u2131", + "\u2133"-"\u2139", + "\u2160"-"\u2183", + "\u3005"-"\u3007", + "\u3021"-"\u302f", + "\u3031"-"\u3035", + "\u3038"-"\u303a", + "\u3041"-"\u3094", + "\u3099"-"\u309a", + "\u309d"-"\u309e", + "\u30a1"-"\u30fe", + "\u3105"-"\u312c", + "\u3131"-"\u318e", + "\u31a0"-"\u31b7", + "\u3400"-"\u4db5", + "\u4e00"-"\u9fa5", + "\ua000"-"\ua48c", + "\uac00"-"\ud7a3", + "\uf900"-"\ufa2d", + "\ufb00"-"\ufb06", + "\ufb13"-"\ufb17", + "\ufb1d"-"\ufb28", + "\ufb2a"-"\ufb36", + "\ufb38"-"\ufb3c", + "\ufb3e", + "\ufb40"-"\ufb41", + "\ufb43"-"\ufb44", + "\ufb46"-"\ufbb1", + "\ufbd3"-"\ufd3d", + "\ufd50"-"\ufd8f", + "\ufd92"-"\ufdc7", + "\ufdf0"-"\ufdfb", + "\ufe20"-"\ufe23", + "\ufe33"-"\ufe34", + "\ufe4d"-"\ufe4f", + "\ufe69", + "\ufe70"-"\ufe72", + "\ufe74", + "\ufe76"-"\ufefc", + "\ufeff", + "\uff04", + "\uff10"-"\uff19", + "\uff21"-"\uff3a", + "\uff3f", + "\uff41"-"\uff5a", + "\uff65"-"\uffbe", + "\uffc2"-"\uffc7", + "\uffca"-"\uffcf", + "\uffd2"-"\uffd7", + "\uffda"-"\uffdc", + "\uffe0"-"\uffe1", + "\uffe5"-"\uffe6", + "\ufff9"-"\ufffb" + ] + > +} + +/* SEPARATORS */ + +TOKEN : +{ + < LPAREN: "(" > +| < RPAREN: ")" > +| < LBRACE: "{" > +| < RBRACE: "}" > +| < LBRACKET: "[" > +| < RBRACKET: "]" > +| < SEMICOLON: ";" > +| < COMMA: "," > +| < DOT: "." > +| < AT: "@" > +} + +/* OPERATORS */ + +TOKEN : +{ + < ASSIGN: "=" > +| < LT: "<" > +| < BANG: "!" > +| < TILDE: "~" > +| < HOOK: "?" > +| < COLON: ":" > +| < EQ: "==" > +| < LE: "<=" > +| < GE: ">=" > +| < NE: "!=" > +| < SC_OR: "||" > +| < SC_AND: "&&" > +| < INCR: "++" > +| < DECR: "--" > +| < PLUS: "+" > +| < MINUS: "-" > +| < STAR: "*" > +| < SLASH: "/" > +| < BIT_AND: "&" > +| < BIT_OR: "|" > +| < XOR: "^" > +| < REM: "%" > +| < LSHIFT: "<<" > +| < PLUSASSIGN: "+=" > +| < MINUSASSIGN: "-=" > +| < STARASSIGN: "*=" > +| < SLASHASSIGN: "/=" > +| < ANDASSIGN: "&=" > +| < ORASSIGN: "|=" > +| < XORASSIGN: "^=" > +| < REMASSIGN: "%=" > +| < LSHIFTASSIGN: "<<=" > +| < RSIGNEDSHIFTASSIGN: ">>=" > +| < RUNSIGNEDSHIFTASSIGN: ">>>=" > +| < ELLIPSIS: "..." > +} + +/* >'s need special attention due to generics syntax. */ +TOKEN : +{ + < RUNSIGNEDSHIFT: ">>>" > + { + matchedToken.kind = GT; + ((Token.GTToken)matchedToken).realKind = RUNSIGNEDSHIFT; + input_stream.backup(2); + matchedToken.image = ">"; + } +| < RSIGNEDSHIFT: ">>" > + { + matchedToken.kind = GT; + ((Token.GTToken)matchedToken).realKind = RSIGNEDSHIFT; + input_stream.backup(1); + matchedToken.image = ">"; + } +| < GT: ">" > +} + +boolean Line() : +{ + int modifiers; +} +{ + <EOF> { + return true; + } +| + LOOKAHEAD(BlockStatement()) + BlockStatement() { + return false; + } +| + LOOKAHEAD(Modifiers() [ TypeParameters() ] [ ResultType() ] <IDENTIFIER> FormalParameters() [ "throws" NameList() ] "{") + ClassOrInterfaceBodyDeclaration(false) { + return false; + } +| + LOOKAHEAD(ClassOrInterfaceBodyDeclaration(false)) + ClassOrInterfaceBodyDeclaration(false) { + return false; + } +| + LOOKAHEAD(Expression()) + Expression() { + return false; + } +| + ImportDeclaration() { + return false; + } +} + +/***************************************** + * THE JAVA LANGUAGE GRAMMAR STARTS HERE * + *****************************************/ + +/* + * Program structuring syntax follows. + */ + +void CompilationUnit(): +{} +{ + [ LOOKAHEAD( ( Annotation() )* "package" ) PackageDeclaration() ] + ( ImportDeclaration() )* + ( TypeDeclaration() )* + ( < "\u001a" > )? + ( <STUFF_TO_IGNORE: ~[]> )? + <EOF> +} + +void PackageDeclaration(): +{} +{ + Modifiers() "package" Name() ";" +} + +void ImportDeclaration(): +{} +{ + "import" [ "static" ] Name() [ "." "*" ] ";" +} + +/* + * Modifiers. We match all modifiers in a single rule to reduce the chances of + * syntax errors for simple modifier mistakes. It will also enable us to give + * better error messages. + */ + +int Modifiers(): +{ + int modifiers = 0; +} +{ + ( + LOOKAHEAD(2) + ( + "public" { modifiers |= ModifierSet.PUBLIC; } + | + "static" { modifiers |= ModifierSet.STATIC; } + | + "protected" { modifiers |= ModifierSet.PROTECTED; } + | + "private" { modifiers |= ModifierSet.PRIVATE; } + | + "final" { modifiers |= ModifierSet.FINAL; } + | + "abstract" { modifiers |= ModifierSet.ABSTRACT; } + | + "synchronized" { modifiers |= ModifierSet.SYNCHRONIZED; } + | + "native" { modifiers |= ModifierSet.NATIVE; } + | + "transient" { modifiers |= ModifierSet.TRANSIENT; } + | + "volatile" { modifiers |= ModifierSet.VOLATILE; } + | + "strictfp" { modifiers |= ModifierSet.STRICTFP; } + | + Annotation() + ) + )* + + { + return modifiers; + } +} + +/* + * Declaration syntax follows. + */ +void TypeDeclaration(): +{ + int modifiers; +} +{ + ";" +| + modifiers = Modifiers() + ( + ClassOrInterfaceDeclaration(modifiers) + | + EnumDeclaration(modifiers) + | + AnnotationTypeDeclaration(modifiers) + ) +} + + +void ClassOrInterfaceDeclaration(int modifiers): +{ + boolean isInterface = false; +} +{ + ( "class" | "interface" { isInterface = true; } ) + <IDENTIFIER> + [ TypeParameters() ] + [ ExtendsList(isInterface) ] + [ ImplementsList(isInterface) ] + ClassOrInterfaceBody(isInterface) +} + +void ExtendsList(boolean isInterface): +{ + boolean extendsMoreThanOne = false; +} +{ + "extends" ClassOrInterfaceType() + ( "," ClassOrInterfaceType() { extendsMoreThanOne = true; } )* + { + if (extendsMoreThanOne && !isInterface) + throw new ParseException("A class cannot extend more than one other class"); + } +} + +void ImplementsList(boolean isInterface): +{} +{ + "implements" ClassOrInterfaceType() + ( "," ClassOrInterfaceType() )* + { + if (isInterface) + throw new ParseException("An interface cannot implement other interfaces"); + } +} + +void EnumDeclaration(int modifiers): +{} +{ + "enum" <IDENTIFIER> + [ ImplementsList(false) ] + EnumBody() +} + +void EnumBody(): +{} +{ + "{" + [ EnumConstant() ( LOOKAHEAD(2) "," EnumConstant() )* ] + [ "," ] + [ ";" ( ClassOrInterfaceBodyDeclaration(false) )* ] + "}" +} + +void EnumConstant(): +{} +{ + Modifiers() <IDENTIFIER> [ Arguments() ] [ ClassOrInterfaceBody(false) ] +} + +void TypeParameters(): +{} +{ + "<" TypeParameter() ( "," TypeParameter() )* ">" +} + +void TypeParameter(): +{} +{ + <IDENTIFIER> [ TypeBound() ] +} + +void TypeBound(): +{} +{ + "extends" ClassOrInterfaceType() ( "&" ClassOrInterfaceType() )* +} + +void ClassOrInterfaceBody(boolean isInterface): +{} +{ + "{" ( ClassOrInterfaceBodyDeclaration(isInterface) )* "}" +} + +void ClassOrInterfaceBodyDeclaration(boolean isInterface): +{ + boolean isNestedInterface = false; + int modifiers; +} +{ + LOOKAHEAD(2) + Initializer() + { + if (isInterface) + throw new ParseException("An interface cannot have initializers"); + } +| + modifiers = Modifiers() // Just get all the modifiers out of the way. If you want to do + // more checks, pass the modifiers down to the member + ( + ClassOrInterfaceDeclaration(modifiers) + | + EnumDeclaration(modifiers) + | + LOOKAHEAD( [ TypeParameters() ] <IDENTIFIER> "(" ) + ConstructorDeclaration() + | + LOOKAHEAD( Type() <IDENTIFIER> ( "[" "]" )* ( "," | "=" | ";" ) ) + FieldDeclaration(modifiers) + | + MethodDeclaration(modifiers) + ) +| + ";" +} + +void FieldDeclaration(int modifiers): +{} +{ + // Modifiers are already matched in the caller + Type() VariableDeclarator() ( "," VariableDeclarator() )* ";" +} + +void VariableDeclarator(): +{} +{ + VariableDeclaratorId() [ "=" VariableInitializer() ] +} + +void VariableDeclaratorId(): +{} +{ + <IDENTIFIER> ( "[" "]" )* +} + +void VariableInitializer(): +{} +{ + ArrayInitializer() +| + Expression() +} + +void ArrayInitializer(): +{} +{ + "{" [ VariableInitializer() ( LOOKAHEAD(2) "," VariableInitializer() )* ] [ "," ] "}" +} + +void MethodDeclaration(int modifiers): +{} +{ + // Modifiers already matched in the caller! + [ TypeParameters() ] + ResultType() + MethodDeclarator() [ "throws" NameList() ] + ( Block() | ";" ) +} + +void MethodDeclarator(): +{} +{ + <IDENTIFIER> FormalParameters() ( "[" "]" )* +} + +void FormalParameters(): +{} +{ + "(" [ FormalParameter() ( "," FormalParameter() )* ] ")" +} + +void FormalParameter(): +{} +{ + Modifiers() Type() [ "..." ] VariableDeclaratorId() +} + +void ConstructorDeclaration(): +{} +{ + [ TypeParameters() ] + // Modifiers matched in the caller + <IDENTIFIER> FormalParameters() [ "throws" NameList() ] + "{" + [ LOOKAHEAD(ExplicitConstructorInvocation()) + ExplicitConstructorInvocation() + ] + ( BlockStatement() )* + "}" +} + +void ExplicitConstructorInvocation(): +{} +{ + ( <IDENTIFIER> "." )* [ LOOKAHEAD(2) "this" "." ] + [ TypeArguments() ] ("this"|"super") Arguments() ";" +} + +void Initializer(): +{} +{ + [ "static" ] Block() +} + + +/* + * Type, name and expression syntax follows. + */ + +void Type(): +{} +{ + LOOKAHEAD(2) ReferenceType() + | + PrimitiveType() +} + +void ReferenceType(): +{} +{ + PrimitiveType() ( LOOKAHEAD(2) "[" "]" )+ + | + ( ClassOrInterfaceType() ) ( LOOKAHEAD(2) "[" "]" )* +} + +void ClassOrInterfaceType(): +{} +{ + <IDENTIFIER> [ LOOKAHEAD(2) TypeArguments() ] + ( LOOKAHEAD(2) "." <IDENTIFIER> [ LOOKAHEAD(2) TypeArguments() ] )* +} + +void TypeArguments(): +{} +{ + "<" TypeArgument() ( "," TypeArgument() )* ">" +} + +void TypeArgument(): +{} +{ + ReferenceType() + | + "?" [ WildcardBounds() ] +} + +void WildcardBounds(): +{} +{ + "extends" ReferenceType() + | + "super" ReferenceType() +} + + +void PrimitiveType(): +{} +{ + "boolean" +| + "char" +| + "byte" +| + "short" +| + "int" +| + "long" +| + "float" +| + "double" +} + +void ResultType(): +{} +{ + "void" +| + Type() +} + +void Name(): +/* + * A lookahead of 2 is required below since "Name" can be followed + * by a ".*" when used in the context of an "ImportDeclaration". + */ +{} +{ + <IDENTIFIER> + ( LOOKAHEAD(2) "." <IDENTIFIER> + )* +} + +void NameList(): +{} +{ + Name() ( "," Name() )* +} + + +/* + * Expression syntax follows. + */ + +void Expression(): +/* + * This expansion has been written this way instead of: + * Assignment() | ConditionalExpression() + * for performance reasons. + * However, it is a weakening of the grammar for it allows the LHS of + * assignments to be any conditional expression whereas it can only be + * a primary expression. Consider adding a semantic predicate to work + * around this. + */ +{} +{ + ConditionalExpression() + [ + LOOKAHEAD(2) + AssignmentOperator() Expression() + ] +} + +void AssignmentOperator(): +{} +{ + "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | ">>>=" | "&=" | "^=" | "|=" +} + +void AssignmentExpression(): +{} +{ + PrimaryExpression() AssignmentOperator() Expression() +} + +void ConditionalExpression(): +{} +{ + ConditionalOrExpression() [ "?" Expression() ":" Expression() ] +} + +void ConditionalOrExpression(): +{} +{ + ConditionalAndExpression() ( "||" ConditionalAndExpression() )* +} + +void ConditionalAndExpression(): +{} +{ + InclusiveOrExpression() ( "&&" InclusiveOrExpression() )* +} + +void InclusiveOrExpression(): +{} +{ + ExclusiveOrExpression() ( "|" ExclusiveOrExpression() )* +} + +void ExclusiveOrExpression(): +{} +{ + AndExpression() ( "^" AndExpression() )* +} + +void AndExpression(): +{} +{ + EqualityExpression() ( "&" EqualityExpression() )* +} + +void EqualityExpression(): +{} +{ + InstanceOfExpression() ( ( "==" | "!=" ) InstanceOfExpression() )* +} + +void InstanceOfExpression(): +{} +{ + RelationalExpression() [ "instanceof" Type() ] +} + +void RelationalExpression(): +{} +{ + ShiftExpression() ( ( "<" | ">" | "<=" | ">=" ) ShiftExpression() )* +} + +void ShiftExpression(): +{} +{ + AdditiveExpression() ( ( "<<" | RSIGNEDSHIFT() | RUNSIGNEDSHIFT() ) AdditiveExpression() )* +} + +void AdditiveExpression(): +{} +{ + MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )* +} + +void MultiplicativeExpression(): +{} +{ + UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )* +} + +void UnaryExpression(): +{} +{ + ( "+" | "-" ) UnaryExpression() +| + PreIncrementExpression() +| + PreDecrementExpression() +| + UnaryExpressionNotPlusMinus() +} + +void PreIncrementExpression(): +{} +{ + "++" PrimaryExpression() +} + +void PreDecrementExpression(): +{} +{ + "--" PrimaryExpression() +} + +void UnaryExpressionNotPlusMinus(): +{} +{ + ( "~" | "!" ) UnaryExpression() +| + LOOKAHEAD( CastLookahead() ) + CastExpression() +| + PostfixExpression() +} + +// This production is to determine lookahead only. The LOOKAHEAD specifications +// below are not used, but they are there just to indicate that we know about +// this. +void CastLookahead(): +{} +{ + LOOKAHEAD(2) + "(" PrimitiveType() +| + LOOKAHEAD("(" Type() "[") + "(" Type() "[" "]" +| + "(" Type() ")" ( "~" | "!" | "(" | <IDENTIFIER> | "this" | "super" | "new" | Literal() ) +} + +void PostfixExpression(): +{} +{ + PrimaryExpression() [ PostfixOperator() ] +} + +void PostfixOperator(): +{} +{ + "++" | "--" +} + +void CastExpression(): +{} +{ + LOOKAHEAD("(" PrimitiveType()) + "(" Type() ")" UnaryExpression() +| + "(" Type() ")" UnaryExpressionNotPlusMinus() +} + +void PrimaryExpression(): +{} +{ + PrimaryPrefix() ( LOOKAHEAD(2) PrimarySuffix() )* +} + +void MemberSelector(): +{} +{ + "." TypeArguments() <IDENTIFIER> +} + +void PrimaryPrefix(): +{} +{ + Literal() +| + LOOKAHEAD( ( <IDENTIFIER> "." )* "this" ) + ( <IDENTIFIER> "." )* + "this" +| + "super" "." <IDENTIFIER> +| + "(" Expression() ")" +| + AllocationExpression() +| + LOOKAHEAD( ResultType() "." "class" ) + ResultType() "." "class" +| + Name() +} + +void PrimarySuffix(): +{} +{ + LOOKAHEAD("." "super" ".") + "." "super" +| + LOOKAHEAD("." "this") + "." "this" +| + LOOKAHEAD(2) + "." AllocationExpression() +| + LOOKAHEAD(3) + MemberSelector() +| + "[" Expression() "]" +| + "." <IDENTIFIER> +| + Arguments() +} + +void Literal(): +{} +{ + <INTEGER_LITERAL> +| + <FLOATING_POINT_LITERAL> +| + <CHARACTER_LITERAL> +| + <STRING_LITERAL> +| + BooleanLiteral() +| + NullLiteral() +} + +void BooleanLiteral(): +{} +{ + "true" +| + "false" +} + +void NullLiteral(): +{} +{ + "null" +} + +void Arguments(): +{} +{ + "(" [ ArgumentList() ] ")" +} + +void ArgumentList(): +{} +{ + Expression() ( "," Expression() )* +} + +void AllocationExpression(): +{} +{ + LOOKAHEAD(2) + "new" PrimitiveType() ArrayDimsAndInits() +| + "new" ClassOrInterfaceType() [ TypeArguments() ] + ( + ArrayDimsAndInits() + | + Arguments() [ ClassOrInterfaceBody(false) ] + ) +} + +/* + * The third LOOKAHEAD specification below is to parse to PrimarySuffix + * if there is an expression between the "[...]". + */ +void ArrayDimsAndInits(): +{} +{ + LOOKAHEAD(2) + ( LOOKAHEAD(2) "[" Expression() "]" )+ ( LOOKAHEAD(2) "[" "]" )* +| + ( "[" "]" )+ ArrayInitializer() +} + + +/* + * Statement syntax follows. + */ + +void Statement(): +{} +{ + LOOKAHEAD(2) + LabeledStatement() +| + AssertStatement() +| + Block() +| + EmptyStatement() +| + StatementExpression() ";" +| + SwitchStatement() +| + IfStatement() +| + WhileStatement() +| + DoStatement() +| + ForStatement() +| + BreakStatement() +| + ContinueStatement() +| + ReturnStatement() +| + ThrowStatement() +| + SynchronizedStatement() +| + TryStatement() +} + +void AssertStatement(): +{} +{ + "assert" Expression() [ ":" Expression() ] ";" +} + +void LabeledStatement(): +{} +{ + <IDENTIFIER> ":" Statement() +} + +void Block(): +{} +{ + "{" ( BlockStatement() )* "}" +} + +void BlockStatement(): +{} +{ + LOOKAHEAD( Modifiers() Type() <IDENTIFIER> ) + LocalVariableDeclaration() ";" +| + Statement() +| + ClassOrInterfaceDeclaration(0) +} + +void LocalVariableDeclaration(): +{} +{ + Modifiers() Type() VariableDeclarator() ( "," VariableDeclarator() )* +} + +void EmptyStatement(): +{} +{ + ";" +} + +void StatementExpression(): +{} +{ + PreIncrementExpression() +| + PreDecrementExpression() +| + LOOKAHEAD(PrimaryExpression() AssignmentOperator()) + AssignmentExpression() +| + PostfixExpression() +} + +void SwitchStatement(): +{} +{ + "switch" "(" Expression() ")" "{" + ( SwitchLabel() ( BlockStatement() )* )* + "}" +} + +void SwitchLabel(): +{} +{ + "case" Expression() ":" +| + "default" ":" +} + +void IfStatement(): +/* + * The disambiguating algorithm of JavaCC automatically binds dangling + * else's to the innermost if statement. The LOOKAHEAD specification + * is to tell JavaCC that we know what we are doing. + */ +{} +{ + "if" "(" Expression() ")" Statement() [ LOOKAHEAD(1) "else" Statement() ] +} + +void WhileStatement(): +{} +{ + "while" "(" Expression() ")" Statement() +} + +void DoStatement(): +{} +{ + "do" Statement() "while" "(" Expression() ")" ";" +} + +void ForStatement(): +{} +{ + "for" "(" + + ( + LOOKAHEAD(Modifiers() Type() <IDENTIFIER> ":") + Modifiers() Type() <IDENTIFIER> ":" Expression() + | + [ ForInit() ] ";" [ Expression() ] ";" [ ForUpdate() ] + ) + + ")" Statement() +} + +void ForInit(): +{} +{ + LOOKAHEAD( Modifiers() Type() <IDENTIFIER> ) + LocalVariableDeclaration() +| + StatementExpressionList() +} + +void StatementExpressionList(): +{} +{ + StatementExpression() ( "," StatementExpression() )* +} + +void ForUpdate(): +{} +{ + StatementExpressionList() +} + +void BreakStatement(): +{} +{ + "break" [ <IDENTIFIER> ] ";" +} + +void ContinueStatement(): +{} +{ + "continue" [ <IDENTIFIER> ] ";" +} + +void ReturnStatement(): +{} +{ + "return" [ Expression() ] ";" +} + +void ThrowStatement(): +{} +{ + "throw" Expression() ";" +} + +void SynchronizedStatement(): +{} +{ + "synchronized" "(" Expression() ")" Block() +} + +void TryStatement(): +/* + * Semantic check required here to make sure that at least one + * finally/catch is present. + */ +{} +{ + "try" Block() + ( "catch" "(" FormalParameter() ")" Block() )* + [ "finally" Block() ] +} + +/* We use productions to match >>>, >> and > so that we can keep the + * type declaration syntax with generics clean + */ + +void RUNSIGNEDSHIFT(): +{} +{ + ( LOOKAHEAD({ getToken(1).kind == GT && + ((Token.GTToken)getToken(1)).realKind == RUNSIGNEDSHIFT} ) + ">" ">" ">" + ) +} + +void RSIGNEDSHIFT(): +{} +{ + ( LOOKAHEAD({ getToken(1).kind == GT && + ((Token.GTToken)getToken(1)).realKind == RSIGNEDSHIFT} ) + ">" ">" + ) +} + +/* Annotation syntax follows. */ + +void Annotation(): +{} +{ + LOOKAHEAD( "@" Name() "(" ( <IDENTIFIER> "=" | ")" )) + NormalAnnotation() + | + LOOKAHEAD( "@" Name() "(" ) + SingleMemberAnnotation() + | + MarkerAnnotation() +} + +void NormalAnnotation(): +{} +{ + "@" Name() "(" [ MemberValuePairs() ] ")" +} + +void MarkerAnnotation(): +{} +{ + "@" Name() +} + +void SingleMemberAnnotation(): +{} +{ + "@" Name() "(" MemberValue() ")" +} + +void MemberValuePairs(): +{} +{ + MemberValuePair() ( "," MemberValuePair() )* +} + +void MemberValuePair(): +{} +{ + <IDENTIFIER> "=" MemberValue() +} + +void MemberValue(): +{} +{ + Annotation() + | + MemberValueArrayInitializer() + | + ConditionalExpression() +} + +void MemberValueArrayInitializer(): +{} +{ + "{" MemberValue() ( LOOKAHEAD(2) "," MemberValue() )* [ "," ] "}" +} + + +/* Annotation Types. */ + +void AnnotationTypeDeclaration(int modifiers): +{} +{ + "@" "interface" <IDENTIFIER> AnnotationTypeBody() +} + +void AnnotationTypeBody(): +{} +{ + "{" ( AnnotationTypeMemberDeclaration() )* "}" +} + +void AnnotationTypeMemberDeclaration(): +{ + int modifiers; +} +{ + modifiers = Modifiers() + ( + LOOKAHEAD(Type() <IDENTIFIER> "(") + Type() <IDENTIFIER> "(" ")" [ DefaultValue() ] ";" + | + ClassOrInterfaceDeclaration(modifiers) + | + EnumDeclaration(modifiers) + | + AnnotationTypeDeclaration(modifiers) + | + FieldDeclaration(modifiers) + ) + | + ( ";" ) +} + +void DefaultValue(): +{} +{ + "default" MemberValue() +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaCharStream.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaCharStream.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaCharStream.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,550 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. JavaCharStream.java Version 4.0 */ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.java.parser; - -/** - * An implementation of interface CharStream, where the stream is assumed to - * contain only ASCII characters (with java-like unicode escape processing). - */ - -public class JavaCharStream { - public static final boolean staticFlag = false; - - static int hexval(char c) throws java.io.IOException { - switch (c) { - case '0': - return 0; - case '1': - return 1; - case '2': - return 2; - case '3': - return 3; - case '4': - return 4; - case '5': - return 5; - case '6': - return 6; - case '7': - return 7; - case '8': - return 8; - case '9': - return 9; - - case 'a': - case 'A': - return 10; - case 'b': - case 'B': - return 11; - case 'c': - case 'C': - return 12; - case 'd': - case 'D': - return 13; - case 'e': - case 'E': - return 14; - case 'f': - case 'F': - return 15; - } - - throw new java.io.IOException(); // Should never come here - } - - public int bufpos = -1; - int bufsize; - int available; - int tokenBegin; - protected int bufline[]; - protected int bufcolumn[]; - - protected int column = 0; - protected int line = 1; - - protected boolean prevCharIsCR = false; - protected boolean prevCharIsLF = false; - - protected java.io.Reader inputStream; - - protected char[] nextCharBuf; - protected char[] buffer; - protected int maxNextCharInd = 0; - protected int nextCharInd = -1; - protected int inBuf = 0; - protected int tabSize = 8; - - protected void setTabSize(int i) { - tabSize = i; - } - - protected int getTabSize(int i) { - return tabSize; - } - - protected void ExpandBuff(boolean wrapAround) { - char[] newbuffer = new char[bufsize + 2048]; - int newbufline[] = new int[bufsize + 2048]; - int newbufcolumn[] = new int[bufsize + 2048]; - - try { - if (wrapAround) { - System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); - System.arraycopy(buffer, 0, newbuffer, - bufsize - tokenBegin, bufpos); - buffer = newbuffer; - - System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); - System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); - bufline = newbufline; - - System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); - System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); - bufcolumn = newbufcolumn; - - bufpos += (bufsize - tokenBegin); - } else { - System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); - buffer = newbuffer; - - System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); - bufline = newbufline; - - System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); - bufcolumn = newbufcolumn; - - bufpos -= tokenBegin; - } - } - catch (Throwable t) { - throw new Error(t.getMessage()); - } - - available = (bufsize += 2048); - tokenBegin = 0; - } - - protected void FillBuff() throws java.io.IOException { - int i; - if (maxNextCharInd == 4096) - maxNextCharInd = nextCharInd = 0; - - try { - if ((i = inputStream.read(nextCharBuf, maxNextCharInd, - 4096 - maxNextCharInd)) == -1) { - inputStream.close(); - throw new java.io.IOException(); - } else { - maxNextCharInd += i; - } - } - catch (java.io.IOException e) { - if (bufpos != 0) { - --bufpos; - backup(0); - } else { - bufline[bufpos] = line; - bufcolumn[bufpos] = column; - } - throw e; - } - } - - protected char ReadByte() throws java.io.IOException { - if (++nextCharInd >= maxNextCharInd) - FillBuff(); - - return nextCharBuf[nextCharInd]; - } - - public char BeginToken() throws java.io.IOException { - if (inBuf > 0) { - --inBuf; - - if (++bufpos == bufsize) { - bufpos = 0; - } - - tokenBegin = bufpos; - return buffer[bufpos]; - } - - tokenBegin = 0; - bufpos = -1; - - return readChar(); - } - - protected void AdjustBuffSize() { - if (available == bufsize) { - if (tokenBegin > 2048) { - bufpos = 0; - available = tokenBegin; - } else - ExpandBuff(false); - } else if (available > tokenBegin) - available = bufsize; - else if ((tokenBegin - available) < 2048) - ExpandBuff(true); - else - available = tokenBegin; - } - - protected void UpdateLineColumn(char c) { - column++; - - if (prevCharIsLF) { - prevCharIsLF = false; - line += (column = 1); - } else if (prevCharIsCR) { - prevCharIsCR = false; - if (c == '\n') { - prevCharIsLF = true; - } else - line += (column = 1); - } - - switch (c) { - case '\r': - prevCharIsCR = true; - break; - case '\n': - prevCharIsLF = true; - break; - case '\t': - column--; - column += (tabSize - (column % tabSize)); - break; - default: - break; - } - - bufline[bufpos] = line; - bufcolumn[bufpos] = column; - } - - public char readChar() throws java.io.IOException { - if (inBuf > 0) { - --inBuf; - - if (++bufpos == bufsize) - bufpos = 0; - - return buffer[bufpos]; - } - - char c; - - if (++bufpos == available) - AdjustBuffSize(); - - if ((buffer[bufpos] = c = ReadByte()) == '\\') { - UpdateLineColumn(c); - - int backSlashCnt = 1; - - for (; ;) // Read all the backslashes - { - if (++bufpos == available) - AdjustBuffSize(); - - try { - if ((buffer[bufpos] = c = ReadByte()) != '\\') { - UpdateLineColumn(c); - // found a non-backslash char. - if ((c == 'u') && ((backSlashCnt & 1) == 1)) { - if (--bufpos < 0) - bufpos = bufsize - 1; - - break; - } - - backup(backSlashCnt); - return '\\'; - } - } - catch (java.io.IOException e) { - if (backSlashCnt > 1) - backup(backSlashCnt); - - return '\\'; - } - - UpdateLineColumn(c); - backSlashCnt++; - } - - // Here, we have seen an odd number of backslash's followed by a 'u' - try { - while ((c = ReadByte()) == 'u') - ++column; - - buffer[bufpos] = c = (char) (hexval(c) << 12 | - hexval(ReadByte()) << 8 | - hexval(ReadByte()) << 4 | - hexval(ReadByte())); - - column += 4; - } - catch (java.io.IOException e) { - throw new Error("Invalid escape character at line " + line + - " column " + column + "."); - } - - if (backSlashCnt == 1) - return c; - else { - backup(backSlashCnt - 1); - return '\\'; - } - } else { - UpdateLineColumn(c); - return (c); - } - } - - /** - * @return column index - * @see #getEndColumn - * @deprecated - */ - - public int getColumn() { - return bufcolumn[bufpos]; - } - - /** - * @return line type ??? - * @see #getEndLine - * @deprecated - */ - - public int getLine() { - return bufline[bufpos]; - } - - public int getEndColumn() { - return bufcolumn[bufpos]; - } - - public int getEndLine() { - return bufline[bufpos]; - } - - public int getBeginColumn() { - return bufcolumn[tokenBegin]; - } - - public int getBeginLine() { - return bufline[tokenBegin]; - } - - public void backup(int amount) { - - inBuf += amount; - if ((bufpos -= amount) < 0) - bufpos += bufsize; - } - - public JavaCharStream(java.io.Reader dstream, - int startline, int startcolumn, int buffersize) { - inputStream = dstream; - line = startline; - column = startcolumn - 1; - - available = bufsize = buffersize; - buffer = new char[buffersize]; - bufline = new int[buffersize]; - bufcolumn = new int[buffersize]; - nextCharBuf = new char[4096]; - } - - public JavaCharStream(java.io.Reader dstream, - int startline, int startcolumn) { - this(dstream, startline, startcolumn, 4096); - } - - public JavaCharStream(java.io.Reader dstream) { - this(dstream, 1, 1, 4096); - } - - public void ReInit(java.io.Reader dstream, - int startline, int startcolumn, int buffersize) { - inputStream = dstream; - line = startline; - column = startcolumn - 1; - - if (buffer == null || buffersize != buffer.length) { - available = bufsize = buffersize; - buffer = new char[buffersize]; - bufline = new int[buffersize]; - bufcolumn = new int[buffersize]; - nextCharBuf = new char[4096]; - } - prevCharIsLF = prevCharIsCR = false; - tokenBegin = inBuf = maxNextCharInd = 0; - nextCharInd = bufpos = -1; - } - - public void ReInit(java.io.Reader dstream, - int startline, int startcolumn) { - ReInit(dstream, startline, startcolumn, 4096); - } - - public void ReInit(java.io.Reader dstream) { - ReInit(dstream, 1, 1, 4096); - } - - public JavaCharStream(java.io.InputStream dstream, String encoding, int startline, - int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException { - this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); - } - - public JavaCharStream(java.io.InputStream dstream, int startline, - int startcolumn, int buffersize) { - this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096); - } - - public JavaCharStream(java.io.InputStream dstream, String encoding, int startline, - int startcolumn) throws java.io.UnsupportedEncodingException { - this(dstream, encoding, startline, startcolumn, 4096); - } - - public JavaCharStream(java.io.InputStream dstream, int startline, - int startcolumn) { - this(dstream, startline, startcolumn, 4096); - } - - public JavaCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException { - this(dstream, encoding, 1, 1, 4096); - } - - public JavaCharStream(java.io.InputStream dstream) { - this(dstream, 1, 1, 4096); - } - - public void ReInit(java.io.InputStream dstream, String encoding, int startline, - int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException { - ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); - } - - public void ReInit(java.io.InputStream dstream, int startline, - int startcolumn, int buffersize) { - ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); - } - - public void ReInit(java.io.InputStream dstream, String encoding, int startline, - int startcolumn) throws java.io.UnsupportedEncodingException { - ReInit(dstream, encoding, startline, startcolumn, 4096); - } - - public void ReInit(java.io.InputStream dstream, int startline, - int startcolumn) { - ReInit(dstream, startline, startcolumn, 4096); - } - - public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException { - ReInit(dstream, encoding, 1, 1, 4096); - } - - public void ReInit(java.io.InputStream dstream) { - ReInit(dstream, 1, 1, 4096); - } - - public String GetImage() { - if (bufpos >= tokenBegin) - return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); - else - return new String(buffer, tokenBegin, bufsize - tokenBegin) + - new String(buffer, 0, bufpos + 1); - } - - public char[] GetSuffix(int len) { - char[] ret = new char[len]; - - if ((bufpos + 1) >= len) - System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); - else { - System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, - len - bufpos - 1); - System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); - } - - return ret; - } - - public void Done() { - nextCharBuf = null; - buffer = null; - bufline = null; - bufcolumn = null; - } - - /** - * Method to adjust line and column numbers for the start of a token. - * - * @param newLine line number ? - * @param newCol column number ? - */ - public void adjustBeginLineColumn(int newLine, int newCol) { - int start = tokenBegin; - int len; - - if (bufpos >= tokenBegin) { - len = bufpos - tokenBegin + inBuf + 1; - } else { - len = bufsize - tokenBegin + bufpos + 1 + inBuf; - } - - int i = 0, j = 0, k; - int nextColDiff, columnDiff = 0; - - while (i < len && - bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) { - bufline[j] = newLine; - nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j]; - bufcolumn[j] = newCol + columnDiff; - columnDiff = nextColDiff; - i++; - } - - if (i < len) { - bufline[j] = newLine++; - bufcolumn[j] = newCol + columnDiff; - - while (i++ < len) { - if (bufline[j = start % bufsize] != bufline[++start % bufsize]) - bufline[j] = newLine++; - else - bufline[j] = newLine; - } - } - - line = bufline[j]; - column = bufcolumn[j]; - } - -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaCharStream.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaCharStream.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaCharStream.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaCharStream.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,550 @@ +/* Generated By:JavaCC: Do not edit this line. JavaCharStream.java Version 4.0 */ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.java.parser; + +/** + * An implementation of interface CharStream, where the stream is assumed to + * contain only ASCII characters (with java-like unicode escape processing). + */ + +public class JavaCharStream { + public static final boolean staticFlag = false; + + static int hexval(char c) throws java.io.IOException { + switch (c) { + case '0': + return 0; + case '1': + return 1; + case '2': + return 2; + case '3': + return 3; + case '4': + return 4; + case '5': + return 5; + case '6': + return 6; + case '7': + return 7; + case '8': + return 8; + case '9': + return 9; + + case 'a': + case 'A': + return 10; + case 'b': + case 'B': + return 11; + case 'c': + case 'C': + return 12; + case 'd': + case 'D': + return 13; + case 'e': + case 'E': + return 14; + case 'f': + case 'F': + return 15; + } + + throw new java.io.IOException(); // Should never come here + } + + public int bufpos = -1; + int bufsize; + int available; + int tokenBegin; + protected int bufline[]; + protected int bufcolumn[]; + + protected int column = 0; + protected int line = 1; + + protected boolean prevCharIsCR = false; + protected boolean prevCharIsLF = false; + + protected java.io.Reader inputStream; + + protected char[] nextCharBuf; + protected char[] buffer; + protected int maxNextCharInd = 0; + protected int nextCharInd = -1; + protected int inBuf = 0; + protected int tabSize = 8; + + protected void setTabSize(int i) { + tabSize = i; + } + + protected int getTabSize(int i) { + return tabSize; + } + + protected void ExpandBuff(boolean wrapAround) { + char[] newbuffer = new char[bufsize + 2048]; + int newbufline[] = new int[bufsize + 2048]; + int newbufcolumn[] = new int[bufsize + 2048]; + + try { + if (wrapAround) { + System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); + System.arraycopy(buffer, 0, newbuffer, + bufsize - tokenBegin, bufpos); + buffer = newbuffer; + + System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); + System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); + bufline = newbufline; + + System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); + System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); + bufcolumn = newbufcolumn; + + bufpos += (bufsize - tokenBegin); + } else { + System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); + buffer = newbuffer; + + System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); + bufline = newbufline; + + System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); + bufcolumn = newbufcolumn; + + bufpos -= tokenBegin; + } + } + catch (Throwable t) { + throw new Error(t.getMessage()); + } + + available = (bufsize += 2048); + tokenBegin = 0; + } + + protected void FillBuff() throws java.io.IOException { + int i; + if (maxNextCharInd == 4096) + maxNextCharInd = nextCharInd = 0; + + try { + if ((i = inputStream.read(nextCharBuf, maxNextCharInd, + 4096 - maxNextCharInd)) == -1) { + inputStream.close(); + throw new java.io.IOException(); + } else { + maxNextCharInd += i; + } + } + catch (java.io.IOException e) { + if (bufpos != 0) { + --bufpos; + backup(0); + } else { + bufline[bufpos] = line; + bufcolumn[bufpos] = column; + } + throw e; + } + } + + protected char ReadByte() throws java.io.IOException { + if (++nextCharInd >= maxNextCharInd) + FillBuff(); + + return nextCharBuf[nextCharInd]; + } + + public char BeginToken() throws java.io.IOException { + if (inBuf > 0) { + --inBuf; + + if (++bufpos == bufsize) { + bufpos = 0; + } + + tokenBegin = bufpos; + return buffer[bufpos]; + } + + tokenBegin = 0; + bufpos = -1; + + return readChar(); + } + + protected void AdjustBuffSize() { + if (available == bufsize) { + if (tokenBegin > 2048) { + bufpos = 0; + available = tokenBegin; + } else + ExpandBuff(false); + } else if (available > tokenBegin) + available = bufsize; + else if ((tokenBegin - available) < 2048) + ExpandBuff(true); + else + available = tokenBegin; + } + + protected void UpdateLineColumn(char c) { + column++; + + if (prevCharIsLF) { + prevCharIsLF = false; + line += (column = 1); + } else if (prevCharIsCR) { + prevCharIsCR = false; + if (c == '\n') { + prevCharIsLF = true; + } else + line += (column = 1); + } + + switch (c) { + case '\r': + prevCharIsCR = true; + break; + case '\n': + prevCharIsLF = true; + break; + case '\t': + column--; + column += (tabSize - (column % tabSize)); + break; + default: + break; + } + + bufline[bufpos] = line; + bufcolumn[bufpos] = column; + } + + public char readChar() throws java.io.IOException { + if (inBuf > 0) { + --inBuf; + + if (++bufpos == bufsize) + bufpos = 0; + + return buffer[bufpos]; + } + + char c; + + if (++bufpos == available) + AdjustBuffSize(); + + if ((buffer[bufpos] = c = ReadByte()) == '\\') { + UpdateLineColumn(c); + + int backSlashCnt = 1; + + for (; ;) // Read all the backslashes + { + if (++bufpos == available) + AdjustBuffSize(); + + try { + if ((buffer[bufpos] = c = ReadByte()) != '\\') { + UpdateLineColumn(c); + // found a non-backslash char. + if ((c == 'u') && ((backSlashCnt & 1) == 1)) { + if (--bufpos < 0) + bufpos = bufsize - 1; + + break; + } + + backup(backSlashCnt); + return '\\'; + } + } + catch (java.io.IOException e) { + if (backSlashCnt > 1) + backup(backSlashCnt); + + return '\\'; + } + + UpdateLineColumn(c); + backSlashCnt++; + } + + // Here, we have seen an odd number of backslash's followed by a 'u' + try { + while ((c = ReadByte()) == 'u') + ++column; + + buffer[bufpos] = c = (char) (hexval(c) << 12 | + hexval(ReadByte()) << 8 | + hexval(ReadByte()) << 4 | + hexval(ReadByte())); + + column += 4; + } + catch (java.io.IOException e) { + throw new Error("Invalid escape character at line " + line + + " column " + column + "."); + } + + if (backSlashCnt == 1) + return c; + else { + backup(backSlashCnt - 1); + return '\\'; + } + } else { + UpdateLineColumn(c); + return (c); + } + } + + /** + * @return column index + * @see #getEndColumn + * @deprecated + */ + + public int getColumn() { + return bufcolumn[bufpos]; + } + + /** + * @return line type ??? + * @see #getEndLine + * @deprecated + */ + + public int getLine() { + return bufline[bufpos]; + } + + public int getEndColumn() { + return bufcolumn[bufpos]; + } + + public int getEndLine() { + return bufline[bufpos]; + } + + public int getBeginColumn() { + return bufcolumn[tokenBegin]; + } + + public int getBeginLine() { + return bufline[tokenBegin]; + } + + public void backup(int amount) { + + inBuf += amount; + if ((bufpos -= amount) < 0) + bufpos += bufsize; + } + + public JavaCharStream(java.io.Reader dstream, + int startline, int startcolumn, int buffersize) { + inputStream = dstream; + line = startline; + column = startcolumn - 1; + + available = bufsize = buffersize; + buffer = new char[buffersize]; + bufline = new int[buffersize]; + bufcolumn = new int[buffersize]; + nextCharBuf = new char[4096]; + } + + public JavaCharStream(java.io.Reader dstream, + int startline, int startcolumn) { + this(dstream, startline, startcolumn, 4096); + } + + public JavaCharStream(java.io.Reader dstream) { + this(dstream, 1, 1, 4096); + } + + public void ReInit(java.io.Reader dstream, + int startline, int startcolumn, int buffersize) { + inputStream = dstream; + line = startline; + column = startcolumn - 1; + + if (buffer == null || buffersize != buffer.length) { + available = bufsize = buffersize; + buffer = new char[buffersize]; + bufline = new int[buffersize]; + bufcolumn = new int[buffersize]; + nextCharBuf = new char[4096]; + } + prevCharIsLF = prevCharIsCR = false; + tokenBegin = inBuf = maxNextCharInd = 0; + nextCharInd = bufpos = -1; + } + + public void ReInit(java.io.Reader dstream, + int startline, int startcolumn) { + ReInit(dstream, startline, startcolumn, 4096); + } + + public void ReInit(java.io.Reader dstream) { + ReInit(dstream, 1, 1, 4096); + } + + public JavaCharStream(java.io.InputStream dstream, String encoding, int startline, + int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException { + this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); + } + + public JavaCharStream(java.io.InputStream dstream, int startline, + int startcolumn, int buffersize) { + this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096); + } + + public JavaCharStream(java.io.InputStream dstream, String encoding, int startline, + int startcolumn) throws java.io.UnsupportedEncodingException { + this(dstream, encoding, startline, startcolumn, 4096); + } + + public JavaCharStream(java.io.InputStream dstream, int startline, + int startcolumn) { + this(dstream, startline, startcolumn, 4096); + } + + public JavaCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException { + this(dstream, encoding, 1, 1, 4096); + } + + public JavaCharStream(java.io.InputStream dstream) { + this(dstream, 1, 1, 4096); + } + + public void ReInit(java.io.InputStream dstream, String encoding, int startline, + int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException { + ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); + } + + public void ReInit(java.io.InputStream dstream, int startline, + int startcolumn, int buffersize) { + ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); + } + + public void ReInit(java.io.InputStream dstream, String encoding, int startline, + int startcolumn) throws java.io.UnsupportedEncodingException { + ReInit(dstream, encoding, startline, startcolumn, 4096); + } + + public void ReInit(java.io.InputStream dstream, int startline, + int startcolumn) { + ReInit(dstream, startline, startcolumn, 4096); + } + + public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException { + ReInit(dstream, encoding, 1, 1, 4096); + } + + public void ReInit(java.io.InputStream dstream) { + ReInit(dstream, 1, 1, 4096); + } + + public String GetImage() { + if (bufpos >= tokenBegin) + return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); + else + return new String(buffer, tokenBegin, bufsize - tokenBegin) + + new String(buffer, 0, bufpos + 1); + } + + public char[] GetSuffix(int len) { + char[] ret = new char[len]; + + if ((bufpos + 1) >= len) + System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); + else { + System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, + len - bufpos - 1); + System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); + } + + return ret; + } + + public void Done() { + nextCharBuf = null; + buffer = null; + bufline = null; + bufcolumn = null; + } + + /** + * Method to adjust line and column numbers for the start of a token. + * + * @param newLine line number ? + * @param newCol column number ? + */ + public void adjustBeginLineColumn(int newLine, int newCol) { + int start = tokenBegin; + int len; + + if (bufpos >= tokenBegin) { + len = bufpos - tokenBegin + inBuf + 1; + } else { + len = bufsize - tokenBegin + bufpos + 1 + inBuf; + } + + int i = 0, j = 0, k; + int nextColDiff, columnDiff = 0; + + while (i < len && + bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) { + bufline[j] = newLine; + nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j]; + bufcolumn[j] = newCol + columnDiff; + columnDiff = nextColDiff; + i++; + } + + if (i < len) { + bufline[j] = newLine++; + bufcolumn[j] = newCol + columnDiff; + + while (i++ < len) { + if (bufline[j = start % bufsize] != bufline[++start % bufsize]) + bufline[j] = newLine++; + else + bufline[j] = newLine; + } + } + + line = bufline[j]; + column = bufcolumn[j]; + } + +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParser.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParser.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParser.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,10068 +0,0 @@ -/* Generated By:JJTree&JavaCC: Do not edit this line. JavaParser.java */ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.java.parser; - -import java.io.File; -import java.io.FileInputStream; - -/** - * Grammar to parse Java version 1.5 - * - * @author Sreenivasa Viswanadha - Simplified and enhanced for 1.5 - */ -public class JavaParser/*@bgen(jjtree)*/ implements JavaParserTreeConstants, JavaParserConstants {/*@bgen(jjtree)*/ - protected JJTJavaParserState jjtree = new JJTJavaParserState(); - - /** Class to hold modifiers. */ - static public final class ModifierSet { - /* Definitions of the bits in the modifiers field. */ - public static final int PUBLIC = 0x0001; - public static final int PROTECTED = 0x0002; - public static final int PRIVATE = 0x0004; - public static final int ABSTRACT = 0x0008; - public static final int STATIC = 0x0010; - public static final int FINAL = 0x0020; - public static final int SYNCHRONIZED = 0x0040; - public static final int NATIVE = 0x0080; - public static final int TRANSIENT = 0x0100; - public static final int VOLATILE = 0x0200; - public static final int STRICTFP = 0x1000; - - /** - * A set of accessors that indicate whether the specified modifier - * is in the set. - */ - - public boolean isPublic(int modifiers) { - return (modifiers & PUBLIC) != 0; - } - - public boolean isProtected(int modifiers) { - return (modifiers & PROTECTED) != 0; - } - - public boolean isPrivate(int modifiers) { - return (modifiers & PRIVATE) != 0; - } - - public boolean isStatic(int modifiers) { - return (modifiers & STATIC) != 0; - } - - public boolean isAbstract(int modifiers) { - return (modifiers & ABSTRACT) != 0; - } - - public boolean isFinal(int modifiers) { - return (modifiers & FINAL) != 0; - } - - public boolean isNative(int modifiers) { - return (modifiers & NATIVE) != 0; - } - - public boolean isStrictfp(int modifiers) { - return (modifiers & STRICTFP) != 0; - } - - public boolean isSynchronized(int modifiers) { - return (modifiers & SYNCHRONIZED) != 0; - } - - public boolean isTransient(int modifiers) { - return (modifiers & TRANSIENT) != 0; - } - - public boolean isVolatile(int modifiers) { - return (modifiers & VOLATILE) != 0; - } - - /** Removes the given modifier. */ - static int removeModifier(int modifiers, int mod) { - return modifiers & ~mod; - } - } - - public JavaParser(String fileName) { - this(System.in); - try { - ReInit(new FileInputStream(new File(fileName))); - } - catch (Exception e) { - e.printStackTrace(); - } - } - - void jjtreeOpenNodeScope(Node n) { - ((SimpleNode) n).firstToken = getToken(1); - } - - void jjtreeCloseNodeScope(Node n) { - ((SimpleNode) n).lastToken = getToken(0); - } - - public SimpleNode popNode() { - if (jjtree.nodeArity() > 0) // number of child nodes - return (SimpleNode) jjtree.popNode(); - else - return null; - } - - public static void main(String args[]) { - JavaParser parser; - if (args.length == 0) { - System.out.println("Java Parser Version 1.1: Reading from standard input . . ."); - parser = new JavaParser(System.in); - } else if (args.length == 1) { - System.out.println("Java Parser Version 1.1: Reading from file " + args[0] + " . . ."); - try { - parser = new JavaParser(new java.io.FileInputStream(args[0])); - } catch (java.io.FileNotFoundException e) { - System.out.println("Java Parser Version 1.1: File " + args[0] + " not found."); - return; - } - } else { - System.out.println("Java Parser Version 1.1: Usage is one of:"); - System.out.println(" java JavaParser < inputfile"); - System.out.println("OR"); - System.out.println(" java JavaParser inputfile"); - return; - } - try { - parser.CompilationUnit(); - System.out.println("Java Parser Version 1.1: Java program parsed successfully."); - } catch (ParseException e) { - System.out.println(e.getMessage()); - System.out.println("Java Parser Version 1.1: Encountered errors during parse."); - } - } - - final public boolean Line() throws ParseException { - /*@bgen(jjtree) Line */ - SimpleNode jjtn000 = new SimpleNode(JJTLINE); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - int modifiers; - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case 0: - jj_consume_token(0); - jjtree.closeNodeScope(jjtn000, true); - jjtc000 = false; - jjtreeCloseNodeScope(jjtn000); - { - if (true) return true; - } - break; - default: - if (jj_2_1(2147483647)) { - BlockStatement(); - jjtree.closeNodeScope(jjtn000, true); - jjtc000 = false; - jjtreeCloseNodeScope(jjtn000); - { - if (true) return false; - } - } else if (jj_2_2(2147483647)) { - ClassOrInterfaceBodyDeclaration(false); - jjtree.closeNodeScope(jjtn000, true); - jjtc000 = false; - jjtreeCloseNodeScope(jjtn000); - { - if (true) return false; - } - } else if (jj_2_3(2147483647)) { - ClassOrInterfaceBodyDeclaration(false); - jjtree.closeNodeScope(jjtn000, true); - jjtc000 = false; - jjtreeCloseNodeScope(jjtn000); - { - if (true) return false; - } - } else if (jj_2_4(2147483647)) { - Expression(); - jjtree.closeNodeScope(jjtn000, true); - jjtc000 = false; - jjtreeCloseNodeScope(jjtn000); - { - if (true) return false; - } - } else { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IMPORT: - ImportDeclaration(); - jjtree.closeNodeScope(jjtn000, true); - jjtc000 = false; - jjtreeCloseNodeScope(jjtn000); - { - if (true) return false; - } - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - throw new Error("Missing return statement in function"); - } - - /** - * ************************************** - * THE JAVA LANGUAGE GRAMMAR STARTS HERE * - * *************************************** - */ - -/* - * Program structuring syntax follows. - */ - final public void CompilationUnit() throws ParseException { - /*@bgen(jjtree) CompilationUnit */ - SimpleNode jjtn000 = new SimpleNode(JJTCOMPILATIONUNIT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - if (jj_2_5(2147483647)) { - PackageDeclaration(); - } else { - ; - } - label_1: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IMPORT: - ; - break; - default: - break label_1; - } - ImportDeclaration(); - } - label_2: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case ABSTRACT: - case CLASS: - case ENUM: - case FINAL: - case INTERFACE: - case NATIVE: - case PRIVATE: - case PROTECTED: - case PUBLIC: - case STATIC: - case STRICTFP: - case SYNCHRONIZED: - case TRANSIENT: - case VOLATILE: - case SEMICOLON: - case AT: - ; - break; - default: - break label_2; - } - TypeDeclaration(); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case 123: - jj_consume_token(123); - break; - default: - ; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case STUFF_TO_IGNORE: - jj_consume_token(STUFF_TO_IGNORE); - break; - default: - ; - } - jj_consume_token(0); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void PackageDeclaration() throws ParseException { - /*@bgen(jjtree) PackageDeclaration */ - SimpleNode jjtn000 = new SimpleNode(JJTPACKAGEDECLARATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - Modifiers(); - jj_consume_token(PACKAGE); - Name(); - jj_consume_token(SEMICOLON); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void ImportDeclaration() throws ParseException { - /*@bgen(jjtree) ImportDeclaration */ - SimpleNode jjtn000 = new SimpleNode(JJTIMPORTDECLARATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(IMPORT); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case STATIC: - jj_consume_token(STATIC); - break; - default: - ; - } - Name(); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case DOT: - jj_consume_token(DOT); - jj_consume_token(STAR); - break; - default: - ; - } - jj_consume_token(SEMICOLON); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - /* - * Modifiers. We match all modifiers in a single rule to reduce the chances of - * syntax errors for simple modifier mistakes. It will also enable us to give - * better error messages. - */ - final public int Modifiers() throws ParseException { - /*@bgen(jjtree) Modifiers */ - SimpleNode jjtn000 = new SimpleNode(JJTMODIFIERS); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - int modifiers = 0; - try { - label_3: - while (true) { - if (jj_2_6(2)) { - ; - } else { - break label_3; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PUBLIC: - jj_consume_token(PUBLIC); - modifiers |= ModifierSet.PUBLIC; - break; - case STATIC: - jj_consume_token(STATIC); - modifiers |= ModifierSet.STATIC; - break; - case PROTECTED: - jj_consume_token(PROTECTED); - modifiers |= ModifierSet.PROTECTED; - break; - case PRIVATE: - jj_consume_token(PRIVATE); - modifiers |= ModifierSet.PRIVATE; - break; - case FINAL: - jj_consume_token(FINAL); - modifiers |= ModifierSet.FINAL; - break; - case ABSTRACT: - jj_consume_token(ABSTRACT); - modifiers |= ModifierSet.ABSTRACT; - break; - case SYNCHRONIZED: - jj_consume_token(SYNCHRONIZED); - modifiers |= ModifierSet.SYNCHRONIZED; - break; - case NATIVE: - jj_consume_token(NATIVE); - modifiers |= ModifierSet.NATIVE; - break; - case TRANSIENT: - jj_consume_token(TRANSIENT); - modifiers |= ModifierSet.TRANSIENT; - break; - case VOLATILE: - jj_consume_token(VOLATILE); - modifiers |= ModifierSet.VOLATILE; - break; - case STRICTFP: - jj_consume_token(STRICTFP); - modifiers |= ModifierSet.STRICTFP; - break; - case AT: - Annotation(); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } - jjtree.closeNodeScope(jjtn000, true); - jjtc000 = false; - jjtreeCloseNodeScope(jjtn000); - { - if (true) return modifiers; - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - throw new Error("Missing return statement in function"); - } - - /* - * Declaration syntax follows. - */ - final public void TypeDeclaration() throws ParseException { - /*@bgen(jjtree) TypeDeclaration */ - SimpleNode jjtn000 = new SimpleNode(JJTTYPEDECLARATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - int modifiers; - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case SEMICOLON: - jj_consume_token(SEMICOLON); - break; - case ABSTRACT: - case CLASS: - case ENUM: - case FINAL: - case INTERFACE: - case NATIVE: - case PRIVATE: - case PROTECTED: - case PUBLIC: - case STATIC: - case STRICTFP: - case SYNCHRONIZED: - case TRANSIENT: - case VOLATILE: - case AT: - modifiers = Modifiers(); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case CLASS: - case INTERFACE: - ClassOrInterfaceDeclaration(modifiers); - break; - case ENUM: - EnumDeclaration(modifiers); - break; - case AT: - AnnotationTypeDeclaration(modifiers); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void ClassOrInterfaceDeclaration(int modifiers) throws ParseException { - /*@bgen(jjtree) ClassOrInterfaceDeclaration */ - SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACEDECLARATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - boolean isInterface = false; - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case CLASS: - jj_consume_token(CLASS); - break; - case INTERFACE: - jj_consume_token(INTERFACE); - isInterface = true; - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - jj_consume_token(IDENTIFIER); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case LT: - TypeParameters(); - break; - default: - ; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case EXTENDS: - ExtendsList(isInterface); - break; - default: - ; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IMPLEMENTS: - ImplementsList(isInterface); - break; - default: - ; - } - ClassOrInterfaceBody(isInterface); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void ExtendsList(boolean isInterface) throws ParseException { - /*@bgen(jjtree) ExtendsList */ - SimpleNode jjtn000 = new SimpleNode(JJTEXTENDSLIST); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - boolean extendsMoreThanOne = false; - try { - jj_consume_token(EXTENDS); - ClassOrInterfaceType(); - label_4: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - ; - break; - default: - break label_4; - } - jj_consume_token(COMMA); - ClassOrInterfaceType(); - extendsMoreThanOne = true; - } - jjtree.closeNodeScope(jjtn000, true); - jjtc000 = false; - jjtreeCloseNodeScope(jjtn000); - if (extendsMoreThanOne && !isInterface) { - if (true) - throw new ParseException("A class cannot extend more than one other class"); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void ImplementsList(boolean isInterface) throws ParseException { - /*@bgen(jjtree) ImplementsList */ - SimpleNode jjtn000 = new SimpleNode(JJTIMPLEMENTSLIST); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(IMPLEMENTS); - ClassOrInterfaceType(); - label_5: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - ; - break; - default: - break label_5; - } - jj_consume_token(COMMA); - ClassOrInterfaceType(); - } - jjtree.closeNodeScope(jjtn000, true); - jjtc000 = false; - jjtreeCloseNodeScope(jjtn000); - if (isInterface) { - if (true) - throw new ParseException("An interface cannot implement other interfaces"); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void EnumDeclaration(int modifiers) throws ParseException { - /*@bgen(jjtree) EnumDeclaration */ - SimpleNode jjtn000 = new SimpleNode(JJTENUMDECLARATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(ENUM); - jj_consume_token(IDENTIFIER); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IMPLEMENTS: - ImplementsList(false); - break; - default: - ; - } - EnumBody(); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void EnumBody() throws ParseException { - /*@bgen(jjtree) EnumBody */ - SimpleNode jjtn000 = new SimpleNode(JJTENUMBODY); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(LBRACE); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case ABSTRACT: - case FINAL: - case NATIVE: - case PRIVATE: - case PROTECTED: - case PUBLIC: - case STATIC: - case STRICTFP: - case SYNCHRONIZED: - case TRANSIENT: - case VOLATILE: - case IDENTIFIER: - case AT: - EnumConstant(); - label_6: - while (true) { - if (jj_2_7(2)) { - ; - } else { - break label_6; - } - jj_consume_token(COMMA); - EnumConstant(); - } - break; - default: - ; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - jj_consume_token(COMMA); - break; - default: - ; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case SEMICOLON: - jj_consume_token(SEMICOLON); - label_7: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case ABSTRACT: - case BOOLEAN: - case BYTE: - case CHAR: - case CLASS: - case DOUBLE: - case ENUM: - case FINAL: - case FLOAT: - case INT: - case INTERFACE: - case LONG: - case NATIVE: - case PRIVATE: - case PROTECTED: - case PUBLIC: - case SHORT: - case STATIC: - case STRICTFP: - case SYNCHRONIZED: - case TRANSIENT: - case VOID: - case VOLATILE: - case IDENTIFIER: - case LBRACE: - case SEMICOLON: - case AT: - case LT: - ; - break; - default: - break label_7; - } - ClassOrInterfaceBodyDeclaration(false); - } - break; - default: - ; - } - jj_consume_token(RBRACE); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void EnumConstant() throws ParseException { - /*@bgen(jjtree) EnumConstant */ - SimpleNode jjtn000 = new SimpleNode(JJTENUMCONSTANT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - Modifiers(); - jj_consume_token(IDENTIFIER); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case LPAREN: - Arguments(); - break; - default: - ; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case LBRACE: - ClassOrInterfaceBody(false); - break; - default: - ; - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void TypeParameters() throws ParseException { - /*@bgen(jjtree) TypeParameters */ - SimpleNode jjtn000 = new SimpleNode(JJTTYPEPARAMETERS); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(LT); - TypeParameter(); - label_8: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - ; - break; - default: - break label_8; - } - jj_consume_token(COMMA); - TypeParameter(); - } - jj_consume_token(GT); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void TypeParameter() throws ParseException { - /*@bgen(jjtree) TypeParameter */ - SimpleNode jjtn000 = new SimpleNode(JJTTYPEPARAMETER); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(IDENTIFIER); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case EXTENDS: - TypeBound(); - break; - default: - ; - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void TypeBound() throws ParseException { - /*@bgen(jjtree) TypeBound */ - SimpleNode jjtn000 = new SimpleNode(JJTTYPEBOUND); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(EXTENDS); - ClassOrInterfaceType(); - label_9: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case BIT_AND: - ; - break; - default: - break label_9; - } - jj_consume_token(BIT_AND); - ClassOrInterfaceType(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void ClassOrInterfaceBody(boolean isInterface) throws ParseException { - /*@bgen(jjtree) ClassOrInterfaceBody */ - SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACEBODY); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(LBRACE); - label_10: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case ABSTRACT: - case BOOLEAN: - case BYTE: - case CHAR: - case CLASS: - case DOUBLE: - case ENUM: - case FINAL: - case FLOAT: - case INT: - case INTERFACE: - case LONG: - case NATIVE: - case PRIVATE: - case PROTECTED: - case PUBLIC: - case SHORT: - case STATIC: - case STRICTFP: - case SYNCHRONIZED: - case TRANSIENT: - case VOID: - case VOLATILE: - case IDENTIFIER: - case LBRACE: - case SEMICOLON: - case AT: - case LT: - ; - break; - default: - break label_10; - } - ClassOrInterfaceBodyDeclaration(isInterface); - } - jj_consume_token(RBRACE); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void ClassOrInterfaceBodyDeclaration(boolean isInterface) throws ParseException { - /*@bgen(jjtree) ClassOrInterfaceBodyDeclaration */ - SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACEBODYDECLARATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - boolean isNestedInterface = false; - int modifiers; - try { - if (jj_2_10(2)) { - Initializer(); - jjtree.closeNodeScope(jjtn000, true); - jjtc000 = false; - jjtreeCloseNodeScope(jjtn000); - if (isInterface) { - if (true) - throw new ParseException("An interface cannot have initializers"); - } - } else { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case ABSTRACT: - case BOOLEAN: - case BYTE: - case CHAR: - case CLASS: - case DOUBLE: - case ENUM: - case FINAL: - case FLOAT: - case INT: - case INTERFACE: - case LONG: - case NATIVE: - case PRIVATE: - case PROTECTED: - case PUBLIC: - case SHORT: - case STATIC: - case STRICTFP: - case SYNCHRONIZED: - case TRANSIENT: - case VOID: - case VOLATILE: - case IDENTIFIER: - case AT: - case LT: - modifiers = Modifiers(); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case CLASS: - case INTERFACE: - ClassOrInterfaceDeclaration(modifiers); - break; - case ENUM: - EnumDeclaration(modifiers); - break; - default: - if (jj_2_8(2147483647)) { - ConstructorDeclaration(); - } else if (jj_2_9(2147483647)) { - FieldDeclaration(modifiers); - } else { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case BOOLEAN: - case BYTE: - case CHAR: - case DOUBLE: - case FLOAT: - case INT: - case LONG: - case SHORT: - case VOID: - case IDENTIFIER: - case LT: - MethodDeclaration(modifiers); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } - } - break; - case SEMICOLON: - jj_consume_token(SEMICOLON); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void FieldDeclaration(int modifiers) throws ParseException { - /*@bgen(jjtree) FieldDeclaration */ - SimpleNode jjtn000 = new SimpleNode(JJTFIELDDECLARATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - Type(); - VariableDeclarator(); - label_11: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - ; - break; - default: - break label_11; - } - jj_consume_token(COMMA); - VariableDeclarator(); - } - jj_consume_token(SEMICOLON); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void VariableDeclarator() throws ParseException { - /*@bgen(jjtree) VariableDeclarator */ - SimpleNode jjtn000 = new SimpleNode(JJTVARIABLEDECLARATOR); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - VariableDeclaratorId(); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case ASSIGN: - jj_consume_token(ASSIGN); - VariableInitializer(); - break; - default: - ; - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void VariableDeclaratorId() throws ParseException { - /*@bgen(jjtree) VariableDeclaratorId */ - SimpleNode jjtn000 = new SimpleNode(JJTVARIABLEDECLARATORID); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(IDENTIFIER); - label_12: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case LBRACKET: - ; - break; - default: - break label_12; - } - jj_consume_token(LBRACKET); - jj_consume_token(RBRACKET); - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void VariableInitializer() throws ParseException { - /*@bgen(jjtree) VariableInitializer */ - SimpleNode jjtn000 = new SimpleNode(JJTVARIABLEINITIALIZER); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case LBRACE: - ArrayInitializer(); - break; - case BOOLEAN: - case BYTE: - case CHAR: - case DOUBLE: - case FALSE: - case FLOAT: - case INT: - case LONG: - case NEW: - case NULL: - case SHORT: - case SUPER: - case THIS: - case TRUE: - case VOID: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case CHARACTER_LITERAL: - case STRING_LITERAL: - case IDENTIFIER: - case LPAREN: - case BANG: - case TILDE: - case INCR: - case DECR: - case PLUS: - case MINUS: - Expression(); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void ArrayInitializer() throws ParseException { - /*@bgen(jjtree) ArrayInitializer */ - SimpleNode jjtn000 = new SimpleNode(JJTARRAYINITIALIZER); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(LBRACE); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case BOOLEAN: - case BYTE: - case CHAR: - case DOUBLE: - case FALSE: - case FLOAT: - case INT: - case LONG: - case NEW: - case NULL: - case SHORT: - case SUPER: - case THIS: - case TRUE: - case VOID: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case CHARACTER_LITERAL: - case STRING_LITERAL: - case IDENTIFIER: - case LPAREN: - case LBRACE: - case BANG: - case TILDE: - case INCR: - case DECR: - case PLUS: - case MINUS: - VariableInitializer(); - label_13: - while (true) { - if (jj_2_11(2)) { - ; - } else { - break label_13; - } - jj_consume_token(COMMA); - VariableInitializer(); - } - break; - default: - ; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - jj_consume_token(COMMA); - break; - default: - ; - } - jj_consume_token(RBRACE); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void MethodDeclaration(int modifiers) throws ParseException { - /*@bgen(jjtree) MethodDeclaration */ - SimpleNode jjtn000 = new SimpleNode(JJTMETHODDECLARATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case LT: - TypeParameters(); - break; - default: - ; - } - ResultType(); - MethodDeclarator(); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case THROWS: - jj_consume_token(THROWS); - NameList(); - break; - default: - ; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case LBRACE: - Block(); - break; - case SEMICOLON: - jj_consume_token(SEMICOLON); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void MethodDeclarator() throws ParseException { - /*@bgen(jjtree) MethodDeclarator */ - SimpleNode jjtn000 = new SimpleNode(JJTMETHODDECLARATOR); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(IDENTIFIER); - FormalParameters(); - label_14: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case LBRACKET: - ; - break; - default: - break label_14; - } - jj_consume_token(LBRACKET); - jj_consume_token(RBRACKET); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void FormalParameters() throws ParseException { - /*@bgen(jjtree) FormalParameters */ - SimpleNode jjtn000 = new SimpleNode(JJTFORMALPARAMETERS); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(LPAREN); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case ABSTRACT: - case BOOLEAN: - case BYTE: - case CHAR: - case DOUBLE: - case FINAL: - case FLOAT: - case INT: - case LONG: - case NATIVE: - case PRIVATE: - case PROTECTED: - case PUBLIC: - case SHORT: - case STATIC: - case STRICTFP: - case SYNCHRONIZED: - case TRANSIENT: - case VOLATILE: - case IDENTIFIER: - case AT: - FormalParameter(); - label_15: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - ; - break; - default: - break label_15; - } - jj_consume_token(COMMA); - FormalParameter(); - } - break; - default: - ; - } - jj_consume_token(RPAREN); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void FormalParameter() throws ParseException { - /*@bgen(jjtree) FormalParameter */ - SimpleNode jjtn000 = new SimpleNode(JJTFORMALPARAMETER); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - Modifiers(); - Type(); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case ELLIPSIS: - jj_consume_token(ELLIPSIS); - break; - default: - ; - } - VariableDeclaratorId(); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void ConstructorDeclaration() throws ParseException { - /*@bgen(jjtree) ConstructorDeclaration */ - SimpleNode jjtn000 = new SimpleNode(JJTCONSTRUCTORDECLARATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case LT: - TypeParameters(); - break; - default: - ; - } - jj_consume_token(IDENTIFIER); - FormalParameters(); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case THROWS: - jj_consume_token(THROWS); - NameList(); - break; - default: - ; - } - jj_consume_token(LBRACE); - if (jj_2_12(2147483647)) { - ExplicitConstructorInvocation(); - } else { - ; - } - label_16: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case ABSTRACT: - case ASSERT: - case BOOLEAN: - case BREAK: - case BYTE: - case CHAR: - case CLASS: - case CONTINUE: - case DO: - case DOUBLE: - case FALSE: - case FINAL: - case FLOAT: - case FOR: - case IF: - case INT: - case INTERFACE: - case LONG: - case NATIVE: - case NEW: - case NULL: - case PRIVATE: - case PROTECTED: - case PUBLIC: - case RETURN: - case SHORT: - case STATIC: - case STRICTFP: - case SUPER: - case SWITCH: - case SYNCHRONIZED: - case THIS: - case THROW: - case TRANSIENT: - case TRUE: - case TRY: - case VOID: - case VOLATILE: - case WHILE: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case CHARACTER_LITERAL: - case STRING_LITERAL: - case IDENTIFIER: - case LPAREN: - case LBRACE: - case SEMICOLON: - case AT: - case INCR: - case DECR: - ; - break; - default: - break label_16; - } - BlockStatement(); - } - jj_consume_token(RBRACE); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void ExplicitConstructorInvocation() throws ParseException { - /*@bgen(jjtree) ExplicitConstructorInvocation */ - SimpleNode jjtn000 = new SimpleNode(JJTEXPLICITCONSTRUCTORINVOCATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - label_17: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IDENTIFIER: - ; - break; - default: - break label_17; - } - jj_consume_token(IDENTIFIER); - jj_consume_token(DOT); - } - if (jj_2_13(2)) { - jj_consume_token(THIS); - jj_consume_token(DOT); - } else { - ; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case LT: - TypeArguments(); - break; - default: - ; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case THIS: - jj_consume_token(THIS); - break; - case SUPER: - jj_consume_token(SUPER); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - Arguments(); - jj_consume_token(SEMICOLON); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void Initializer() throws ParseException { - /*@bgen(jjtree) Initializer */ - SimpleNode jjtn000 = new SimpleNode(JJTINITIALIZER); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case STATIC: - jj_consume_token(STATIC); - break; - default: - ; - } - Block(); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - /* - * Type, name and expression syntax follows. - */ - final public void Type() throws ParseException { - /*@bgen(jjtree) Type */ - SimpleNode jjtn000 = new SimpleNode(JJTTYPE); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - if (jj_2_14(2)) { - ReferenceType(); - } else { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case BOOLEAN: - case BYTE: - case CHAR: - case DOUBLE: - case FLOAT: - case INT: - case LONG: - case SHORT: - PrimitiveType(); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void ReferenceType() throws ParseException { - /*@bgen(jjtree) ReferenceType */ - SimpleNode jjtn000 = new SimpleNode(JJTREFERENCETYPE); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case BOOLEAN: - case BYTE: - case CHAR: - case DOUBLE: - case FLOAT: - case INT: - case LONG: - case SHORT: - PrimitiveType(); - label_18: - while (true) { - jj_consume_token(LBRACKET); - jj_consume_token(RBRACKET); - if (jj_2_15(2)) { - ; - } else { - break label_18; - } - } - break; - case IDENTIFIER: - ClassOrInterfaceType(); - label_19: - while (true) { - if (jj_2_16(2)) { - ; - } else { - break label_19; - } - jj_consume_token(LBRACKET); - jj_consume_token(RBRACKET); - } - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void ClassOrInterfaceType() throws ParseException { - /*@bgen(jjtree) ClassOrInterfaceType */ - SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACETYPE); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(IDENTIFIER); - if (jj_2_17(2)) { - TypeArguments(); - } else { - ; - } - label_20: - while (true) { - if (jj_2_18(2)) { - ; - } else { - break label_20; - } - jj_consume_token(DOT); - jj_consume_token(IDENTIFIER); - if (jj_2_19(2)) { - TypeArguments(); - } else { - ; - } - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void TypeArguments() throws ParseException { - /*@bgen(jjtree) TypeArguments */ - SimpleNode jjtn000 = new SimpleNode(JJTTYPEARGUMENTS); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(LT); - TypeArgument(); - label_21: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - ; - break; - default: - break label_21; - } - jj_consume_token(COMMA); - TypeArgument(); - } - jj_consume_token(GT); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void TypeArgument() throws ParseException { - /*@bgen(jjtree) TypeArgument */ - SimpleNode jjtn000 = new SimpleNode(JJTTYPEARGUMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case BOOLEAN: - case BYTE: - case CHAR: - case DOUBLE: - case FLOAT: - case INT: - case LONG: - case SHORT: - case IDENTIFIER: - ReferenceType(); - break; - case HOOK: - jj_consume_token(HOOK); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case EXTENDS: - case SUPER: - WildcardBounds(); - break; - default: - ; - } - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void WildcardBounds() throws ParseException { - /*@bgen(jjtree) WildcardBounds */ - SimpleNode jjtn000 = new SimpleNode(JJTWILDCARDBOUNDS); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case EXTENDS: - jj_consume_token(EXTENDS); - ReferenceType(); - break; - case SUPER: - jj_consume_token(SUPER); - ReferenceType(); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void PrimitiveType() throws ParseException { - /*@bgen(jjtree) PrimitiveType */ - SimpleNode jjtn000 = new SimpleNode(JJTPRIMITIVETYPE); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case BOOLEAN: - jj_consume_token(BOOLEAN); - break; - case CHAR: - jj_consume_token(CHAR); - break; - case BYTE: - jj_consume_token(BYTE); - break; - case SHORT: - jj_consume_token(SHORT); - break; - case INT: - jj_consume_token(INT); - break; - case LONG: - jj_consume_token(LONG); - break; - case FLOAT: - jj_consume_token(FLOAT); - break; - case DOUBLE: - jj_consume_token(DOUBLE); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void ResultType() throws ParseException { - /*@bgen(jjtree) ResultType */ - SimpleNode jjtn000 = new SimpleNode(JJTRESULTTYPE); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case VOID: - jj_consume_token(VOID); - break; - case BOOLEAN: - case BYTE: - case CHAR: - case DOUBLE: - case FLOAT: - case INT: - case LONG: - case SHORT: - case IDENTIFIER: - Type(); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void Name() throws ParseException { - /*@bgen(jjtree) Name */ - SimpleNode jjtn000 = new SimpleNode(JJTNAME); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(IDENTIFIER); - label_22: - while (true) { - if (jj_2_20(2)) { - ; - } else { - break label_22; - } - jj_consume_token(DOT); - jj_consume_token(IDENTIFIER); - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void NameList() throws ParseException { - /*@bgen(jjtree) NameList */ - SimpleNode jjtn000 = new SimpleNode(JJTNAMELIST); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - Name(); - label_23: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - ; - break; - default: - break label_23; - } - jj_consume_token(COMMA); - Name(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - /* - * Expression syntax follows. - */ - final public void Expression() throws ParseException { - /*@bgen(jjtree) Expression */ - SimpleNode jjtn000 = new SimpleNode(JJTEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - ConditionalExpression(); - if (jj_2_21(2)) { - AssignmentOperator(); - Expression(); - } else { - ; - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void AssignmentOperator() throws ParseException { - /*@bgen(jjtree) AssignmentOperator */ - SimpleNode jjtn000 = new SimpleNode(JJTASSIGNMENTOPERATOR); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case ASSIGN: - jj_consume_token(ASSIGN); - break; - case STARASSIGN: - jj_consume_token(STARASSIGN); - break; - case SLASHASSIGN: - jj_consume_token(SLASHASSIGN); - break; - case REMASSIGN: - jj_consume_token(REMASSIGN); - break; - case PLUSASSIGN: - jj_consume_token(PLUSASSIGN); - break; - case MINUSASSIGN: - jj_consume_token(MINUSASSIGN); - break; - case LSHIFTASSIGN: - jj_consume_token(LSHIFTASSIGN); - break; - case RSIGNEDSHIFTASSIGN: - jj_consume_token(RSIGNEDSHIFTASSIGN); - break; - case RUNSIGNEDSHIFTASSIGN: - jj_consume_token(RUNSIGNEDSHIFTASSIGN); - break; - case ANDASSIGN: - jj_consume_token(ANDASSIGN); - break; - case XORASSIGN: - jj_consume_token(XORASSIGN); - break; - case ORASSIGN: - jj_consume_token(ORASSIGN); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void AssignmentExpression() throws ParseException { - /*@bgen(jjtree) AssignmentExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTASSIGNMENTEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - PrimaryExpression(); - AssignmentOperator(); - Expression(); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void ConditionalExpression() throws ParseException { - /*@bgen(jjtree) ConditionalExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTCONDITIONALEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - ConditionalOrExpression(); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case HOOK: - jj_consume_token(HOOK); - Expression(); - jj_consume_token(COLON); - Expression(); - break; - default: - ; - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void ConditionalOrExpression() throws ParseException { - /*@bgen(jjtree) ConditionalOrExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTCONDITIONALOREXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - ConditionalAndExpression(); - label_24: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case SC_OR: - ; - break; - default: - break label_24; - } - jj_consume_token(SC_OR); - ConditionalAndExpression(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void ConditionalAndExpression() throws ParseException { - /*@bgen(jjtree) ConditionalAndExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTCONDITIONALANDEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - InclusiveOrExpression(); - label_25: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case SC_AND: - ; - break; - default: - break label_25; - } - jj_consume_token(SC_AND); - InclusiveOrExpression(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void InclusiveOrExpression() throws ParseException { - /*@bgen(jjtree) InclusiveOrExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTINCLUSIVEOREXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - ExclusiveOrExpression(); - label_26: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case BIT_OR: - ; - break; - default: - break label_26; - } - jj_consume_token(BIT_OR); - ExclusiveOrExpression(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void ExclusiveOrExpression() throws ParseException { - /*@bgen(jjtree) ExclusiveOrExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTEXCLUSIVEOREXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - AndExpression(); - label_27: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case XOR: - ; - break; - default: - break label_27; - } - jj_consume_token(XOR); - AndExpression(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void AndExpression() throws ParseException { - /*@bgen(jjtree) AndExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTANDEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - EqualityExpression(); - label_28: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case BIT_AND: - ; - break; - default: - break label_28; - } - jj_consume_token(BIT_AND); - EqualityExpression(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void EqualityExpression() throws ParseException { - /*@bgen(jjtree) EqualityExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTEQUALITYEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - InstanceOfExpression(); - label_29: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case EQ: - case NE: - ; - break; - default: - break label_29; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case EQ: - jj_consume_token(EQ); - break; - case NE: - jj_consume_token(NE); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - InstanceOfExpression(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void InstanceOfExpression() throws ParseException { - /*@bgen(jjtree) InstanceOfExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTINSTANCEOFEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - RelationalExpression(); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INSTANCEOF: - jj_consume_token(INSTANCEOF); - Type(); - break; - default: - ; - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void RelationalExpression() throws ParseException { - /*@bgen(jjtree) RelationalExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTRELATIONALEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - ShiftExpression(); - label_30: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case LT: - case LE: - case GE: - case GT: - ; - break; - default: - break label_30; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case LT: - jj_consume_token(LT); - break; - case GT: - jj_consume_token(GT); - break; - case LE: - jj_consume_token(LE); - break; - case GE: - jj_consume_token(GE); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - ShiftExpression(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void ShiftExpression() throws ParseException { - /*@bgen(jjtree) ShiftExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTSHIFTEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - AdditiveExpression(); - label_31: - while (true) { - if (jj_2_22(1)) { - ; - } else { - break label_31; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case LSHIFT: - jj_consume_token(LSHIFT); - break; - default: - if (jj_2_23(1)) { - RSIGNEDSHIFT(); - } else if (jj_2_24(1)) { - RUNSIGNEDSHIFT(); - } else { - jj_consume_token(-1); - throw new ParseException(); - } - } - AdditiveExpression(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void AdditiveExpression() throws ParseException { - /*@bgen(jjtree) AdditiveExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTADDITIVEEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - MultiplicativeExpression(); - label_32: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case MINUS: - ; - break; - default: - break label_32; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - jj_consume_token(PLUS); - break; - case MINUS: - jj_consume_token(MINUS); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - MultiplicativeExpression(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void MultiplicativeExpression() throws ParseException { - /*@bgen(jjtree) MultiplicativeExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTMULTIPLICATIVEEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - UnaryExpression(); - label_33: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case STAR: - case SLASH: - case REM: - ; - break; - default: - break label_33; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case STAR: - jj_consume_token(STAR); - break; - case SLASH: - jj_consume_token(SLASH); - break; - case REM: - jj_consume_token(REM); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - UnaryExpression(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void UnaryExpression() throws ParseException { - /*@bgen(jjtree) UnaryExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTUNARYEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case MINUS: - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - jj_consume_token(PLUS); - break; - case MINUS: - jj_consume_token(MINUS); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - UnaryExpression(); - break; - case INCR: - PreIncrementExpression(); - break; - case DECR: - PreDecrementExpression(); - break; - case BOOLEAN: - case BYTE: - case CHAR: - case DOUBLE: - case FALSE: - case FLOAT: - case INT: - case LONG: - case NEW: - case NULL: - case SHORT: - case SUPER: - case THIS: - case TRUE: - case VOID: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case CHARACTER_LITERAL: - case STRING_LITERAL: - case IDENTIFIER: - case LPAREN: - case BANG: - case TILDE: - UnaryExpressionNotPlusMinus(); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void PreIncrementExpression() throws ParseException { - /*@bgen(jjtree) PreIncrementExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTPREINCREMENTEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(INCR); - PrimaryExpression(); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void PreDecrementExpression() throws ParseException { - /*@bgen(jjtree) PreDecrementExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTPREDECREMENTEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(DECR); - PrimaryExpression(); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void UnaryExpressionNotPlusMinus() throws ParseException { - /*@bgen(jjtree) UnaryExpressionNotPlusMinus */ - SimpleNode jjtn000 = new SimpleNode(JJTUNARYEXPRESSIONNOTPLUSMINUS); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case BANG: - case TILDE: - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case TILDE: - jj_consume_token(TILDE); - break; - case BANG: - jj_consume_token(BANG); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - UnaryExpression(); - break; - default: - if (jj_2_25(2147483647)) { - CastExpression(); - } else { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case BOOLEAN: - case BYTE: - case CHAR: - case DOUBLE: - case FALSE: - case FLOAT: - case INT: - case LONG: - case NEW: - case NULL: - case SHORT: - case SUPER: - case THIS: - case TRUE: - case VOID: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case CHARACTER_LITERAL: - case STRING_LITERAL: - case IDENTIFIER: - case LPAREN: - PostfixExpression(); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - -// This production is to determine lookahead only. The LOOKAHEAD specifications -// below are not used, but they are there just to indicate that we know about - - // this. - final public void CastLookahead() throws ParseException { - /*@bgen(jjtree) CastLookahead */ - SimpleNode jjtn000 = new SimpleNode(JJTCASTLOOKAHEAD); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - if (jj_2_26(2)) { - jj_consume_token(LPAREN); - PrimitiveType(); - } else if (jj_2_27(2147483647)) { - jj_consume_token(LPAREN); - Type(); - jj_consume_token(LBRACKET); - jj_consume_token(RBRACKET); - } else { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case LPAREN: - jj_consume_token(LPAREN); - Type(); - jj_consume_token(RPAREN); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case TILDE: - jj_consume_token(TILDE); - break; - case BANG: - jj_consume_token(BANG); - break; - case LPAREN: - jj_consume_token(LPAREN); - break; - case IDENTIFIER: - jj_consume_token(IDENTIFIER); - break; - case THIS: - jj_consume_token(THIS); - break; - case SUPER: - jj_consume_token(SUPER); - break; - case NEW: - jj_consume_token(NEW); - break; - case FALSE: - case NULL: - case TRUE: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case CHARACTER_LITERAL: - case STRING_LITERAL: - Literal(); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void PostfixExpression() throws ParseException { - /*@bgen(jjtree) PostfixExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTPOSTFIXEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - PrimaryExpression(); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INCR: - case DECR: - PostfixOperator(); - break; - default: - ; - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void PostfixOperator() throws ParseException { - /*@bgen(jjtree) PostfixOperator */ - SimpleNode jjtn000 = new SimpleNode(JJTPOSTFIXOPERATOR); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INCR: - jj_consume_token(INCR); - break; - case DECR: - jj_consume_token(DECR); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void CastExpression() throws ParseException { - /*@bgen(jjtree) CastExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTCASTEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - if (jj_2_28(2147483647)) { - jj_consume_token(LPAREN); - Type(); - jj_consume_token(RPAREN); - UnaryExpression(); - } else { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case LPAREN: - jj_consume_token(LPAREN); - Type(); - jj_consume_token(RPAREN); - UnaryExpressionNotPlusMinus(); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void PrimaryExpression() throws ParseException { - /*@bgen(jjtree) PrimaryExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTPRIMARYEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - PrimaryPrefix(); - label_34: - while (true) { - if (jj_2_29(2)) { - ; - } else { - break label_34; - } - PrimarySuffix(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void MemberSelector() throws ParseException { - /*@bgen(jjtree) MemberSelector */ - SimpleNode jjtn000 = new SimpleNode(JJTMEMBERSELECTOR); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(DOT); - TypeArguments(); - jj_consume_token(IDENTIFIER); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void PrimaryPrefix() throws ParseException { - /*@bgen(jjtree) PrimaryPrefix */ - SimpleNode jjtn000 = new SimpleNode(JJTPRIMARYPREFIX); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case FALSE: - case NULL: - case TRUE: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case CHARACTER_LITERAL: - case STRING_LITERAL: - Literal(); - break; - default: - if (jj_2_30(2147483647)) { - label_35: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IDENTIFIER: - ; - break; - default: - break label_35; - } - jj_consume_token(IDENTIFIER); - jj_consume_token(DOT); - } - jj_consume_token(THIS); - } else { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case SUPER: - jj_consume_token(SUPER); - jj_consume_token(DOT); - jj_consume_token(IDENTIFIER); - break; - case LPAREN: - jj_consume_token(LPAREN); - Expression(); - jj_consume_token(RPAREN); - break; - case NEW: - AllocationExpression(); - break; - default: - if (jj_2_31(2147483647)) { - ResultType(); - jj_consume_token(DOT); - jj_consume_token(CLASS); - } else { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IDENTIFIER: - Name(); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } - } - } - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void PrimarySuffix() throws ParseException { - /*@bgen(jjtree) PrimarySuffix */ - SimpleNode jjtn000 = new SimpleNode(JJTPRIMARYSUFFIX); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - if (jj_2_32(2147483647)) { - jj_consume_token(DOT); - jj_consume_token(SUPER); - } else if (jj_2_33(2147483647)) { - jj_consume_token(DOT); - jj_consume_token(THIS); - } else if (jj_2_34(2)) { - jj_consume_token(DOT); - AllocationExpression(); - } else if (jj_2_35(3)) { - MemberSelector(); - } else { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case LBRACKET: - jj_consume_token(LBRACKET); - Expression(); - jj_consume_token(RBRACKET); - break; - case DOT: - jj_consume_token(DOT); - jj_consume_token(IDENTIFIER); - break; - case LPAREN: - Arguments(); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void Literal() throws ParseException { - /*@bgen(jjtree) Literal */ - SimpleNode jjtn000 = new SimpleNode(JJTLITERAL); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTEGER_LITERAL: - jj_consume_token(INTEGER_LITERAL); - break; - case FLOATING_POINT_LITERAL: - jj_consume_token(FLOATING_POINT_LITERAL); - break; - case CHARACTER_LITERAL: - jj_consume_token(CHARACTER_LITERAL); - break; - case STRING_LITERAL: - jj_consume_token(STRING_LITERAL); - break; - case FALSE: - case TRUE: - BooleanLiteral(); - break; - case NULL: - NullLiteral(); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void BooleanLiteral() throws ParseException { - /*@bgen(jjtree) BooleanLiteral */ - SimpleNode jjtn000 = new SimpleNode(JJTBOOLEANLITERAL); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case TRUE: - jj_consume_token(TRUE); - break; - case FALSE: - jj_consume_token(FALSE); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void NullLiteral() throws ParseException { - /*@bgen(jjtree) NullLiteral */ - SimpleNode jjtn000 = new SimpleNode(JJTNULLLITERAL); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(NULL); - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void Arguments() throws ParseException { - /*@bgen(jjtree) Arguments */ - SimpleNode jjtn000 = new SimpleNode(JJTARGUMENTS); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(LPAREN); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case BOOLEAN: - case BYTE: - case CHAR: - case DOUBLE: - case FALSE: - case FLOAT: - case INT: - case LONG: - case NEW: - case NULL: - case SHORT: - case SUPER: - case THIS: - case TRUE: - case VOID: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case CHARACTER_LITERAL: - case STRING_LITERAL: - case IDENTIFIER: - case LPAREN: - case BANG: - case TILDE: - case INCR: - case DECR: - case PLUS: - case MINUS: - ArgumentList(); - break; - default: - ; - } - jj_consume_token(RPAREN); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void ArgumentList() throws ParseException { - /*@bgen(jjtree) ArgumentList */ - SimpleNode jjtn000 = new SimpleNode(JJTARGUMENTLIST); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - Expression(); - label_36: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - ; - break; - default: - break label_36; - } - jj_consume_token(COMMA); - Expression(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void AllocationExpression() throws ParseException { - /*@bgen(jjtree) AllocationExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTALLOCATIONEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - if (jj_2_36(2)) { - jj_consume_token(NEW); - PrimitiveType(); - ArrayDimsAndInits(); - } else { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case NEW: - jj_consume_token(NEW); - ClassOrInterfaceType(); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case LT: - TypeArguments(); - break; - default: - ; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case LBRACKET: - ArrayDimsAndInits(); - break; - case LPAREN: - Arguments(); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case LBRACE: - ClassOrInterfaceBody(false); - break; - default: - ; - } - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - /* - * The third LOOKAHEAD specification below is to parse to PrimarySuffix - * if there is an expression between the "[...]". - */ - final public void ArrayDimsAndInits() throws ParseException { - /*@bgen(jjtree) ArrayDimsAndInits */ - SimpleNode jjtn000 = new SimpleNode(JJTARRAYDIMSANDINITS); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - if (jj_2_39(2)) { - label_37: - while (true) { - jj_consume_token(LBRACKET); - Expression(); - jj_consume_token(RBRACKET); - if (jj_2_37(2)) { - ; - } else { - break label_37; - } - } - label_38: - while (true) { - if (jj_2_38(2)) { - ; - } else { - break label_38; - } - jj_consume_token(LBRACKET); - jj_consume_token(RBRACKET); - } - } else { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case LBRACKET: - label_39: - while (true) { - jj_consume_token(LBRACKET); - jj_consume_token(RBRACKET); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case LBRACKET: - ; - break; - default: - break label_39; - } - } - ArrayInitializer(); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - /* - * Statement syntax follows. - */ - final public void Statement() throws ParseException { - /*@bgen(jjtree) Statement */ - SimpleNode jjtn000 = new SimpleNode(JJTSTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - if (jj_2_40(2)) { - LabeledStatement(); - } else { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case ASSERT: - AssertStatement(); - break; - case LBRACE: - Block(); - break; - case SEMICOLON: - EmptyStatement(); - break; - case BOOLEAN: - case BYTE: - case CHAR: - case DOUBLE: - case FALSE: - case FLOAT: - case INT: - case LONG: - case NEW: - case NULL: - case SHORT: - case SUPER: - case THIS: - case TRUE: - case VOID: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case CHARACTER_LITERAL: - case STRING_LITERAL: - case IDENTIFIER: - case LPAREN: - case INCR: - case DECR: - StatementExpression(); - jj_consume_token(SEMICOLON); - break; - case SWITCH: - SwitchStatement(); - break; - case IF: - IfStatement(); - break; - case WHILE: - WhileStatement(); - break; - case DO: - DoStatement(); - break; - case FOR: - ForStatement(); - break; - case BREAK: - BreakStatement(); - break; - case CONTINUE: - ContinueStatement(); - break; - case RETURN: - ReturnStatement(); - break; - case THROW: - ThrowStatement(); - break; - case SYNCHRONIZED: - SynchronizedStatement(); - break; - case TRY: - TryStatement(); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void AssertStatement() throws ParseException { - /*@bgen(jjtree) AssertStatement */ - SimpleNode jjtn000 = new SimpleNode(JJTASSERTSTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(ASSERT); - Expression(); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COLON: - jj_consume_token(COLON); - Expression(); - break; - default: - ; - } - jj_consume_token(SEMICOLON); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void LabeledStatement() throws ParseException { - /*@bgen(jjtree) LabeledStatement */ - SimpleNode jjtn000 = new SimpleNode(JJTLABELEDSTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(IDENTIFIER); - jj_consume_token(COLON); - Statement(); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void Block() throws ParseException { - /*@bgen(jjtree) Block */ - SimpleNode jjtn000 = new SimpleNode(JJTBLOCK); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(LBRACE); - label_40: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case ABSTRACT: - case ASSERT: - case BOOLEAN: - case BREAK: - case BYTE: - case CHAR: - case CLASS: - case CONTINUE: - case DO: - case DOUBLE: - case FALSE: - case FINAL: - case FLOAT: - case FOR: - case IF: - case INT: - case INTERFACE: - case LONG: - case NATIVE: - case NEW: - case NULL: - case PRIVATE: - case PROTECTED: - case PUBLIC: - case RETURN: - case SHORT: - case STATIC: - case STRICTFP: - case SUPER: - case SWITCH: - case SYNCHRONIZED: - case THIS: - case THROW: - case TRANSIENT: - case TRUE: - case TRY: - case VOID: - case VOLATILE: - case WHILE: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case CHARACTER_LITERAL: - case STRING_LITERAL: - case IDENTIFIER: - case LPAREN: - case LBRACE: - case SEMICOLON: - case AT: - case INCR: - case DECR: - ; - break; - default: - break label_40; - } - BlockStatement(); - } - jj_consume_token(RBRACE); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void BlockStatement() throws ParseException { - /*@bgen(jjtree) BlockStatement */ - SimpleNode jjtn000 = new SimpleNode(JJTBLOCKSTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - if (jj_2_41(2147483647)) { - LocalVariableDeclaration(); - jj_consume_token(SEMICOLON); - } else { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case ASSERT: - case BOOLEAN: - case BREAK: - case BYTE: - case CHAR: - case CONTINUE: - case DO: - case DOUBLE: - case FALSE: - case FLOAT: - case FOR: - case IF: - case INT: - case LONG: - case NEW: - case NULL: - case RETURN: - case SHORT: - case SUPER: - case SWITCH: - case SYNCHRONIZED: - case THIS: - case THROW: - case TRUE: - case TRY: - case VOID: - case WHILE: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case CHARACTER_LITERAL: - case STRING_LITERAL: - case IDENTIFIER: - case LPAREN: - case LBRACE: - case SEMICOLON: - case INCR: - case DECR: - Statement(); - break; - case CLASS: - case INTERFACE: - ClassOrInterfaceDeclaration(0); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void LocalVariableDeclaration() throws ParseException { - /*@bgen(jjtree) LocalVariableDeclaration */ - SimpleNode jjtn000 = new SimpleNode(JJTLOCALVARIABLEDECLARATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - Modifiers(); - Type(); - VariableDeclarator(); - label_41: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - ; - break; - default: - break label_41; - } - jj_consume_token(COMMA); - VariableDeclarator(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void EmptyStatement() throws ParseException { - /*@bgen(jjtree) EmptyStatement */ - SimpleNode jjtn000 = new SimpleNode(JJTEMPTYSTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(SEMICOLON); - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void StatementExpression() throws ParseException { - /*@bgen(jjtree) StatementExpression */ - SimpleNode jjtn000 = new SimpleNode(JJTSTATEMENTEXPRESSION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INCR: - PreIncrementExpression(); - break; - case DECR: - PreDecrementExpression(); - break; - default: - if (jj_2_42(2147483647)) { - AssignmentExpression(); - } else { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case BOOLEAN: - case BYTE: - case CHAR: - case DOUBLE: - case FALSE: - case FLOAT: - case INT: - case LONG: - case NEW: - case NULL: - case SHORT: - case SUPER: - case THIS: - case TRUE: - case VOID: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case CHARACTER_LITERAL: - case STRING_LITERAL: - case IDENTIFIER: - case LPAREN: - PostfixExpression(); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void SwitchStatement() throws ParseException { - /*@bgen(jjtree) SwitchStatement */ - SimpleNode jjtn000 = new SimpleNode(JJTSWITCHSTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(SWITCH); - jj_consume_token(LPAREN); - Expression(); - jj_consume_token(RPAREN); - jj_consume_token(LBRACE); - label_42: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case CASE: - case _DEFAULT: - ; - break; - default: - break label_42; - } - SwitchLabel(); - label_43: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case ABSTRACT: - case ASSERT: - case BOOLEAN: - case BREAK: - case BYTE: - case CHAR: - case CLASS: - case CONTINUE: - case DO: - case DOUBLE: - case FALSE: - case FINAL: - case FLOAT: - case FOR: - case IF: - case INT: - case INTERFACE: - case LONG: - case NATIVE: - case NEW: - case NULL: - case PRIVATE: - case PROTECTED: - case PUBLIC: - case RETURN: - case SHORT: - case STATIC: - case STRICTFP: - case SUPER: - case SWITCH: - case SYNCHRONIZED: - case THIS: - case THROW: - case TRANSIENT: - case TRUE: - case TRY: - case VOID: - case VOLATILE: - case WHILE: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case CHARACTER_LITERAL: - case STRING_LITERAL: - case IDENTIFIER: - case LPAREN: - case LBRACE: - case SEMICOLON: - case AT: - case INCR: - case DECR: - ; - break; - default: - break label_43; - } - BlockStatement(); - } - } - jj_consume_token(RBRACE); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void SwitchLabel() throws ParseException { - /*@bgen(jjtree) SwitchLabel */ - SimpleNode jjtn000 = new SimpleNode(JJTSWITCHLABEL); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case CASE: - jj_consume_token(CASE); - Expression(); - jj_consume_token(COLON); - break; - case _DEFAULT: - jj_consume_token(_DEFAULT); - jj_consume_token(COLON); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void IfStatement() throws ParseException { - /*@bgen(jjtree) IfStatement */ - SimpleNode jjtn000 = new SimpleNode(JJTIFSTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(IF); - jj_consume_token(LPAREN); - Expression(); - jj_consume_token(RPAREN); - Statement(); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case ELSE: - jj_consume_token(ELSE); - Statement(); - break; - default: - ; - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void WhileStatement() throws ParseException { - /*@bgen(jjtree) WhileStatement */ - SimpleNode jjtn000 = new SimpleNode(JJTWHILESTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(WHILE); - jj_consume_token(LPAREN); - Expression(); - jj_consume_token(RPAREN); - Statement(); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void DoStatement() throws ParseException { - /*@bgen(jjtree) DoStatement */ - SimpleNode jjtn000 = new SimpleNode(JJTDOSTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(DO); - Statement(); - jj_consume_token(WHILE); - jj_consume_token(LPAREN); - Expression(); - jj_consume_token(RPAREN); - jj_consume_token(SEMICOLON); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void ForStatement() throws ParseException { - /*@bgen(jjtree) ForStatement */ - SimpleNode jjtn000 = new SimpleNode(JJTFORSTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(FOR); - jj_consume_token(LPAREN); - if (jj_2_43(2147483647)) { - Modifiers(); - Type(); - jj_consume_token(IDENTIFIER); - jj_consume_token(COLON); - Expression(); - } else { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case ABSTRACT: - case BOOLEAN: - case BYTE: - case CHAR: - case DOUBLE: - case FALSE: - case FINAL: - case FLOAT: - case INT: - case LONG: - case NATIVE: - case NEW: - case NULL: - case PRIVATE: - case PROTECTED: - case PUBLIC: - case SHORT: - case STATIC: - case STRICTFP: - case SUPER: - case SYNCHRONIZED: - case THIS: - case TRANSIENT: - case TRUE: - case VOID: - case VOLATILE: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case CHARACTER_LITERAL: - case STRING_LITERAL: - case IDENTIFIER: - case LPAREN: - case SEMICOLON: - case AT: - case INCR: - case DECR: - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case ABSTRACT: - case BOOLEAN: - case BYTE: - case CHAR: - case DOUBLE: - case FALSE: - case FINAL: - case FLOAT: - case INT: - case LONG: - case NATIVE: - case NEW: - case NULL: - case PRIVATE: - case PROTECTED: - case PUBLIC: - case SHORT: - case STATIC: - case STRICTFP: - case SUPER: - case SYNCHRONIZED: - case THIS: - case TRANSIENT: - case TRUE: - case VOID: - case VOLATILE: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case CHARACTER_LITERAL: - case STRING_LITERAL: - case IDENTIFIER: - case LPAREN: - case AT: - case INCR: - case DECR: - ForInit(); - break; - default: - ; - } - jj_consume_token(SEMICOLON); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case BOOLEAN: - case BYTE: - case CHAR: - case DOUBLE: - case FALSE: - case FLOAT: - case INT: - case LONG: - case NEW: - case NULL: - case SHORT: - case SUPER: - case THIS: - case TRUE: - case VOID: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case CHARACTER_LITERAL: - case STRING_LITERAL: - case IDENTIFIER: - case LPAREN: - case BANG: - case TILDE: - case INCR: - case DECR: - case PLUS: - case MINUS: - Expression(); - break; - default: - ; - } - jj_consume_token(SEMICOLON); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case BOOLEAN: - case BYTE: - case CHAR: - case DOUBLE: - case FALSE: - case FLOAT: - case INT: - case LONG: - case NEW: - case NULL: - case SHORT: - case SUPER: - case THIS: - case TRUE: - case VOID: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case CHARACTER_LITERAL: - case STRING_LITERAL: - case IDENTIFIER: - case LPAREN: - case INCR: - case DECR: - ForUpdate(); - break; - default: - ; - } - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } - jj_consume_token(RPAREN); - Statement(); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void ForInit() throws ParseException { - /*@bgen(jjtree) ForInit */ - SimpleNode jjtn000 = new SimpleNode(JJTFORINIT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - if (jj_2_44(2147483647)) { - LocalVariableDeclaration(); - } else { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case BOOLEAN: - case BYTE: - case CHAR: - case DOUBLE: - case FALSE: - case FLOAT: - case INT: - case LONG: - case NEW: - case NULL: - case SHORT: - case SUPER: - case THIS: - case TRUE: - case VOID: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case CHARACTER_LITERAL: - case STRING_LITERAL: - case IDENTIFIER: - case LPAREN: - case INCR: - case DECR: - StatementExpressionList(); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void StatementExpressionList() throws ParseException { - /*@bgen(jjtree) StatementExpressionList */ - SimpleNode jjtn000 = new SimpleNode(JJTSTATEMENTEXPRESSIONLIST); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - StatementExpression(); - label_44: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - ; - break; - default: - break label_44; - } - jj_consume_token(COMMA); - StatementExpression(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void ForUpdate() throws ParseException { - /*@bgen(jjtree) ForUpdate */ - SimpleNode jjtn000 = new SimpleNode(JJTFORUPDATE); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - StatementExpressionList(); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void BreakStatement() throws ParseException { - /*@bgen(jjtree) BreakStatement */ - SimpleNode jjtn000 = new SimpleNode(JJTBREAKSTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(BREAK); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IDENTIFIER: - jj_consume_token(IDENTIFIER); - break; - default: - ; - } - jj_consume_token(SEMICOLON); - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void ContinueStatement() throws ParseException { - /*@bgen(jjtree) ContinueStatement */ - SimpleNode jjtn000 = new SimpleNode(JJTCONTINUESTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(CONTINUE); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IDENTIFIER: - jj_consume_token(IDENTIFIER); - break; - default: - ; - } - jj_consume_token(SEMICOLON); - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void ReturnStatement() throws ParseException { - /*@bgen(jjtree) ReturnStatement */ - SimpleNode jjtn000 = new SimpleNode(JJTRETURNSTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(RETURN); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case BOOLEAN: - case BYTE: - case CHAR: - case DOUBLE: - case FALSE: - case FLOAT: - case INT: - case LONG: - case NEW: - case NULL: - case SHORT: - case SUPER: - case THIS: - case TRUE: - case VOID: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case CHARACTER_LITERAL: - case STRING_LITERAL: - case IDENTIFIER: - case LPAREN: - case BANG: - case TILDE: - case INCR: - case DECR: - case PLUS: - case MINUS: - Expression(); - break; - default: - ; - } - jj_consume_token(SEMICOLON); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void ThrowStatement() throws ParseException { - /*@bgen(jjtree) ThrowStatement */ - SimpleNode jjtn000 = new SimpleNode(JJTTHROWSTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(THROW); - Expression(); - jj_consume_token(SEMICOLON); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void SynchronizedStatement() throws ParseException { - /*@bgen(jjtree) SynchronizedStatement */ - SimpleNode jjtn000 = new SimpleNode(JJTSYNCHRONIZEDSTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(SYNCHRONIZED); - jj_consume_token(LPAREN); - Expression(); - jj_consume_token(RPAREN); - Block(); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void TryStatement() throws ParseException { - /*@bgen(jjtree) TryStatement */ - SimpleNode jjtn000 = new SimpleNode(JJTTRYSTATEMENT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(TRY); - Block(); - label_45: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case CATCH: - ; - break; - default: - break label_45; - } - jj_consume_token(CATCH); - jj_consume_token(LPAREN); - FormalParameter(); - jj_consume_token(RPAREN); - Block(); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case FINALLY: - jj_consume_token(FINALLY); - Block(); - break; - default: - ; - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - /* We use productions to match >>>, >> and > so that we can keep the - * type declaration syntax with generics clean - */ - final public void RUNSIGNEDSHIFT() throws ParseException { - /*@bgen(jjtree) RUNSIGNEDSHIFT */ - SimpleNode jjtn000 = new SimpleNode(JJTRUNSIGNEDSHIFT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - if (getToken(1).kind == GT && - ((Token.GTToken) getToken(1)).realKind == RUNSIGNEDSHIFT) { - - } else { - jj_consume_token(-1); - throw new ParseException(); - } - jj_consume_token(GT); - jj_consume_token(GT); - jj_consume_token(GT); - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void RSIGNEDSHIFT() throws ParseException { - /*@bgen(jjtree) RSIGNEDSHIFT */ - SimpleNode jjtn000 = new SimpleNode(JJTRSIGNEDSHIFT); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - if (getToken(1).kind == GT && - ((Token.GTToken) getToken(1)).realKind == RSIGNEDSHIFT) { - - } else { - jj_consume_token(-1); - throw new ParseException(); - } - jj_consume_token(GT); - jj_consume_token(GT); - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - /* Annotation syntax follows. */ - final public void Annotation() throws ParseException { - /*@bgen(jjtree) Annotation */ - SimpleNode jjtn000 = new SimpleNode(JJTANNOTATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - if (jj_2_45(2147483647)) { - NormalAnnotation(); - } else if (jj_2_46(2147483647)) { - SingleMemberAnnotation(); - } else { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case AT: - MarkerAnnotation(); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void NormalAnnotation() throws ParseException { - /*@bgen(jjtree) NormalAnnotation */ - SimpleNode jjtn000 = new SimpleNode(JJTNORMALANNOTATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(AT); - Name(); - jj_consume_token(LPAREN); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IDENTIFIER: - MemberValuePairs(); - break; - default: - ; - } - jj_consume_token(RPAREN); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void MarkerAnnotation() throws ParseException { - /*@bgen(jjtree) MarkerAnnotation */ - SimpleNode jjtn000 = new SimpleNode(JJTMARKERANNOTATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(AT); - Name(); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void SingleMemberAnnotation() throws ParseException { - /*@bgen(jjtree) SingleMemberAnnotation */ - SimpleNode jjtn000 = new SimpleNode(JJTSINGLEMEMBERANNOTATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(AT); - Name(); - jj_consume_token(LPAREN); - MemberValue(); - jj_consume_token(RPAREN); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void MemberValuePairs() throws ParseException { - /*@bgen(jjtree) MemberValuePairs */ - SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUEPAIRS); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - MemberValuePair(); - label_46: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - ; - break; - default: - break label_46; - } - jj_consume_token(COMMA); - MemberValuePair(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void MemberValuePair() throws ParseException { - /*@bgen(jjtree) MemberValuePair */ - SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUEPAIR); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(IDENTIFIER); - jj_consume_token(ASSIGN); - MemberValue(); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void MemberValue() throws ParseException { - /*@bgen(jjtree) MemberValue */ - SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUE); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case AT: - Annotation(); - break; - case LBRACE: - MemberValueArrayInitializer(); - break; - case BOOLEAN: - case BYTE: - case CHAR: - case DOUBLE: - case FALSE: - case FLOAT: - case INT: - case LONG: - case NEW: - case NULL: - case SHORT: - case SUPER: - case THIS: - case TRUE: - case VOID: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case CHARACTER_LITERAL: - case STRING_LITERAL: - case IDENTIFIER: - case LPAREN: - case BANG: - case TILDE: - case INCR: - case DECR: - case PLUS: - case MINUS: - ConditionalExpression(); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void MemberValueArrayInitializer() throws ParseException { - /*@bgen(jjtree) MemberValueArrayInitializer */ - SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUEARRAYINITIALIZER); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(LBRACE); - MemberValue(); - label_47: - while (true) { - if (jj_2_47(2)) { - ; - } else { - break label_47; - } - jj_consume_token(COMMA); - MemberValue(); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - jj_consume_token(COMMA); - break; - default: - ; - } - jj_consume_token(RBRACE); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - /* Annotation Types. */ - final public void AnnotationTypeDeclaration(int modifiers) throws ParseException { - /*@bgen(jjtree) AnnotationTypeDeclaration */ - SimpleNode jjtn000 = new SimpleNode(JJTANNOTATIONTYPEDECLARATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(AT); - jj_consume_token(INTERFACE); - jj_consume_token(IDENTIFIER); - AnnotationTypeBody(); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void AnnotationTypeBody() throws ParseException { - /*@bgen(jjtree) AnnotationTypeBody */ - SimpleNode jjtn000 = new SimpleNode(JJTANNOTATIONTYPEBODY); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(LBRACE); - label_48: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case ABSTRACT: - case BOOLEAN: - case BYTE: - case CHAR: - case CLASS: - case DOUBLE: - case ENUM: - case FINAL: - case FLOAT: - case INT: - case INTERFACE: - case LONG: - case NATIVE: - case PRIVATE: - case PROTECTED: - case PUBLIC: - case SHORT: - case STATIC: - case STRICTFP: - case SYNCHRONIZED: - case TRANSIENT: - case VOLATILE: - case IDENTIFIER: - case SEMICOLON: - case AT: - ; - break; - default: - break label_48; - } - AnnotationTypeMemberDeclaration(); - } - jj_consume_token(RBRACE); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void AnnotationTypeMemberDeclaration() throws ParseException { - /*@bgen(jjtree) AnnotationTypeMemberDeclaration */ - SimpleNode jjtn000 = new SimpleNode(JJTANNOTATIONTYPEMEMBERDECLARATION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - int modifiers; - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case ABSTRACT: - case BOOLEAN: - case BYTE: - case CHAR: - case CLASS: - case DOUBLE: - case ENUM: - case FINAL: - case FLOAT: - case INT: - case INTERFACE: - case LONG: - case NATIVE: - case PRIVATE: - case PROTECTED: - case PUBLIC: - case SHORT: - case STATIC: - case STRICTFP: - case SYNCHRONIZED: - case TRANSIENT: - case VOLATILE: - case IDENTIFIER: - case AT: - modifiers = Modifiers(); - if (jj_2_48(2147483647)) { - Type(); - jj_consume_token(IDENTIFIER); - jj_consume_token(LPAREN); - jj_consume_token(RPAREN); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case _DEFAULT: - DefaultValue(); - break; - default: - ; - } - jj_consume_token(SEMICOLON); - } else { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case CLASS: - case INTERFACE: - ClassOrInterfaceDeclaration(modifiers); - break; - case ENUM: - EnumDeclaration(modifiers); - break; - case AT: - AnnotationTypeDeclaration(modifiers); - break; - case BOOLEAN: - case BYTE: - case CHAR: - case DOUBLE: - case FLOAT: - case INT: - case LONG: - case SHORT: - case IDENTIFIER: - FieldDeclaration(modifiers); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } - break; - case SEMICOLON: - jj_consume_token(SEMICOLON); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final public void DefaultValue() throws ParseException { - /*@bgen(jjtree) DefaultValue */ - SimpleNode jjtn000 = new SimpleNode(JJTDEFAULTVALUE); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - jjtreeOpenNodeScope(jjtn000); - try { - jj_consume_token(_DEFAULT); - MemberValue(); - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - { - if (true) throw (RuntimeException) jjte000; - } - } - if (jjte000 instanceof ParseException) { - { - if (true) throw (ParseException) jjte000; - } - } - { - if (true) throw (Error) jjte000; - } - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - jjtreeCloseNodeScope(jjtn000); - } - } - } - - final private boolean jj_2_1(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_1(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_2(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_2(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_3(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_3(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_4(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_4(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_5(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_5(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_6(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_6(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_7(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_7(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_8(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_8(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_9(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_9(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_10(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_10(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_11(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_11(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_12(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_12(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_13(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_13(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_14(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_14(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_15(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_15(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_16(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_16(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_17(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_17(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_18(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_18(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_19(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_19(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_20(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_20(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_21(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_21(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_22(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_22(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_23(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_23(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_24(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_24(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_25(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_25(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_26(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_26(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_27(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_27(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_28(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_28(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_29(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_29(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_30(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_30(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_31(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_31(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_32(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_32(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_33(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_33(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_34(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_34(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_35(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_35(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_36(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_36(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_37(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_37(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_38(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_38(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_39(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_39(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_40(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_40(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_41(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_41(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_42(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_42(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_43(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_43(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_44(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_44(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_45(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_45(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_46(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_46(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_47(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_47(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_2_48(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_48(); - } - catch (LookaheadSuccess ls) { - return true; - } - } - - final private boolean jj_3R_56() { - if (jj_3R_101()) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3_21()) jj_scanpos = xsp; - return false; - } - - final private boolean jj_3R_135() { - if (jj_scan_token(COMMA)) return true; - if (jj_3R_91()) return true; - return false; - } - - final private boolean jj_3R_99() { - if (jj_3R_91()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_135()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3_20() { - if (jj_scan_token(DOT)) return true; - if (jj_scan_token(IDENTIFIER)) return true; - return false; - } - - final private boolean jj_3R_91() { - if (jj_scan_token(IDENTIFIER)) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3_20()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3R_122() { - if (jj_3R_72()) return true; - return false; - } - - final private boolean jj_3R_86() { - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(58)) { - jj_scanpos = xsp; - if (jj_3R_122()) return true; - } - return false; - } - - final private boolean jj_3_19() { - if (jj_3R_78()) return true; - return false; - } - - final private boolean jj_3R_83() { - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(10)) { - jj_scanpos = xsp; - if (jj_scan_token(15)) { - jj_scanpos = xsp; - if (jj_scan_token(12)) { - jj_scanpos = xsp; - if (jj_scan_token(46)) { - jj_scanpos = xsp; - if (jj_scan_token(35)) { - jj_scanpos = xsp; - if (jj_scan_token(37)) { - jj_scanpos = xsp; - if (jj_scan_token(28)) { - jj_scanpos = xsp; - if (jj_scan_token(21)) return true; - } - } - } - } - } - } - } - return false; - } - - final private boolean jj_3R_194() { - if (jj_scan_token(COMMA)) return true; - if (jj_3R_112()) return true; - return false; - } - - final private boolean jj_3R_290() { - if (jj_scan_token(SUPER)) return true; - if (jj_3R_77()) return true; - return false; - } - - final private boolean jj_3_16() { - if (jj_scan_token(LBRACKET)) return true; - if (jj_scan_token(RBRACKET)) return true; - return false; - } - - final private boolean jj_3R_289() { - if (jj_scan_token(EXTENDS)) return true; - if (jj_3R_77()) return true; - return false; - } - - final private boolean jj_3R_277() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_289()) { - jj_scanpos = xsp; - if (jj_3R_290()) return true; - } - return false; - } - - final private boolean jj_3R_256() { - if (jj_3R_277()) return true; - return false; - } - - final private boolean jj_3R_151() { - if (jj_scan_token(HOOK)) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_256()) jj_scanpos = xsp; - return false; - } - - final private boolean jj_3_17() { - if (jj_3R_78()) return true; - return false; - } - - final private boolean jj_3R_112() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_150()) { - jj_scanpos = xsp; - if (jj_3R_151()) return true; - } - return false; - } - - final private boolean jj_3R_150() { - if (jj_3R_77()) return true; - return false; - } - - final private boolean jj_3_15() { - if (jj_scan_token(LBRACKET)) return true; - if (jj_scan_token(RBRACKET)) return true; - return false; - } - - final private boolean jj_3R_78() { - if (jj_scan_token(LT)) return true; - if (jj_3R_112()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_194()) { - jj_scanpos = xsp; - break; - } - } - if (jj_scan_token(GT)) return true; - return false; - } - - final private boolean jj_3_18() { - if (jj_scan_token(DOT)) return true; - if (jj_scan_token(IDENTIFIER)) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3_19()) jj_scanpos = xsp; - return false; - } - - final private boolean jj_3R_149() { - if (jj_scan_token(IDENTIFIER)) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3_17()) jj_scanpos = xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3_18()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3R_111() { - if (jj_3R_149()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3_16()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3R_110() { - if (jj_3R_83()) return true; - Token xsp; - if (jj_3_15()) return true; - while (true) { - xsp = jj_scanpos; - if (jj_3_15()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3R_77() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_110()) { - jj_scanpos = xsp; - if (jj_3R_111()) return true; - } - return false; - } - - final private boolean jj_3_13() { - if (jj_scan_token(THIS)) return true; - if (jj_scan_token(DOT)) return true; - return false; - } - - final private boolean jj_3R_221() { - if (jj_scan_token(THROWS)) return true; - if (jj_3R_99()) return true; - return false; - } - - final private boolean jj_3R_103() { - if (jj_3R_83()) return true; - return false; - } - - final private boolean jj_3R_72() { - Token xsp; - xsp = jj_scanpos; - if (jj_3_14()) { - jj_scanpos = xsp; - if (jj_3R_103()) return true; - } - return false; - } - - final private boolean jj_3_14() { - if (jj_3R_77()) return true; - return false; - } - - final private boolean jj_3R_74() { - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(47)) jj_scanpos = xsp; - if (jj_3R_104()) return true; - return false; - } - - final private boolean jj_3_12() { - if (jj_3R_76()) return true; - return false; - } - - final private boolean jj_3R_108() { - if (jj_3R_78()) return true; - return false; - } - - final private boolean jj_3R_107() { - if (jj_scan_token(IDENTIFIER)) return true; - if (jj_scan_token(DOT)) return true; - return false; - } - - final private boolean jj_3R_252() { - if (jj_scan_token(LBRACKET)) return true; - if (jj_scan_token(RBRACKET)) return true; - return false; - } - - final private boolean jj_3R_76() { - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_107()) { - jj_scanpos = xsp; - break; - } - } - xsp = jj_scanpos; - if (jj_3_13()) jj_scanpos = xsp; - xsp = jj_scanpos; - if (jj_3R_108()) jj_scanpos = xsp; - xsp = jj_scanpos; - if (jj_scan_token(52)) { - jj_scanpos = xsp; - if (jj_scan_token(49)) return true; - } - if (jj_3R_109()) return true; - if (jj_scan_token(SEMICOLON)) return true; - return false; - } - - final private boolean jj_3R_134() { - if (jj_scan_token(COMMA)) return true; - if (jj_3R_133()) return true; - return false; - } - - final private boolean jj_3R_223() { - if (jj_3R_49()) return true; - return false; - } - - final private boolean jj_3R_222() { - if (jj_3R_76()) return true; - return false; - } - - final private boolean jj_3R_220() { - if (jj_3R_97()) return true; - return false; - } - - final private boolean jj_3R_186() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_220()) jj_scanpos = xsp; - if (jj_scan_token(IDENTIFIER)) return true; - if (jj_3R_53()) return true; - xsp = jj_scanpos; - if (jj_3R_221()) jj_scanpos = xsp; - if (jj_scan_token(LBRACE)) return true; - xsp = jj_scanpos; - if (jj_3R_222()) jj_scanpos = xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_223()) { - jj_scanpos = xsp; - break; - } - } - if (jj_scan_token(RBRACE)) return true; - return false; - } - - final private boolean jj_3_11() { - if (jj_scan_token(COMMA)) return true; - if (jj_3R_75()) return true; - return false; - } - - final private boolean jj_3R_227() { - if (jj_scan_token(THROWS)) return true; - if (jj_3R_99()) return true; - return false; - } - - final private boolean jj_3R_98() { - if (jj_3R_133()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_134()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3R_133() { - if (jj_3R_50()) return true; - if (jj_3R_72()) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(119)) jj_scanpos = xsp; - if (jj_3R_184()) return true; - return false; - } - - final private boolean jj_3R_53() { - if (jj_scan_token(LPAREN)) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_98()) jj_scanpos = xsp; - if (jj_scan_token(RPAREN)) return true; - return false; - } - - final private boolean jj_3_48() { - if (jj_3R_72()) return true; - if (jj_scan_token(IDENTIFIER)) return true; - if (jj_scan_token(LPAREN)) return true; - return false; - } - - final private boolean jj_3R_226() { - if (jj_scan_token(IDENTIFIER)) return true; - if (jj_3R_53()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_252()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3R_228() { - if (jj_3R_104()) return true; - return false; - } - - final private boolean jj_3R_225() { - if (jj_3R_97()) return true; - return false; - } - - final private boolean jj_3R_292() { - if (jj_3R_75()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3_11()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3R_188() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_225()) jj_scanpos = xsp; - if (jj_3R_86()) return true; - if (jj_3R_226()) return true; - xsp = jj_scanpos; - if (jj_3R_227()) jj_scanpos = xsp; - xsp = jj_scanpos; - if (jj_3R_228()) { - jj_scanpos = xsp; - if (jj_scan_token(81)) return true; - } - return false; - } - - final private boolean jj_3R_198() { - if (jj_scan_token(ASSIGN)) return true; - if (jj_3R_75()) return true; - return false; - } - - final private boolean jj_3R_224() { - if (jj_scan_token(COMMA)) return true; - if (jj_3R_161()) return true; - return false; - } - - final private boolean jj_3_47() { - if (jj_scan_token(COMMA)) return true; - if (jj_3R_93()) return true; - return false; - } - - final private boolean jj_3R_217() { - if (jj_scan_token(LBRACKET)) return true; - if (jj_scan_token(RBRACKET)) return true; - return false; - } - - final private boolean jj_3R_147() { - if (jj_scan_token(LBRACE)) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_292()) jj_scanpos = xsp; - xsp = jj_scanpos; - if (jj_scan_token(82)) jj_scanpos = xsp; - if (jj_scan_token(RBRACE)) return true; - return false; - } - - final private boolean jj_3R_73() { - if (jj_scan_token(LBRACKET)) return true; - if (jj_scan_token(RBRACKET)) return true; - return false; - } - - final private boolean jj_3R_106() { - if (jj_3R_56()) return true; - return false; - } - - final private boolean jj_3R_105() { - if (jj_3R_147()) return true; - return false; - } - - final private boolean jj_3R_75() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_105()) { - jj_scanpos = xsp; - if (jj_3R_106()) return true; - } - return false; - } - - final private boolean jj_3R_184() { - if (jj_scan_token(IDENTIFIER)) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_217()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3R_160() { - if (jj_scan_token(LBRACE)) return true; - if (jj_3R_93()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3_47()) { - jj_scanpos = xsp; - break; - } - } - xsp = jj_scanpos; - if (jj_scan_token(82)) jj_scanpos = xsp; - if (jj_scan_token(RBRACE)) return true; - return false; - } - - final private boolean jj_3R_276() { - if (jj_scan_token(COMMA)) return true; - if (jj_3R_275()) return true; - return false; - } - - final private boolean jj_3R_161() { - if (jj_3R_184()) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_198()) jj_scanpos = xsp; - return false; - } - - final private boolean jj_3R_127() { - if (jj_3R_101()) return true; - return false; - } - - final private boolean jj_3_9() { - if (jj_3R_72()) return true; - if (jj_scan_token(IDENTIFIER)) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_73()) { - jj_scanpos = xsp; - break; - } - } - xsp = jj_scanpos; - if (jj_scan_token(82)) { - jj_scanpos = xsp; - if (jj_scan_token(85)) { - jj_scanpos = xsp; - if (jj_scan_token(81)) return true; - } - } - return false; - } - - final private boolean jj_3R_126() { - if (jj_3R_160()) return true; - return false; - } - - final private boolean jj_3R_71() { - if (jj_3R_97()) return true; - return false; - } - - final private boolean jj_3R_93() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_125()) { - jj_scanpos = xsp; - if (jj_3R_126()) { - jj_scanpos = xsp; - if (jj_3R_127()) return true; - } - } - return false; - } - - final private boolean jj_3R_125() { - if (jj_3R_102()) return true; - return false; - } - - final private boolean jj_3_8() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_71()) jj_scanpos = xsp; - if (jj_scan_token(IDENTIFIER)) return true; - if (jj_scan_token(LPAREN)) return true; - return false; - } - - final private boolean jj_3R_187() { - if (jj_3R_72()) return true; - if (jj_3R_161()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_224()) { - jj_scanpos = xsp; - break; - } - } - if (jj_scan_token(SEMICOLON)) return true; - return false; - } - - final private boolean jj_3R_275() { - if (jj_scan_token(IDENTIFIER)) return true; - if (jj_scan_token(ASSIGN)) return true; - if (jj_3R_93()) return true; - return false; - } - - final private boolean jj_3R_140() { - if (jj_3R_188()) return true; - return false; - } - - final private boolean jj_3R_139() { - if (jj_3R_187()) return true; - return false; - } - - final private boolean jj_3R_249() { - if (jj_scan_token(BIT_AND)) return true; - if (jj_3R_149()) return true; - return false; - } - - final private boolean jj_3R_138() { - if (jj_3R_186()) return true; - return false; - } - - final private boolean jj_3R_255() { - if (jj_3R_275()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_276()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3R_231() { - if (jj_3R_255()) return true; - return false; - } - - final private boolean jj_3R_137() { - if (jj_3R_185()) return true; - return false; - } - - final private boolean jj_3R_92() { - if (jj_scan_token(IDENTIFIER)) return true; - if (jj_scan_token(ASSIGN)) return true; - return false; - } - - final private boolean jj_3R_136() { - if (jj_3R_130()) return true; - return false; - } - - final private boolean jj_3R_192() { - if (jj_scan_token(AT)) return true; - if (jj_3R_91()) return true; - if (jj_scan_token(LPAREN)) return true; - if (jj_3R_93()) return true; - if (jj_scan_token(RPAREN)) return true; - return false; - } - - final private boolean jj_3R_286() { - if (jj_3R_182()) return true; - return false; - } - - final private boolean jj_3R_100() { - if (jj_3R_50()) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_136()) { - jj_scanpos = xsp; - if (jj_3R_137()) { - jj_scanpos = xsp; - if (jj_3R_138()) { - jj_scanpos = xsp; - if (jj_3R_139()) { - jj_scanpos = xsp; - if (jj_3R_140()) return true; - } - } - } - } - return false; - } - - final private boolean jj_3R_193() { - if (jj_scan_token(AT)) return true; - if (jj_3R_91()) return true; - return false; - } - - final private boolean jj_3_46() { - if (jj_scan_token(AT)) return true; - if (jj_3R_91()) return true; - if (jj_scan_token(LPAREN)) return true; - return false; - } - - final private boolean jj_3_10() { - if (jj_3R_74()) return true; - return false; - } - - final private boolean jj_3R_55() { - Token xsp; - xsp = jj_scanpos; - if (jj_3_10()) { - jj_scanpos = xsp; - if (jj_3R_100()) { - jj_scanpos = xsp; - if (jj_scan_token(81)) return true; - } - } - return false; - } - - final private boolean jj_3R_191() { - if (jj_scan_token(AT)) return true; - if (jj_3R_91()) return true; - if (jj_scan_token(LPAREN)) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_231()) jj_scanpos = xsp; - if (jj_scan_token(RPAREN)) return true; - return false; - } - - final private boolean jj_3_45() { - if (jj_scan_token(AT)) return true; - if (jj_3R_91()) return true; - if (jj_scan_token(LPAREN)) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_92()) { - jj_scanpos = xsp; - if (jj_scan_token(76)) return true; - } - return false; - } - - final private boolean jj_3R_215() { - if (jj_3R_55()) return true; - return false; - } - - final private boolean jj_3R_132() { - if (jj_scan_token(COMMA)) return true; - if (jj_3R_131()) return true; - return false; - } - - final private boolean jj_3R_183() { - if (jj_3R_216()) return true; - return false; - } - - final private boolean jj_3R_285() { - if (jj_3R_109()) return true; - return false; - } - - final private boolean jj_3R_145() { - if (jj_3R_193()) return true; - return false; - } - - final private boolean jj_3R_182() { - if (jj_scan_token(LBRACE)) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_215()) { - jj_scanpos = xsp; - break; - } - } - if (jj_scan_token(RBRACE)) return true; - return false; - } - - final private boolean jj_3R_144() { - if (jj_3R_192()) return true; - return false; - } - - final private boolean jj_3R_113() { - return false; - } - - final private boolean jj_3R_102() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_143()) { - jj_scanpos = xsp; - if (jj_3R_144()) { - jj_scanpos = xsp; - if (jj_3R_145()) return true; - } - } - return false; - } - - final private boolean jj_3R_143() { - if (jj_3R_191()) return true; - return false; - } - - final private boolean jj_3R_216() { - if (jj_scan_token(EXTENDS)) return true; - if (jj_3R_149()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_249()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3R_131() { - if (jj_scan_token(IDENTIFIER)) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_183()) jj_scanpos = xsp; - return false; - } - - final private boolean jj_3R_114() { - return false; - } - - final private boolean jj_3_7() { - if (jj_scan_token(COMMA)) return true; - if (jj_3R_70()) return true; - return false; - } - - final private boolean jj_3R_80() { - Token xsp; - xsp = jj_scanpos; - lookingAhead = true; - jj_semLA = getToken(1).kind == GT && - ((Token.GTToken) getToken(1)).realKind == RSIGNEDSHIFT; - lookingAhead = false; - if (!jj_semLA || jj_3R_113()) return true; - if (jj_scan_token(GT)) return true; - if (jj_scan_token(GT)) return true; - return false; - } - - final private boolean jj_3R_97() { - if (jj_scan_token(LT)) return true; - if (jj_3R_131()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_132()) { - jj_scanpos = xsp; - break; - } - } - if (jj_scan_token(GT)) return true; - return false; - } - - final private boolean jj_3R_272() { - if (jj_3R_55()) return true; - return false; - } - - final private boolean jj_3R_70() { - if (jj_3R_50()) return true; - if (jj_scan_token(IDENTIFIER)) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_285()) jj_scanpos = xsp; - xsp = jj_scanpos; - if (jj_3R_286()) jj_scanpos = xsp; - return false; - } - - final private boolean jj_3R_81() { - Token xsp; - xsp = jj_scanpos; - lookingAhead = true; - jj_semLA = getToken(1).kind == GT && - ((Token.GTToken) getToken(1)).realKind == RUNSIGNEDSHIFT; - lookingAhead = false; - if (!jj_semLA || jj_3R_114()) return true; - if (jj_scan_token(GT)) return true; - if (jj_scan_token(GT)) return true; - if (jj_scan_token(GT)) return true; - return false; - } - - final private boolean jj_3R_251() { - if (jj_scan_token(SEMICOLON)) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_272()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3R_250() { - if (jj_3R_70()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3_7()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3R_246() { - if (jj_scan_token(FINALLY)) return true; - if (jj_3R_104()) return true; - return false; - } - - final private boolean jj_3R_219() { - if (jj_scan_token(LBRACE)) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_250()) jj_scanpos = xsp; - xsp = jj_scanpos; - if (jj_scan_token(82)) jj_scanpos = xsp; - xsp = jj_scanpos; - if (jj_3R_251()) jj_scanpos = xsp; - if (jj_scan_token(RBRACE)) return true; - return false; - } - - final private boolean jj_3R_245() { - if (jj_scan_token(CATCH)) return true; - if (jj_scan_token(LPAREN)) return true; - if (jj_3R_133()) return true; - if (jj_scan_token(RPAREN)) return true; - if (jj_3R_104()) return true; - return false; - } - - final private boolean jj_3R_212() { - if (jj_scan_token(TRY)) return true; - if (jj_3R_104()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_245()) { - jj_scanpos = xsp; - break; - } - } - xsp = jj_scanpos; - if (jj_3R_246()) jj_scanpos = xsp; - return false; - } - - final private boolean jj_3R_218() { - if (jj_3R_214()) return true; - return false; - } - - final private boolean jj_3R_185() { - if (jj_scan_token(ENUM)) return true; - if (jj_scan_token(IDENTIFIER)) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_218()) jj_scanpos = xsp; - if (jj_3R_219()) return true; - return false; - } - - final private boolean jj_3R_211() { - if (jj_scan_token(SYNCHRONIZED)) return true; - if (jj_scan_token(LPAREN)) return true; - if (jj_3R_56()) return true; - if (jj_scan_token(RPAREN)) return true; - if (jj_3R_104()) return true; - return false; - } - - final private boolean jj_3R_244() { - if (jj_3R_56()) return true; - return false; - } - - final private boolean jj_3R_248() { - if (jj_scan_token(COMMA)) return true; - if (jj_3R_149()) return true; - return false; - } - - final private boolean jj_3R_214() { - if (jj_scan_token(IMPLEMENTS)) return true; - if (jj_3R_149()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_248()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3R_210() { - if (jj_scan_token(THROW)) return true; - if (jj_3R_56()) return true; - if (jj_scan_token(SEMICOLON)) return true; - return false; - } - - final private boolean jj_3R_271() { - if (jj_3R_284()) return true; - return false; - } - - final private boolean jj_3R_299() { - if (jj_scan_token(COMMA)) return true; - if (jj_3R_201()) return true; - return false; - } - - final private boolean jj_3R_209() { - if (jj_scan_token(RETURN)) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_244()) jj_scanpos = xsp; - if (jj_scan_token(SEMICOLON)) return true; - return false; - } - - final private boolean jj_3R_247() { - if (jj_scan_token(COMMA)) return true; - if (jj_3R_149()) return true; - return false; - } - - final private boolean jj_3R_213() { - if (jj_scan_token(EXTENDS)) return true; - if (jj_3R_149()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_247()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3R_208() { - if (jj_scan_token(CONTINUE)) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(72)) jj_scanpos = xsp; - if (jj_scan_token(SEMICOLON)) return true; - return false; - } - - final private boolean jj_3R_178() { - if (jj_scan_token(INTERFACE)) return true; - return false; - } - - final private boolean jj_3R_207() { - if (jj_scan_token(BREAK)) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(72)) jj_scanpos = xsp; - if (jj_scan_token(SEMICOLON)) return true; - return false; - } - - final private boolean jj_3R_181() { - if (jj_3R_214()) return true; - return false; - } - - final private boolean jj_3R_180() { - if (jj_3R_213()) return true; - return false; - } - - final private boolean jj_3R_179() { - if (jj_3R_97()) return true; - return false; - } - - final private boolean jj_3R_284() { - if (jj_3R_296()) return true; - return false; - } - - final private boolean jj_3R_270() { - if (jj_3R_56()) return true; - return false; - } - - final private boolean jj_3R_130() { - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(16)) { - jj_scanpos = xsp; - if (jj_3R_178()) return true; - } - if (jj_scan_token(IDENTIFIER)) return true; - xsp = jj_scanpos; - if (jj_3R_179()) jj_scanpos = xsp; - xsp = jj_scanpos; - if (jj_3R_180()) jj_scanpos = xsp; - xsp = jj_scanpos; - if (jj_3R_181()) jj_scanpos = xsp; - if (jj_3R_182()) return true; - return false; - } - - final private boolean jj_3_44() { - if (jj_3R_50()) return true; - if (jj_3R_72()) return true; - if (jj_scan_token(IDENTIFIER)) return true; - return false; - } - - final private boolean jj_3R_296() { - if (jj_3R_201()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_299()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3R_241() { - if (jj_scan_token(ELSE)) return true; - if (jj_3R_129()) return true; - return false; - } - - final private boolean jj_3R_295() { - if (jj_3R_296()) return true; - return false; - } - - final private boolean jj_3_43() { - if (jj_3R_50()) return true; - if (jj_3R_72()) return true; - if (jj_scan_token(IDENTIFIER)) return true; - if (jj_scan_token(COLON)) return true; - return false; - } - - final private boolean jj_3R_294() { - if (jj_3R_128()) return true; - return false; - } - - final private boolean jj_3R_283() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_294()) { - jj_scanpos = xsp; - if (jj_3R_295()) return true; - } - return false; - } - - final private boolean jj_3R_269() { - if (jj_3R_283()) return true; - return false; - } - - final private boolean jj_3R_243() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_269()) jj_scanpos = xsp; - if (jj_scan_token(SEMICOLON)) return true; - xsp = jj_scanpos; - if (jj_3R_270()) jj_scanpos = xsp; - if (jj_scan_token(SEMICOLON)) return true; - xsp = jj_scanpos; - if (jj_3R_271()) jj_scanpos = xsp; - return false; - } - - final private boolean jj_3R_242() { - if (jj_3R_50()) return true; - if (jj_3R_72()) return true; - if (jj_scan_token(IDENTIFIER)) return true; - if (jj_scan_token(COLON)) return true; - if (jj_3R_56()) return true; - return false; - } - - final private boolean jj_3R_54() { - if (jj_scan_token(THROWS)) return true; - if (jj_3R_99()) return true; - return false; - } - - final private boolean jj_3R_206() { - if (jj_scan_token(FOR)) return true; - if (jj_scan_token(LPAREN)) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_242()) { - jj_scanpos = xsp; - if (jj_3R_243()) return true; - } - if (jj_scan_token(RPAREN)) return true; - if (jj_3R_129()) return true; - return false; - } - - final private boolean jj_3R_69() { - if (jj_3R_102()) return true; - return false; - } - - final private boolean jj_3R_205() { - if (jj_scan_token(DO)) return true; - if (jj_3R_129()) return true; - if (jj_scan_token(WHILE)) return true; - if (jj_scan_token(LPAREN)) return true; - if (jj_3R_56()) return true; - if (jj_scan_token(RPAREN)) return true; - if (jj_scan_token(SEMICOLON)) return true; - return false; - } - - final private boolean jj_3R_68() { - if (jj_scan_token(STRICTFP)) return true; - return false; - } - - final private boolean jj_3R_67() { - if (jj_scan_token(VOLATILE)) return true; - return false; - } - - final private boolean jj_3R_66() { - if (jj_scan_token(TRANSIENT)) return true; - return false; - } - - final private boolean jj_3R_204() { - if (jj_scan_token(WHILE)) return true; - if (jj_scan_token(LPAREN)) return true; - if (jj_3R_56()) return true; - if (jj_scan_token(RPAREN)) return true; - if (jj_3R_129()) return true; - return false; - } - - final private boolean jj_3R_65() { - if (jj_scan_token(NATIVE)) return true; - return false; - } - - final private boolean jj_3R_64() { - if (jj_scan_token(SYNCHRONIZED)) return true; - return false; - } - - final private boolean jj_3R_63() { - if (jj_scan_token(ABSTRACT)) return true; - return false; - } - - final private boolean jj_3R_268() { - if (jj_3R_49()) return true; - return false; - } - - final private boolean jj_3R_203() { - if (jj_scan_token(IF)) return true; - if (jj_scan_token(LPAREN)) return true; - if (jj_3R_56()) return true; - if (jj_scan_token(RPAREN)) return true; - if (jj_3R_129()) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_241()) jj_scanpos = xsp; - return false; - } - - final private boolean jj_3R_62() { - if (jj_scan_token(FINAL)) return true; - return false; - } - - final private boolean jj_3R_61() { - if (jj_scan_token(PRIVATE)) return true; - return false; - } - - final private boolean jj_3R_162() { - if (jj_scan_token(COMMA)) return true; - if (jj_3R_161()) return true; - return false; - } - - final private boolean jj_3R_60() { - if (jj_scan_token(PROTECTED)) return true; - return false; - } - - final private boolean jj_3R_59() { - if (jj_scan_token(STATIC)) return true; - return false; - } - - final private boolean jj_3R_58() { - if (jj_scan_token(PUBLIC)) return true; - return false; - } - - final private boolean jj_3R_282() { - if (jj_scan_token(_DEFAULT)) return true; - if (jj_scan_token(COLON)) return true; - return false; - } - - final private boolean jj_3_6() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_58()) { - jj_scanpos = xsp; - if (jj_3R_59()) { - jj_scanpos = xsp; - if (jj_3R_60()) { - jj_scanpos = xsp; - if (jj_3R_61()) { - jj_scanpos = xsp; - if (jj_3R_62()) { - jj_scanpos = xsp; - if (jj_3R_63()) { - jj_scanpos = xsp; - if (jj_3R_64()) { - jj_scanpos = xsp; - if (jj_3R_65()) { - jj_scanpos = xsp; - if (jj_3R_66()) { - jj_scanpos = xsp; - if (jj_3R_67()) { - jj_scanpos = xsp; - if (jj_3R_68()) { - jj_scanpos = xsp; - if (jj_3R_69()) return true; - } - } - } - } - } - } - } - } - } - } - } - return false; - } - - final private boolean jj_3R_281() { - if (jj_scan_token(CASE)) return true; - if (jj_3R_56()) return true; - if (jj_scan_token(COLON)) return true; - return false; - } - - final private boolean jj_3R_267() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_281()) { - jj_scanpos = xsp; - if (jj_3R_282()) return true; - } - return false; - } - - final private boolean jj_3R_50() { - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3_6()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3R_240() { - if (jj_3R_267()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_268()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3_42() { - if (jj_3R_90()) return true; - if (jj_3R_79()) return true; - return false; - } - - final private boolean jj_3R_202() { - if (jj_scan_token(SWITCH)) return true; - if (jj_scan_token(LPAREN)) return true; - if (jj_3R_56()) return true; - if (jj_scan_token(RPAREN)) return true; - if (jj_scan_token(LBRACE)) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_240()) { - jj_scanpos = xsp; - break; - } - } - if (jj_scan_token(RBRACE)) return true; - return false; - } - - final private boolean jj_3R_239() { - if (jj_3R_266()) return true; - return false; - } - - final private boolean jj_3R_57() { - if (jj_3R_102()) return true; - return false; - } - - final private boolean jj_3R_52() { - if (jj_3R_86()) return true; - return false; - } - - final private boolean jj_3R_238() { - if (jj_3R_265()) return true; - return false; - } - - final private boolean jj_3_5() { - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_57()) { - jj_scanpos = xsp; - break; - } - } - if (jj_scan_token(PACKAGE)) return true; - return false; - } - - final private boolean jj_3R_237() { - if (jj_3R_264()) return true; - return false; - } - - final private boolean jj_3R_201() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_236()) { - jj_scanpos = xsp; - if (jj_3R_237()) { - jj_scanpos = xsp; - if (jj_3R_238()) { - jj_scanpos = xsp; - if (jj_3R_239()) return true; - } - } - } - return false; - } - - final private boolean jj_3R_236() { - if (jj_3R_263()) return true; - return false; - } - - final private boolean jj_3R_200() { - if (jj_scan_token(SEMICOLON)) return true; - return false; - } - - final private boolean jj_3_41() { - if (jj_3R_50()) return true; - if (jj_3R_72()) return true; - if (jj_scan_token(IDENTIFIER)) return true; - return false; - } - - final private boolean jj_3R_128() { - if (jj_3R_50()) return true; - if (jj_3R_72()) return true; - if (jj_3R_161()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_162()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3R_51() { - if (jj_3R_97()) return true; - return false; - } - - final private boolean jj_3R_235() { - if (jj_scan_token(COLON)) return true; - if (jj_3R_56()) return true; - return false; - } - - final private boolean jj_3R_96() { - if (jj_3R_130()) return true; - return false; - } - - final private boolean jj_3R_95() { - if (jj_3R_129()) return true; - return false; - } - - final private boolean jj_3_4() { - if (jj_3R_56()) return true; - return false; - } - - final private boolean jj_3R_94() { - if (jj_3R_128()) return true; - if (jj_scan_token(SEMICOLON)) return true; - return false; - } - - final private boolean jj_3R_49() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_94()) { - jj_scanpos = xsp; - if (jj_3R_95()) { - jj_scanpos = xsp; - if (jj_3R_96()) return true; - } - } - return false; - } - - final private boolean jj_3R_146() { - if (jj_3R_49()) return true; - return false; - } - - final private boolean jj_3_3() { - if (jj_3R_55()) return true; - return false; - } - - final private boolean jj_3R_104() { - if (jj_scan_token(LBRACE)) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_146()) { - jj_scanpos = xsp; - break; - } - } - if (jj_scan_token(RBRACE)) return true; - return false; - } - - final private boolean jj_3_2() { - if (jj_3R_50()) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_51()) jj_scanpos = xsp; - xsp = jj_scanpos; - if (jj_3R_52()) jj_scanpos = xsp; - if (jj_scan_token(IDENTIFIER)) return true; - if (jj_3R_53()) return true; - xsp = jj_scanpos; - if (jj_3R_54()) jj_scanpos = xsp; - if (jj_scan_token(LBRACE)) return true; - return false; - } - - final private boolean jj_3R_89() { - if (jj_scan_token(IDENTIFIER)) return true; - if (jj_scan_token(COLON)) return true; - if (jj_3R_129()) return true; - return false; - } - - final private boolean jj_3_1() { - if (jj_3R_49()) return true; - return false; - } - - final private boolean jj_3R_199() { - if (jj_scan_token(ASSERT)) return true; - if (jj_3R_56()) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_235()) jj_scanpos = xsp; - if (jj_scan_token(SEMICOLON)) return true; - return false; - } - - final private boolean jj_3R_177() { - if (jj_3R_212()) return true; - return false; - } - - final private boolean jj_3R_176() { - if (jj_3R_211()) return true; - return false; - } - - final private boolean jj_3_38() { - if (jj_scan_token(LBRACKET)) return true; - if (jj_scan_token(RBRACKET)) return true; - return false; - } - - final private boolean jj_3R_175() { - if (jj_3R_210()) return true; - return false; - } - - final private boolean jj_3R_174() { - if (jj_3R_209()) return true; - return false; - } - - final private boolean jj_3R_173() { - if (jj_3R_208()) return true; - return false; - } - - final private boolean jj_3R_172() { - if (jj_3R_207()) return true; - return false; - } - - final private boolean jj_3R_171() { - if (jj_3R_206()) return true; - return false; - } - - final private boolean jj_3R_170() { - if (jj_3R_205()) return true; - return false; - } - - final private boolean jj_3R_169() { - if (jj_3R_204()) return true; - return false; - } - - final private boolean jj_3R_168() { - if (jj_3R_203()) return true; - return false; - } - - final private boolean jj_3R_167() { - if (jj_3R_202()) return true; - return false; - } - - final private boolean jj_3R_166() { - if (jj_3R_201()) return true; - if (jj_scan_token(SEMICOLON)) return true; - return false; - } - - final private boolean jj_3R_165() { - if (jj_3R_200()) return true; - return false; - } - - final private boolean jj_3R_164() { - if (jj_3R_104()) return true; - return false; - } - - final private boolean jj_3R_163() { - if (jj_3R_199()) return true; - return false; - } - - final private boolean jj_3R_260() { - if (jj_3R_78()) return true; - return false; - } - - final private boolean jj_3_40() { - if (jj_3R_89()) return true; - return false; - } - - final private boolean jj_3R_129() { - Token xsp; - xsp = jj_scanpos; - if (jj_3_40()) { - jj_scanpos = xsp; - if (jj_3R_163()) { - jj_scanpos = xsp; - if (jj_3R_164()) { - jj_scanpos = xsp; - if (jj_3R_165()) { - jj_scanpos = xsp; - if (jj_3R_166()) { - jj_scanpos = xsp; - if (jj_3R_167()) { - jj_scanpos = xsp; - if (jj_3R_168()) { - jj_scanpos = xsp; - if (jj_3R_169()) { - jj_scanpos = xsp; - if (jj_3R_170()) { - jj_scanpos = xsp; - if (jj_3R_171()) { - jj_scanpos = xsp; - if (jj_3R_172()) { - jj_scanpos = xsp; - if (jj_3R_173()) { - jj_scanpos = xsp; - if (jj_3R_174()) { - jj_scanpos = xsp; - if (jj_3R_175()) { - jj_scanpos = xsp; - if (jj_3R_176()) { - jj_scanpos = xsp; - if (jj_3R_177()) - return true; - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - return false; - } - - final private boolean jj_3R_279() { - if (jj_3R_182()) return true; - return false; - } - - final private boolean jj_3R_291() { - if (jj_scan_token(LBRACKET)) return true; - if (jj_scan_token(RBRACKET)) return true; - return false; - } - - final private boolean jj_3R_278() { - Token xsp; - if (jj_3R_291()) return true; - while (true) { - xsp = jj_scanpos; - if (jj_3R_291()) { - jj_scanpos = xsp; - break; - } - } - if (jj_3R_147()) return true; - return false; - } - - final private boolean jj_3_37() { - if (jj_scan_token(LBRACKET)) return true; - if (jj_3R_56()) return true; - if (jj_scan_token(RBRACKET)) return true; - return false; - } - - final private boolean jj_3_39() { - Token xsp; - if (jj_3_37()) return true; - while (true) { - xsp = jj_scanpos; - if (jj_3_37()) { - jj_scanpos = xsp; - break; - } - } - while (true) { - xsp = jj_scanpos; - if (jj_3_38()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3R_259() { - Token xsp; - xsp = jj_scanpos; - if (jj_3_39()) { - jj_scanpos = xsp; - if (jj_3R_278()) return true; - } - return false; - } - - final private boolean jj_3R_262() { - if (jj_3R_109()) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_279()) jj_scanpos = xsp; - return false; - } - - final private boolean jj_3R_232() { - if (jj_scan_token(COMMA)) return true; - if (jj_3R_56()) return true; - return false; - } - - final private boolean jj_3R_261() { - if (jj_3R_259()) return true; - return false; - } - - final private boolean jj_3R_123() { - if (jj_scan_token(NEW)) return true; - if (jj_3R_149()) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_260()) jj_scanpos = xsp; - xsp = jj_scanpos; - if (jj_3R_261()) { - jj_scanpos = xsp; - if (jj_3R_262()) return true; - } - return false; - } - - final private boolean jj_3R_87() { - Token xsp; - xsp = jj_scanpos; - if (jj_3_36()) { - jj_scanpos = xsp; - if (jj_3R_123()) return true; - } - return false; - } - - final private boolean jj_3_36() { - if (jj_scan_token(NEW)) return true; - if (jj_3R_83()) return true; - if (jj_3R_259()) return true; - return false; - } - - final private boolean jj_3R_148() { - if (jj_3R_195()) return true; - return false; - } - - final private boolean jj_3R_195() { - if (jj_3R_56()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_232()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3R_109() { - if (jj_scan_token(LPAREN)) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_148()) jj_scanpos = xsp; - if (jj_scan_token(RPAREN)) return true; - return false; - } - - final private boolean jj_3R_258() { - if (jj_scan_token(NULL)) return true; - return false; - } - - final private boolean jj_3R_257() { - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(56)) { - jj_scanpos = xsp; - if (jj_scan_token(25)) return true; - } - return false; - } - - final private boolean jj_3R_234() { - if (jj_3R_258()) return true; - return false; - } - - final private boolean jj_3R_233() { - if (jj_3R_257()) return true; - return false; - } - - final private boolean jj_3R_196() { - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(61)) { - jj_scanpos = xsp; - if (jj_scan_token(65)) { - jj_scanpos = xsp; - if (jj_scan_token(70)) { - jj_scanpos = xsp; - if (jj_scan_token(71)) { - jj_scanpos = xsp; - if (jj_3R_233()) { - jj_scanpos = xsp; - if (jj_3R_234()) return true; - } - } - } - } - } - return false; - } - - final private boolean jj_3R_152() { - if (jj_3R_196()) return true; - return false; - } - - final private boolean jj_3R_121() { - if (jj_3R_109()) return true; - return false; - } - - final private boolean jj_3R_120() { - if (jj_scan_token(DOT)) return true; - if (jj_scan_token(IDENTIFIER)) return true; - return false; - } - - final private boolean jj_3_33() { - if (jj_scan_token(DOT)) return true; - if (jj_scan_token(THIS)) return true; - return false; - } - - final private boolean jj_3R_119() { - if (jj_scan_token(LBRACKET)) return true; - if (jj_3R_56()) return true; - if (jj_scan_token(RBRACKET)) return true; - return false; - } - - final private boolean jj_3_32() { - if (jj_scan_token(DOT)) return true; - if (jj_scan_token(SUPER)) return true; - if (jj_scan_token(DOT)) return true; - return false; - } - - final private boolean jj_3_35() { - if (jj_3R_88()) return true; - return false; - } - - final private boolean jj_3_34() { - if (jj_scan_token(DOT)) return true; - if (jj_3R_87()) return true; - return false; - } - - final private boolean jj_3R_118() { - if (jj_scan_token(DOT)) return true; - if (jj_scan_token(THIS)) return true; - return false; - } - - final private boolean jj_3_31() { - if (jj_3R_86()) return true; - if (jj_scan_token(DOT)) return true; - if (jj_scan_token(CLASS)) return true; - return false; - } - - final private boolean jj_3R_117() { - if (jj_scan_token(DOT)) return true; - if (jj_scan_token(SUPER)) return true; - return false; - } - - final private boolean jj_3R_84() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_117()) { - jj_scanpos = xsp; - if (jj_3R_118()) { - jj_scanpos = xsp; - if (jj_3_34()) { - jj_scanpos = xsp; - if (jj_3_35()) { - jj_scanpos = xsp; - if (jj_3R_119()) { - jj_scanpos = xsp; - if (jj_3R_120()) { - jj_scanpos = xsp; - if (jj_3R_121()) return true; - } - } - } - } - } - } - return false; - } - - final private boolean jj_3R_85() { - if (jj_scan_token(IDENTIFIER)) return true; - if (jj_scan_token(DOT)) return true; - return false; - } - - final private boolean jj_3R_159() { - if (jj_3R_91()) return true; - return false; - } - - final private boolean jj_3_30() { - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_85()) { - jj_scanpos = xsp; - break; - } - } - if (jj_scan_token(THIS)) return true; - return false; - } - - final private boolean jj_3R_158() { - if (jj_3R_86()) return true; - if (jj_scan_token(DOT)) return true; - if (jj_scan_token(CLASS)) return true; - return false; - } - - final private boolean jj_3R_157() { - if (jj_3R_87()) return true; - return false; - } - - final private boolean jj_3R_156() { - if (jj_scan_token(LPAREN)) return true; - if (jj_3R_56()) return true; - if (jj_scan_token(RPAREN)) return true; - return false; - } - - final private boolean jj_3_29() { - if (jj_3R_84()) return true; - return false; - } - - final private boolean jj_3R_155() { - if (jj_scan_token(SUPER)) return true; - if (jj_scan_token(DOT)) return true; - if (jj_scan_token(IDENTIFIER)) return true; - return false; - } - - final private boolean jj_3R_197() { - if (jj_scan_token(IDENTIFIER)) return true; - if (jj_scan_token(DOT)) return true; - return false; - } - - final private boolean jj_3R_154() { - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_197()) { - jj_scanpos = xsp; - break; - } - } - if (jj_scan_token(THIS)) return true; - return false; - } - - final private boolean jj_3R_124() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_153()) { - jj_scanpos = xsp; - if (jj_3R_154()) { - jj_scanpos = xsp; - if (jj_3R_155()) { - jj_scanpos = xsp; - if (jj_3R_156()) { - jj_scanpos = xsp; - if (jj_3R_157()) { - jj_scanpos = xsp; - if (jj_3R_158()) { - jj_scanpos = xsp; - if (jj_3R_159()) return true; - } - } - } - } - } - } - return false; - } - - final private boolean jj_3R_153() { - if (jj_3R_196()) return true; - return false; - } - - final private boolean jj_3R_88() { - if (jj_scan_token(DOT)) return true; - if (jj_3R_78()) return true; - if (jj_scan_token(IDENTIFIER)) return true; - return false; - } - - final private boolean jj_3R_280() { - if (jj_3R_293()) return true; - return false; - } - - final private boolean jj_3_28() { - if (jj_scan_token(LPAREN)) return true; - if (jj_3R_83()) return true; - return false; - } - - final private boolean jj_3R_90() { - if (jj_3R_124()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3_29()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3R_319() { - if (jj_scan_token(LPAREN)) return true; - if (jj_3R_72()) return true; - if (jj_scan_token(RPAREN)) return true; - if (jj_3R_313()) return true; - return false; - } - - final private boolean jj_3R_318() { - if (jj_scan_token(LPAREN)) return true; - if (jj_3R_72()) return true; - if (jj_scan_token(RPAREN)) return true; - if (jj_3R_307()) return true; - return false; - } - - final private boolean jj_3R_317() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_318()) { - jj_scanpos = xsp; - if (jj_3R_319()) return true; - } - return false; - } - - final private boolean jj_3R_293() { - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(97)) { - jj_scanpos = xsp; - if (jj_scan_token(98)) return true; - } - return false; - } - - final private boolean jj_3_27() { - if (jj_scan_token(LPAREN)) return true; - if (jj_3R_72()) return true; - if (jj_scan_token(LBRACKET)) return true; - return false; - } - - final private boolean jj_3R_266() { - if (jj_3R_90()) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_280()) jj_scanpos = xsp; - return false; - } - - final private boolean jj_3R_116() { - if (jj_scan_token(LPAREN)) return true; - if (jj_3R_72()) return true; - if (jj_scan_token(RPAREN)) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(88)) { - jj_scanpos = xsp; - if (jj_scan_token(87)) { - jj_scanpos = xsp; - if (jj_scan_token(75)) { - jj_scanpos = xsp; - if (jj_scan_token(72)) { - jj_scanpos = xsp; - if (jj_scan_token(52)) { - jj_scanpos = xsp; - if (jj_scan_token(49)) { - jj_scanpos = xsp; - if (jj_scan_token(39)) { - jj_scanpos = xsp; - if (jj_3R_152()) return true; - } - } - } - } - } - } - } - return false; - } - - final private boolean jj_3R_115() { - if (jj_scan_token(LPAREN)) return true; - if (jj_3R_72()) return true; - if (jj_scan_token(LBRACKET)) return true; - if (jj_scan_token(RBRACKET)) return true; - return false; - } - - final private boolean jj_3R_82() { - Token xsp; - xsp = jj_scanpos; - if (jj_3_26()) { - jj_scanpos = xsp; - if (jj_3R_115()) { - jj_scanpos = xsp; - if (jj_3R_116()) return true; - } - } - return false; - } - - final private boolean jj_3_26() { - if (jj_scan_token(LPAREN)) return true; - if (jj_3R_83()) return true; - return false; - } - - final private boolean jj_3_25() { - if (jj_3R_82()) return true; - return false; - } - - final private boolean jj_3_24() { - if (jj_3R_81()) return true; - return false; - } - - final private boolean jj_3R_316() { - if (jj_3R_266()) return true; - return false; - } - - final private boolean jj_3R_315() { - if (jj_3R_317()) return true; - return false; - } - - final private boolean jj_3R_314() { - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(88)) { - jj_scanpos = xsp; - if (jj_scan_token(87)) return true; - } - if (jj_3R_307()) return true; - return false; - } - - final private boolean jj_3R_313() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_314()) { - jj_scanpos = xsp; - if (jj_3R_315()) { - jj_scanpos = xsp; - if (jj_3R_316()) return true; - } - } - return false; - } - - final private boolean jj_3R_264() { - if (jj_scan_token(DECR)) return true; - if (jj_3R_90()) return true; - return false; - } - - final private boolean jj_3R_306() { - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(99)) { - jj_scanpos = xsp; - if (jj_scan_token(100)) return true; - } - if (jj_3R_305()) return true; - return false; - } - - final private boolean jj_3R_308() { - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(101)) { - jj_scanpos = xsp; - if (jj_scan_token(102)) { - jj_scanpos = xsp; - if (jj_scan_token(106)) return true; - } - } - if (jj_3R_307()) return true; - return false; - } - - final private boolean jj_3_23() { - if (jj_3R_80()) return true; - return false; - } - - final private boolean jj_3R_263() { - if (jj_scan_token(INCR)) return true; - if (jj_3R_90()) return true; - return false; - } - - final private boolean jj_3R_312() { - if (jj_3R_313()) return true; - return false; - } - - final private boolean jj_3_22() { - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(107)) { - jj_scanpos = xsp; - if (jj_3_23()) { - jj_scanpos = xsp; - if (jj_3_24()) return true; - } - } - if (jj_3R_304()) return true; - return false; - } - - final private boolean jj_3R_311() { - if (jj_3R_264()) return true; - return false; - } - - final private boolean jj_3R_310() { - if (jj_3R_263()) return true; - return false; - } - - final private boolean jj_3R_309() { - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(99)) { - jj_scanpos = xsp; - if (jj_scan_token(100)) return true; - } - if (jj_3R_307()) return true; - return false; - } - - final private boolean jj_3R_307() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_309()) { - jj_scanpos = xsp; - if (jj_3R_310()) { - jj_scanpos = xsp; - if (jj_3R_311()) { - jj_scanpos = xsp; - if (jj_3R_312()) return true; - } - } - } - return false; - } - - final private boolean jj_3R_303() { - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(86)) { - jj_scanpos = xsp; - if (jj_scan_token(122)) { - jj_scanpos = xsp; - if (jj_scan_token(92)) { - jj_scanpos = xsp; - if (jj_scan_token(93)) return true; - } - } - } - if (jj_3R_302()) return true; - return false; - } - - final private boolean jj_3R_301() { - if (jj_scan_token(INSTANCEOF)) return true; - if (jj_3R_72()) return true; - return false; - } - - final private boolean jj_3R_305() { - if (jj_3R_307()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_308()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3R_298() { - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(91)) { - jj_scanpos = xsp; - if (jj_scan_token(94)) return true; - } - if (jj_3R_297()) return true; - return false; - } - - final private boolean jj_3R_304() { - if (jj_3R_305()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_306()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3R_302() { - if (jj_3R_304()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3_22()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3R_288() { - if (jj_scan_token(BIT_AND)) return true; - if (jj_3R_287()) return true; - return false; - } - - final private boolean jj_3R_300() { - if (jj_3R_302()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_303()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3R_254() { - if (jj_scan_token(BIT_OR)) return true; - if (jj_3R_253()) return true; - return false; - } - - final private boolean jj_3R_297() { - if (jj_3R_300()) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_301()) jj_scanpos = xsp; - return false; - } - - final private boolean jj_3R_274() { - if (jj_scan_token(XOR)) return true; - if (jj_3R_273()) return true; - return false; - } - - final private boolean jj_3R_230() { - if (jj_scan_token(SC_AND)) return true; - if (jj_3R_229()) return true; - return false; - } - - final private boolean jj_3R_287() { - if (jj_3R_297()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_298()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3R_190() { - if (jj_scan_token(SC_OR)) return true; - if (jj_3R_189()) return true; - return false; - } - - final private boolean jj_3R_273() { - if (jj_3R_287()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_288()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3R_142() { - if (jj_scan_token(HOOK)) return true; - if (jj_3R_56()) return true; - if (jj_scan_token(COLON)) return true; - if (jj_3R_56()) return true; - return false; - } - - final private boolean jj_3R_253() { - if (jj_3R_273()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_274()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3R_229() { - if (jj_3R_253()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_254()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3R_189() { - if (jj_3R_229()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_230()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3R_141() { - if (jj_3R_189()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_190()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - final private boolean jj_3R_101() { - if (jj_3R_141()) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_142()) jj_scanpos = xsp; - return false; - } - - final private boolean jj_3R_265() { - if (jj_3R_90()) return true; - if (jj_3R_79()) return true; - if (jj_3R_56()) return true; - return false; - } - - final private boolean jj_3R_79() { - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(85)) { - jj_scanpos = xsp; - if (jj_scan_token(110)) { - jj_scanpos = xsp; - if (jj_scan_token(111)) { - jj_scanpos = xsp; - if (jj_scan_token(115)) { - jj_scanpos = xsp; - if (jj_scan_token(108)) { - jj_scanpos = xsp; - if (jj_scan_token(109)) { - jj_scanpos = xsp; - if (jj_scan_token(116)) { - jj_scanpos = xsp; - if (jj_scan_token(117)) { - jj_scanpos = xsp; - if (jj_scan_token(118)) { - jj_scanpos = xsp; - if (jj_scan_token(112)) { - jj_scanpos = xsp; - if (jj_scan_token(114)) { - jj_scanpos = xsp; - if (jj_scan_token(113)) - return true; - } - } - } - } - } - } - } - } - } - } - } - return false; - } - - final private boolean jj_3_21() { - if (jj_3R_79()) return true; - if (jj_3R_56()) return true; - return false; - } - - public JavaParserTokenManager token_source; - JavaCharStream jj_input_stream; - public Token token, jj_nt; - private int jj_ntk; - private Token jj_scanpos, jj_lastpos; - private int jj_la; - public boolean lookingAhead = false; - private boolean jj_semLA; - - public JavaParser(java.io.InputStream stream) { - this(stream, null); - } - - public JavaParser(java.io.InputStream stream, String encoding) { - try { - jj_input_stream = new JavaCharStream(stream, encoding, 1, 1); - } catch (java.io.UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - token_source = new JavaParserTokenManager(jj_input_stream); - token = new Token(); - jj_ntk = -1; - } - - public void ReInit(java.io.InputStream stream) { - ReInit(stream, null); - } - - public void ReInit(java.io.InputStream stream, String encoding) { - try { - jj_input_stream.ReInit(stream, encoding, 1, 1); - } catch (java.io.UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - token_source.ReInit(jj_input_stream); - token = new Token(); - jj_ntk = -1; - jjtree.reset(); - } - - public JavaParser(java.io.Reader stream) { - jj_input_stream = new JavaCharStream(stream, 1, 1); - token_source = new JavaParserTokenManager(jj_input_stream); - token = new Token(); - jj_ntk = -1; - } - - public void ReInit(java.io.Reader stream) { - jj_input_stream.ReInit(stream, 1, 1); - token_source.ReInit(jj_input_stream); - token = new Token(); - jj_ntk = -1; - jjtree.reset(); - } - - public JavaParser(JavaParserTokenManager tm) { - token_source = tm; - token = new Token(); - jj_ntk = -1; - } - - public void ReInit(JavaParserTokenManager tm) { - token_source = tm; - token = new Token(); - jj_ntk = -1; - jjtree.reset(); - } - - final private Token jj_consume_token(int kind) throws ParseException { - Token oldToken; - if ((oldToken = token).next != null) token = token.next; - else token = token.next = token_source.getNextToken(); - jj_ntk = -1; - if (token.kind == kind) { - return token; - } - token = oldToken; - throw generateParseException(); - } - - static private final class LookaheadSuccess extends java.lang.Error { - } - - final private LookaheadSuccess jj_ls = new LookaheadSuccess(); - - final private boolean jj_scan_token(int kind) { - if (jj_scanpos == jj_lastpos) { - jj_la--; - if (jj_scanpos.next == null) { - jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken(); - } else { - jj_lastpos = jj_scanpos = jj_scanpos.next; - } - } else { - jj_scanpos = jj_scanpos.next; - } - if (jj_scanpos.kind != kind) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls; - return false; - } - - final public Token getNextToken() { - if (token.next != null) token = token.next; - else token = token.next = token_source.getNextToken(); - jj_ntk = -1; - return token; - } - - final public Token getToken(int index) { - Token t = lookingAhead ? jj_scanpos : token; - for (int i = 0; i < index; i++) { - if (t.next != null) t = t.next; - else t = t.next = token_source.getNextToken(); - } - return t; - } - - final private int jj_ntk() { - if ((jj_nt = token.next) == null) - return (jj_ntk = (token.next = token_source.getNextToken()).kind); - else - return (jj_ntk = jj_nt.kind); - } - - public ParseException generateParseException() { - Token errortok = token.next; - int line = errortok.beginLine, column = errortok.beginColumn; - String mess = (errortok.kind == 0) ? tokenImage[0] : errortok.image; - return new ParseException("Unable to parse Java code near token: " + mess, line, column); - } - - final public void enable_tracing() { - } - - final public void disable_tracing() { - } - -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParser.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParser.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParser.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParser.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,10068 @@ +/* Generated By:JJTree&JavaCC: Do not edit this line. JavaParser.java */ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.java.parser; + +import java.io.File; +import java.io.FileInputStream; + +/** + * Grammar to parse Java version 1.5 + * + * @author Sreenivasa Viswanadha - Simplified and enhanced for 1.5 + */ +public class JavaParser/*@bgen(jjtree)*/ implements JavaParserTreeConstants, JavaParserConstants {/*@bgen(jjtree)*/ + protected JJTJavaParserState jjtree = new JJTJavaParserState(); + + /** Class to hold modifiers. */ + static public final class ModifierSet { + /* Definitions of the bits in the modifiers field. */ + public static final int PUBLIC = 0x0001; + public static final int PROTECTED = 0x0002; + public static final int PRIVATE = 0x0004; + public static final int ABSTRACT = 0x0008; + public static final int STATIC = 0x0010; + public static final int FINAL = 0x0020; + public static final int SYNCHRONIZED = 0x0040; + public static final int NATIVE = 0x0080; + public static final int TRANSIENT = 0x0100; + public static final int VOLATILE = 0x0200; + public static final int STRICTFP = 0x1000; + + /** + * A set of accessors that indicate whether the specified modifier + * is in the set. + */ + + public boolean isPublic(int modifiers) { + return (modifiers & PUBLIC) != 0; + } + + public boolean isProtected(int modifiers) { + return (modifiers & PROTECTED) != 0; + } + + public boolean isPrivate(int modifiers) { + return (modifiers & PRIVATE) != 0; + } + + public boolean isStatic(int modifiers) { + return (modifiers & STATIC) != 0; + } + + public boolean isAbstract(int modifiers) { + return (modifiers & ABSTRACT) != 0; + } + + public boolean isFinal(int modifiers) { + return (modifiers & FINAL) != 0; + } + + public boolean isNative(int modifiers) { + return (modifiers & NATIVE) != 0; + } + + public boolean isStrictfp(int modifiers) { + return (modifiers & STRICTFP) != 0; + } + + public boolean isSynchronized(int modifiers) { + return (modifiers & SYNCHRONIZED) != 0; + } + + public boolean isTransient(int modifiers) { + return (modifiers & TRANSIENT) != 0; + } + + public boolean isVolatile(int modifiers) { + return (modifiers & VOLATILE) != 0; + } + + /** Removes the given modifier. */ + static int removeModifier(int modifiers, int mod) { + return modifiers & ~mod; + } + } + + public JavaParser(String fileName) { + this(System.in); + try { + ReInit(new FileInputStream(new File(fileName))); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + void jjtreeOpenNodeScope(Node n) { + ((SimpleNode) n).firstToken = getToken(1); + } + + void jjtreeCloseNodeScope(Node n) { + ((SimpleNode) n).lastToken = getToken(0); + } + + public SimpleNode popNode() { + if (jjtree.nodeArity() > 0) // number of child nodes + return (SimpleNode) jjtree.popNode(); + else + return null; + } + + public static void main(String args[]) { + JavaParser parser; + if (args.length == 0) { + System.out.println("Java Parser Version 1.1: Reading from standard input . . ."); + parser = new JavaParser(System.in); + } else if (args.length == 1) { + System.out.println("Java Parser Version 1.1: Reading from file " + args[0] + " . . ."); + try { + parser = new JavaParser(new java.io.FileInputStream(args[0])); + } catch (java.io.FileNotFoundException e) { + System.out.println("Java Parser Version 1.1: File " + args[0] + " not found."); + return; + } + } else { + System.out.println("Java Parser Version 1.1: Usage is one of:"); + System.out.println(" java JavaParser < inputfile"); + System.out.println("OR"); + System.out.println(" java JavaParser inputfile"); + return; + } + try { + parser.CompilationUnit(); + System.out.println("Java Parser Version 1.1: Java program parsed successfully."); + } catch (ParseException e) { + System.out.println(e.getMessage()); + System.out.println("Java Parser Version 1.1: Encountered errors during parse."); + } + } + + final public boolean Line() throws ParseException { + /*@bgen(jjtree) Line */ + SimpleNode jjtn000 = new SimpleNode(JJTLINE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + int modifiers; + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case 0: + jj_consume_token(0); + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtreeCloseNodeScope(jjtn000); + { + if (true) return true; + } + break; + default: + if (jj_2_1(2147483647)) { + BlockStatement(); + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtreeCloseNodeScope(jjtn000); + { + if (true) return false; + } + } else if (jj_2_2(2147483647)) { + ClassOrInterfaceBodyDeclaration(false); + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtreeCloseNodeScope(jjtn000); + { + if (true) return false; + } + } else if (jj_2_3(2147483647)) { + ClassOrInterfaceBodyDeclaration(false); + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtreeCloseNodeScope(jjtn000); + { + if (true) return false; + } + } else if (jj_2_4(2147483647)) { + Expression(); + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtreeCloseNodeScope(jjtn000); + { + if (true) return false; + } + } else { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case IMPORT: + ImportDeclaration(); + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtreeCloseNodeScope(jjtn000); + { + if (true) return false; + } + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + throw new Error("Missing return statement in function"); + } + + /** + * ************************************** + * THE JAVA LANGUAGE GRAMMAR STARTS HERE * + * *************************************** + */ + +/* + * Program structuring syntax follows. + */ + final public void CompilationUnit() throws ParseException { + /*@bgen(jjtree) CompilationUnit */ + SimpleNode jjtn000 = new SimpleNode(JJTCOMPILATIONUNIT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + if (jj_2_5(2147483647)) { + PackageDeclaration(); + } else { + ; + } + label_1: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case IMPORT: + ; + break; + default: + break label_1; + } + ImportDeclaration(); + } + label_2: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case ABSTRACT: + case CLASS: + case ENUM: + case FINAL: + case INTERFACE: + case NATIVE: + case PRIVATE: + case PROTECTED: + case PUBLIC: + case STATIC: + case STRICTFP: + case SYNCHRONIZED: + case TRANSIENT: + case VOLATILE: + case SEMICOLON: + case AT: + ; + break; + default: + break label_2; + } + TypeDeclaration(); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case 123: + jj_consume_token(123); + break; + default: + ; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case STUFF_TO_IGNORE: + jj_consume_token(STUFF_TO_IGNORE); + break; + default: + ; + } + jj_consume_token(0); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void PackageDeclaration() throws ParseException { + /*@bgen(jjtree) PackageDeclaration */ + SimpleNode jjtn000 = new SimpleNode(JJTPACKAGEDECLARATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + Modifiers(); + jj_consume_token(PACKAGE); + Name(); + jj_consume_token(SEMICOLON); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void ImportDeclaration() throws ParseException { + /*@bgen(jjtree) ImportDeclaration */ + SimpleNode jjtn000 = new SimpleNode(JJTIMPORTDECLARATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(IMPORT); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case STATIC: + jj_consume_token(STATIC); + break; + default: + ; + } + Name(); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case DOT: + jj_consume_token(DOT); + jj_consume_token(STAR); + break; + default: + ; + } + jj_consume_token(SEMICOLON); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + /* + * Modifiers. We match all modifiers in a single rule to reduce the chances of + * syntax errors for simple modifier mistakes. It will also enable us to give + * better error messages. + */ + final public int Modifiers() throws ParseException { + /*@bgen(jjtree) Modifiers */ + SimpleNode jjtn000 = new SimpleNode(JJTMODIFIERS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + int modifiers = 0; + try { + label_3: + while (true) { + if (jj_2_6(2)) { + ; + } else { + break label_3; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PUBLIC: + jj_consume_token(PUBLIC); + modifiers |= ModifierSet.PUBLIC; + break; + case STATIC: + jj_consume_token(STATIC); + modifiers |= ModifierSet.STATIC; + break; + case PROTECTED: + jj_consume_token(PROTECTED); + modifiers |= ModifierSet.PROTECTED; + break; + case PRIVATE: + jj_consume_token(PRIVATE); + modifiers |= ModifierSet.PRIVATE; + break; + case FINAL: + jj_consume_token(FINAL); + modifiers |= ModifierSet.FINAL; + break; + case ABSTRACT: + jj_consume_token(ABSTRACT); + modifiers |= ModifierSet.ABSTRACT; + break; + case SYNCHRONIZED: + jj_consume_token(SYNCHRONIZED); + modifiers |= ModifierSet.SYNCHRONIZED; + break; + case NATIVE: + jj_consume_token(NATIVE); + modifiers |= ModifierSet.NATIVE; + break; + case TRANSIENT: + jj_consume_token(TRANSIENT); + modifiers |= ModifierSet.TRANSIENT; + break; + case VOLATILE: + jj_consume_token(VOLATILE); + modifiers |= ModifierSet.VOLATILE; + break; + case STRICTFP: + jj_consume_token(STRICTFP); + modifiers |= ModifierSet.STRICTFP; + break; + case AT: + Annotation(); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtreeCloseNodeScope(jjtn000); + { + if (true) return modifiers; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + throw new Error("Missing return statement in function"); + } + + /* + * Declaration syntax follows. + */ + final public void TypeDeclaration() throws ParseException { + /*@bgen(jjtree) TypeDeclaration */ + SimpleNode jjtn000 = new SimpleNode(JJTTYPEDECLARATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + int modifiers; + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case SEMICOLON: + jj_consume_token(SEMICOLON); + break; + case ABSTRACT: + case CLASS: + case ENUM: + case FINAL: + case INTERFACE: + case NATIVE: + case PRIVATE: + case PROTECTED: + case PUBLIC: + case STATIC: + case STRICTFP: + case SYNCHRONIZED: + case TRANSIENT: + case VOLATILE: + case AT: + modifiers = Modifiers(); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case CLASS: + case INTERFACE: + ClassOrInterfaceDeclaration(modifiers); + break; + case ENUM: + EnumDeclaration(modifiers); + break; + case AT: + AnnotationTypeDeclaration(modifiers); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void ClassOrInterfaceDeclaration(int modifiers) throws ParseException { + /*@bgen(jjtree) ClassOrInterfaceDeclaration */ + SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACEDECLARATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + boolean isInterface = false; + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case CLASS: + jj_consume_token(CLASS); + break; + case INTERFACE: + jj_consume_token(INTERFACE); + isInterface = true; + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + jj_consume_token(IDENTIFIER); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LT: + TypeParameters(); + break; + default: + ; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case EXTENDS: + ExtendsList(isInterface); + break; + default: + ; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case IMPLEMENTS: + ImplementsList(isInterface); + break; + default: + ; + } + ClassOrInterfaceBody(isInterface); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void ExtendsList(boolean isInterface) throws ParseException { + /*@bgen(jjtree) ExtendsList */ + SimpleNode jjtn000 = new SimpleNode(JJTEXTENDSLIST); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + boolean extendsMoreThanOne = false; + try { + jj_consume_token(EXTENDS); + ClassOrInterfaceType(); + label_4: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COMMA: + ; + break; + default: + break label_4; + } + jj_consume_token(COMMA); + ClassOrInterfaceType(); + extendsMoreThanOne = true; + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtreeCloseNodeScope(jjtn000); + if (extendsMoreThanOne && !isInterface) { + if (true) + throw new ParseException("A class cannot extend more than one other class"); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void ImplementsList(boolean isInterface) throws ParseException { + /*@bgen(jjtree) ImplementsList */ + SimpleNode jjtn000 = new SimpleNode(JJTIMPLEMENTSLIST); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(IMPLEMENTS); + ClassOrInterfaceType(); + label_5: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COMMA: + ; + break; + default: + break label_5; + } + jj_consume_token(COMMA); + ClassOrInterfaceType(); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtreeCloseNodeScope(jjtn000); + if (isInterface) { + if (true) + throw new ParseException("An interface cannot implement other interfaces"); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void EnumDeclaration(int modifiers) throws ParseException { + /*@bgen(jjtree) EnumDeclaration */ + SimpleNode jjtn000 = new SimpleNode(JJTENUMDECLARATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(ENUM); + jj_consume_token(IDENTIFIER); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case IMPLEMENTS: + ImplementsList(false); + break; + default: + ; + } + EnumBody(); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void EnumBody() throws ParseException { + /*@bgen(jjtree) EnumBody */ + SimpleNode jjtn000 = new SimpleNode(JJTENUMBODY); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(LBRACE); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case ABSTRACT: + case FINAL: + case NATIVE: + case PRIVATE: + case PROTECTED: + case PUBLIC: + case STATIC: + case STRICTFP: + case SYNCHRONIZED: + case TRANSIENT: + case VOLATILE: + case IDENTIFIER: + case AT: + EnumConstant(); + label_6: + while (true) { + if (jj_2_7(2)) { + ; + } else { + break label_6; + } + jj_consume_token(COMMA); + EnumConstant(); + } + break; + default: + ; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COMMA: + jj_consume_token(COMMA); + break; + default: + ; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case SEMICOLON: + jj_consume_token(SEMICOLON); + label_7: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case ABSTRACT: + case BOOLEAN: + case BYTE: + case CHAR: + case CLASS: + case DOUBLE: + case ENUM: + case FINAL: + case FLOAT: + case INT: + case INTERFACE: + case LONG: + case NATIVE: + case PRIVATE: + case PROTECTED: + case PUBLIC: + case SHORT: + case STATIC: + case STRICTFP: + case SYNCHRONIZED: + case TRANSIENT: + case VOID: + case VOLATILE: + case IDENTIFIER: + case LBRACE: + case SEMICOLON: + case AT: + case LT: + ; + break; + default: + break label_7; + } + ClassOrInterfaceBodyDeclaration(false); + } + break; + default: + ; + } + jj_consume_token(RBRACE); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void EnumConstant() throws ParseException { + /*@bgen(jjtree) EnumConstant */ + SimpleNode jjtn000 = new SimpleNode(JJTENUMCONSTANT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + Modifiers(); + jj_consume_token(IDENTIFIER); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LPAREN: + Arguments(); + break; + default: + ; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LBRACE: + ClassOrInterfaceBody(false); + break; + default: + ; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void TypeParameters() throws ParseException { + /*@bgen(jjtree) TypeParameters */ + SimpleNode jjtn000 = new SimpleNode(JJTTYPEPARAMETERS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(LT); + TypeParameter(); + label_8: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COMMA: + ; + break; + default: + break label_8; + } + jj_consume_token(COMMA); + TypeParameter(); + } + jj_consume_token(GT); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void TypeParameter() throws ParseException { + /*@bgen(jjtree) TypeParameter */ + SimpleNode jjtn000 = new SimpleNode(JJTTYPEPARAMETER); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(IDENTIFIER); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case EXTENDS: + TypeBound(); + break; + default: + ; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void TypeBound() throws ParseException { + /*@bgen(jjtree) TypeBound */ + SimpleNode jjtn000 = new SimpleNode(JJTTYPEBOUND); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(EXTENDS); + ClassOrInterfaceType(); + label_9: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case BIT_AND: + ; + break; + default: + break label_9; + } + jj_consume_token(BIT_AND); + ClassOrInterfaceType(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void ClassOrInterfaceBody(boolean isInterface) throws ParseException { + /*@bgen(jjtree) ClassOrInterfaceBody */ + SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACEBODY); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(LBRACE); + label_10: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case ABSTRACT: + case BOOLEAN: + case BYTE: + case CHAR: + case CLASS: + case DOUBLE: + case ENUM: + case FINAL: + case FLOAT: + case INT: + case INTERFACE: + case LONG: + case NATIVE: + case PRIVATE: + case PROTECTED: + case PUBLIC: + case SHORT: + case STATIC: + case STRICTFP: + case SYNCHRONIZED: + case TRANSIENT: + case VOID: + case VOLATILE: + case IDENTIFIER: + case LBRACE: + case SEMICOLON: + case AT: + case LT: + ; + break; + default: + break label_10; + } + ClassOrInterfaceBodyDeclaration(isInterface); + } + jj_consume_token(RBRACE); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void ClassOrInterfaceBodyDeclaration(boolean isInterface) throws ParseException { + /*@bgen(jjtree) ClassOrInterfaceBodyDeclaration */ + SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACEBODYDECLARATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + boolean isNestedInterface = false; + int modifiers; + try { + if (jj_2_10(2)) { + Initializer(); + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtreeCloseNodeScope(jjtn000); + if (isInterface) { + if (true) + throw new ParseException("An interface cannot have initializers"); + } + } else { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case ABSTRACT: + case BOOLEAN: + case BYTE: + case CHAR: + case CLASS: + case DOUBLE: + case ENUM: + case FINAL: + case FLOAT: + case INT: + case INTERFACE: + case LONG: + case NATIVE: + case PRIVATE: + case PROTECTED: + case PUBLIC: + case SHORT: + case STATIC: + case STRICTFP: + case SYNCHRONIZED: + case TRANSIENT: + case VOID: + case VOLATILE: + case IDENTIFIER: + case AT: + case LT: + modifiers = Modifiers(); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case CLASS: + case INTERFACE: + ClassOrInterfaceDeclaration(modifiers); + break; + case ENUM: + EnumDeclaration(modifiers); + break; + default: + if (jj_2_8(2147483647)) { + ConstructorDeclaration(); + } else if (jj_2_9(2147483647)) { + FieldDeclaration(modifiers); + } else { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FLOAT: + case INT: + case LONG: + case SHORT: + case VOID: + case IDENTIFIER: + case LT: + MethodDeclaration(modifiers); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } + } + break; + case SEMICOLON: + jj_consume_token(SEMICOLON); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void FieldDeclaration(int modifiers) throws ParseException { + /*@bgen(jjtree) FieldDeclaration */ + SimpleNode jjtn000 = new SimpleNode(JJTFIELDDECLARATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + Type(); + VariableDeclarator(); + label_11: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COMMA: + ; + break; + default: + break label_11; + } + jj_consume_token(COMMA); + VariableDeclarator(); + } + jj_consume_token(SEMICOLON); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void VariableDeclarator() throws ParseException { + /*@bgen(jjtree) VariableDeclarator */ + SimpleNode jjtn000 = new SimpleNode(JJTVARIABLEDECLARATOR); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + VariableDeclaratorId(); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case ASSIGN: + jj_consume_token(ASSIGN); + VariableInitializer(); + break; + default: + ; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void VariableDeclaratorId() throws ParseException { + /*@bgen(jjtree) VariableDeclaratorId */ + SimpleNode jjtn000 = new SimpleNode(JJTVARIABLEDECLARATORID); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(IDENTIFIER); + label_12: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LBRACKET: + ; + break; + default: + break label_12; + } + jj_consume_token(LBRACKET); + jj_consume_token(RBRACKET); + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void VariableInitializer() throws ParseException { + /*@bgen(jjtree) VariableInitializer */ + SimpleNode jjtn000 = new SimpleNode(JJTVARIABLEINITIALIZER); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LBRACE: + ArrayInitializer(); + break; + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FLOAT: + case INT: + case LONG: + case NEW: + case NULL: + case SHORT: + case SUPER: + case THIS: + case TRUE: + case VOID: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case BANG: + case TILDE: + case INCR: + case DECR: + case PLUS: + case MINUS: + Expression(); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void ArrayInitializer() throws ParseException { + /*@bgen(jjtree) ArrayInitializer */ + SimpleNode jjtn000 = new SimpleNode(JJTARRAYINITIALIZER); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(LBRACE); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FLOAT: + case INT: + case LONG: + case NEW: + case NULL: + case SHORT: + case SUPER: + case THIS: + case TRUE: + case VOID: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case LBRACE: + case BANG: + case TILDE: + case INCR: + case DECR: + case PLUS: + case MINUS: + VariableInitializer(); + label_13: + while (true) { + if (jj_2_11(2)) { + ; + } else { + break label_13; + } + jj_consume_token(COMMA); + VariableInitializer(); + } + break; + default: + ; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COMMA: + jj_consume_token(COMMA); + break; + default: + ; + } + jj_consume_token(RBRACE); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void MethodDeclaration(int modifiers) throws ParseException { + /*@bgen(jjtree) MethodDeclaration */ + SimpleNode jjtn000 = new SimpleNode(JJTMETHODDECLARATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LT: + TypeParameters(); + break; + default: + ; + } + ResultType(); + MethodDeclarator(); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case THROWS: + jj_consume_token(THROWS); + NameList(); + break; + default: + ; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LBRACE: + Block(); + break; + case SEMICOLON: + jj_consume_token(SEMICOLON); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void MethodDeclarator() throws ParseException { + /*@bgen(jjtree) MethodDeclarator */ + SimpleNode jjtn000 = new SimpleNode(JJTMETHODDECLARATOR); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(IDENTIFIER); + FormalParameters(); + label_14: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LBRACKET: + ; + break; + default: + break label_14; + } + jj_consume_token(LBRACKET); + jj_consume_token(RBRACKET); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void FormalParameters() throws ParseException { + /*@bgen(jjtree) FormalParameters */ + SimpleNode jjtn000 = new SimpleNode(JJTFORMALPARAMETERS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(LPAREN); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case ABSTRACT: + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FINAL: + case FLOAT: + case INT: + case LONG: + case NATIVE: + case PRIVATE: + case PROTECTED: + case PUBLIC: + case SHORT: + case STATIC: + case STRICTFP: + case SYNCHRONIZED: + case TRANSIENT: + case VOLATILE: + case IDENTIFIER: + case AT: + FormalParameter(); + label_15: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COMMA: + ; + break; + default: + break label_15; + } + jj_consume_token(COMMA); + FormalParameter(); + } + break; + default: + ; + } + jj_consume_token(RPAREN); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void FormalParameter() throws ParseException { + /*@bgen(jjtree) FormalParameter */ + SimpleNode jjtn000 = new SimpleNode(JJTFORMALPARAMETER); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + Modifiers(); + Type(); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case ELLIPSIS: + jj_consume_token(ELLIPSIS); + break; + default: + ; + } + VariableDeclaratorId(); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void ConstructorDeclaration() throws ParseException { + /*@bgen(jjtree) ConstructorDeclaration */ + SimpleNode jjtn000 = new SimpleNode(JJTCONSTRUCTORDECLARATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LT: + TypeParameters(); + break; + default: + ; + } + jj_consume_token(IDENTIFIER); + FormalParameters(); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case THROWS: + jj_consume_token(THROWS); + NameList(); + break; + default: + ; + } + jj_consume_token(LBRACE); + if (jj_2_12(2147483647)) { + ExplicitConstructorInvocation(); + } else { + ; + } + label_16: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case ABSTRACT: + case ASSERT: + case BOOLEAN: + case BREAK: + case BYTE: + case CHAR: + case CLASS: + case CONTINUE: + case DO: + case DOUBLE: + case FALSE: + case FINAL: + case FLOAT: + case FOR: + case IF: + case INT: + case INTERFACE: + case LONG: + case NATIVE: + case NEW: + case NULL: + case PRIVATE: + case PROTECTED: + case PUBLIC: + case RETURN: + case SHORT: + case STATIC: + case STRICTFP: + case SUPER: + case SWITCH: + case SYNCHRONIZED: + case THIS: + case THROW: + case TRANSIENT: + case TRUE: + case TRY: + case VOID: + case VOLATILE: + case WHILE: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case LBRACE: + case SEMICOLON: + case AT: + case INCR: + case DECR: + ; + break; + default: + break label_16; + } + BlockStatement(); + } + jj_consume_token(RBRACE); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void ExplicitConstructorInvocation() throws ParseException { + /*@bgen(jjtree) ExplicitConstructorInvocation */ + SimpleNode jjtn000 = new SimpleNode(JJTEXPLICITCONSTRUCTORINVOCATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + label_17: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case IDENTIFIER: + ; + break; + default: + break label_17; + } + jj_consume_token(IDENTIFIER); + jj_consume_token(DOT); + } + if (jj_2_13(2)) { + jj_consume_token(THIS); + jj_consume_token(DOT); + } else { + ; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LT: + TypeArguments(); + break; + default: + ; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case THIS: + jj_consume_token(THIS); + break; + case SUPER: + jj_consume_token(SUPER); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + Arguments(); + jj_consume_token(SEMICOLON); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void Initializer() throws ParseException { + /*@bgen(jjtree) Initializer */ + SimpleNode jjtn000 = new SimpleNode(JJTINITIALIZER); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case STATIC: + jj_consume_token(STATIC); + break; + default: + ; + } + Block(); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + /* + * Type, name and expression syntax follows. + */ + final public void Type() throws ParseException { + /*@bgen(jjtree) Type */ + SimpleNode jjtn000 = new SimpleNode(JJTTYPE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + if (jj_2_14(2)) { + ReferenceType(); + } else { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FLOAT: + case INT: + case LONG: + case SHORT: + PrimitiveType(); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void ReferenceType() throws ParseException { + /*@bgen(jjtree) ReferenceType */ + SimpleNode jjtn000 = new SimpleNode(JJTREFERENCETYPE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FLOAT: + case INT: + case LONG: + case SHORT: + PrimitiveType(); + label_18: + while (true) { + jj_consume_token(LBRACKET); + jj_consume_token(RBRACKET); + if (jj_2_15(2)) { + ; + } else { + break label_18; + } + } + break; + case IDENTIFIER: + ClassOrInterfaceType(); + label_19: + while (true) { + if (jj_2_16(2)) { + ; + } else { + break label_19; + } + jj_consume_token(LBRACKET); + jj_consume_token(RBRACKET); + } + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void ClassOrInterfaceType() throws ParseException { + /*@bgen(jjtree) ClassOrInterfaceType */ + SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACETYPE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(IDENTIFIER); + if (jj_2_17(2)) { + TypeArguments(); + } else { + ; + } + label_20: + while (true) { + if (jj_2_18(2)) { + ; + } else { + break label_20; + } + jj_consume_token(DOT); + jj_consume_token(IDENTIFIER); + if (jj_2_19(2)) { + TypeArguments(); + } else { + ; + } + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void TypeArguments() throws ParseException { + /*@bgen(jjtree) TypeArguments */ + SimpleNode jjtn000 = new SimpleNode(JJTTYPEARGUMENTS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(LT); + TypeArgument(); + label_21: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COMMA: + ; + break; + default: + break label_21; + } + jj_consume_token(COMMA); + TypeArgument(); + } + jj_consume_token(GT); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void TypeArgument() throws ParseException { + /*@bgen(jjtree) TypeArgument */ + SimpleNode jjtn000 = new SimpleNode(JJTTYPEARGUMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FLOAT: + case INT: + case LONG: + case SHORT: + case IDENTIFIER: + ReferenceType(); + break; + case HOOK: + jj_consume_token(HOOK); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case EXTENDS: + case SUPER: + WildcardBounds(); + break; + default: + ; + } + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void WildcardBounds() throws ParseException { + /*@bgen(jjtree) WildcardBounds */ + SimpleNode jjtn000 = new SimpleNode(JJTWILDCARDBOUNDS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case EXTENDS: + jj_consume_token(EXTENDS); + ReferenceType(); + break; + case SUPER: + jj_consume_token(SUPER); + ReferenceType(); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void PrimitiveType() throws ParseException { + /*@bgen(jjtree) PrimitiveType */ + SimpleNode jjtn000 = new SimpleNode(JJTPRIMITIVETYPE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case BOOLEAN: + jj_consume_token(BOOLEAN); + break; + case CHAR: + jj_consume_token(CHAR); + break; + case BYTE: + jj_consume_token(BYTE); + break; + case SHORT: + jj_consume_token(SHORT); + break; + case INT: + jj_consume_token(INT); + break; + case LONG: + jj_consume_token(LONG); + break; + case FLOAT: + jj_consume_token(FLOAT); + break; + case DOUBLE: + jj_consume_token(DOUBLE); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void ResultType() throws ParseException { + /*@bgen(jjtree) ResultType */ + SimpleNode jjtn000 = new SimpleNode(JJTRESULTTYPE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case VOID: + jj_consume_token(VOID); + break; + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FLOAT: + case INT: + case LONG: + case SHORT: + case IDENTIFIER: + Type(); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void Name() throws ParseException { + /*@bgen(jjtree) Name */ + SimpleNode jjtn000 = new SimpleNode(JJTNAME); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(IDENTIFIER); + label_22: + while (true) { + if (jj_2_20(2)) { + ; + } else { + break label_22; + } + jj_consume_token(DOT); + jj_consume_token(IDENTIFIER); + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void NameList() throws ParseException { + /*@bgen(jjtree) NameList */ + SimpleNode jjtn000 = new SimpleNode(JJTNAMELIST); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + Name(); + label_23: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COMMA: + ; + break; + default: + break label_23; + } + jj_consume_token(COMMA); + Name(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + /* + * Expression syntax follows. + */ + final public void Expression() throws ParseException { + /*@bgen(jjtree) Expression */ + SimpleNode jjtn000 = new SimpleNode(JJTEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + ConditionalExpression(); + if (jj_2_21(2)) { + AssignmentOperator(); + Expression(); + } else { + ; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void AssignmentOperator() throws ParseException { + /*@bgen(jjtree) AssignmentOperator */ + SimpleNode jjtn000 = new SimpleNode(JJTASSIGNMENTOPERATOR); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case ASSIGN: + jj_consume_token(ASSIGN); + break; + case STARASSIGN: + jj_consume_token(STARASSIGN); + break; + case SLASHASSIGN: + jj_consume_token(SLASHASSIGN); + break; + case REMASSIGN: + jj_consume_token(REMASSIGN); + break; + case PLUSASSIGN: + jj_consume_token(PLUSASSIGN); + break; + case MINUSASSIGN: + jj_consume_token(MINUSASSIGN); + break; + case LSHIFTASSIGN: + jj_consume_token(LSHIFTASSIGN); + break; + case RSIGNEDSHIFTASSIGN: + jj_consume_token(RSIGNEDSHIFTASSIGN); + break; + case RUNSIGNEDSHIFTASSIGN: + jj_consume_token(RUNSIGNEDSHIFTASSIGN); + break; + case ANDASSIGN: + jj_consume_token(ANDASSIGN); + break; + case XORASSIGN: + jj_consume_token(XORASSIGN); + break; + case ORASSIGN: + jj_consume_token(ORASSIGN); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void AssignmentExpression() throws ParseException { + /*@bgen(jjtree) AssignmentExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTASSIGNMENTEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + PrimaryExpression(); + AssignmentOperator(); + Expression(); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void ConditionalExpression() throws ParseException { + /*@bgen(jjtree) ConditionalExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTCONDITIONALEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + ConditionalOrExpression(); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case HOOK: + jj_consume_token(HOOK); + Expression(); + jj_consume_token(COLON); + Expression(); + break; + default: + ; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void ConditionalOrExpression() throws ParseException { + /*@bgen(jjtree) ConditionalOrExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTCONDITIONALOREXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + ConditionalAndExpression(); + label_24: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case SC_OR: + ; + break; + default: + break label_24; + } + jj_consume_token(SC_OR); + ConditionalAndExpression(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void ConditionalAndExpression() throws ParseException { + /*@bgen(jjtree) ConditionalAndExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTCONDITIONALANDEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + InclusiveOrExpression(); + label_25: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case SC_AND: + ; + break; + default: + break label_25; + } + jj_consume_token(SC_AND); + InclusiveOrExpression(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void InclusiveOrExpression() throws ParseException { + /*@bgen(jjtree) InclusiveOrExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTINCLUSIVEOREXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + ExclusiveOrExpression(); + label_26: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case BIT_OR: + ; + break; + default: + break label_26; + } + jj_consume_token(BIT_OR); + ExclusiveOrExpression(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void ExclusiveOrExpression() throws ParseException { + /*@bgen(jjtree) ExclusiveOrExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTEXCLUSIVEOREXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + AndExpression(); + label_27: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case XOR: + ; + break; + default: + break label_27; + } + jj_consume_token(XOR); + AndExpression(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void AndExpression() throws ParseException { + /*@bgen(jjtree) AndExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTANDEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + EqualityExpression(); + label_28: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case BIT_AND: + ; + break; + default: + break label_28; + } + jj_consume_token(BIT_AND); + EqualityExpression(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void EqualityExpression() throws ParseException { + /*@bgen(jjtree) EqualityExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTEQUALITYEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + InstanceOfExpression(); + label_29: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case EQ: + case NE: + ; + break; + default: + break label_29; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case EQ: + jj_consume_token(EQ); + break; + case NE: + jj_consume_token(NE); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + InstanceOfExpression(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void InstanceOfExpression() throws ParseException { + /*@bgen(jjtree) InstanceOfExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTINSTANCEOFEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + RelationalExpression(); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case INSTANCEOF: + jj_consume_token(INSTANCEOF); + Type(); + break; + default: + ; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void RelationalExpression() throws ParseException { + /*@bgen(jjtree) RelationalExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTRELATIONALEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + ShiftExpression(); + label_30: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LT: + case LE: + case GE: + case GT: + ; + break; + default: + break label_30; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LT: + jj_consume_token(LT); + break; + case GT: + jj_consume_token(GT); + break; + case LE: + jj_consume_token(LE); + break; + case GE: + jj_consume_token(GE); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + ShiftExpression(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void ShiftExpression() throws ParseException { + /*@bgen(jjtree) ShiftExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTSHIFTEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + AdditiveExpression(); + label_31: + while (true) { + if (jj_2_22(1)) { + ; + } else { + break label_31; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LSHIFT: + jj_consume_token(LSHIFT); + break; + default: + if (jj_2_23(1)) { + RSIGNEDSHIFT(); + } else if (jj_2_24(1)) { + RUNSIGNEDSHIFT(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } + AdditiveExpression(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void AdditiveExpression() throws ParseException { + /*@bgen(jjtree) AdditiveExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTADDITIVEEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + MultiplicativeExpression(); + label_32: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PLUS: + case MINUS: + ; + break; + default: + break label_32; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PLUS: + jj_consume_token(PLUS); + break; + case MINUS: + jj_consume_token(MINUS); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + MultiplicativeExpression(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void MultiplicativeExpression() throws ParseException { + /*@bgen(jjtree) MultiplicativeExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTMULTIPLICATIVEEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + UnaryExpression(); + label_33: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case STAR: + case SLASH: + case REM: + ; + break; + default: + break label_33; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case STAR: + jj_consume_token(STAR); + break; + case SLASH: + jj_consume_token(SLASH); + break; + case REM: + jj_consume_token(REM); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + UnaryExpression(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void UnaryExpression() throws ParseException { + /*@bgen(jjtree) UnaryExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTUNARYEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PLUS: + case MINUS: + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PLUS: + jj_consume_token(PLUS); + break; + case MINUS: + jj_consume_token(MINUS); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + UnaryExpression(); + break; + case INCR: + PreIncrementExpression(); + break; + case DECR: + PreDecrementExpression(); + break; + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FLOAT: + case INT: + case LONG: + case NEW: + case NULL: + case SHORT: + case SUPER: + case THIS: + case TRUE: + case VOID: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case BANG: + case TILDE: + UnaryExpressionNotPlusMinus(); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void PreIncrementExpression() throws ParseException { + /*@bgen(jjtree) PreIncrementExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTPREINCREMENTEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(INCR); + PrimaryExpression(); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void PreDecrementExpression() throws ParseException { + /*@bgen(jjtree) PreDecrementExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTPREDECREMENTEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(DECR); + PrimaryExpression(); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void UnaryExpressionNotPlusMinus() throws ParseException { + /*@bgen(jjtree) UnaryExpressionNotPlusMinus */ + SimpleNode jjtn000 = new SimpleNode(JJTUNARYEXPRESSIONNOTPLUSMINUS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case BANG: + case TILDE: + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case TILDE: + jj_consume_token(TILDE); + break; + case BANG: + jj_consume_token(BANG); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + UnaryExpression(); + break; + default: + if (jj_2_25(2147483647)) { + CastExpression(); + } else { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FLOAT: + case INT: + case LONG: + case NEW: + case NULL: + case SHORT: + case SUPER: + case THIS: + case TRUE: + case VOID: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + PostfixExpression(); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + +// This production is to determine lookahead only. The LOOKAHEAD specifications +// below are not used, but they are there just to indicate that we know about + + // this. + final public void CastLookahead() throws ParseException { + /*@bgen(jjtree) CastLookahead */ + SimpleNode jjtn000 = new SimpleNode(JJTCASTLOOKAHEAD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + if (jj_2_26(2)) { + jj_consume_token(LPAREN); + PrimitiveType(); + } else if (jj_2_27(2147483647)) { + jj_consume_token(LPAREN); + Type(); + jj_consume_token(LBRACKET); + jj_consume_token(RBRACKET); + } else { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LPAREN: + jj_consume_token(LPAREN); + Type(); + jj_consume_token(RPAREN); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case TILDE: + jj_consume_token(TILDE); + break; + case BANG: + jj_consume_token(BANG); + break; + case LPAREN: + jj_consume_token(LPAREN); + break; + case IDENTIFIER: + jj_consume_token(IDENTIFIER); + break; + case THIS: + jj_consume_token(THIS); + break; + case SUPER: + jj_consume_token(SUPER); + break; + case NEW: + jj_consume_token(NEW); + break; + case FALSE: + case NULL: + case TRUE: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + Literal(); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void PostfixExpression() throws ParseException { + /*@bgen(jjtree) PostfixExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTPOSTFIXEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + PrimaryExpression(); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case INCR: + case DECR: + PostfixOperator(); + break; + default: + ; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void PostfixOperator() throws ParseException { + /*@bgen(jjtree) PostfixOperator */ + SimpleNode jjtn000 = new SimpleNode(JJTPOSTFIXOPERATOR); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case INCR: + jj_consume_token(INCR); + break; + case DECR: + jj_consume_token(DECR); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void CastExpression() throws ParseException { + /*@bgen(jjtree) CastExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTCASTEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + if (jj_2_28(2147483647)) { + jj_consume_token(LPAREN); + Type(); + jj_consume_token(RPAREN); + UnaryExpression(); + } else { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LPAREN: + jj_consume_token(LPAREN); + Type(); + jj_consume_token(RPAREN); + UnaryExpressionNotPlusMinus(); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void PrimaryExpression() throws ParseException { + /*@bgen(jjtree) PrimaryExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTPRIMARYEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + PrimaryPrefix(); + label_34: + while (true) { + if (jj_2_29(2)) { + ; + } else { + break label_34; + } + PrimarySuffix(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void MemberSelector() throws ParseException { + /*@bgen(jjtree) MemberSelector */ + SimpleNode jjtn000 = new SimpleNode(JJTMEMBERSELECTOR); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(DOT); + TypeArguments(); + jj_consume_token(IDENTIFIER); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void PrimaryPrefix() throws ParseException { + /*@bgen(jjtree) PrimaryPrefix */ + SimpleNode jjtn000 = new SimpleNode(JJTPRIMARYPREFIX); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case FALSE: + case NULL: + case TRUE: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + Literal(); + break; + default: + if (jj_2_30(2147483647)) { + label_35: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case IDENTIFIER: + ; + break; + default: + break label_35; + } + jj_consume_token(IDENTIFIER); + jj_consume_token(DOT); + } + jj_consume_token(THIS); + } else { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case SUPER: + jj_consume_token(SUPER); + jj_consume_token(DOT); + jj_consume_token(IDENTIFIER); + break; + case LPAREN: + jj_consume_token(LPAREN); + Expression(); + jj_consume_token(RPAREN); + break; + case NEW: + AllocationExpression(); + break; + default: + if (jj_2_31(2147483647)) { + ResultType(); + jj_consume_token(DOT); + jj_consume_token(CLASS); + } else { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case IDENTIFIER: + Name(); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } + } + } + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void PrimarySuffix() throws ParseException { + /*@bgen(jjtree) PrimarySuffix */ + SimpleNode jjtn000 = new SimpleNode(JJTPRIMARYSUFFIX); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + if (jj_2_32(2147483647)) { + jj_consume_token(DOT); + jj_consume_token(SUPER); + } else if (jj_2_33(2147483647)) { + jj_consume_token(DOT); + jj_consume_token(THIS); + } else if (jj_2_34(2)) { + jj_consume_token(DOT); + AllocationExpression(); + } else if (jj_2_35(3)) { + MemberSelector(); + } else { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LBRACKET: + jj_consume_token(LBRACKET); + Expression(); + jj_consume_token(RBRACKET); + break; + case DOT: + jj_consume_token(DOT); + jj_consume_token(IDENTIFIER); + break; + case LPAREN: + Arguments(); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void Literal() throws ParseException { + /*@bgen(jjtree) Literal */ + SimpleNode jjtn000 = new SimpleNode(JJTLITERAL); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case INTEGER_LITERAL: + jj_consume_token(INTEGER_LITERAL); + break; + case FLOATING_POINT_LITERAL: + jj_consume_token(FLOATING_POINT_LITERAL); + break; + case CHARACTER_LITERAL: + jj_consume_token(CHARACTER_LITERAL); + break; + case STRING_LITERAL: + jj_consume_token(STRING_LITERAL); + break; + case FALSE: + case TRUE: + BooleanLiteral(); + break; + case NULL: + NullLiteral(); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void BooleanLiteral() throws ParseException { + /*@bgen(jjtree) BooleanLiteral */ + SimpleNode jjtn000 = new SimpleNode(JJTBOOLEANLITERAL); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case TRUE: + jj_consume_token(TRUE); + break; + case FALSE: + jj_consume_token(FALSE); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void NullLiteral() throws ParseException { + /*@bgen(jjtree) NullLiteral */ + SimpleNode jjtn000 = new SimpleNode(JJTNULLLITERAL); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(NULL); + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void Arguments() throws ParseException { + /*@bgen(jjtree) Arguments */ + SimpleNode jjtn000 = new SimpleNode(JJTARGUMENTS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(LPAREN); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FLOAT: + case INT: + case LONG: + case NEW: + case NULL: + case SHORT: + case SUPER: + case THIS: + case TRUE: + case VOID: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case BANG: + case TILDE: + case INCR: + case DECR: + case PLUS: + case MINUS: + ArgumentList(); + break; + default: + ; + } + jj_consume_token(RPAREN); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void ArgumentList() throws ParseException { + /*@bgen(jjtree) ArgumentList */ + SimpleNode jjtn000 = new SimpleNode(JJTARGUMENTLIST); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + Expression(); + label_36: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COMMA: + ; + break; + default: + break label_36; + } + jj_consume_token(COMMA); + Expression(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void AllocationExpression() throws ParseException { + /*@bgen(jjtree) AllocationExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTALLOCATIONEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + if (jj_2_36(2)) { + jj_consume_token(NEW); + PrimitiveType(); + ArrayDimsAndInits(); + } else { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case NEW: + jj_consume_token(NEW); + ClassOrInterfaceType(); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LT: + TypeArguments(); + break; + default: + ; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LBRACKET: + ArrayDimsAndInits(); + break; + case LPAREN: + Arguments(); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LBRACE: + ClassOrInterfaceBody(false); + break; + default: + ; + } + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + /* + * The third LOOKAHEAD specification below is to parse to PrimarySuffix + * if there is an expression between the "[...]". + */ + final public void ArrayDimsAndInits() throws ParseException { + /*@bgen(jjtree) ArrayDimsAndInits */ + SimpleNode jjtn000 = new SimpleNode(JJTARRAYDIMSANDINITS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + if (jj_2_39(2)) { + label_37: + while (true) { + jj_consume_token(LBRACKET); + Expression(); + jj_consume_token(RBRACKET); + if (jj_2_37(2)) { + ; + } else { + break label_37; + } + } + label_38: + while (true) { + if (jj_2_38(2)) { + ; + } else { + break label_38; + } + jj_consume_token(LBRACKET); + jj_consume_token(RBRACKET); + } + } else { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LBRACKET: + label_39: + while (true) { + jj_consume_token(LBRACKET); + jj_consume_token(RBRACKET); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LBRACKET: + ; + break; + default: + break label_39; + } + } + ArrayInitializer(); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + /* + * Statement syntax follows. + */ + final public void Statement() throws ParseException { + /*@bgen(jjtree) Statement */ + SimpleNode jjtn000 = new SimpleNode(JJTSTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + if (jj_2_40(2)) { + LabeledStatement(); + } else { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case ASSERT: + AssertStatement(); + break; + case LBRACE: + Block(); + break; + case SEMICOLON: + EmptyStatement(); + break; + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FLOAT: + case INT: + case LONG: + case NEW: + case NULL: + case SHORT: + case SUPER: + case THIS: + case TRUE: + case VOID: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case INCR: + case DECR: + StatementExpression(); + jj_consume_token(SEMICOLON); + break; + case SWITCH: + SwitchStatement(); + break; + case IF: + IfStatement(); + break; + case WHILE: + WhileStatement(); + break; + case DO: + DoStatement(); + break; + case FOR: + ForStatement(); + break; + case BREAK: + BreakStatement(); + break; + case CONTINUE: + ContinueStatement(); + break; + case RETURN: + ReturnStatement(); + break; + case THROW: + ThrowStatement(); + break; + case SYNCHRONIZED: + SynchronizedStatement(); + break; + case TRY: + TryStatement(); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void AssertStatement() throws ParseException { + /*@bgen(jjtree) AssertStatement */ + SimpleNode jjtn000 = new SimpleNode(JJTASSERTSTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(ASSERT); + Expression(); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COLON: + jj_consume_token(COLON); + Expression(); + break; + default: + ; + } + jj_consume_token(SEMICOLON); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void LabeledStatement() throws ParseException { + /*@bgen(jjtree) LabeledStatement */ + SimpleNode jjtn000 = new SimpleNode(JJTLABELEDSTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(IDENTIFIER); + jj_consume_token(COLON); + Statement(); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void Block() throws ParseException { + /*@bgen(jjtree) Block */ + SimpleNode jjtn000 = new SimpleNode(JJTBLOCK); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(LBRACE); + label_40: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case ABSTRACT: + case ASSERT: + case BOOLEAN: + case BREAK: + case BYTE: + case CHAR: + case CLASS: + case CONTINUE: + case DO: + case DOUBLE: + case FALSE: + case FINAL: + case FLOAT: + case FOR: + case IF: + case INT: + case INTERFACE: + case LONG: + case NATIVE: + case NEW: + case NULL: + case PRIVATE: + case PROTECTED: + case PUBLIC: + case RETURN: + case SHORT: + case STATIC: + case STRICTFP: + case SUPER: + case SWITCH: + case SYNCHRONIZED: + case THIS: + case THROW: + case TRANSIENT: + case TRUE: + case TRY: + case VOID: + case VOLATILE: + case WHILE: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case LBRACE: + case SEMICOLON: + case AT: + case INCR: + case DECR: + ; + break; + default: + break label_40; + } + BlockStatement(); + } + jj_consume_token(RBRACE); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void BlockStatement() throws ParseException { + /*@bgen(jjtree) BlockStatement */ + SimpleNode jjtn000 = new SimpleNode(JJTBLOCKSTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + if (jj_2_41(2147483647)) { + LocalVariableDeclaration(); + jj_consume_token(SEMICOLON); + } else { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case ASSERT: + case BOOLEAN: + case BREAK: + case BYTE: + case CHAR: + case CONTINUE: + case DO: + case DOUBLE: + case FALSE: + case FLOAT: + case FOR: + case IF: + case INT: + case LONG: + case NEW: + case NULL: + case RETURN: + case SHORT: + case SUPER: + case SWITCH: + case SYNCHRONIZED: + case THIS: + case THROW: + case TRUE: + case TRY: + case VOID: + case WHILE: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case LBRACE: + case SEMICOLON: + case INCR: + case DECR: + Statement(); + break; + case CLASS: + case INTERFACE: + ClassOrInterfaceDeclaration(0); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void LocalVariableDeclaration() throws ParseException { + /*@bgen(jjtree) LocalVariableDeclaration */ + SimpleNode jjtn000 = new SimpleNode(JJTLOCALVARIABLEDECLARATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + Modifiers(); + Type(); + VariableDeclarator(); + label_41: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COMMA: + ; + break; + default: + break label_41; + } + jj_consume_token(COMMA); + VariableDeclarator(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void EmptyStatement() throws ParseException { + /*@bgen(jjtree) EmptyStatement */ + SimpleNode jjtn000 = new SimpleNode(JJTEMPTYSTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(SEMICOLON); + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void StatementExpression() throws ParseException { + /*@bgen(jjtree) StatementExpression */ + SimpleNode jjtn000 = new SimpleNode(JJTSTATEMENTEXPRESSION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case INCR: + PreIncrementExpression(); + break; + case DECR: + PreDecrementExpression(); + break; + default: + if (jj_2_42(2147483647)) { + AssignmentExpression(); + } else { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FLOAT: + case INT: + case LONG: + case NEW: + case NULL: + case SHORT: + case SUPER: + case THIS: + case TRUE: + case VOID: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + PostfixExpression(); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void SwitchStatement() throws ParseException { + /*@bgen(jjtree) SwitchStatement */ + SimpleNode jjtn000 = new SimpleNode(JJTSWITCHSTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(SWITCH); + jj_consume_token(LPAREN); + Expression(); + jj_consume_token(RPAREN); + jj_consume_token(LBRACE); + label_42: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case CASE: + case _DEFAULT: + ; + break; + default: + break label_42; + } + SwitchLabel(); + label_43: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case ABSTRACT: + case ASSERT: + case BOOLEAN: + case BREAK: + case BYTE: + case CHAR: + case CLASS: + case CONTINUE: + case DO: + case DOUBLE: + case FALSE: + case FINAL: + case FLOAT: + case FOR: + case IF: + case INT: + case INTERFACE: + case LONG: + case NATIVE: + case NEW: + case NULL: + case PRIVATE: + case PROTECTED: + case PUBLIC: + case RETURN: + case SHORT: + case STATIC: + case STRICTFP: + case SUPER: + case SWITCH: + case SYNCHRONIZED: + case THIS: + case THROW: + case TRANSIENT: + case TRUE: + case TRY: + case VOID: + case VOLATILE: + case WHILE: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case LBRACE: + case SEMICOLON: + case AT: + case INCR: + case DECR: + ; + break; + default: + break label_43; + } + BlockStatement(); + } + } + jj_consume_token(RBRACE); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void SwitchLabel() throws ParseException { + /*@bgen(jjtree) SwitchLabel */ + SimpleNode jjtn000 = new SimpleNode(JJTSWITCHLABEL); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case CASE: + jj_consume_token(CASE); + Expression(); + jj_consume_token(COLON); + break; + case _DEFAULT: + jj_consume_token(_DEFAULT); + jj_consume_token(COLON); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void IfStatement() throws ParseException { + /*@bgen(jjtree) IfStatement */ + SimpleNode jjtn000 = new SimpleNode(JJTIFSTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(IF); + jj_consume_token(LPAREN); + Expression(); + jj_consume_token(RPAREN); + Statement(); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case ELSE: + jj_consume_token(ELSE); + Statement(); + break; + default: + ; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void WhileStatement() throws ParseException { + /*@bgen(jjtree) WhileStatement */ + SimpleNode jjtn000 = new SimpleNode(JJTWHILESTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(WHILE); + jj_consume_token(LPAREN); + Expression(); + jj_consume_token(RPAREN); + Statement(); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void DoStatement() throws ParseException { + /*@bgen(jjtree) DoStatement */ + SimpleNode jjtn000 = new SimpleNode(JJTDOSTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(DO); + Statement(); + jj_consume_token(WHILE); + jj_consume_token(LPAREN); + Expression(); + jj_consume_token(RPAREN); + jj_consume_token(SEMICOLON); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void ForStatement() throws ParseException { + /*@bgen(jjtree) ForStatement */ + SimpleNode jjtn000 = new SimpleNode(JJTFORSTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(FOR); + jj_consume_token(LPAREN); + if (jj_2_43(2147483647)) { + Modifiers(); + Type(); + jj_consume_token(IDENTIFIER); + jj_consume_token(COLON); + Expression(); + } else { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case ABSTRACT: + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FINAL: + case FLOAT: + case INT: + case LONG: + case NATIVE: + case NEW: + case NULL: + case PRIVATE: + case PROTECTED: + case PUBLIC: + case SHORT: + case STATIC: + case STRICTFP: + case SUPER: + case SYNCHRONIZED: + case THIS: + case TRANSIENT: + case TRUE: + case VOID: + case VOLATILE: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case SEMICOLON: + case AT: + case INCR: + case DECR: + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case ABSTRACT: + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FINAL: + case FLOAT: + case INT: + case LONG: + case NATIVE: + case NEW: + case NULL: + case PRIVATE: + case PROTECTED: + case PUBLIC: + case SHORT: + case STATIC: + case STRICTFP: + case SUPER: + case SYNCHRONIZED: + case THIS: + case TRANSIENT: + case TRUE: + case VOID: + case VOLATILE: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case AT: + case INCR: + case DECR: + ForInit(); + break; + default: + ; + } + jj_consume_token(SEMICOLON); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FLOAT: + case INT: + case LONG: + case NEW: + case NULL: + case SHORT: + case SUPER: + case THIS: + case TRUE: + case VOID: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case BANG: + case TILDE: + case INCR: + case DECR: + case PLUS: + case MINUS: + Expression(); + break; + default: + ; + } + jj_consume_token(SEMICOLON); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FLOAT: + case INT: + case LONG: + case NEW: + case NULL: + case SHORT: + case SUPER: + case THIS: + case TRUE: + case VOID: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case INCR: + case DECR: + ForUpdate(); + break; + default: + ; + } + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } + jj_consume_token(RPAREN); + Statement(); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void ForInit() throws ParseException { + /*@bgen(jjtree) ForInit */ + SimpleNode jjtn000 = new SimpleNode(JJTFORINIT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + if (jj_2_44(2147483647)) { + LocalVariableDeclaration(); + } else { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FLOAT: + case INT: + case LONG: + case NEW: + case NULL: + case SHORT: + case SUPER: + case THIS: + case TRUE: + case VOID: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case INCR: + case DECR: + StatementExpressionList(); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void StatementExpressionList() throws ParseException { + /*@bgen(jjtree) StatementExpressionList */ + SimpleNode jjtn000 = new SimpleNode(JJTSTATEMENTEXPRESSIONLIST); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + StatementExpression(); + label_44: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COMMA: + ; + break; + default: + break label_44; + } + jj_consume_token(COMMA); + StatementExpression(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void ForUpdate() throws ParseException { + /*@bgen(jjtree) ForUpdate */ + SimpleNode jjtn000 = new SimpleNode(JJTFORUPDATE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + StatementExpressionList(); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void BreakStatement() throws ParseException { + /*@bgen(jjtree) BreakStatement */ + SimpleNode jjtn000 = new SimpleNode(JJTBREAKSTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(BREAK); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case IDENTIFIER: + jj_consume_token(IDENTIFIER); + break; + default: + ; + } + jj_consume_token(SEMICOLON); + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void ContinueStatement() throws ParseException { + /*@bgen(jjtree) ContinueStatement */ + SimpleNode jjtn000 = new SimpleNode(JJTCONTINUESTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(CONTINUE); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case IDENTIFIER: + jj_consume_token(IDENTIFIER); + break; + default: + ; + } + jj_consume_token(SEMICOLON); + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void ReturnStatement() throws ParseException { + /*@bgen(jjtree) ReturnStatement */ + SimpleNode jjtn000 = new SimpleNode(JJTRETURNSTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(RETURN); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FLOAT: + case INT: + case LONG: + case NEW: + case NULL: + case SHORT: + case SUPER: + case THIS: + case TRUE: + case VOID: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case BANG: + case TILDE: + case INCR: + case DECR: + case PLUS: + case MINUS: + Expression(); + break; + default: + ; + } + jj_consume_token(SEMICOLON); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void ThrowStatement() throws ParseException { + /*@bgen(jjtree) ThrowStatement */ + SimpleNode jjtn000 = new SimpleNode(JJTTHROWSTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(THROW); + Expression(); + jj_consume_token(SEMICOLON); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void SynchronizedStatement() throws ParseException { + /*@bgen(jjtree) SynchronizedStatement */ + SimpleNode jjtn000 = new SimpleNode(JJTSYNCHRONIZEDSTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(SYNCHRONIZED); + jj_consume_token(LPAREN); + Expression(); + jj_consume_token(RPAREN); + Block(); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void TryStatement() throws ParseException { + /*@bgen(jjtree) TryStatement */ + SimpleNode jjtn000 = new SimpleNode(JJTTRYSTATEMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(TRY); + Block(); + label_45: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case CATCH: + ; + break; + default: + break label_45; + } + jj_consume_token(CATCH); + jj_consume_token(LPAREN); + FormalParameter(); + jj_consume_token(RPAREN); + Block(); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case FINALLY: + jj_consume_token(FINALLY); + Block(); + break; + default: + ; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + /* We use productions to match >>>, >> and > so that we can keep the + * type declaration syntax with generics clean + */ + final public void RUNSIGNEDSHIFT() throws ParseException { + /*@bgen(jjtree) RUNSIGNEDSHIFT */ + SimpleNode jjtn000 = new SimpleNode(JJTRUNSIGNEDSHIFT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + if (getToken(1).kind == GT && + ((Token.GTToken) getToken(1)).realKind == RUNSIGNEDSHIFT) { + + } else { + jj_consume_token(-1); + throw new ParseException(); + } + jj_consume_token(GT); + jj_consume_token(GT); + jj_consume_token(GT); + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void RSIGNEDSHIFT() throws ParseException { + /*@bgen(jjtree) RSIGNEDSHIFT */ + SimpleNode jjtn000 = new SimpleNode(JJTRSIGNEDSHIFT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + if (getToken(1).kind == GT && + ((Token.GTToken) getToken(1)).realKind == RSIGNEDSHIFT) { + + } else { + jj_consume_token(-1); + throw new ParseException(); + } + jj_consume_token(GT); + jj_consume_token(GT); + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + /* Annotation syntax follows. */ + final public void Annotation() throws ParseException { + /*@bgen(jjtree) Annotation */ + SimpleNode jjtn000 = new SimpleNode(JJTANNOTATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + if (jj_2_45(2147483647)) { + NormalAnnotation(); + } else if (jj_2_46(2147483647)) { + SingleMemberAnnotation(); + } else { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case AT: + MarkerAnnotation(); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void NormalAnnotation() throws ParseException { + /*@bgen(jjtree) NormalAnnotation */ + SimpleNode jjtn000 = new SimpleNode(JJTNORMALANNOTATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(AT); + Name(); + jj_consume_token(LPAREN); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case IDENTIFIER: + MemberValuePairs(); + break; + default: + ; + } + jj_consume_token(RPAREN); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void MarkerAnnotation() throws ParseException { + /*@bgen(jjtree) MarkerAnnotation */ + SimpleNode jjtn000 = new SimpleNode(JJTMARKERANNOTATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(AT); + Name(); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void SingleMemberAnnotation() throws ParseException { + /*@bgen(jjtree) SingleMemberAnnotation */ + SimpleNode jjtn000 = new SimpleNode(JJTSINGLEMEMBERANNOTATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(AT); + Name(); + jj_consume_token(LPAREN); + MemberValue(); + jj_consume_token(RPAREN); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void MemberValuePairs() throws ParseException { + /*@bgen(jjtree) MemberValuePairs */ + SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUEPAIRS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + MemberValuePair(); + label_46: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COMMA: + ; + break; + default: + break label_46; + } + jj_consume_token(COMMA); + MemberValuePair(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void MemberValuePair() throws ParseException { + /*@bgen(jjtree) MemberValuePair */ + SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUEPAIR); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(IDENTIFIER); + jj_consume_token(ASSIGN); + MemberValue(); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void MemberValue() throws ParseException { + /*@bgen(jjtree) MemberValue */ + SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case AT: + Annotation(); + break; + case LBRACE: + MemberValueArrayInitializer(); + break; + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FLOAT: + case INT: + case LONG: + case NEW: + case NULL: + case SHORT: + case SUPER: + case THIS: + case TRUE: + case VOID: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case BANG: + case TILDE: + case INCR: + case DECR: + case PLUS: + case MINUS: + ConditionalExpression(); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void MemberValueArrayInitializer() throws ParseException { + /*@bgen(jjtree) MemberValueArrayInitializer */ + SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUEARRAYINITIALIZER); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(LBRACE); + MemberValue(); + label_47: + while (true) { + if (jj_2_47(2)) { + ; + } else { + break label_47; + } + jj_consume_token(COMMA); + MemberValue(); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COMMA: + jj_consume_token(COMMA); + break; + default: + ; + } + jj_consume_token(RBRACE); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + /* Annotation Types. */ + final public void AnnotationTypeDeclaration(int modifiers) throws ParseException { + /*@bgen(jjtree) AnnotationTypeDeclaration */ + SimpleNode jjtn000 = new SimpleNode(JJTANNOTATIONTYPEDECLARATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(AT); + jj_consume_token(INTERFACE); + jj_consume_token(IDENTIFIER); + AnnotationTypeBody(); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void AnnotationTypeBody() throws ParseException { + /*@bgen(jjtree) AnnotationTypeBody */ + SimpleNode jjtn000 = new SimpleNode(JJTANNOTATIONTYPEBODY); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(LBRACE); + label_48: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case ABSTRACT: + case BOOLEAN: + case BYTE: + case CHAR: + case CLASS: + case DOUBLE: + case ENUM: + case FINAL: + case FLOAT: + case INT: + case INTERFACE: + case LONG: + case NATIVE: + case PRIVATE: + case PROTECTED: + case PUBLIC: + case SHORT: + case STATIC: + case STRICTFP: + case SYNCHRONIZED: + case TRANSIENT: + case VOLATILE: + case IDENTIFIER: + case SEMICOLON: + case AT: + ; + break; + default: + break label_48; + } + AnnotationTypeMemberDeclaration(); + } + jj_consume_token(RBRACE); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void AnnotationTypeMemberDeclaration() throws ParseException { + /*@bgen(jjtree) AnnotationTypeMemberDeclaration */ + SimpleNode jjtn000 = new SimpleNode(JJTANNOTATIONTYPEMEMBERDECLARATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + int modifiers; + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case ABSTRACT: + case BOOLEAN: + case BYTE: + case CHAR: + case CLASS: + case DOUBLE: + case ENUM: + case FINAL: + case FLOAT: + case INT: + case INTERFACE: + case LONG: + case NATIVE: + case PRIVATE: + case PROTECTED: + case PUBLIC: + case SHORT: + case STATIC: + case STRICTFP: + case SYNCHRONIZED: + case TRANSIENT: + case VOLATILE: + case IDENTIFIER: + case AT: + modifiers = Modifiers(); + if (jj_2_48(2147483647)) { + Type(); + jj_consume_token(IDENTIFIER); + jj_consume_token(LPAREN); + jj_consume_token(RPAREN); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case _DEFAULT: + DefaultValue(); + break; + default: + ; + } + jj_consume_token(SEMICOLON); + } else { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case CLASS: + case INTERFACE: + ClassOrInterfaceDeclaration(modifiers); + break; + case ENUM: + EnumDeclaration(modifiers); + break; + case AT: + AnnotationTypeDeclaration(modifiers); + break; + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FLOAT: + case INT: + case LONG: + case SHORT: + case IDENTIFIER: + FieldDeclaration(modifiers); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } + break; + case SEMICOLON: + jj_consume_token(SEMICOLON); + break; + default: + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final public void DefaultValue() throws ParseException { + /*@bgen(jjtree) DefaultValue */ + SimpleNode jjtn000 = new SimpleNode(JJTDEFAULTVALUE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(_DEFAULT); + MemberValue(); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + + final private boolean jj_2_1(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_1(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_2(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_2(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_3(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_3(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_4(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_4(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_5(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_5(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_6(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_6(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_7(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_7(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_8(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_8(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_9(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_9(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_10(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_10(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_11(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_11(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_12(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_12(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_13(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_13(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_14(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_14(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_15(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_15(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_16(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_16(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_17(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_17(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_18(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_18(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_19(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_19(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_20(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_20(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_21(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_21(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_22(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_22(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_23(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_23(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_24(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_24(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_25(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_25(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_26(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_26(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_27(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_27(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_28(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_28(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_29(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_29(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_30(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_30(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_31(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_31(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_32(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_32(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_33(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_33(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_34(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_34(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_35(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_35(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_36(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_36(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_37(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_37(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_38(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_38(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_39(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_39(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_40(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_40(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_41(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_41(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_42(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_42(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_43(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_43(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_44(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_44(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_45(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_45(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_46(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_46(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_47(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_47(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_2_48(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_48(); + } + catch (LookaheadSuccess ls) { + return true; + } + } + + final private boolean jj_3R_56() { + if (jj_3R_101()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3_21()) jj_scanpos = xsp; + return false; + } + + final private boolean jj_3R_135() { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_91()) return true; + return false; + } + + final private boolean jj_3R_99() { + if (jj_3R_91()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_135()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3_20() { + if (jj_scan_token(DOT)) return true; + if (jj_scan_token(IDENTIFIER)) return true; + return false; + } + + final private boolean jj_3R_91() { + if (jj_scan_token(IDENTIFIER)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_20()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3R_122() { + if (jj_3R_72()) return true; + return false; + } + + final private boolean jj_3R_86() { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(58)) { + jj_scanpos = xsp; + if (jj_3R_122()) return true; + } + return false; + } + + final private boolean jj_3_19() { + if (jj_3R_78()) return true; + return false; + } + + final private boolean jj_3R_83() { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(10)) { + jj_scanpos = xsp; + if (jj_scan_token(15)) { + jj_scanpos = xsp; + if (jj_scan_token(12)) { + jj_scanpos = xsp; + if (jj_scan_token(46)) { + jj_scanpos = xsp; + if (jj_scan_token(35)) { + jj_scanpos = xsp; + if (jj_scan_token(37)) { + jj_scanpos = xsp; + if (jj_scan_token(28)) { + jj_scanpos = xsp; + if (jj_scan_token(21)) return true; + } + } + } + } + } + } + } + return false; + } + + final private boolean jj_3R_194() { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_112()) return true; + return false; + } + + final private boolean jj_3R_290() { + if (jj_scan_token(SUPER)) return true; + if (jj_3R_77()) return true; + return false; + } + + final private boolean jj_3_16() { + if (jj_scan_token(LBRACKET)) return true; + if (jj_scan_token(RBRACKET)) return true; + return false; + } + + final private boolean jj_3R_289() { + if (jj_scan_token(EXTENDS)) return true; + if (jj_3R_77()) return true; + return false; + } + + final private boolean jj_3R_277() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_289()) { + jj_scanpos = xsp; + if (jj_3R_290()) return true; + } + return false; + } + + final private boolean jj_3R_256() { + if (jj_3R_277()) return true; + return false; + } + + final private boolean jj_3R_151() { + if (jj_scan_token(HOOK)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_256()) jj_scanpos = xsp; + return false; + } + + final private boolean jj_3_17() { + if (jj_3R_78()) return true; + return false; + } + + final private boolean jj_3R_112() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_150()) { + jj_scanpos = xsp; + if (jj_3R_151()) return true; + } + return false; + } + + final private boolean jj_3R_150() { + if (jj_3R_77()) return true; + return false; + } + + final private boolean jj_3_15() { + if (jj_scan_token(LBRACKET)) return true; + if (jj_scan_token(RBRACKET)) return true; + return false; + } + + final private boolean jj_3R_78() { + if (jj_scan_token(LT)) return true; + if (jj_3R_112()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_194()) { + jj_scanpos = xsp; + break; + } + } + if (jj_scan_token(GT)) return true; + return false; + } + + final private boolean jj_3_18() { + if (jj_scan_token(DOT)) return true; + if (jj_scan_token(IDENTIFIER)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3_19()) jj_scanpos = xsp; + return false; + } + + final private boolean jj_3R_149() { + if (jj_scan_token(IDENTIFIER)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3_17()) jj_scanpos = xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_18()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3R_111() { + if (jj_3R_149()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_16()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3R_110() { + if (jj_3R_83()) return true; + Token xsp; + if (jj_3_15()) return true; + while (true) { + xsp = jj_scanpos; + if (jj_3_15()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3R_77() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_110()) { + jj_scanpos = xsp; + if (jj_3R_111()) return true; + } + return false; + } + + final private boolean jj_3_13() { + if (jj_scan_token(THIS)) return true; + if (jj_scan_token(DOT)) return true; + return false; + } + + final private boolean jj_3R_221() { + if (jj_scan_token(THROWS)) return true; + if (jj_3R_99()) return true; + return false; + } + + final private boolean jj_3R_103() { + if (jj_3R_83()) return true; + return false; + } + + final private boolean jj_3R_72() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_14()) { + jj_scanpos = xsp; + if (jj_3R_103()) return true; + } + return false; + } + + final private boolean jj_3_14() { + if (jj_3R_77()) return true; + return false; + } + + final private boolean jj_3R_74() { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(47)) jj_scanpos = xsp; + if (jj_3R_104()) return true; + return false; + } + + final private boolean jj_3_12() { + if (jj_3R_76()) return true; + return false; + } + + final private boolean jj_3R_108() { + if (jj_3R_78()) return true; + return false; + } + + final private boolean jj_3R_107() { + if (jj_scan_token(IDENTIFIER)) return true; + if (jj_scan_token(DOT)) return true; + return false; + } + + final private boolean jj_3R_252() { + if (jj_scan_token(LBRACKET)) return true; + if (jj_scan_token(RBRACKET)) return true; + return false; + } + + final private boolean jj_3R_76() { + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_107()) { + jj_scanpos = xsp; + break; + } + } + xsp = jj_scanpos; + if (jj_3_13()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_108()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_scan_token(52)) { + jj_scanpos = xsp; + if (jj_scan_token(49)) return true; + } + if (jj_3R_109()) return true; + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + final private boolean jj_3R_134() { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_133()) return true; + return false; + } + + final private boolean jj_3R_223() { + if (jj_3R_49()) return true; + return false; + } + + final private boolean jj_3R_222() { + if (jj_3R_76()) return true; + return false; + } + + final private boolean jj_3R_220() { + if (jj_3R_97()) return true; + return false; + } + + final private boolean jj_3R_186() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_220()) jj_scanpos = xsp; + if (jj_scan_token(IDENTIFIER)) return true; + if (jj_3R_53()) return true; + xsp = jj_scanpos; + if (jj_3R_221()) jj_scanpos = xsp; + if (jj_scan_token(LBRACE)) return true; + xsp = jj_scanpos; + if (jj_3R_222()) jj_scanpos = xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_223()) { + jj_scanpos = xsp; + break; + } + } + if (jj_scan_token(RBRACE)) return true; + return false; + } + + final private boolean jj_3_11() { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_75()) return true; + return false; + } + + final private boolean jj_3R_227() { + if (jj_scan_token(THROWS)) return true; + if (jj_3R_99()) return true; + return false; + } + + final private boolean jj_3R_98() { + if (jj_3R_133()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_134()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3R_133() { + if (jj_3R_50()) return true; + if (jj_3R_72()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(119)) jj_scanpos = xsp; + if (jj_3R_184()) return true; + return false; + } + + final private boolean jj_3R_53() { + if (jj_scan_token(LPAREN)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_98()) jj_scanpos = xsp; + if (jj_scan_token(RPAREN)) return true; + return false; + } + + final private boolean jj_3_48() { + if (jj_3R_72()) return true; + if (jj_scan_token(IDENTIFIER)) return true; + if (jj_scan_token(LPAREN)) return true; + return false; + } + + final private boolean jj_3R_226() { + if (jj_scan_token(IDENTIFIER)) return true; + if (jj_3R_53()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_252()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3R_228() { + if (jj_3R_104()) return true; + return false; + } + + final private boolean jj_3R_225() { + if (jj_3R_97()) return true; + return false; + } + + final private boolean jj_3R_292() { + if (jj_3R_75()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_11()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3R_188() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_225()) jj_scanpos = xsp; + if (jj_3R_86()) return true; + if (jj_3R_226()) return true; + xsp = jj_scanpos; + if (jj_3R_227()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_228()) { + jj_scanpos = xsp; + if (jj_scan_token(81)) return true; + } + return false; + } + + final private boolean jj_3R_198() { + if (jj_scan_token(ASSIGN)) return true; + if (jj_3R_75()) return true; + return false; + } + + final private boolean jj_3R_224() { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_161()) return true; + return false; + } + + final private boolean jj_3_47() { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_93()) return true; + return false; + } + + final private boolean jj_3R_217() { + if (jj_scan_token(LBRACKET)) return true; + if (jj_scan_token(RBRACKET)) return true; + return false; + } + + final private boolean jj_3R_147() { + if (jj_scan_token(LBRACE)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_292()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_scan_token(82)) jj_scanpos = xsp; + if (jj_scan_token(RBRACE)) return true; + return false; + } + + final private boolean jj_3R_73() { + if (jj_scan_token(LBRACKET)) return true; + if (jj_scan_token(RBRACKET)) return true; + return false; + } + + final private boolean jj_3R_106() { + if (jj_3R_56()) return true; + return false; + } + + final private boolean jj_3R_105() { + if (jj_3R_147()) return true; + return false; + } + + final private boolean jj_3R_75() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_105()) { + jj_scanpos = xsp; + if (jj_3R_106()) return true; + } + return false; + } + + final private boolean jj_3R_184() { + if (jj_scan_token(IDENTIFIER)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_217()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3R_160() { + if (jj_scan_token(LBRACE)) return true; + if (jj_3R_93()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_47()) { + jj_scanpos = xsp; + break; + } + } + xsp = jj_scanpos; + if (jj_scan_token(82)) jj_scanpos = xsp; + if (jj_scan_token(RBRACE)) return true; + return false; + } + + final private boolean jj_3R_276() { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_275()) return true; + return false; + } + + final private boolean jj_3R_161() { + if (jj_3R_184()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_198()) jj_scanpos = xsp; + return false; + } + + final private boolean jj_3R_127() { + if (jj_3R_101()) return true; + return false; + } + + final private boolean jj_3_9() { + if (jj_3R_72()) return true; + if (jj_scan_token(IDENTIFIER)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_73()) { + jj_scanpos = xsp; + break; + } + } + xsp = jj_scanpos; + if (jj_scan_token(82)) { + jj_scanpos = xsp; + if (jj_scan_token(85)) { + jj_scanpos = xsp; + if (jj_scan_token(81)) return true; + } + } + return false; + } + + final private boolean jj_3R_126() { + if (jj_3R_160()) return true; + return false; + } + + final private boolean jj_3R_71() { + if (jj_3R_97()) return true; + return false; + } + + final private boolean jj_3R_93() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_125()) { + jj_scanpos = xsp; + if (jj_3R_126()) { + jj_scanpos = xsp; + if (jj_3R_127()) return true; + } + } + return false; + } + + final private boolean jj_3R_125() { + if (jj_3R_102()) return true; + return false; + } + + final private boolean jj_3_8() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_71()) jj_scanpos = xsp; + if (jj_scan_token(IDENTIFIER)) return true; + if (jj_scan_token(LPAREN)) return true; + return false; + } + + final private boolean jj_3R_187() { + if (jj_3R_72()) return true; + if (jj_3R_161()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_224()) { + jj_scanpos = xsp; + break; + } + } + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + final private boolean jj_3R_275() { + if (jj_scan_token(IDENTIFIER)) return true; + if (jj_scan_token(ASSIGN)) return true; + if (jj_3R_93()) return true; + return false; + } + + final private boolean jj_3R_140() { + if (jj_3R_188()) return true; + return false; + } + + final private boolean jj_3R_139() { + if (jj_3R_187()) return true; + return false; + } + + final private boolean jj_3R_249() { + if (jj_scan_token(BIT_AND)) return true; + if (jj_3R_149()) return true; + return false; + } + + final private boolean jj_3R_138() { + if (jj_3R_186()) return true; + return false; + } + + final private boolean jj_3R_255() { + if (jj_3R_275()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_276()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3R_231() { + if (jj_3R_255()) return true; + return false; + } + + final private boolean jj_3R_137() { + if (jj_3R_185()) return true; + return false; + } + + final private boolean jj_3R_92() { + if (jj_scan_token(IDENTIFIER)) return true; + if (jj_scan_token(ASSIGN)) return true; + return false; + } + + final private boolean jj_3R_136() { + if (jj_3R_130()) return true; + return false; + } + + final private boolean jj_3R_192() { + if (jj_scan_token(AT)) return true; + if (jj_3R_91()) return true; + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_93()) return true; + if (jj_scan_token(RPAREN)) return true; + return false; + } + + final private boolean jj_3R_286() { + if (jj_3R_182()) return true; + return false; + } + + final private boolean jj_3R_100() { + if (jj_3R_50()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_136()) { + jj_scanpos = xsp; + if (jj_3R_137()) { + jj_scanpos = xsp; + if (jj_3R_138()) { + jj_scanpos = xsp; + if (jj_3R_139()) { + jj_scanpos = xsp; + if (jj_3R_140()) return true; + } + } + } + } + return false; + } + + final private boolean jj_3R_193() { + if (jj_scan_token(AT)) return true; + if (jj_3R_91()) return true; + return false; + } + + final private boolean jj_3_46() { + if (jj_scan_token(AT)) return true; + if (jj_3R_91()) return true; + if (jj_scan_token(LPAREN)) return true; + return false; + } + + final private boolean jj_3_10() { + if (jj_3R_74()) return true; + return false; + } + + final private boolean jj_3R_55() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_10()) { + jj_scanpos = xsp; + if (jj_3R_100()) { + jj_scanpos = xsp; + if (jj_scan_token(81)) return true; + } + } + return false; + } + + final private boolean jj_3R_191() { + if (jj_scan_token(AT)) return true; + if (jj_3R_91()) return true; + if (jj_scan_token(LPAREN)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_231()) jj_scanpos = xsp; + if (jj_scan_token(RPAREN)) return true; + return false; + } + + final private boolean jj_3_45() { + if (jj_scan_token(AT)) return true; + if (jj_3R_91()) return true; + if (jj_scan_token(LPAREN)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_92()) { + jj_scanpos = xsp; + if (jj_scan_token(76)) return true; + } + return false; + } + + final private boolean jj_3R_215() { + if (jj_3R_55()) return true; + return false; + } + + final private boolean jj_3R_132() { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_131()) return true; + return false; + } + + final private boolean jj_3R_183() { + if (jj_3R_216()) return true; + return false; + } + + final private boolean jj_3R_285() { + if (jj_3R_109()) return true; + return false; + } + + final private boolean jj_3R_145() { + if (jj_3R_193()) return true; + return false; + } + + final private boolean jj_3R_182() { + if (jj_scan_token(LBRACE)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_215()) { + jj_scanpos = xsp; + break; + } + } + if (jj_scan_token(RBRACE)) return true; + return false; + } + + final private boolean jj_3R_144() { + if (jj_3R_192()) return true; + return false; + } + + final private boolean jj_3R_113() { + return false; + } + + final private boolean jj_3R_102() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_143()) { + jj_scanpos = xsp; + if (jj_3R_144()) { + jj_scanpos = xsp; + if (jj_3R_145()) return true; + } + } + return false; + } + + final private boolean jj_3R_143() { + if (jj_3R_191()) return true; + return false; + } + + final private boolean jj_3R_216() { + if (jj_scan_token(EXTENDS)) return true; + if (jj_3R_149()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_249()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3R_131() { + if (jj_scan_token(IDENTIFIER)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_183()) jj_scanpos = xsp; + return false; + } + + final private boolean jj_3R_114() { + return false; + } + + final private boolean jj_3_7() { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_70()) return true; + return false; + } + + final private boolean jj_3R_80() { + Token xsp; + xsp = jj_scanpos; + lookingAhead = true; + jj_semLA = getToken(1).kind == GT && + ((Token.GTToken) getToken(1)).realKind == RSIGNEDSHIFT; + lookingAhead = false; + if (!jj_semLA || jj_3R_113()) return true; + if (jj_scan_token(GT)) return true; + if (jj_scan_token(GT)) return true; + return false; + } + + final private boolean jj_3R_97() { + if (jj_scan_token(LT)) return true; + if (jj_3R_131()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_132()) { + jj_scanpos = xsp; + break; + } + } + if (jj_scan_token(GT)) return true; + return false; + } + + final private boolean jj_3R_272() { + if (jj_3R_55()) return true; + return false; + } + + final private boolean jj_3R_70() { + if (jj_3R_50()) return true; + if (jj_scan_token(IDENTIFIER)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_285()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_286()) jj_scanpos = xsp; + return false; + } + + final private boolean jj_3R_81() { + Token xsp; + xsp = jj_scanpos; + lookingAhead = true; + jj_semLA = getToken(1).kind == GT && + ((Token.GTToken) getToken(1)).realKind == RUNSIGNEDSHIFT; + lookingAhead = false; + if (!jj_semLA || jj_3R_114()) return true; + if (jj_scan_token(GT)) return true; + if (jj_scan_token(GT)) return true; + if (jj_scan_token(GT)) return true; + return false; + } + + final private boolean jj_3R_251() { + if (jj_scan_token(SEMICOLON)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_272()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3R_250() { + if (jj_3R_70()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_7()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3R_246() { + if (jj_scan_token(FINALLY)) return true; + if (jj_3R_104()) return true; + return false; + } + + final private boolean jj_3R_219() { + if (jj_scan_token(LBRACE)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_250()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_scan_token(82)) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_251()) jj_scanpos = xsp; + if (jj_scan_token(RBRACE)) return true; + return false; + } + + final private boolean jj_3R_245() { + if (jj_scan_token(CATCH)) return true; + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_133()) return true; + if (jj_scan_token(RPAREN)) return true; + if (jj_3R_104()) return true; + return false; + } + + final private boolean jj_3R_212() { + if (jj_scan_token(TRY)) return true; + if (jj_3R_104()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_245()) { + jj_scanpos = xsp; + break; + } + } + xsp = jj_scanpos; + if (jj_3R_246()) jj_scanpos = xsp; + return false; + } + + final private boolean jj_3R_218() { + if (jj_3R_214()) return true; + return false; + } + + final private boolean jj_3R_185() { + if (jj_scan_token(ENUM)) return true; + if (jj_scan_token(IDENTIFIER)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_218()) jj_scanpos = xsp; + if (jj_3R_219()) return true; + return false; + } + + final private boolean jj_3R_211() { + if (jj_scan_token(SYNCHRONIZED)) return true; + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_56()) return true; + if (jj_scan_token(RPAREN)) return true; + if (jj_3R_104()) return true; + return false; + } + + final private boolean jj_3R_244() { + if (jj_3R_56()) return true; + return false; + } + + final private boolean jj_3R_248() { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_149()) return true; + return false; + } + + final private boolean jj_3R_214() { + if (jj_scan_token(IMPLEMENTS)) return true; + if (jj_3R_149()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_248()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3R_210() { + if (jj_scan_token(THROW)) return true; + if (jj_3R_56()) return true; + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + final private boolean jj_3R_271() { + if (jj_3R_284()) return true; + return false; + } + + final private boolean jj_3R_299() { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_201()) return true; + return false; + } + + final private boolean jj_3R_209() { + if (jj_scan_token(RETURN)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_244()) jj_scanpos = xsp; + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + final private boolean jj_3R_247() { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_149()) return true; + return false; + } + + final private boolean jj_3R_213() { + if (jj_scan_token(EXTENDS)) return true; + if (jj_3R_149()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_247()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3R_208() { + if (jj_scan_token(CONTINUE)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(72)) jj_scanpos = xsp; + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + final private boolean jj_3R_178() { + if (jj_scan_token(INTERFACE)) return true; + return false; + } + + final private boolean jj_3R_207() { + if (jj_scan_token(BREAK)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(72)) jj_scanpos = xsp; + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + final private boolean jj_3R_181() { + if (jj_3R_214()) return true; + return false; + } + + final private boolean jj_3R_180() { + if (jj_3R_213()) return true; + return false; + } + + final private boolean jj_3R_179() { + if (jj_3R_97()) return true; + return false; + } + + final private boolean jj_3R_284() { + if (jj_3R_296()) return true; + return false; + } + + final private boolean jj_3R_270() { + if (jj_3R_56()) return true; + return false; + } + + final private boolean jj_3R_130() { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(16)) { + jj_scanpos = xsp; + if (jj_3R_178()) return true; + } + if (jj_scan_token(IDENTIFIER)) return true; + xsp = jj_scanpos; + if (jj_3R_179()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_180()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_181()) jj_scanpos = xsp; + if (jj_3R_182()) return true; + return false; + } + + final private boolean jj_3_44() { + if (jj_3R_50()) return true; + if (jj_3R_72()) return true; + if (jj_scan_token(IDENTIFIER)) return true; + return false; + } + + final private boolean jj_3R_296() { + if (jj_3R_201()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_299()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3R_241() { + if (jj_scan_token(ELSE)) return true; + if (jj_3R_129()) return true; + return false; + } + + final private boolean jj_3R_295() { + if (jj_3R_296()) return true; + return false; + } + + final private boolean jj_3_43() { + if (jj_3R_50()) return true; + if (jj_3R_72()) return true; + if (jj_scan_token(IDENTIFIER)) return true; + if (jj_scan_token(COLON)) return true; + return false; + } + + final private boolean jj_3R_294() { + if (jj_3R_128()) return true; + return false; + } + + final private boolean jj_3R_283() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_294()) { + jj_scanpos = xsp; + if (jj_3R_295()) return true; + } + return false; + } + + final private boolean jj_3R_269() { + if (jj_3R_283()) return true; + return false; + } + + final private boolean jj_3R_243() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_269()) jj_scanpos = xsp; + if (jj_scan_token(SEMICOLON)) return true; + xsp = jj_scanpos; + if (jj_3R_270()) jj_scanpos = xsp; + if (jj_scan_token(SEMICOLON)) return true; + xsp = jj_scanpos; + if (jj_3R_271()) jj_scanpos = xsp; + return false; + } + + final private boolean jj_3R_242() { + if (jj_3R_50()) return true; + if (jj_3R_72()) return true; + if (jj_scan_token(IDENTIFIER)) return true; + if (jj_scan_token(COLON)) return true; + if (jj_3R_56()) return true; + return false; + } + + final private boolean jj_3R_54() { + if (jj_scan_token(THROWS)) return true; + if (jj_3R_99()) return true; + return false; + } + + final private boolean jj_3R_206() { + if (jj_scan_token(FOR)) return true; + if (jj_scan_token(LPAREN)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_242()) { + jj_scanpos = xsp; + if (jj_3R_243()) return true; + } + if (jj_scan_token(RPAREN)) return true; + if (jj_3R_129()) return true; + return false; + } + + final private boolean jj_3R_69() { + if (jj_3R_102()) return true; + return false; + } + + final private boolean jj_3R_205() { + if (jj_scan_token(DO)) return true; + if (jj_3R_129()) return true; + if (jj_scan_token(WHILE)) return true; + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_56()) return true; + if (jj_scan_token(RPAREN)) return true; + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + final private boolean jj_3R_68() { + if (jj_scan_token(STRICTFP)) return true; + return false; + } + + final private boolean jj_3R_67() { + if (jj_scan_token(VOLATILE)) return true; + return false; + } + + final private boolean jj_3R_66() { + if (jj_scan_token(TRANSIENT)) return true; + return false; + } + + final private boolean jj_3R_204() { + if (jj_scan_token(WHILE)) return true; + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_56()) return true; + if (jj_scan_token(RPAREN)) return true; + if (jj_3R_129()) return true; + return false; + } + + final private boolean jj_3R_65() { + if (jj_scan_token(NATIVE)) return true; + return false; + } + + final private boolean jj_3R_64() { + if (jj_scan_token(SYNCHRONIZED)) return true; + return false; + } + + final private boolean jj_3R_63() { + if (jj_scan_token(ABSTRACT)) return true; + return false; + } + + final private boolean jj_3R_268() { + if (jj_3R_49()) return true; + return false; + } + + final private boolean jj_3R_203() { + if (jj_scan_token(IF)) return true; + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_56()) return true; + if (jj_scan_token(RPAREN)) return true; + if (jj_3R_129()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_241()) jj_scanpos = xsp; + return false; + } + + final private boolean jj_3R_62() { + if (jj_scan_token(FINAL)) return true; + return false; + } + + final private boolean jj_3R_61() { + if (jj_scan_token(PRIVATE)) return true; + return false; + } + + final private boolean jj_3R_162() { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_161()) return true; + return false; + } + + final private boolean jj_3R_60() { + if (jj_scan_token(PROTECTED)) return true; + return false; + } + + final private boolean jj_3R_59() { + if (jj_scan_token(STATIC)) return true; + return false; + } + + final private boolean jj_3R_58() { + if (jj_scan_token(PUBLIC)) return true; + return false; + } + + final private boolean jj_3R_282() { + if (jj_scan_token(_DEFAULT)) return true; + if (jj_scan_token(COLON)) return true; + return false; + } + + final private boolean jj_3_6() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_58()) { + jj_scanpos = xsp; + if (jj_3R_59()) { + jj_scanpos = xsp; + if (jj_3R_60()) { + jj_scanpos = xsp; + if (jj_3R_61()) { + jj_scanpos = xsp; + if (jj_3R_62()) { + jj_scanpos = xsp; + if (jj_3R_63()) { + jj_scanpos = xsp; + if (jj_3R_64()) { + jj_scanpos = xsp; + if (jj_3R_65()) { + jj_scanpos = xsp; + if (jj_3R_66()) { + jj_scanpos = xsp; + if (jj_3R_67()) { + jj_scanpos = xsp; + if (jj_3R_68()) { + jj_scanpos = xsp; + if (jj_3R_69()) return true; + } + } + } + } + } + } + } + } + } + } + } + return false; + } + + final private boolean jj_3R_281() { + if (jj_scan_token(CASE)) return true; + if (jj_3R_56()) return true; + if (jj_scan_token(COLON)) return true; + return false; + } + + final private boolean jj_3R_267() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_281()) { + jj_scanpos = xsp; + if (jj_3R_282()) return true; + } + return false; + } + + final private boolean jj_3R_50() { + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_6()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3R_240() { + if (jj_3R_267()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_268()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3_42() { + if (jj_3R_90()) return true; + if (jj_3R_79()) return true; + return false; + } + + final private boolean jj_3R_202() { + if (jj_scan_token(SWITCH)) return true; + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_56()) return true; + if (jj_scan_token(RPAREN)) return true; + if (jj_scan_token(LBRACE)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_240()) { + jj_scanpos = xsp; + break; + } + } + if (jj_scan_token(RBRACE)) return true; + return false; + } + + final private boolean jj_3R_239() { + if (jj_3R_266()) return true; + return false; + } + + final private boolean jj_3R_57() { + if (jj_3R_102()) return true; + return false; + } + + final private boolean jj_3R_52() { + if (jj_3R_86()) return true; + return false; + } + + final private boolean jj_3R_238() { + if (jj_3R_265()) return true; + return false; + } + + final private boolean jj_3_5() { + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_57()) { + jj_scanpos = xsp; + break; + } + } + if (jj_scan_token(PACKAGE)) return true; + return false; + } + + final private boolean jj_3R_237() { + if (jj_3R_264()) return true; + return false; + } + + final private boolean jj_3R_201() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_236()) { + jj_scanpos = xsp; + if (jj_3R_237()) { + jj_scanpos = xsp; + if (jj_3R_238()) { + jj_scanpos = xsp; + if (jj_3R_239()) return true; + } + } + } + return false; + } + + final private boolean jj_3R_236() { + if (jj_3R_263()) return true; + return false; + } + + final private boolean jj_3R_200() { + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + final private boolean jj_3_41() { + if (jj_3R_50()) return true; + if (jj_3R_72()) return true; + if (jj_scan_token(IDENTIFIER)) return true; + return false; + } + + final private boolean jj_3R_128() { + if (jj_3R_50()) return true; + if (jj_3R_72()) return true; + if (jj_3R_161()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_162()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3R_51() { + if (jj_3R_97()) return true; + return false; + } + + final private boolean jj_3R_235() { + if (jj_scan_token(COLON)) return true; + if (jj_3R_56()) return true; + return false; + } + + final private boolean jj_3R_96() { + if (jj_3R_130()) return true; + return false; + } + + final private boolean jj_3R_95() { + if (jj_3R_129()) return true; + return false; + } + + final private boolean jj_3_4() { + if (jj_3R_56()) return true; + return false; + } + + final private boolean jj_3R_94() { + if (jj_3R_128()) return true; + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + final private boolean jj_3R_49() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_94()) { + jj_scanpos = xsp; + if (jj_3R_95()) { + jj_scanpos = xsp; + if (jj_3R_96()) return true; + } + } + return false; + } + + final private boolean jj_3R_146() { + if (jj_3R_49()) return true; + return false; + } + + final private boolean jj_3_3() { + if (jj_3R_55()) return true; + return false; + } + + final private boolean jj_3R_104() { + if (jj_scan_token(LBRACE)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_146()) { + jj_scanpos = xsp; + break; + } + } + if (jj_scan_token(RBRACE)) return true; + return false; + } + + final private boolean jj_3_2() { + if (jj_3R_50()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_51()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_52()) jj_scanpos = xsp; + if (jj_scan_token(IDENTIFIER)) return true; + if (jj_3R_53()) return true; + xsp = jj_scanpos; + if (jj_3R_54()) jj_scanpos = xsp; + if (jj_scan_token(LBRACE)) return true; + return false; + } + + final private boolean jj_3R_89() { + if (jj_scan_token(IDENTIFIER)) return true; + if (jj_scan_token(COLON)) return true; + if (jj_3R_129()) return true; + return false; + } + + final private boolean jj_3_1() { + if (jj_3R_49()) return true; + return false; + } + + final private boolean jj_3R_199() { + if (jj_scan_token(ASSERT)) return true; + if (jj_3R_56()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_235()) jj_scanpos = xsp; + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + final private boolean jj_3R_177() { + if (jj_3R_212()) return true; + return false; + } + + final private boolean jj_3R_176() { + if (jj_3R_211()) return true; + return false; + } + + final private boolean jj_3_38() { + if (jj_scan_token(LBRACKET)) return true; + if (jj_scan_token(RBRACKET)) return true; + return false; + } + + final private boolean jj_3R_175() { + if (jj_3R_210()) return true; + return false; + } + + final private boolean jj_3R_174() { + if (jj_3R_209()) return true; + return false; + } + + final private boolean jj_3R_173() { + if (jj_3R_208()) return true; + return false; + } + + final private boolean jj_3R_172() { + if (jj_3R_207()) return true; + return false; + } + + final private boolean jj_3R_171() { + if (jj_3R_206()) return true; + return false; + } + + final private boolean jj_3R_170() { + if (jj_3R_205()) return true; + return false; + } + + final private boolean jj_3R_169() { + if (jj_3R_204()) return true; + return false; + } + + final private boolean jj_3R_168() { + if (jj_3R_203()) return true; + return false; + } + + final private boolean jj_3R_167() { + if (jj_3R_202()) return true; + return false; + } + + final private boolean jj_3R_166() { + if (jj_3R_201()) return true; + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + final private boolean jj_3R_165() { + if (jj_3R_200()) return true; + return false; + } + + final private boolean jj_3R_164() { + if (jj_3R_104()) return true; + return false; + } + + final private boolean jj_3R_163() { + if (jj_3R_199()) return true; + return false; + } + + final private boolean jj_3R_260() { + if (jj_3R_78()) return true; + return false; + } + + final private boolean jj_3_40() { + if (jj_3R_89()) return true; + return false; + } + + final private boolean jj_3R_129() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_40()) { + jj_scanpos = xsp; + if (jj_3R_163()) { + jj_scanpos = xsp; + if (jj_3R_164()) { + jj_scanpos = xsp; + if (jj_3R_165()) { + jj_scanpos = xsp; + if (jj_3R_166()) { + jj_scanpos = xsp; + if (jj_3R_167()) { + jj_scanpos = xsp; + if (jj_3R_168()) { + jj_scanpos = xsp; + if (jj_3R_169()) { + jj_scanpos = xsp; + if (jj_3R_170()) { + jj_scanpos = xsp; + if (jj_3R_171()) { + jj_scanpos = xsp; + if (jj_3R_172()) { + jj_scanpos = xsp; + if (jj_3R_173()) { + jj_scanpos = xsp; + if (jj_3R_174()) { + jj_scanpos = xsp; + if (jj_3R_175()) { + jj_scanpos = xsp; + if (jj_3R_176()) { + jj_scanpos = xsp; + if (jj_3R_177()) + return true; + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + return false; + } + + final private boolean jj_3R_279() { + if (jj_3R_182()) return true; + return false; + } + + final private boolean jj_3R_291() { + if (jj_scan_token(LBRACKET)) return true; + if (jj_scan_token(RBRACKET)) return true; + return false; + } + + final private boolean jj_3R_278() { + Token xsp; + if (jj_3R_291()) return true; + while (true) { + xsp = jj_scanpos; + if (jj_3R_291()) { + jj_scanpos = xsp; + break; + } + } + if (jj_3R_147()) return true; + return false; + } + + final private boolean jj_3_37() { + if (jj_scan_token(LBRACKET)) return true; + if (jj_3R_56()) return true; + if (jj_scan_token(RBRACKET)) return true; + return false; + } + + final private boolean jj_3_39() { + Token xsp; + if (jj_3_37()) return true; + while (true) { + xsp = jj_scanpos; + if (jj_3_37()) { + jj_scanpos = xsp; + break; + } + } + while (true) { + xsp = jj_scanpos; + if (jj_3_38()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3R_259() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_39()) { + jj_scanpos = xsp; + if (jj_3R_278()) return true; + } + return false; + } + + final private boolean jj_3R_262() { + if (jj_3R_109()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_279()) jj_scanpos = xsp; + return false; + } + + final private boolean jj_3R_232() { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_56()) return true; + return false; + } + + final private boolean jj_3R_261() { + if (jj_3R_259()) return true; + return false; + } + + final private boolean jj_3R_123() { + if (jj_scan_token(NEW)) return true; + if (jj_3R_149()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_260()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_261()) { + jj_scanpos = xsp; + if (jj_3R_262()) return true; + } + return false; + } + + final private boolean jj_3R_87() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_36()) { + jj_scanpos = xsp; + if (jj_3R_123()) return true; + } + return false; + } + + final private boolean jj_3_36() { + if (jj_scan_token(NEW)) return true; + if (jj_3R_83()) return true; + if (jj_3R_259()) return true; + return false; + } + + final private boolean jj_3R_148() { + if (jj_3R_195()) return true; + return false; + } + + final private boolean jj_3R_195() { + if (jj_3R_56()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_232()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3R_109() { + if (jj_scan_token(LPAREN)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_148()) jj_scanpos = xsp; + if (jj_scan_token(RPAREN)) return true; + return false; + } + + final private boolean jj_3R_258() { + if (jj_scan_token(NULL)) return true; + return false; + } + + final private boolean jj_3R_257() { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(56)) { + jj_scanpos = xsp; + if (jj_scan_token(25)) return true; + } + return false; + } + + final private boolean jj_3R_234() { + if (jj_3R_258()) return true; + return false; + } + + final private boolean jj_3R_233() { + if (jj_3R_257()) return true; + return false; + } + + final private boolean jj_3R_196() { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(61)) { + jj_scanpos = xsp; + if (jj_scan_token(65)) { + jj_scanpos = xsp; + if (jj_scan_token(70)) { + jj_scanpos = xsp; + if (jj_scan_token(71)) { + jj_scanpos = xsp; + if (jj_3R_233()) { + jj_scanpos = xsp; + if (jj_3R_234()) return true; + } + } + } + } + } + return false; + } + + final private boolean jj_3R_152() { + if (jj_3R_196()) return true; + return false; + } + + final private boolean jj_3R_121() { + if (jj_3R_109()) return true; + return false; + } + + final private boolean jj_3R_120() { + if (jj_scan_token(DOT)) return true; + if (jj_scan_token(IDENTIFIER)) return true; + return false; + } + + final private boolean jj_3_33() { + if (jj_scan_token(DOT)) return true; + if (jj_scan_token(THIS)) return true; + return false; + } + + final private boolean jj_3R_119() { + if (jj_scan_token(LBRACKET)) return true; + if (jj_3R_56()) return true; + if (jj_scan_token(RBRACKET)) return true; + return false; + } + + final private boolean jj_3_32() { + if (jj_scan_token(DOT)) return true; + if (jj_scan_token(SUPER)) return true; + if (jj_scan_token(DOT)) return true; + return false; + } + + final private boolean jj_3_35() { + if (jj_3R_88()) return true; + return false; + } + + final private boolean jj_3_34() { + if (jj_scan_token(DOT)) return true; + if (jj_3R_87()) return true; + return false; + } + + final private boolean jj_3R_118() { + if (jj_scan_token(DOT)) return true; + if (jj_scan_token(THIS)) return true; + return false; + } + + final private boolean jj_3_31() { + if (jj_3R_86()) return true; + if (jj_scan_token(DOT)) return true; + if (jj_scan_token(CLASS)) return true; + return false; + } + + final private boolean jj_3R_117() { + if (jj_scan_token(DOT)) return true; + if (jj_scan_token(SUPER)) return true; + return false; + } + + final private boolean jj_3R_84() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_117()) { + jj_scanpos = xsp; + if (jj_3R_118()) { + jj_scanpos = xsp; + if (jj_3_34()) { + jj_scanpos = xsp; + if (jj_3_35()) { + jj_scanpos = xsp; + if (jj_3R_119()) { + jj_scanpos = xsp; + if (jj_3R_120()) { + jj_scanpos = xsp; + if (jj_3R_121()) return true; + } + } + } + } + } + } + return false; + } + + final private boolean jj_3R_85() { + if (jj_scan_token(IDENTIFIER)) return true; + if (jj_scan_token(DOT)) return true; + return false; + } + + final private boolean jj_3R_159() { + if (jj_3R_91()) return true; + return false; + } + + final private boolean jj_3_30() { + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_85()) { + jj_scanpos = xsp; + break; + } + } + if (jj_scan_token(THIS)) return true; + return false; + } + + final private boolean jj_3R_158() { + if (jj_3R_86()) return true; + if (jj_scan_token(DOT)) return true; + if (jj_scan_token(CLASS)) return true; + return false; + } + + final private boolean jj_3R_157() { + if (jj_3R_87()) return true; + return false; + } + + final private boolean jj_3R_156() { + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_56()) return true; + if (jj_scan_token(RPAREN)) return true; + return false; + } + + final private boolean jj_3_29() { + if (jj_3R_84()) return true; + return false; + } + + final private boolean jj_3R_155() { + if (jj_scan_token(SUPER)) return true; + if (jj_scan_token(DOT)) return true; + if (jj_scan_token(IDENTIFIER)) return true; + return false; + } + + final private boolean jj_3R_197() { + if (jj_scan_token(IDENTIFIER)) return true; + if (jj_scan_token(DOT)) return true; + return false; + } + + final private boolean jj_3R_154() { + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_197()) { + jj_scanpos = xsp; + break; + } + } + if (jj_scan_token(THIS)) return true; + return false; + } + + final private boolean jj_3R_124() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_153()) { + jj_scanpos = xsp; + if (jj_3R_154()) { + jj_scanpos = xsp; + if (jj_3R_155()) { + jj_scanpos = xsp; + if (jj_3R_156()) { + jj_scanpos = xsp; + if (jj_3R_157()) { + jj_scanpos = xsp; + if (jj_3R_158()) { + jj_scanpos = xsp; + if (jj_3R_159()) return true; + } + } + } + } + } + } + return false; + } + + final private boolean jj_3R_153() { + if (jj_3R_196()) return true; + return false; + } + + final private boolean jj_3R_88() { + if (jj_scan_token(DOT)) return true; + if (jj_3R_78()) return true; + if (jj_scan_token(IDENTIFIER)) return true; + return false; + } + + final private boolean jj_3R_280() { + if (jj_3R_293()) return true; + return false; + } + + final private boolean jj_3_28() { + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_83()) return true; + return false; + } + + final private boolean jj_3R_90() { + if (jj_3R_124()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_29()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3R_319() { + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_72()) return true; + if (jj_scan_token(RPAREN)) return true; + if (jj_3R_313()) return true; + return false; + } + + final private boolean jj_3R_318() { + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_72()) return true; + if (jj_scan_token(RPAREN)) return true; + if (jj_3R_307()) return true; + return false; + } + + final private boolean jj_3R_317() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_318()) { + jj_scanpos = xsp; + if (jj_3R_319()) return true; + } + return false; + } + + final private boolean jj_3R_293() { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(97)) { + jj_scanpos = xsp; + if (jj_scan_token(98)) return true; + } + return false; + } + + final private boolean jj_3_27() { + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_72()) return true; + if (jj_scan_token(LBRACKET)) return true; + return false; + } + + final private boolean jj_3R_266() { + if (jj_3R_90()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_280()) jj_scanpos = xsp; + return false; + } + + final private boolean jj_3R_116() { + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_72()) return true; + if (jj_scan_token(RPAREN)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(88)) { + jj_scanpos = xsp; + if (jj_scan_token(87)) { + jj_scanpos = xsp; + if (jj_scan_token(75)) { + jj_scanpos = xsp; + if (jj_scan_token(72)) { + jj_scanpos = xsp; + if (jj_scan_token(52)) { + jj_scanpos = xsp; + if (jj_scan_token(49)) { + jj_scanpos = xsp; + if (jj_scan_token(39)) { + jj_scanpos = xsp; + if (jj_3R_152()) return true; + } + } + } + } + } + } + } + return false; + } + + final private boolean jj_3R_115() { + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_72()) return true; + if (jj_scan_token(LBRACKET)) return true; + if (jj_scan_token(RBRACKET)) return true; + return false; + } + + final private boolean jj_3R_82() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_26()) { + jj_scanpos = xsp; + if (jj_3R_115()) { + jj_scanpos = xsp; + if (jj_3R_116()) return true; + } + } + return false; + } + + final private boolean jj_3_26() { + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_83()) return true; + return false; + } + + final private boolean jj_3_25() { + if (jj_3R_82()) return true; + return false; + } + + final private boolean jj_3_24() { + if (jj_3R_81()) return true; + return false; + } + + final private boolean jj_3R_316() { + if (jj_3R_266()) return true; + return false; + } + + final private boolean jj_3R_315() { + if (jj_3R_317()) return true; + return false; + } + + final private boolean jj_3R_314() { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(88)) { + jj_scanpos = xsp; + if (jj_scan_token(87)) return true; + } + if (jj_3R_307()) return true; + return false; + } + + final private boolean jj_3R_313() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_314()) { + jj_scanpos = xsp; + if (jj_3R_315()) { + jj_scanpos = xsp; + if (jj_3R_316()) return true; + } + } + return false; + } + + final private boolean jj_3R_264() { + if (jj_scan_token(DECR)) return true; + if (jj_3R_90()) return true; + return false; + } + + final private boolean jj_3R_306() { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(99)) { + jj_scanpos = xsp; + if (jj_scan_token(100)) return true; + } + if (jj_3R_305()) return true; + return false; + } + + final private boolean jj_3R_308() { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(101)) { + jj_scanpos = xsp; + if (jj_scan_token(102)) { + jj_scanpos = xsp; + if (jj_scan_token(106)) return true; + } + } + if (jj_3R_307()) return true; + return false; + } + + final private boolean jj_3_23() { + if (jj_3R_80()) return true; + return false; + } + + final private boolean jj_3R_263() { + if (jj_scan_token(INCR)) return true; + if (jj_3R_90()) return true; + return false; + } + + final private boolean jj_3R_312() { + if (jj_3R_313()) return true; + return false; + } + + final private boolean jj_3_22() { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(107)) { + jj_scanpos = xsp; + if (jj_3_23()) { + jj_scanpos = xsp; + if (jj_3_24()) return true; + } + } + if (jj_3R_304()) return true; + return false; + } + + final private boolean jj_3R_311() { + if (jj_3R_264()) return true; + return false; + } + + final private boolean jj_3R_310() { + if (jj_3R_263()) return true; + return false; + } + + final private boolean jj_3R_309() { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(99)) { + jj_scanpos = xsp; + if (jj_scan_token(100)) return true; + } + if (jj_3R_307()) return true; + return false; + } + + final private boolean jj_3R_307() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_309()) { + jj_scanpos = xsp; + if (jj_3R_310()) { + jj_scanpos = xsp; + if (jj_3R_311()) { + jj_scanpos = xsp; + if (jj_3R_312()) return true; + } + } + } + return false; + } + + final private boolean jj_3R_303() { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(86)) { + jj_scanpos = xsp; + if (jj_scan_token(122)) { + jj_scanpos = xsp; + if (jj_scan_token(92)) { + jj_scanpos = xsp; + if (jj_scan_token(93)) return true; + } + } + } + if (jj_3R_302()) return true; + return false; + } + + final private boolean jj_3R_301() { + if (jj_scan_token(INSTANCEOF)) return true; + if (jj_3R_72()) return true; + return false; + } + + final private boolean jj_3R_305() { + if (jj_3R_307()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_308()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3R_298() { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(91)) { + jj_scanpos = xsp; + if (jj_scan_token(94)) return true; + } + if (jj_3R_297()) return true; + return false; + } + + final private boolean jj_3R_304() { + if (jj_3R_305()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_306()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3R_302() { + if (jj_3R_304()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_22()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3R_288() { + if (jj_scan_token(BIT_AND)) return true; + if (jj_3R_287()) return true; + return false; + } + + final private boolean jj_3R_300() { + if (jj_3R_302()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_303()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3R_254() { + if (jj_scan_token(BIT_OR)) return true; + if (jj_3R_253()) return true; + return false; + } + + final private boolean jj_3R_297() { + if (jj_3R_300()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_301()) jj_scanpos = xsp; + return false; + } + + final private boolean jj_3R_274() { + if (jj_scan_token(XOR)) return true; + if (jj_3R_273()) return true; + return false; + } + + final private boolean jj_3R_230() { + if (jj_scan_token(SC_AND)) return true; + if (jj_3R_229()) return true; + return false; + } + + final private boolean jj_3R_287() { + if (jj_3R_297()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_298()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3R_190() { + if (jj_scan_token(SC_OR)) return true; + if (jj_3R_189()) return true; + return false; + } + + final private boolean jj_3R_273() { + if (jj_3R_287()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_288()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3R_142() { + if (jj_scan_token(HOOK)) return true; + if (jj_3R_56()) return true; + if (jj_scan_token(COLON)) return true; + if (jj_3R_56()) return true; + return false; + } + + final private boolean jj_3R_253() { + if (jj_3R_273()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_274()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3R_229() { + if (jj_3R_253()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_254()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3R_189() { + if (jj_3R_229()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_230()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3R_141() { + if (jj_3R_189()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_190()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + final private boolean jj_3R_101() { + if (jj_3R_141()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_142()) jj_scanpos = xsp; + return false; + } + + final private boolean jj_3R_265() { + if (jj_3R_90()) return true; + if (jj_3R_79()) return true; + if (jj_3R_56()) return true; + return false; + } + + final private boolean jj_3R_79() { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(85)) { + jj_scanpos = xsp; + if (jj_scan_token(110)) { + jj_scanpos = xsp; + if (jj_scan_token(111)) { + jj_scanpos = xsp; + if (jj_scan_token(115)) { + jj_scanpos = xsp; + if (jj_scan_token(108)) { + jj_scanpos = xsp; + if (jj_scan_token(109)) { + jj_scanpos = xsp; + if (jj_scan_token(116)) { + jj_scanpos = xsp; + if (jj_scan_token(117)) { + jj_scanpos = xsp; + if (jj_scan_token(118)) { + jj_scanpos = xsp; + if (jj_scan_token(112)) { + jj_scanpos = xsp; + if (jj_scan_token(114)) { + jj_scanpos = xsp; + if (jj_scan_token(113)) + return true; + } + } + } + } + } + } + } + } + } + } + } + return false; + } + + final private boolean jj_3_21() { + if (jj_3R_79()) return true; + if (jj_3R_56()) return true; + return false; + } + + public JavaParserTokenManager token_source; + JavaCharStream jj_input_stream; + public Token token, jj_nt; + private int jj_ntk; + private Token jj_scanpos, jj_lastpos; + private int jj_la; + public boolean lookingAhead = false; + private boolean jj_semLA; + + public JavaParser(java.io.InputStream stream) { + this(stream, null); + } + + public JavaParser(java.io.InputStream stream, String encoding) { + try { + jj_input_stream = new JavaCharStream(stream, encoding, 1, 1); + } catch (java.io.UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + token_source = new JavaParserTokenManager(jj_input_stream); + token = new Token(); + jj_ntk = -1; + } + + public void ReInit(java.io.InputStream stream) { + ReInit(stream, null); + } + + public void ReInit(java.io.InputStream stream, String encoding) { + try { + jj_input_stream.ReInit(stream, encoding, 1, 1); + } catch (java.io.UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + token_source.ReInit(jj_input_stream); + token = new Token(); + jj_ntk = -1; + jjtree.reset(); + } + + public JavaParser(java.io.Reader stream) { + jj_input_stream = new JavaCharStream(stream, 1, 1); + token_source = new JavaParserTokenManager(jj_input_stream); + token = new Token(); + jj_ntk = -1; + } + + public void ReInit(java.io.Reader stream) { + jj_input_stream.ReInit(stream, 1, 1); + token_source.ReInit(jj_input_stream); + token = new Token(); + jj_ntk = -1; + jjtree.reset(); + } + + public JavaParser(JavaParserTokenManager tm) { + token_source = tm; + token = new Token(); + jj_ntk = -1; + } + + public void ReInit(JavaParserTokenManager tm) { + token_source = tm; + token = new Token(); + jj_ntk = -1; + jjtree.reset(); + } + + final private Token jj_consume_token(int kind) throws ParseException { + Token oldToken; + if ((oldToken = token).next != null) token = token.next; + else token = token.next = token_source.getNextToken(); + jj_ntk = -1; + if (token.kind == kind) { + return token; + } + token = oldToken; + throw generateParseException(); + } + + static private final class LookaheadSuccess extends java.lang.Error { + } + + final private LookaheadSuccess jj_ls = new LookaheadSuccess(); + + final private boolean jj_scan_token(int kind) { + if (jj_scanpos == jj_lastpos) { + jj_la--; + if (jj_scanpos.next == null) { + jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken(); + } else { + jj_lastpos = jj_scanpos = jj_scanpos.next; + } + } else { + jj_scanpos = jj_scanpos.next; + } + if (jj_scanpos.kind != kind) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls; + return false; + } + + final public Token getNextToken() { + if (token.next != null) token = token.next; + else token = token.next = token_source.getNextToken(); + jj_ntk = -1; + return token; + } + + final public Token getToken(int index) { + Token t = lookingAhead ? jj_scanpos : token; + for (int i = 0; i < index; i++) { + if (t.next != null) t = t.next; + else t = t.next = token_source.getNextToken(); + } + return t; + } + + final private int jj_ntk() { + if ((jj_nt = token.next) == null) + return (jj_ntk = (token.next = token_source.getNextToken()).kind); + else + return (jj_ntk = jj_nt.kind); + } + + public ParseException generateParseException() { + Token errortok = token.next; + int line = errortok.beginLine, column = errortok.beginColumn; + String mess = (errortok.kind == 0) ? tokenImage[0] : errortok.image; + return new ParseException("Unable to parse Java code near token: " + mess, line, column); + } + + final public void enable_tracing() { + } + + final public void disable_tracing() { + } + +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParserConstants.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParserConstants.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParserConstants.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,280 +0,0 @@ -/* Generated By:JJTree&JavaCC: Do not edit this line. JavaParserConstants.java */ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.java.parser; - -public interface JavaParserConstants { - - int EOF = 0; - int WHITE_SPACE = 3; - int SINGLE_LINE_COMMENT = 4; - int FORMAL_COMMENT = 5; - int MULTI_LINE_COMMENT = 6; - int ABSTRACT = 8; - int ASSERT = 9; - int BOOLEAN = 10; - int BREAK = 11; - int BYTE = 12; - int CASE = 13; - int CATCH = 14; - int CHAR = 15; - int CLASS = 16; - int CONST = 17; - int CONTINUE = 18; - int _DEFAULT = 19; - int DO = 20; - int DOUBLE = 21; - int ELSE = 22; - int ENUM = 23; - int EXTENDS = 24; - int FALSE = 25; - int FINAL = 26; - int FINALLY = 27; - int FLOAT = 28; - int FOR = 29; - int GOTO = 30; - int IF = 31; - int IMPLEMENTS = 32; - int IMPORT = 33; - int INSTANCEOF = 34; - int INT = 35; - int INTERFACE = 36; - int LONG = 37; - int NATIVE = 38; - int NEW = 39; - int NULL = 40; - int PACKAGE = 41; - int PRIVATE = 42; - int PROTECTED = 43; - int PUBLIC = 44; - int RETURN = 45; - int SHORT = 46; - int STATIC = 47; - int STRICTFP = 48; - int SUPER = 49; - int SWITCH = 50; - int SYNCHRONIZED = 51; - int THIS = 52; - int THROW = 53; - int THROWS = 54; - int TRANSIENT = 55; - int TRUE = 56; - int TRY = 57; - int VOID = 58; - int VOLATILE = 59; - int WHILE = 60; - int INTEGER_LITERAL = 61; - int DECIMAL_LITERAL = 62; - int HEX_LITERAL = 63; - int OCTAL_LITERAL = 64; - int FLOATING_POINT_LITERAL = 65; - int DECIMAL_FLOATING_POINT_LITERAL = 66; - int DECIMAL_EXPONENT = 67; - int HEXADECIMAL_FLOATING_POINT_LITERAL = 68; - int HEXADECIMAL_EXPONENT = 69; - int CHARACTER_LITERAL = 70; - int STRING_LITERAL = 71; - int IDENTIFIER = 72; - int LETTER = 73; - int PART_LETTER = 74; - int LPAREN = 75; - int RPAREN = 76; - int LBRACE = 77; - int RBRACE = 78; - int LBRACKET = 79; - int RBRACKET = 80; - int SEMICOLON = 81; - int COMMA = 82; - int DOT = 83; - int AT = 84; - int ASSIGN = 85; - int LT = 86; - int BANG = 87; - int TILDE = 88; - int HOOK = 89; - int COLON = 90; - int EQ = 91; - int LE = 92; - int GE = 93; - int NE = 94; - int SC_OR = 95; - int SC_AND = 96; - int INCR = 97; - int DECR = 98; - int PLUS = 99; - int MINUS = 100; - int STAR = 101; - int SLASH = 102; - int BIT_AND = 103; - int BIT_OR = 104; - int XOR = 105; - int REM = 106; - int LSHIFT = 107; - int PLUSASSIGN = 108; - int MINUSASSIGN = 109; - int STARASSIGN = 110; - int SLASHASSIGN = 111; - int ANDASSIGN = 112; - int ORASSIGN = 113; - int XORASSIGN = 114; - int REMASSIGN = 115; - int LSHIFTASSIGN = 116; - int RSIGNEDSHIFTASSIGN = 117; - int RUNSIGNEDSHIFTASSIGN = 118; - int ELLIPSIS = 119; - int RUNSIGNEDSHIFT = 120; - int RSIGNEDSHIFT = 121; - int GT = 122; - int STUFF_TO_IGNORE = 124; - - int DEFAULT = 0; - int IN_FORMAL_COMMENT = 1; - int IN_MULTI_LINE_COMMENT = 2; - - String[] tokenImage = { - "<EOF>", - "<token of kind 1>", - "\"/*\"", - "<WHITE_SPACE>", - "<SINGLE_LINE_COMMENT>", - "\"*/\"", - "\"*/\"", - "<token of kind 7>", - "\"abstract\"", - "\"assert\"", - "\"boolean\"", - "\"break\"", - "\"byte\"", - "\"case\"", - "\"catch\"", - "\"char\"", - "\"class\"", - "\"const\"", - "\"continue\"", - "\"default\"", - "\"do\"", - "\"double\"", - "\"else\"", - "\"enum\"", - "\"extends\"", - "\"false\"", - "\"final\"", - "\"finally\"", - "\"float\"", - "\"for\"", - "\"goto\"", - "\"if\"", - "\"implements\"", - "\"import\"", - "\"instanceof\"", - "\"int\"", - "\"interface\"", - "\"long\"", - "\"native\"", - "\"new\"", - "\"null\"", - "\"package\"", - "\"private\"", - "\"protected\"", - "\"public\"", - "\"return\"", - "\"short\"", - "\"static\"", - "\"strictfp\"", - "\"super\"", - "\"switch\"", - "\"synchronized\"", - "\"this\"", - "\"throw\"", - "\"throws\"", - "\"transient\"", - "\"true\"", - "\"try\"", - "\"void\"", - "\"volatile\"", - "\"while\"", - "<INTEGER_LITERAL>", - "<DECIMAL_LITERAL>", - "<HEX_LITERAL>", - "<OCTAL_LITERAL>", - "<FLOATING_POINT_LITERAL>", - "<DECIMAL_FLOATING_POINT_LITERAL>", - "<DECIMAL_EXPONENT>", - "<HEXADECIMAL_FLOATING_POINT_LITERAL>", - "<HEXADECIMAL_EXPONENT>", - "<CHARACTER_LITERAL>", - "<STRING_LITERAL>", - "<IDENTIFIER>", - "<LETTER>", - "<PART_LETTER>", - "\"(\"", - "\")\"", - "\"{\"", - "\"}\"", - "\"[\"", - "\"]\"", - "\";\"", - "\",\"", - "\".\"", - "\"@\"", - "\"=\"", - "\"<\"", - "\"!\"", - "\"~\"", - "\"?\"", - "\":\"", - "\"==\"", - "\"<=\"", - "\">=\"", - "\"!=\"", - "\"||\"", - "\"&&\"", - "\"++\"", - "\"--\"", - "\"+\"", - "\"-\"", - "\"*\"", - "\"/\"", - "\"&\"", - "\"|\"", - "\"^\"", - "\"%\"", - "\"<<\"", - "\"+=\"", - "\"-=\"", - "\"*=\"", - "\"/=\"", - "\"&=\"", - "\"|=\"", - "\"^=\"", - "\"%=\"", - "\"<<=\"", - "\">>=\"", - "\">>>=\"", - "\"...\"", - "\">>>\"", - "\">>\"", - "\">\"", - "\"\\u001a\"", - "<STUFF_TO_IGNORE>", - }; - -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParserConstants.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParserConstants.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParserConstants.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParserConstants.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,280 @@ +/* Generated By:JJTree&JavaCC: Do not edit this line. JavaParserConstants.java */ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.java.parser; + +public interface JavaParserConstants { + + int EOF = 0; + int WHITE_SPACE = 3; + int SINGLE_LINE_COMMENT = 4; + int FORMAL_COMMENT = 5; + int MULTI_LINE_COMMENT = 6; + int ABSTRACT = 8; + int ASSERT = 9; + int BOOLEAN = 10; + int BREAK = 11; + int BYTE = 12; + int CASE = 13; + int CATCH = 14; + int CHAR = 15; + int CLASS = 16; + int CONST = 17; + int CONTINUE = 18; + int _DEFAULT = 19; + int DO = 20; + int DOUBLE = 21; + int ELSE = 22; + int ENUM = 23; + int EXTENDS = 24; + int FALSE = 25; + int FINAL = 26; + int FINALLY = 27; + int FLOAT = 28; + int FOR = 29; + int GOTO = 30; + int IF = 31; + int IMPLEMENTS = 32; + int IMPORT = 33; + int INSTANCEOF = 34; + int INT = 35; + int INTERFACE = 36; + int LONG = 37; + int NATIVE = 38; + int NEW = 39; + int NULL = 40; + int PACKAGE = 41; + int PRIVATE = 42; + int PROTECTED = 43; + int PUBLIC = 44; + int RETURN = 45; + int SHORT = 46; + int STATIC = 47; + int STRICTFP = 48; + int SUPER = 49; + int SWITCH = 50; + int SYNCHRONIZED = 51; + int THIS = 52; + int THROW = 53; + int THROWS = 54; + int TRANSIENT = 55; + int TRUE = 56; + int TRY = 57; + int VOID = 58; + int VOLATILE = 59; + int WHILE = 60; + int INTEGER_LITERAL = 61; + int DECIMAL_LITERAL = 62; + int HEX_LITERAL = 63; + int OCTAL_LITERAL = 64; + int FLOATING_POINT_LITERAL = 65; + int DECIMAL_FLOATING_POINT_LITERAL = 66; + int DECIMAL_EXPONENT = 67; + int HEXADECIMAL_FLOATING_POINT_LITERAL = 68; + int HEXADECIMAL_EXPONENT = 69; + int CHARACTER_LITERAL = 70; + int STRING_LITERAL = 71; + int IDENTIFIER = 72; + int LETTER = 73; + int PART_LETTER = 74; + int LPAREN = 75; + int RPAREN = 76; + int LBRACE = 77; + int RBRACE = 78; + int LBRACKET = 79; + int RBRACKET = 80; + int SEMICOLON = 81; + int COMMA = 82; + int DOT = 83; + int AT = 84; + int ASSIGN = 85; + int LT = 86; + int BANG = 87; + int TILDE = 88; + int HOOK = 89; + int COLON = 90; + int EQ = 91; + int LE = 92; + int GE = 93; + int NE = 94; + int SC_OR = 95; + int SC_AND = 96; + int INCR = 97; + int DECR = 98; + int PLUS = 99; + int MINUS = 100; + int STAR = 101; + int SLASH = 102; + int BIT_AND = 103; + int BIT_OR = 104; + int XOR = 105; + int REM = 106; + int LSHIFT = 107; + int PLUSASSIGN = 108; + int MINUSASSIGN = 109; + int STARASSIGN = 110; + int SLASHASSIGN = 111; + int ANDASSIGN = 112; + int ORASSIGN = 113; + int XORASSIGN = 114; + int REMASSIGN = 115; + int LSHIFTASSIGN = 116; + int RSIGNEDSHIFTASSIGN = 117; + int RUNSIGNEDSHIFTASSIGN = 118; + int ELLIPSIS = 119; + int RUNSIGNEDSHIFT = 120; + int RSIGNEDSHIFT = 121; + int GT = 122; + int STUFF_TO_IGNORE = 124; + + int DEFAULT = 0; + int IN_FORMAL_COMMENT = 1; + int IN_MULTI_LINE_COMMENT = 2; + + String[] tokenImage = { + "<EOF>", + "<token of kind 1>", + "\"/*\"", + "<WHITE_SPACE>", + "<SINGLE_LINE_COMMENT>", + "\"*/\"", + "\"*/\"", + "<token of kind 7>", + "\"abstract\"", + "\"assert\"", + "\"boolean\"", + "\"break\"", + "\"byte\"", + "\"case\"", + "\"catch\"", + "\"char\"", + "\"class\"", + "\"const\"", + "\"continue\"", + "\"default\"", + "\"do\"", + "\"double\"", + "\"else\"", + "\"enum\"", + "\"extends\"", + "\"false\"", + "\"final\"", + "\"finally\"", + "\"float\"", + "\"for\"", + "\"goto\"", + "\"if\"", + "\"implements\"", + "\"import\"", + "\"instanceof\"", + "\"int\"", + "\"interface\"", + "\"long\"", + "\"native\"", + "\"new\"", + "\"null\"", + "\"package\"", + "\"private\"", + "\"protected\"", + "\"public\"", + "\"return\"", + "\"short\"", + "\"static\"", + "\"strictfp\"", + "\"super\"", + "\"switch\"", + "\"synchronized\"", + "\"this\"", + "\"throw\"", + "\"throws\"", + "\"transient\"", + "\"true\"", + "\"try\"", + "\"void\"", + "\"volatile\"", + "\"while\"", + "<INTEGER_LITERAL>", + "<DECIMAL_LITERAL>", + "<HEX_LITERAL>", + "<OCTAL_LITERAL>", + "<FLOATING_POINT_LITERAL>", + "<DECIMAL_FLOATING_POINT_LITERAL>", + "<DECIMAL_EXPONENT>", + "<HEXADECIMAL_FLOATING_POINT_LITERAL>", + "<HEXADECIMAL_EXPONENT>", + "<CHARACTER_LITERAL>", + "<STRING_LITERAL>", + "<IDENTIFIER>", + "<LETTER>", + "<PART_LETTER>", + "\"(\"", + "\")\"", + "\"{\"", + "\"}\"", + "\"[\"", + "\"]\"", + "\";\"", + "\",\"", + "\".\"", + "\"@\"", + "\"=\"", + "\"<\"", + "\"!\"", + "\"~\"", + "\"?\"", + "\":\"", + "\"==\"", + "\"<=\"", + "\">=\"", + "\"!=\"", + "\"||\"", + "\"&&\"", + "\"++\"", + "\"--\"", + "\"+\"", + "\"-\"", + "\"*\"", + "\"/\"", + "\"&\"", + "\"|\"", + "\"^\"", + "\"%\"", + "\"<<\"", + "\"+=\"", + "\"-=\"", + "\"*=\"", + "\"/=\"", + "\"&=\"", + "\"|=\"", + "\"^=\"", + "\"%=\"", + "\"<<=\"", + "\">>=\"", + "\">>>=\"", + "\"...\"", + "\">>>\"", + "\">>\"", + "\">\"", + "\"\\u001a\"", + "<STUFF_TO_IGNORE>", + }; + +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParserTokenManager.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParserTokenManager.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParserTokenManager.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,2092 +0,0 @@ -/* Generated By:JJTree&JavaCC: Do not edit this line. JavaParserTokenManager.java */ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.java.parser; - -public class JavaParserTokenManager implements JavaParserConstants { - public java.io.PrintStream debugStream = System.out; - - public void setDebugStream(java.io.PrintStream ds) { - debugStream = ds; - } - - private int jjStopStringLiteralDfa_0(int pos, long active0, long active1) { - switch (pos) { - case 0: - if ((active0 & 0x4L) != 0L || (active1 & 0x804000000000L) != 0L) - return 48; - if ((active1 & 0x80000000080000L) != 0L) - return 5; - if ((active0 & 0x1fffffffffffff00L) != 0L) { - jjmatchedKind = 72; - return 29; - } - return -1; - case 1: - if ((active0 & 0x4L) != 0L) - return 46; - if ((active0 & 0x1fffffff7fcfff00L) != 0L) { - if (jjmatchedPos != 1) { - jjmatchedKind = 72; - jjmatchedPos = 1; - } - return 29; - } - if ((active0 & 0x80300000L) != 0L) - return 29; - return -1; - case 2: - if ((active0 & 0x1dffff675fefff00L) != 0L) { - if (jjmatchedPos != 2) { - jjmatchedKind = 72; - jjmatchedPos = 2; - } - return 29; - } - if ((active0 & 0x200009820000000L) != 0L) - return 29; - return -1; - case 3: - if ((active0 & 0x18effe571f2f4f00L) != 0L) { - jjmatchedKind = 72; - jjmatchedPos = 3; - return 29; - } - if ((active0 & 0x510012040c0b000L) != 0L) - return 29; - return -1; - case 4: - if ((active0 & 0x88dbe57012c0700L) != 0L) { - if (jjmatchedPos != 4) { - jjmatchedKind = 72; - jjmatchedPos = 4; - } - return 29; - } - if ((active0 & 0x106240001e034800L) != 0L) - return 29; - return -1; - case 5: - if ((active0 & 0x8890e15090c0500L) != 0L) { - jjmatchedKind = 72; - jjmatchedPos = 5; - return 29; - } - if ((active0 & 0x44b04200200200L) != 0L) - return 29; - return -1; - case 6: - if ((active0 & 0x889081500040100L) != 0L) { - jjmatchedKind = 72; - jjmatchedPos = 6; - return 29; - } - if ((active0 & 0x60009080400L) != 0L) - return 29; - return -1; - case 7: - if ((active0 & 0x801000000040100L) != 0L) - return 29; - if ((active0 & 0x88081500000000L) != 0L) { - jjmatchedKind = 72; - jjmatchedPos = 7; - return 29; - } - return -1; - case 8: - if ((active0 & 0x8000500000000L) != 0L) { - jjmatchedKind = 72; - jjmatchedPos = 8; - return 29; - } - if ((active0 & 0x80081000000000L) != 0L) - return 29; - return -1; - case 9: - if ((active0 & 0x8000000000000L) != 0L) { - jjmatchedKind = 72; - jjmatchedPos = 9; - return 29; - } - if ((active0 & 0x500000000L) != 0L) - return 29; - return -1; - case 10: - if ((active0 & 0x8000000000000L) != 0L) { - jjmatchedKind = 72; - jjmatchedPos = 10; - return 29; - } - return -1; - default: - return -1; - } - } - - private int jjStartNfa_0(int pos, long active0, long active1) { - return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0, active1), pos + 1); - } - - private int jjStopAtPos(int pos, int kind) { - jjmatchedKind = kind; - jjmatchedPos = pos; - return pos + 1; - } - - private int jjStartNfaWithStates_0(int pos, int kind, int state) { - jjmatchedKind = kind; - jjmatchedPos = pos; - try { - curChar = input_stream.readChar(); - } - catch (java.io.IOException e) { - return pos + 1; - } - return jjMoveNfa_0(state, pos + 1); - } - - private int jjMoveStringLiteralDfa0_0() { - switch (curChar) { - case 26: - return jjStopAtPos(0, 123); - case 33: - jjmatchedKind = 87; - return jjMoveStringLiteralDfa1_0(0x0L, 0x40000000L); - case 37: - jjmatchedKind = 106; - return jjMoveStringLiteralDfa1_0(0x0L, 0x8000000000000L); - case 38: - jjmatchedKind = 103; - return jjMoveStringLiteralDfa1_0(0x0L, 0x1000100000000L); - case 40: - return jjStopAtPos(0, 75); - case 41: - return jjStopAtPos(0, 76); - case 42: - jjmatchedKind = 101; - return jjMoveStringLiteralDfa1_0(0x0L, 0x400000000000L); - case 43: - jjmatchedKind = 99; - return jjMoveStringLiteralDfa1_0(0x0L, 0x100200000000L); - case 44: - return jjStopAtPos(0, 82); - case 45: - jjmatchedKind = 100; - return jjMoveStringLiteralDfa1_0(0x0L, 0x200400000000L); - case 46: - jjmatchedKind = 83; - return jjMoveStringLiteralDfa1_0(0x0L, 0x80000000000000L); - case 47: - jjmatchedKind = 102; - return jjMoveStringLiteralDfa1_0(0x4L, 0x800000000000L); - case 58: - return jjStopAtPos(0, 90); - case 59: - return jjStopAtPos(0, 81); - case 60: - jjmatchedKind = 86; - return jjMoveStringLiteralDfa1_0(0x0L, 0x10080010000000L); - case 61: - jjmatchedKind = 85; - return jjMoveStringLiteralDfa1_0(0x0L, 0x8000000L); - case 62: - jjmatchedKind = 122; - return jjMoveStringLiteralDfa1_0(0x0L, 0x360000020000000L); - case 63: - return jjStopAtPos(0, 89); - case 64: - return jjStopAtPos(0, 84); - case 91: - return jjStopAtPos(0, 79); - case 93: - return jjStopAtPos(0, 80); - case 94: - jjmatchedKind = 105; - return jjMoveStringLiteralDfa1_0(0x0L, 0x4000000000000L); - case 97: - return jjMoveStringLiteralDfa1_0(0x300L, 0x0L); - case 98: - return jjMoveStringLiteralDfa1_0(0x1c00L, 0x0L); - case 99: - return jjMoveStringLiteralDfa1_0(0x7e000L, 0x0L); - case 100: - return jjMoveStringLiteralDfa1_0(0x380000L, 0x0L); - case 101: - return jjMoveStringLiteralDfa1_0(0x1c00000L, 0x0L); - case 102: - return jjMoveStringLiteralDfa1_0(0x3e000000L, 0x0L); - case 103: - return jjMoveStringLiteralDfa1_0(0x40000000L, 0x0L); - case 105: - return jjMoveStringLiteralDfa1_0(0x1f80000000L, 0x0L); - case 108: - return jjMoveStringLiteralDfa1_0(0x2000000000L, 0x0L); - case 110: - return jjMoveStringLiteralDfa1_0(0x1c000000000L, 0x0L); - case 112: - return jjMoveStringLiteralDfa1_0(0x1e0000000000L, 0x0L); - case 114: - return jjMoveStringLiteralDfa1_0(0x200000000000L, 0x0L); - case 115: - return jjMoveStringLiteralDfa1_0(0xfc00000000000L, 0x0L); - case 116: - return jjMoveStringLiteralDfa1_0(0x3f0000000000000L, 0x0L); - case 118: - return jjMoveStringLiteralDfa1_0(0xc00000000000000L, 0x0L); - case 119: - return jjMoveStringLiteralDfa1_0(0x1000000000000000L, 0x0L); - case 123: - return jjStopAtPos(0, 77); - case 124: - jjmatchedKind = 104; - return jjMoveStringLiteralDfa1_0(0x0L, 0x2000080000000L); - case 125: - return jjStopAtPos(0, 78); - case 126: - return jjStopAtPos(0, 88); - default: - return jjMoveNfa_0(1, 0); - } - } - - private int jjMoveStringLiteralDfa1_0(long active0, long active1) { - try { - curChar = input_stream.readChar(); - } - catch (java.io.IOException e) { - jjStopStringLiteralDfa_0(0, active0, active1); - return 1; - } - switch (curChar) { - case 38: - if ((active1 & 0x100000000L) != 0L) - return jjStopAtPos(1, 96); - break; - case 42: - if ((active0 & 0x4L) != 0L) - return jjStartNfaWithStates_0(1, 2, 46); - break; - case 43: - if ((active1 & 0x200000000L) != 0L) - return jjStopAtPos(1, 97); - break; - case 45: - if ((active1 & 0x400000000L) != 0L) - return jjStopAtPos(1, 98); - break; - case 46: - return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x80000000000000L); - case 60: - if ((active1 & 0x80000000000L) != 0L) { - jjmatchedKind = 107; - jjmatchedPos = 1; - } - return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x10000000000000L); - case 61: - if ((active1 & 0x8000000L) != 0L) - return jjStopAtPos(1, 91); - else if ((active1 & 0x10000000L) != 0L) - return jjStopAtPos(1, 92); - else if ((active1 & 0x20000000L) != 0L) - return jjStopAtPos(1, 93); - else if ((active1 & 0x40000000L) != 0L) - return jjStopAtPos(1, 94); - else if ((active1 & 0x100000000000L) != 0L) - return jjStopAtPos(1, 108); - else if ((active1 & 0x200000000000L) != 0L) - return jjStopAtPos(1, 109); - else if ((active1 & 0x400000000000L) != 0L) - return jjStopAtPos(1, 110); - else if ((active1 & 0x800000000000L) != 0L) - return jjStopAtPos(1, 111); - else if ((active1 & 0x1000000000000L) != 0L) - return jjStopAtPos(1, 112); - else if ((active1 & 0x2000000000000L) != 0L) - return jjStopAtPos(1, 113); - else if ((active1 & 0x4000000000000L) != 0L) - return jjStopAtPos(1, 114); - else if ((active1 & 0x8000000000000L) != 0L) - return jjStopAtPos(1, 115); - break; - case 62: - if ((active1 & 0x200000000000000L) != 0L) { - jjmatchedKind = 121; - jjmatchedPos = 1; - } - return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x160000000000000L); - case 97: - return jjMoveStringLiteralDfa2_0(active0, 0x24002006000L, active1, 0L); - case 98: - return jjMoveStringLiteralDfa2_0(active0, 0x100L, active1, 0L); - case 101: - return jjMoveStringLiteralDfa2_0(active0, 0x208000080000L, active1, 0L); - case 102: - if ((active0 & 0x80000000L) != 0L) - return jjStartNfaWithStates_0(1, 31, 29); - break; - case 104: - return jjMoveStringLiteralDfa2_0(active0, 0x1070400000008000L, active1, 0L); - case 105: - return jjMoveStringLiteralDfa2_0(active0, 0xc000000L, active1, 0L); - case 108: - return jjMoveStringLiteralDfa2_0(active0, 0x10410000L, active1, 0L); - case 109: - return jjMoveStringLiteralDfa2_0(active0, 0x300000000L, active1, 0L); - case 110: - return jjMoveStringLiteralDfa2_0(active0, 0x1c00800000L, active1, 0L); - case 111: - if ((active0 & 0x100000L) != 0L) { - jjmatchedKind = 20; - jjmatchedPos = 1; - } - return jjMoveStringLiteralDfa2_0(active0, 0xc00002060260400L, active1, 0L); - case 114: - return jjMoveStringLiteralDfa2_0(active0, 0x3800c0000000800L, active1, 0L); - case 115: - return jjMoveStringLiteralDfa2_0(active0, 0x200L, active1, 0L); - case 116: - return jjMoveStringLiteralDfa2_0(active0, 0x1800000000000L, active1, 0L); - case 117: - return jjMoveStringLiteralDfa2_0(active0, 0x2110000000000L, active1, 0L); - case 119: - return jjMoveStringLiteralDfa2_0(active0, 0x4000000000000L, active1, 0L); - case 120: - return jjMoveStringLiteralDfa2_0(active0, 0x1000000L, active1, 0L); - case 121: - return jjMoveStringLiteralDfa2_0(active0, 0x8000000001000L, active1, 0L); - case 124: - if ((active1 & 0x80000000L) != 0L) - return jjStopAtPos(1, 95); - break; - default: - break; - } - return jjStartNfa_0(0, active0, active1); - } - - private int jjMoveStringLiteralDfa2_0(long old0, long active0, long old1, long active1) { - if (((active0 &= old0) | (active1 &= old1)) == 0L) - return jjStartNfa_0(0, old0, old1); - try { - curChar = input_stream.readChar(); - } - catch (java.io.IOException e) { - jjStopStringLiteralDfa_0(1, active0, active1); - return 2; - } - switch (curChar) { - case 46: - if ((active1 & 0x80000000000000L) != 0L) - return jjStopAtPos(2, 119); - break; - case 61: - if ((active1 & 0x10000000000000L) != 0L) - return jjStopAtPos(2, 116); - else if ((active1 & 0x20000000000000L) != 0L) - return jjStopAtPos(2, 117); - break; - case 62: - if ((active1 & 0x100000000000000L) != 0L) { - jjmatchedKind = 120; - jjmatchedPos = 2; - } - return jjMoveStringLiteralDfa3_0(active0, 0L, active1, 0x40000000000000L); - case 97: - return jjMoveStringLiteralDfa3_0(active0, 0x80800000018000L, active1, 0L); - case 98: - return jjMoveStringLiteralDfa3_0(active0, 0x100000000000L, active1, 0L); - case 99: - return jjMoveStringLiteralDfa3_0(active0, 0x20000000000L, active1, 0L); - case 101: - return jjMoveStringLiteralDfa3_0(active0, 0x800L, active1, 0L); - case 102: - return jjMoveStringLiteralDfa3_0(active0, 0x80000L, active1, 0L); - case 105: - return jjMoveStringLiteralDfa3_0(active0, 0x1414040000000000L, active1, 0L); - case 108: - return jjMoveStringLiteralDfa3_0(active0, 0x800010002000000L, active1, 0L); - case 110: - return jjMoveStringLiteralDfa3_0(active0, 0x800200c060000L, active1, 0L); - case 111: - return jjMoveStringLiteralDfa3_0(active0, 0x480010000400L, active1, 0L); - case 112: - return jjMoveStringLiteralDfa3_0(active0, 0x2000300000000L, active1, 0L); - case 114: - if ((active0 & 0x20000000L) != 0L) - return jjStartNfaWithStates_0(2, 29, 29); - return jjMoveStringLiteralDfa3_0(active0, 0x61000000000000L, active1, 0L); - case 115: - return jjMoveStringLiteralDfa3_0(active0, 0x400402300L, active1, 0L); - case 116: - if ((active0 & 0x800000000L) != 0L) { - jjmatchedKind = 35; - jjmatchedPos = 2; - } - return jjMoveStringLiteralDfa3_0(active0, 0x205041005000L, active1, 0L); - case 117: - return jjMoveStringLiteralDfa3_0(active0, 0x100000000a00000L, active1, 0L); - case 119: - if ((active0 & 0x8000000000L) != 0L) - return jjStartNfaWithStates_0(2, 39, 29); - break; - case 121: - if ((active0 & 0x200000000000000L) != 0L) - return jjStartNfaWithStates_0(2, 57, 29); - break; - default: - break; - } - return jjStartNfa_0(1, active0, active1); - } - - private int jjMoveStringLiteralDfa3_0(long old0, long active0, long old1, long active1) { - if (((active0 &= old0) | (active1 &= old1)) == 0L) - return jjStartNfa_0(1, old0, old1); - try { - curChar = input_stream.readChar(); - } - catch (java.io.IOException e) { - jjStopStringLiteralDfa_0(2, active0, active1); - return 3; - } - switch (curChar) { - case 61: - if ((active1 & 0x40000000000000L) != 0L) - return jjStopAtPos(3, 118); - break; - case 97: - return jjMoveStringLiteralDfa4_0(active0, 0x80000001c080800L, active1, 0L); - case 98: - return jjMoveStringLiteralDfa4_0(active0, 0x200000L, active1, 0L); - case 99: - return jjMoveStringLiteralDfa4_0(active0, 0x8000000004000L, active1, 0L); - case 100: - if ((active0 & 0x400000000000000L) != 0L) - return jjStartNfaWithStates_0(3, 58, 29); - break; - case 101: - if ((active0 & 0x1000L) != 0L) - return jjStartNfaWithStates_0(3, 12, 29); - else if ((active0 & 0x2000L) != 0L) - return jjStartNfaWithStates_0(3, 13, 29); - else if ((active0 & 0x400000L) != 0L) - return jjStartNfaWithStates_0(3, 22, 29); - else if ((active0 & 0x100000000000000L) != 0L) - return jjStartNfaWithStates_0(3, 56, 29); - return jjMoveStringLiteralDfa4_0(active0, 0x2001001000200L, active1, 0L); - case 103: - if ((active0 & 0x2000000000L) != 0L) - return jjStartNfaWithStates_0(3, 37, 29); - break; - case 105: - return jjMoveStringLiteralDfa4_0(active0, 0x1004000000000L, active1, 0L); - case 107: - return jjMoveStringLiteralDfa4_0(active0, 0x20000000000L, active1, 0L); - case 108: - if ((active0 & 0x10000000000L) != 0L) - return jjStartNfaWithStates_0(3, 40, 29); - return jjMoveStringLiteralDfa4_0(active0, 0x1000100100000400L, active1, 0L); - case 109: - if ((active0 & 0x800000L) != 0L) - return jjStartNfaWithStates_0(3, 23, 29); - break; - case 110: - return jjMoveStringLiteralDfa4_0(active0, 0x80000000000000L, active1, 0L); - case 111: - if ((active0 & 0x40000000L) != 0L) - return jjStartNfaWithStates_0(3, 30, 29); - return jjMoveStringLiteralDfa4_0(active0, 0x60000200000000L, active1, 0L); - case 114: - if ((active0 & 0x8000L) != 0L) - return jjStartNfaWithStates_0(3, 15, 29); - return jjMoveStringLiteralDfa4_0(active0, 0x400000000000L, active1, 0L); - case 115: - if ((active0 & 0x10000000000000L) != 0L) - return jjStartNfaWithStates_0(3, 52, 29); - return jjMoveStringLiteralDfa4_0(active0, 0x2030000L, active1, 0L); - case 116: - return jjMoveStringLiteralDfa4_0(active0, 0x4880400040100L, active1, 0L); - case 117: - return jjMoveStringLiteralDfa4_0(active0, 0x200000000000L, active1, 0L); - case 118: - return jjMoveStringLiteralDfa4_0(active0, 0x40000000000L, active1, 0L); - default: - break; - } - return jjStartNfa_0(2, active0, active1); - } - - private int jjMoveStringLiteralDfa4_0(long old0, long active0, long old1, long active1) { - if (((active0 &= old0) | (active1 &= old1)) == 0L) - return jjStartNfa_0(2, old0, old1); - try { - curChar = input_stream.readChar(); - } - catch (java.io.IOException e) { - jjStopStringLiteralDfa_0(3, active0, 0L); - return 4; - } - switch (curChar) { - case 97: - return jjMoveStringLiteralDfa5_0(active0, 0x60400000000L); - case 99: - return jjMoveStringLiteralDfa5_0(active0, 0x5000000000000L); - case 101: - if ((active0 & 0x2000000L) != 0L) - return jjStartNfaWithStates_0(4, 25, 29); - else if ((active0 & 0x1000000000000000L) != 0L) - return jjStartNfaWithStates_0(4, 60, 29); - return jjMoveStringLiteralDfa5_0(active0, 0x80100000400L); - case 104: - if ((active0 & 0x4000L) != 0L) - return jjStartNfaWithStates_0(4, 14, 29); - return jjMoveStringLiteralDfa5_0(active0, 0x8000000000000L); - case 105: - return jjMoveStringLiteralDfa5_0(active0, 0x900000040000L); - case 107: - if ((active0 & 0x800L) != 0L) - return jjStartNfaWithStates_0(4, 11, 29); - break; - case 108: - if ((active0 & 0x4000000L) != 0L) { - jjmatchedKind = 26; - jjmatchedPos = 4; - } - return jjMoveStringLiteralDfa5_0(active0, 0x8200000L); - case 110: - return jjMoveStringLiteralDfa5_0(active0, 0x1000000L); - case 114: - if ((active0 & 0x2000000000000L) != 0L) - return jjStartNfaWithStates_0(4, 49, 29); - return jjMoveStringLiteralDfa5_0(active0, 0x201200000300L); - case 115: - if ((active0 & 0x10000L) != 0L) - return jjStartNfaWithStates_0(4, 16, 29); - return jjMoveStringLiteralDfa5_0(active0, 0x80000000000000L); - case 116: - if ((active0 & 0x20000L) != 0L) - return jjStartNfaWithStates_0(4, 17, 29); - else if ((active0 & 0x10000000L) != 0L) - return jjStartNfaWithStates_0(4, 28, 29); - else if ((active0 & 0x400000000000L) != 0L) - return jjStartNfaWithStates_0(4, 46, 29); - return jjMoveStringLiteralDfa5_0(active0, 0x800000000000000L); - case 117: - return jjMoveStringLiteralDfa5_0(active0, 0x80000L); - case 118: - return jjMoveStringLiteralDfa5_0(active0, 0x4000000000L); - case 119: - if ((active0 & 0x20000000000000L) != 0L) { - jjmatchedKind = 53; - jjmatchedPos = 4; - } - return jjMoveStringLiteralDfa5_0(active0, 0x40000000000000L); - default: - break; - } - return jjStartNfa_0(3, active0, 0L); - } - - private int jjMoveStringLiteralDfa5_0(long old0, long active0) { - if (((active0 &= old0)) == 0L) - return jjStartNfa_0(3, old0, 0L); - try { - curChar = input_stream.readChar(); - } - catch (java.io.IOException e) { - jjStopStringLiteralDfa_0(4, active0, 0L); - return 5; - } - switch (curChar) { - case 97: - return jjMoveStringLiteralDfa6_0(active0, 0x500L); - case 99: - if ((active0 & 0x100000000000L) != 0L) - return jjStartNfaWithStates_0(5, 44, 29); - else if ((active0 & 0x800000000000L) != 0L) - return jjStartNfaWithStates_0(5, 47, 29); - return jjMoveStringLiteralDfa6_0(active0, 0x80000000000L); - case 100: - return jjMoveStringLiteralDfa6_0(active0, 0x1000000L); - case 101: - if ((active0 & 0x200000L) != 0L) - return jjStartNfaWithStates_0(5, 21, 29); - else if ((active0 & 0x4000000000L) != 0L) - return jjStartNfaWithStates_0(5, 38, 29); - break; - case 102: - return jjMoveStringLiteralDfa6_0(active0, 0x1000000000L); - case 103: - return jjMoveStringLiteralDfa6_0(active0, 0x20000000000L); - case 104: - if ((active0 & 0x4000000000000L) != 0L) - return jjStartNfaWithStates_0(5, 50, 29); - break; - case 105: - return jjMoveStringLiteralDfa6_0(active0, 0x880000000000000L); - case 108: - return jjMoveStringLiteralDfa6_0(active0, 0x8080000L); - case 109: - return jjMoveStringLiteralDfa6_0(active0, 0x100000000L); - case 110: - if ((active0 & 0x200000000000L) != 0L) - return jjStartNfaWithStates_0(5, 45, 29); - return jjMoveStringLiteralDfa6_0(active0, 0x400040000L); - case 114: - return jjMoveStringLiteralDfa6_0(active0, 0x8000000000000L); - case 115: - if ((active0 & 0x40000000000000L) != 0L) - return jjStartNfaWithStates_0(5, 54, 29); - break; - case 116: - if ((active0 & 0x200L) != 0L) - return jjStartNfaWithStates_0(5, 9, 29); - else if ((active0 & 0x200000000L) != 0L) - return jjStartNfaWithStates_0(5, 33, 29); - return jjMoveStringLiteralDfa6_0(active0, 0x1040000000000L); - default: - break; - } - return jjStartNfa_0(4, active0, 0L); - } - - private int jjMoveStringLiteralDfa6_0(long old0, long active0) { - if (((active0 &= old0)) == 0L) - return jjStartNfa_0(4, old0, 0L); - try { - curChar = input_stream.readChar(); - } - catch (java.io.IOException e) { - jjStopStringLiteralDfa_0(5, active0, 0L); - return 6; - } - switch (curChar) { - case 97: - return jjMoveStringLiteralDfa7_0(active0, 0x1000000000L); - case 99: - return jjMoveStringLiteralDfa7_0(active0, 0x400000100L); - case 101: - if ((active0 & 0x20000000000L) != 0L) - return jjStartNfaWithStates_0(6, 41, 29); - else if ((active0 & 0x40000000000L) != 0L) - return jjStartNfaWithStates_0(6, 42, 29); - return jjMoveStringLiteralDfa7_0(active0, 0x80000100000000L); - case 102: - return jjMoveStringLiteralDfa7_0(active0, 0x1000000000000L); - case 108: - return jjMoveStringLiteralDfa7_0(active0, 0x800000000000000L); - case 110: - if ((active0 & 0x400L) != 0L) - return jjStartNfaWithStates_0(6, 10, 29); - break; - case 111: - return jjMoveStringLiteralDfa7_0(active0, 0x8000000000000L); - case 115: - if ((active0 & 0x1000000L) != 0L) - return jjStartNfaWithStates_0(6, 24, 29); - break; - case 116: - if ((active0 & 0x80000L) != 0L) - return jjStartNfaWithStates_0(6, 19, 29); - return jjMoveStringLiteralDfa7_0(active0, 0x80000000000L); - case 117: - return jjMoveStringLiteralDfa7_0(active0, 0x40000L); - case 121: - if ((active0 & 0x8000000L) != 0L) - return jjStartNfaWithStates_0(6, 27, 29); - break; - default: - break; - } - return jjStartNfa_0(5, active0, 0L); - } - - private int jjMoveStringLiteralDfa7_0(long old0, long active0) { - if (((active0 &= old0)) == 0L) - return jjStartNfa_0(5, old0, 0L); - try { - curChar = input_stream.readChar(); - } - catch (java.io.IOException e) { - jjStopStringLiteralDfa_0(6, active0, 0L); - return 7; - } - switch (curChar) { - case 99: - return jjMoveStringLiteralDfa8_0(active0, 0x1000000000L); - case 101: - if ((active0 & 0x40000L) != 0L) - return jjStartNfaWithStates_0(7, 18, 29); - else if ((active0 & 0x800000000000000L) != 0L) - return jjStartNfaWithStates_0(7, 59, 29); - return jjMoveStringLiteralDfa8_0(active0, 0x80400000000L); - case 110: - return jjMoveStringLiteralDfa8_0(active0, 0x88000100000000L); - case 112: - if ((active0 & 0x1000000000000L) != 0L) - return jjStartNfaWithStates_0(7, 48, 29); - break; - case 116: - if ((active0 & 0x100L) != 0L) - return jjStartNfaWithStates_0(7, 8, 29); - break; - default: - break; - } - return jjStartNfa_0(6, active0, 0L); - } - - private int jjMoveStringLiteralDfa8_0(long old0, long active0) { - if (((active0 &= old0)) == 0L) - return jjStartNfa_0(6, old0, 0L); - try { - curChar = input_stream.readChar(); - } - catch (java.io.IOException e) { - jjStopStringLiteralDfa_0(7, active0, 0L); - return 8; - } - switch (curChar) { - case 100: - if ((active0 & 0x80000000000L) != 0L) - return jjStartNfaWithStates_0(8, 43, 29); - break; - case 101: - if ((active0 & 0x1000000000L) != 0L) - return jjStartNfaWithStates_0(8, 36, 29); - break; - case 105: - return jjMoveStringLiteralDfa9_0(active0, 0x8000000000000L); - case 111: - return jjMoveStringLiteralDfa9_0(active0, 0x400000000L); - case 116: - if ((active0 & 0x80000000000000L) != 0L) - return jjStartNfaWithStates_0(8, 55, 29); - return jjMoveStringLiteralDfa9_0(active0, 0x100000000L); - default: - break; - } - return jjStartNfa_0(7, active0, 0L); - } - - private int jjMoveStringLiteralDfa9_0(long old0, long active0) { - if (((active0 &= old0)) == 0L) - return jjStartNfa_0(7, old0, 0L); - try { - curChar = input_stream.readChar(); - } - catch (java.io.IOException e) { - jjStopStringLiteralDfa_0(8, active0, 0L); - return 9; - } - switch (curChar) { - case 102: - if ((active0 & 0x400000000L) != 0L) - return jjStartNfaWithStates_0(9, 34, 29); - break; - case 115: - if ((active0 & 0x100000000L) != 0L) - return jjStartNfaWithStates_0(9, 32, 29); - break; - case 122: - return jjMoveStringLiteralDfa10_0(active0, 0x8000000000000L); - default: - break; - } - return jjStartNfa_0(8, active0, 0L); - } - - private int jjMoveStringLiteralDfa10_0(long old0, long active0) { - if (((active0 &= old0)) == 0L) - return jjStartNfa_0(8, old0, 0L); - try { - curChar = input_stream.readChar(); - } - catch (java.io.IOException e) { - jjStopStringLiteralDfa_0(9, active0, 0L); - return 10; - } - switch (curChar) { - case 101: - return jjMoveStringLiteralDfa11_0(active0, 0x8000000000000L); - default: - break; - } - return jjStartNfa_0(9, active0, 0L); - } - - private int jjMoveStringLiteralDfa11_0(long old0, long active0) { - if (((active0 &= old0)) == 0L) - return jjStartNfa_0(9, old0, 0L); - try { - curChar = input_stream.readChar(); - } - catch (java.io.IOException e) { - jjStopStringLiteralDfa_0(10, active0, 0L); - return 11; - } - switch (curChar) { - case 100: - if ((active0 & 0x8000000000000L) != 0L) - return jjStartNfaWithStates_0(11, 51, 29); - break; - default: - break; - } - return jjStartNfa_0(10, active0, 0L); - } - - private void jjCheckNAdd(int state) { - if (jjrounds[state] != jjround) { - jjstateSet[jjnewStateCnt++] = state; - jjrounds[state] = jjround; - } - } - - private void jjAddStates(int start, int end) { - do { - jjstateSet[jjnewStateCnt++] = jjnextStates[start]; - } while (start++ != end); - } - - private void jjCheckNAddTwoStates(int state1, int state2) { - jjCheckNAdd(state1); - jjCheckNAdd(state2); - } - - private void jjCheckNAddStates(int start, int end) { - do { - jjCheckNAdd(jjnextStates[start]); - } while (start++ != end); - } - - private void jjCheckNAddStates(int start) { - jjCheckNAdd(jjnextStates[start]); - jjCheckNAdd(jjnextStates[start + 1]); - } - - static final long[] jjbitVec0 = { - 0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL - }; - static final long[] jjbitVec2 = { - 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL - }; - static final long[] jjbitVec3 = { - 0xfff0000000200002L, 0xffffffffffffdfffL, 0xfffff00f7fffffffL, 0x12000000007fffffL - }; - static final long[] jjbitVec4 = { - 0x0L, 0x0L, 0x420043c00000000L, 0xff7fffffff7fffffL - }; - static final long[] jjbitVec5 = { - 0xffffcffffffffL, 0xffffffffffff0000L, 0xf9ff3fffffffffffL, 0x401f00030003L - }; - static final long[] jjbitVec6 = { - 0x0L, 0x400000000000000L, 0xfffffffbffffd740L, 0xffffffcff7fffL - }; - static final long[] jjbitVec7 = { - 0xffffffffffffffffL, 0xffffffffffffffffL, 0xfffffffffffff003L, 0x33fffffffff199fL - }; - static final long[] jjbitVec8 = { - 0xfffe000000000000L, 0xfffffffe027fffffL, 0xffL, 0x707ffffff0000L - }; - static final long[] jjbitVec9 = { - 0x7fffffe00000000L, 0xfffe0000000007ffL, 0xffffffffffffffffL, 0x1c000060002fffffL - }; - static final long[] jjbitVec10 = { - 0x1ffffffd0000L, 0x0L, 0x3fffffffffL, 0x0L - }; - static final long[] jjbitVec11 = { - 0x23ffffffffffffe0L, 0x3ff010000L, 0x3c5fdfffff99fe0L, 0xf0003b0000000L - }; - static final long[] jjbitVec12 = { - 0x36dfdfffff987e0L, 0x1c00005e000000L, 0x23edfdfffffbafe0L, 0x100010000L - }; - static final long[] jjbitVec13 = { - 0x23cdfdfffff99fe0L, 0x3b0000000L, 0x3bfc718d63dc7e0L, 0x0L - }; - static final long[] jjbitVec14 = { - 0x3effdfffffddfe0L, 0x300000000L, 0x3effdfffffddfe0L, 0x340000000L - }; - static final long[] jjbitVec15 = { - 0x3fffdfffffddfe0L, 0x300000000L, 0x2ffbfffffc7fffe0L, 0x7fL - }; - static final long[] jjbitVec16 = { - 0x800dfffffffffffeL, 0x7fL, 0x200decaefef02596L, 0x3000005fL - }; - static final long[] jjbitVec17 = { - 0x1L, 0x7fffffffeffL, 0xf00L, 0x0L - }; - static final long[] jjbitVec18 = { - 0x6fbffffffffL, 0x3f0000L, 0xffffffff00000000L, 0x7fffffffff003fL - }; - static final long[] jjbitVec19 = { - 0xffffffffffffffffL, 0xffffffff83ffffffL, 0xffffff07ffffffffL, 0x3ffffffffffffffL - }; - static final long[] jjbitVec20 = { - 0xffffffffffffff7fL, 0xffffffff3d7f3d7fL, 0x7f3d7fffffff3d7fL, 0xffff7fffff7f7f3dL - }; - static final long[] jjbitVec21 = { - 0xffffffff7f3d7fffL, 0x7ffff7fL, 0xffffffff00000000L, 0x1fffffffffffffL - }; - static final long[] jjbitVec22 = { - 0xffffffffffffffffL, 0x7f9fffffffffffL, 0xffffffff07fffffeL, 0x7ffffffffffL - }; - static final long[] jjbitVec23 = { - 0x0L, 0x0L, 0xfffffffffffffL, 0x8000000L - }; - static final long[] jjbitVec24 = { - 0xffffffff00000000L, 0xffffffffffffffL, 0x1ffffffffffL, 0x0L - }; - static final long[] jjbitVec25 = { - 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffff0fffffffL, 0x3ffffffffffffffL - }; - static final long[] jjbitVec26 = { - 0xffffffff3f3fffffL, 0x3fffffffaaff3f3fL, 0x5fdfffffffffffffL, 0x1fdc1fff0fcf1fdcL - }; - static final long[] jjbitVec27 = { - 0x8000000000000000L, 0x8000000000000001L, 0xffff00000000L, 0x0L - }; - static final long[] jjbitVec28 = { - 0x3fbbd503e2ffc84L, 0xffffffff00000000L, 0xfL, 0x0L - }; - static final long[] jjbitVec29 = { - 0x73e03fe000000e0L, 0xfffffffffffffffeL, 0xfffffffe601fffffL, 0x7fffffffffffffffL - }; - static final long[] jjbitVec30 = { - 0xfffe1fffffffffe0L, 0xffffffffffffffffL, 0xffffff00007fffL, 0x0L - }; - static final long[] jjbitVec31 = { - 0xffffffffffffffffL, 0xffffffffffffffffL, 0x3fffffffffffffL, 0x0L - }; - static final long[] jjbitVec32 = { - 0xffffffffffffffffL, 0xffffffffffffffffL, 0x3fffffffffL, 0x0L - }; - static final long[] jjbitVec33 = { - 0xffffffffffffffffL, 0xffffffffffffffffL, 0x1fffL, 0x0L - }; - static final long[] jjbitVec34 = { - 0xffffffffffffffffL, 0xffffffffffffffffL, 0xfffffffffL, 0x0L - }; - static final long[] jjbitVec35 = { - 0x3fffffffffffL, 0x0L, 0x0L, 0x0L - }; - static final long[] jjbitVec36 = { - 0x5f7ffdffa0f8007fL, 0xffffffffffffffdbL, 0x3ffffffffffffL, 0xfffffffffff80000L - }; - static final long[] jjbitVec37 = { - 0x3fffffffffffffffL, 0xffffffffffff0000L, 0xfffffffffffcffffL, 0xfff0000000000ffL - }; - static final long[] jjbitVec38 = { - 0x18000000000000L, 0xffd702000000e000L, 0xffffffffffffffffL, 0x1fffffffffffffffL - }; - static final long[] jjbitVec39 = { - 0x87fffffe00000010L, 0xffffffe007fffffeL, 0x7fffffffffffffffL, 0x631cfcfcfcL - }; - static final long[] jjbitVec40 = { - 0x0L, 0x0L, 0x420043cffffffffL, 0xff7fffffff7fffffL - }; - static final long[] jjbitVec41 = { - 0xffffffffffffffffL, 0x400000700007fffL, 0xfffffffbffffd740L, 0xffffffcff7fffL - }; - static final long[] jjbitVec42 = { - 0xffffffffffffffffL, 0xffffffffffffffffL, 0xfffffffffffff07bL, 0x33fffffffff199fL - }; - static final long[] jjbitVec43 = { - 0xfffe000000000000L, 0xfffffffe027fffffL, 0xbbfffffbfffe00ffL, 0x707ffffff0016L - }; - static final long[] jjbitVec44 = { - 0x7fffffe00000000L, 0xffff03ff003fffffL, 0xffffffffffffffffL, 0x1fff3dff9fefffffL - }; - static final long[] jjbitVec45 = { - 0xffff1fffffff8000L, 0x7ffL, 0x1ffffffffffffL, 0x0L - }; - static final long[] jjbitVec46 = { - 0xf3ffffffffffffeeL, 0xffcfff1f3fffL, 0xd3c5fdfffff99feeL, 0xfffcfb080399fL - }; - static final long[] jjbitVec47 = { - 0xd36dfdfffff987e4L, 0x1fffc05e003987L, 0xf3edfdfffffbafeeL, 0xffc100013bbfL - }; - static final long[] jjbitVec48 = { - 0xf3cdfdfffff99feeL, 0xffc3b0c0398fL, 0xc3bfc718d63dc7ecL, 0xff8000803dc7L - }; - static final long[] jjbitVec49 = { - 0xc3effdfffffddfeeL, 0xffc300603ddfL, 0xc3effdfffffddfecL, 0xffc340603ddfL - }; - static final long[] jjbitVec50 = { - 0xc3fffdfffffddfecL, 0xffc300803dcfL, 0x2ffbfffffc7fffecL, 0xc0000ff5f847fL - }; - static final long[] jjbitVec51 = { - 0x87fffffffffffffeL, 0x3ff7fffL, 0x3bffecaefef02596L, 0x33ff3f5fL - }; - static final long[] jjbitVec52 = { - 0xc2a003ff03000001L, 0xfffe07fffffffeffL, 0x1ffffffffeff0fdfL, 0x40L - }; - static final long[] jjbitVec53 = { - 0x3c7f6fbffffffffL, 0x3ff03ffL, 0xffffffff00000000L, 0x7fffffffff003fL - }; - static final long[] jjbitVec54 = { - 0xffffffff7f3d7fffL, 0x3fe0007ffff7fL, 0xffffffff00000000L, 0x1fffffffffffffL - }; - static final long[] jjbitVec55 = { - 0x0L, 0x0L, 0xffffffffffffffffL, 0x3ff080fffffL - }; - static final long[] jjbitVec56 = { - 0xffffffff03ff7800L, 0xffffffffffffffL, 0x3ffffffffffL, 0x0L - }; - static final long[] jjbitVec57 = { - 0x80007c000000f000L, 0x8000fc0000000001L, 0xffff00000000L, 0x21fff0000L - }; - static final long[] jjbitVec58 = { - 0x73efffe000000e0L, 0xfffffffffffffffeL, 0xfffffffe661fffffL, 0x7fffffffffffffffL - }; - static final long[] jjbitVec59 = { - 0x5f7ffdffe0f8007fL, 0xffffffffffffffdbL, 0x3ffffffffffffL, 0xfffffffffff80000L - }; - static final long[] jjbitVec60 = { - 0x18000f00000000L, 0xffd702000000e000L, 0xffffffffffffffffL, 0x9fffffffffffffffL - }; - static final long[] jjbitVec61 = { - 0x87fffffe03ff0010L, 0xffffffe007fffffeL, 0x7fffffffffffffffL, 0xe0000631cfcfcfcL - }; - - private int jjMoveNfa_0(int startState, int curPos) { - int[] nextStates; - int startsAt = 0; - jjnewStateCnt = 71; - int i = 1; - jjstateSet[0] = startState; - int j, kind = 0x7fffffff; - for (; ;) { - if (++jjround == 0x7fffffff) - ReInitRounds(); - if (curChar < 64) { - long l = 1L << curChar; - MatchLoop: - do { - switch (jjstateSet[--i]) { - case 1: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(0, 6); - else if ((0x100003600L & l) != 0L) { - if (kind > 3) - kind = 3; - jjCheckNAdd(0); - } else if (curChar == 47) - jjAddStates(7, 8); - else if (curChar == 36) { - if (kind > 72) - kind = 72; - jjCheckNAdd(29); - } else if (curChar == 34) - jjCheckNAddStates(9, 11); - else if (curChar == 39) - jjAddStates(12, 13); - else if (curChar == 46) - jjCheckNAdd(5); - if ((0x3fe000000000000L & l) != 0L) { - if (kind > 61) - kind = 61; - jjCheckNAddTwoStates(2, 3); - } else if (curChar == 48) { - if (kind > 61) - kind = 61; - jjCheckNAddStates(14, 18); - } - break; - case 48: - if (curChar == 47) { - if (kind > 4) - kind = 4; - jjCheckNAddStates(19, 21); - } else if (curChar == 42) - jjstateSet[jjnewStateCnt++] = 46; - break; - case 0: - if ((0x100003600L & l) == 0L) - break; - if (kind > 3) - kind = 3; - jjCheckNAdd(0); - break; - case 2: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 61) - kind = 61; - jjCheckNAddTwoStates(2, 3); - break; - case 4: - if (curChar == 46) - jjCheckNAdd(5); - break; - case 5: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 65) - kind = 65; - jjCheckNAddStates(22, 24); - break; - case 7: - if ((0x280000000000L & l) != 0L) - jjCheckNAdd(8); - break; - case 8: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 65) - kind = 65; - jjCheckNAddTwoStates(8, 9); - break; - case 10: - if (curChar == 39) - jjAddStates(12, 13); - break; - case 11: - if ((0xffffff7fffffdbffL & l) != 0L) - jjCheckNAdd(12); - break; - case 12: - if (curChar == 39 && kind > 70) - kind = 70; - break; - case 14: - if ((0x8400000000L & l) != 0L) - jjCheckNAdd(12); - break; - case 15: - if ((0xff000000000000L & l) != 0L) - jjCheckNAddTwoStates(16, 12); - break; - case 16: - if ((0xff000000000000L & l) != 0L) - jjCheckNAdd(12); - break; - case 17: - if ((0xf000000000000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 18; - break; - case 18: - if ((0xff000000000000L & l) != 0L) - jjCheckNAdd(16); - break; - case 19: - if (curChar == 34) - jjCheckNAddStates(9, 11); - break; - case 20: - if ((0xfffffffbffffdbffL & l) != 0L) - jjCheckNAddStates(9, 11); - break; - case 22: - if ((0x8400000000L & l) != 0L) - jjCheckNAddStates(9, 11); - break; - case 23: - if (curChar == 34 && kind > 71) - kind = 71; - break; - case 24: - if ((0xff000000000000L & l) != 0L) - jjCheckNAddStates(25, 28); - break; - case 25: - if ((0xff000000000000L & l) != 0L) - jjCheckNAddStates(9, 11); - break; - case 26: - if ((0xf000000000000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 27; - break; - case 27: - if ((0xff000000000000L & l) != 0L) - jjCheckNAdd(25); - break; - case 28: - if (curChar != 36) - break; - if (kind > 72) - kind = 72; - jjCheckNAdd(29); - break; - case 29: - if ((0x3ff00100fffc1ffL & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAdd(29); - break; - case 30: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(0, 6); - break; - case 31: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(29, 31); - break; - case 33: - if ((0x280000000000L & l) != 0L) - jjCheckNAdd(34); - break; - case 34: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(34, 9); - break; - case 35: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(35, 36); - break; - case 37: - if ((0x280000000000L & l) != 0L) - jjCheckNAdd(38); - break; - case 38: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 65) - kind = 65; - jjCheckNAddTwoStates(38, 9); - break; - case 39: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(39, 40); - break; - case 40: - if (curChar != 46) - break; - if (kind > 65) - kind = 65; - jjCheckNAddStates(32, 34); - break; - case 41: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 65) - kind = 65; - jjCheckNAddStates(32, 34); - break; - case 43: - if ((0x280000000000L & l) != 0L) - jjCheckNAdd(44); - break; - case 44: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 65) - kind = 65; - jjCheckNAddTwoStates(44, 9); - break; - case 45: - if (curChar == 47) - jjAddStates(7, 8); - break; - case 46: - if (curChar == 42) - jjstateSet[jjnewStateCnt++] = 47; - break; - case 47: - if ((0xffff7fffffffffffL & l) != 0L && kind > 1) - kind = 1; - break; - case 49: - if (curChar != 47) - break; - if (kind > 4) - kind = 4; - jjCheckNAddStates(19, 21); - break; - case 50: - if ((0xffffffffffffdbffL & l) == 0L) - break; - if (kind > 4) - kind = 4; - jjCheckNAddStates(19, 21); - break; - case 51: - if ((0x2400L & l) != 0L && kind > 4) - kind = 4; - break; - case 52: - if (curChar == 10 && kind > 4) - kind = 4; - break; - case 53: - if (curChar == 13) - jjstateSet[jjnewStateCnt++] = 52; - break; - case 54: - if (curChar != 48) - break; - if (kind > 61) - kind = 61; - jjCheckNAddStates(14, 18); - break; - case 56: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 61) - kind = 61; - jjCheckNAddTwoStates(56, 3); - break; - case 57: - if ((0xff000000000000L & l) == 0L) - break; - if (kind > 61) - kind = 61; - jjCheckNAddTwoStates(57, 3); - break; - case 59: - if ((0x3ff000000000000L & l) != 0L) - jjAddStates(35, 36); - break; - case 60: - if (curChar == 46) - jjCheckNAdd(61); - break; - case 61: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(61, 62); - break; - case 63: - if ((0x280000000000L & l) != 0L) - jjCheckNAdd(64); - break; - case 64: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 65) - kind = 65; - jjCheckNAddTwoStates(64, 9); - break; - case 66: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(37, 39); - break; - case 67: - if (curChar == 46) - jjCheckNAdd(68); - break; - case 69: - if ((0x280000000000L & l) != 0L) - jjCheckNAdd(70); - break; - case 70: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 65) - kind = 65; - jjCheckNAddTwoStates(70, 9); - break; - default: - break; - } - } while (i != startsAt); - } else if (curChar < 128) { - long l = 1L << (curChar & 077); - MatchLoop: - do { - switch (jjstateSet[--i]) { - case 1: - if ((0x7fffffe87fffffeL & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAdd(29); - break; - case 3: - if ((0x100000001000L & l) != 0L && kind > 61) - kind = 61; - break; - case 6: - if ((0x2000000020L & l) != 0L) - jjAddStates(40, 41); - break; - case 9: - if ((0x5000000050L & l) != 0L && kind > 65) - kind = 65; - break; - case 11: - if ((0xffffffffefffffffL & l) != 0L) - jjCheckNAdd(12); - break; - case 13: - if (curChar == 92) - jjAddStates(42, 44); - break; - case 14: - if ((0x14404410000000L & l) != 0L) - jjCheckNAdd(12); - break; - case 20: - if ((0xffffffffefffffffL & l) != 0L) - jjCheckNAddStates(9, 11); - break; - case 21: - if (curChar == 92) - jjAddStates(45, 47); - break; - case 22: - if ((0x14404410000000L & l) != 0L) - jjCheckNAddStates(9, 11); - break; - case 29: - if ((0x87fffffe87fffffeL & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAdd(29); - break; - case 32: - if ((0x2000000020L & l) != 0L) - jjAddStates(48, 49); - break; - case 36: - if ((0x2000000020L & l) != 0L) - jjAddStates(50, 51); - break; - case 42: - if ((0x2000000020L & l) != 0L) - jjAddStates(52, 53); - break; - case 47: - if (kind > 1) - kind = 1; - break; - case 50: - if (kind > 4) - kind = 4; - jjAddStates(19, 21); - break; - case 55: - if ((0x100000001000000L & l) != 0L) - jjCheckNAdd(56); - break; - case 56: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 61) - kind = 61; - jjCheckNAddTwoStates(56, 3); - break; - case 58: - if ((0x100000001000000L & l) != 0L) - jjCheckNAddTwoStates(59, 60); - break; - case 59: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddTwoStates(59, 60); - break; - case 61: - if ((0x7e0000007eL & l) != 0L) - jjAddStates(54, 55); - break; - case 62: - if ((0x1000000010000L & l) != 0L) - jjAddStates(56, 57); - break; - case 65: - if ((0x100000001000000L & l) != 0L) - jjCheckNAdd(66); - break; - case 66: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(37, 39); - break; - case 68: - if ((0x1000000010000L & l) != 0L) - jjAddStates(58, 59); - break; - default: - break; - } - } while (i != startsAt); - } else { - int hiByte = (int) (curChar >> 8); - int i1 = hiByte >> 6; - long l1 = 1L << (hiByte & 077); - int i2 = (curChar & 0xff) >> 6; - long l2 = 1L << (curChar & 077); - MatchLoop: - do { - switch (jjstateSet[--i]) { - case 1: - if (!jjCanMove_1(hiByte, i1, i2, l1, l2)) - break; - if (kind > 72) - kind = 72; - jjCheckNAdd(29); - break; - case 11: - if (jjCanMove_0(hiByte, i1, i2, l1, l2)) - jjstateSet[jjnewStateCnt++] = 12; - break; - case 20: - if (jjCanMove_0(hiByte, i1, i2, l1, l2)) - jjAddStates(9, 11); - break; - case 29: - if (!jjCanMove_2(hiByte, i1, i2, l1, l2)) - break; - if (kind > 72) - kind = 72; - jjCheckNAdd(29); - break; - case 47: - if (jjCanMove_0(hiByte, i1, i2, l1, l2) && kind > 1) - kind = 1; - break; - case 50: - if (!jjCanMove_0(hiByte, i1, i2, l1, l2)) - break; - if (kind > 4) - kind = 4; - jjAddStates(19, 21); - break; - default: - break; - } - } while (i != startsAt); - } - if (kind != 0x7fffffff) { - jjmatchedKind = kind; - jjmatchedPos = curPos; - kind = 0x7fffffff; - } - ++curPos; - if ((i = jjnewStateCnt) == (startsAt = 71 - (jjnewStateCnt = startsAt))) - return curPos; - try { - curChar = input_stream.readChar(); - } - catch (java.io.IOException e) { - return curPos; - } - } - } - - private int jjMoveStringLiteralDfa0_2() { - switch (curChar) { - case 42: - return jjMoveStringLiteralDfa1_2(0x40L); - default: - return 1; - } - } - - private int jjMoveStringLiteralDfa1_2(long active0) { - try { - curChar = input_stream.readChar(); - } - catch (java.io.IOException e) { - return 1; - } - switch (curChar) { - case 47: - if ((active0 & 0x40L) != 0L) - return jjStopAtPos(1, 6); - break; - default: - return 2; - } - return 2; - } - - private int jjMoveStringLiteralDfa0_1() { - switch (curChar) { - case 42: - return jjMoveStringLiteralDfa1_1(0x20L); - default: - return 1; - } - } - - private int jjMoveStringLiteralDfa1_1(long active0) { - try { - curChar = input_stream.readChar(); - } - catch (java.io.IOException e) { - return 1; - } - switch (curChar) { - case 47: - if ((active0 & 0x20L) != 0L) - return jjStopAtPos(1, 5); - break; - default: - return 2; - } - return 2; - } - - static final int[] jjnextStates = { - 31, 32, 9, 35, 36, 39, 40, 48, 49, 20, 21, 23, 11, 13, 55, 57, - 3, 58, 65, 50, 51, 53, 5, 6, 9, 20, 21, 25, 23, 31, 32, 9, - 41, 42, 9, 59, 60, 66, 67, 68, 7, 8, 14, 15, 17, 22, 24, 26, - 33, 34, 37, 38, 43, 44, 61, 62, 63, 64, 69, 70, - }; - - private static boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2) { - switch (hiByte) { - case 0: - return ((jjbitVec2[i2] & l2) != 0L); - default: - if ((jjbitVec0[i1] & l1) != 0L) - return true; - return false; - } - } - - private static boolean jjCanMove_1(int hiByte, int i1, int i2, long l1, long l2) { - switch (hiByte) { - case 0: - return ((jjbitVec4[i2] & l2) != 0L); - case 2: - return ((jjbitVec5[i2] & l2) != 0L); - case 3: - return ((jjbitVec6[i2] & l2) != 0L); - case 4: - return ((jjbitVec7[i2] & l2) != 0L); - case 5: - return ((jjbitVec8[i2] & l2) != 0L); - case 6: - return ((jjbitVec9[i2] & l2) != 0L); - case 7: - return ((jjbitVec10[i2] & l2) != 0L); - case 9: - return ((jjbitVec11[i2] & l2) != 0L); - case 10: - return ((jjbitVec12[i2] & l2) != 0L); - case 11: - return ((jjbitVec13[i2] & l2) != 0L); - case 12: - return ((jjbitVec14[i2] & l2) != 0L); - case 13: - return ((jjbitVec15[i2] & l2) != 0L); - case 14: - return ((jjbitVec16[i2] & l2) != 0L); - case 15: - return ((jjbitVec17[i2] & l2) != 0L); - case 16: - return ((jjbitVec18[i2] & l2) != 0L); - case 17: - return ((jjbitVec19[i2] & l2) != 0L); - case 18: - return ((jjbitVec20[i2] & l2) != 0L); - case 19: - return ((jjbitVec21[i2] & l2) != 0L); - case 20: - return ((jjbitVec0[i2] & l2) != 0L); - case 22: - return ((jjbitVec22[i2] & l2) != 0L); - case 23: - return ((jjbitVec23[i2] & l2) != 0L); - case 24: - return ((jjbitVec24[i2] & l2) != 0L); - case 30: - return ((jjbitVec25[i2] & l2) != 0L); - case 31: - return ((jjbitVec26[i2] & l2) != 0L); - case 32: - return ((jjbitVec27[i2] & l2) != 0L); - case 33: - return ((jjbitVec28[i2] & l2) != 0L); - case 48: - return ((jjbitVec29[i2] & l2) != 0L); - case 49: - return ((jjbitVec30[i2] & l2) != 0L); - case 77: - return ((jjbitVec31[i2] & l2) != 0L); - case 159: - return ((jjbitVec32[i2] & l2) != 0L); - case 164: - return ((jjbitVec33[i2] & l2) != 0L); - case 215: - return ((jjbitVec34[i2] & l2) != 0L); - case 250: - return ((jjbitVec35[i2] & l2) != 0L); - case 251: - return ((jjbitVec36[i2] & l2) != 0L); - case 253: - return ((jjbitVec37[i2] & l2) != 0L); - case 254: - return ((jjbitVec38[i2] & l2) != 0L); - case 255: - return ((jjbitVec39[i2] & l2) != 0L); - default: - if ((jjbitVec3[i1] & l1) != 0L) - return true; - return false; - } - } - - private static boolean jjCanMove_2(int hiByte, int i1, int i2, long l1, long l2) { - switch (hiByte) { - case 0: - return ((jjbitVec40[i2] & l2) != 0L); - case 2: - return ((jjbitVec5[i2] & l2) != 0L); - case 3: - return ((jjbitVec41[i2] & l2) != 0L); - case 4: - return ((jjbitVec42[i2] & l2) != 0L); - case 5: - return ((jjbitVec43[i2] & l2) != 0L); - case 6: - return ((jjbitVec44[i2] & l2) != 0L); - case 7: - return ((jjbitVec45[i2] & l2) != 0L); - case 9: - return ((jjbitVec46[i2] & l2) != 0L); - case 10: - return ((jjbitVec47[i2] & l2) != 0L); - case 11: - return ((jjbitVec48[i2] & l2) != 0L); - case 12: - return ((jjbitVec49[i2] & l2) != 0L); - case 13: - return ((jjbitVec50[i2] & l2) != 0L); - case 14: - return ((jjbitVec51[i2] & l2) != 0L); - case 15: - return ((jjbitVec52[i2] & l2) != 0L); - case 16: - return ((jjbitVec53[i2] & l2) != 0L); - case 17: - return ((jjbitVec19[i2] & l2) != 0L); - case 18: - return ((jjbitVec20[i2] & l2) != 0L); - case 19: - return ((jjbitVec54[i2] & l2) != 0L); - case 20: - return ((jjbitVec0[i2] & l2) != 0L); - case 22: - return ((jjbitVec22[i2] & l2) != 0L); - case 23: - return ((jjbitVec55[i2] & l2) != 0L); - case 24: - return ((jjbitVec56[i2] & l2) != 0L); - case 30: - return ((jjbitVec25[i2] & l2) != 0L); - case 31: - return ((jjbitVec26[i2] & l2) != 0L); - case 32: - return ((jjbitVec57[i2] & l2) != 0L); - case 33: - return ((jjbitVec28[i2] & l2) != 0L); - case 48: - return ((jjbitVec58[i2] & l2) != 0L); - case 49: - return ((jjbitVec30[i2] & l2) != 0L); - case 77: - return ((jjbitVec31[i2] & l2) != 0L); - case 159: - return ((jjbitVec32[i2] & l2) != 0L); - case 164: - return ((jjbitVec33[i2] & l2) != 0L); - case 215: - return ((jjbitVec34[i2] & l2) != 0L); - case 250: - return ((jjbitVec35[i2] & l2) != 0L); - case 251: - return ((jjbitVec59[i2] & l2) != 0L); - case 253: - return ((jjbitVec37[i2] & l2) != 0L); - case 254: - return ((jjbitVec60[i2] & l2) != 0L); - case 255: - return ((jjbitVec61[i2] & l2) != 0L); - default: - if ((jjbitVec3[i1] & l1) != 0L) - return true; - return false; - } - } - - public static final String[] jjstrLiteralImages = { - "", null, null, null, null, null, null, null, - "\141\142\163\164\162\141\143\164", "\141\163\163\145\162\164", "\142\157\157\154\145\141\156", - "\142\162\145\141\153", "\142\171\164\145", "\143\141\163\145", "\143\141\164\143\150", - "\143\150\141\162", "\143\154\141\163\163", "\143\157\156\163\164", - "\143\157\156\164\151\156\165\145", "\144\145\146\141\165\154\164", "\144\157", "\144\157\165\142\154\145", - "\145\154\163\145", "\145\156\165\155", "\145\170\164\145\156\144\163", "\146\141\154\163\145", - "\146\151\156\141\154", "\146\151\156\141\154\154\171", "\146\154\157\141\164", "\146\157\162", - "\147\157\164\157", "\151\146", "\151\155\160\154\145\155\145\156\164\163", - "\151\155\160\157\162\164", "\151\156\163\164\141\156\143\145\157\146", "\151\156\164", - "\151\156\164\145\162\146\141\143\145", "\154\157\156\147", "\156\141\164\151\166\145", "\156\145\167", - "\156\165\154\154", "\160\141\143\153\141\147\145", "\160\162\151\166\141\164\145", - "\160\162\157\164\145\143\164\145\144", "\160\165\142\154\151\143", "\162\145\164\165\162\156", - "\163\150\157\162\164", "\163\164\141\164\151\143", "\163\164\162\151\143\164\146\160", - "\163\165\160\145\162", "\163\167\151\164\143\150", - "\163\171\156\143\150\162\157\156\151\172\145\144", "\164\150\151\163", "\164\150\162\157\167", "\164\150\162\157\167\163", - "\164\162\141\156\163\151\145\156\164", "\164\162\165\145", "\164\162\171", "\166\157\151\144", - "\166\157\154\141\164\151\154\145", "\167\150\151\154\145", null, null, null, null, null, null, null, null, null, - null, null, null, null, null, "\50", "\51", "\173", "\175", "\133", "\135", "\73", - "\54", "\56", "\100", "\75", "\74", "\41", "\176", "\77", "\72", "\75\75", "\74\75", - "\76\75", "\41\75", "\174\174", "\46\46", "\53\53", "\55\55", "\53", "\55", "\52", - "\57", "\46", "\174", "\136", "\45", "\74\74", "\53\75", "\55\75", "\52\75", - "\57\75", "\46\75", "\174\75", "\136\75", "\45\75", "\74\74\75", "\76\76\75", - "\76\76\76\75", "\56\56\56", "\76\76\76", "\76\76", "\76", "\32", null,}; - public static final String[] lexStateNames = { - "DEFAULT", - "IN_FORMAL_COMMENT", - "IN_MULTI_LINE_COMMENT", - }; - public static final int[] jjnewLexState = { - -1, 1, 2, -1, -1, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - }; - static final long[] jjtoToken = { - 0x3fffffffffffff01L, 0x1ffffffffffff9c2L, - }; - static final long[] jjtoSkip = { - 0x78L, 0x0L, - }; - static final long[] jjtoSpecial = { - 0x78L, 0x0L, - }; - static final long[] jjtoMore = { - 0x86L, 0x0L, - }; - protected JavaCharStream input_stream; - private final int[] jjrounds = new int[71]; - private final int[] jjstateSet = new int[142]; - StringBuffer image; - int jjimageLen; - int lengthOfMatch; - protected char curChar; - - public JavaParserTokenManager(JavaCharStream stream) { - if (JavaCharStream.staticFlag) - throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); - input_stream = stream; - } - - public JavaParserTokenManager(JavaCharStream stream, int lexState) { - this(stream); - SwitchTo(lexState); - } - - public void ReInit(JavaCharStream stream) { - jjmatchedPos = jjnewStateCnt = 0; - curLexState = defaultLexState; - input_stream = stream; - ReInitRounds(); - } - - private void ReInitRounds() { - int i; - jjround = 0x80000001; - for (i = 71; i-- > 0;) - jjrounds[i] = 0x80000000; - } - - public void ReInit(JavaCharStream stream, int lexState) { - ReInit(stream); - SwitchTo(lexState); - } - - public void SwitchTo(int lexState) { - if (lexState >= 3 || lexState < 0) - throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); - else - curLexState = lexState; - } - - protected Token jjFillToken() { - Token t = Token.newToken(jjmatchedKind); - t.kind = jjmatchedKind; - String im = jjstrLiteralImages[jjmatchedKind]; - t.image = (im == null) ? input_stream.GetImage() : im; - t.beginLine = input_stream.getBeginLine(); - t.beginColumn = input_stream.getBeginColumn(); - t.endLine = input_stream.getEndLine(); - t.endColumn = input_stream.getEndColumn(); - return t; - } - - int curLexState = 0; - int defaultLexState = 0; - int jjnewStateCnt; - int jjround; - int jjmatchedPos; - int jjmatchedKind; - - public Token getNextToken() { - int kind; - Token specialToken = null; - Token matchedToken; - int curPos = 0; - - EOFLoop: - for (; ;) { - try { - curChar = input_stream.BeginToken(); - } - catch (java.io.IOException e) { - jjmatchedKind = 0; - matchedToken = jjFillToken(); - matchedToken.specialToken = specialToken; - return matchedToken; - } - image = null; - jjimageLen = 0; - - for (; ;) { - switch (curLexState) { - case 0: - jjmatchedKind = 0x7fffffff; - jjmatchedPos = 0; - curPos = jjMoveStringLiteralDfa0_0(); - if (jjmatchedPos == 0 && jjmatchedKind > 124) { - jjmatchedKind = 124; - } - break; - case 1: - jjmatchedKind = 0x7fffffff; - jjmatchedPos = 0; - curPos = jjMoveStringLiteralDfa0_1(); - if (jjmatchedPos == 0 && jjmatchedKind > 7) { - jjmatchedKind = 7; - } - break; - case 2: - jjmatchedKind = 0x7fffffff; - jjmatchedPos = 0; - curPos = jjMoveStringLiteralDfa0_2(); - if (jjmatchedPos == 0 && jjmatchedKind > 7) { - jjmatchedKind = 7; - } - break; - } - if (jjmatchedKind != 0x7fffffff) { - if (jjmatchedPos + 1 < curPos) - input_stream.backup(curPos - jjmatchedPos - 1); - if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) { - matchedToken = jjFillToken(); - matchedToken.specialToken = specialToken; - TokenLexicalActions(matchedToken); - if (jjnewLexState[jjmatchedKind] != -1) - curLexState = jjnewLexState[jjmatchedKind]; - return matchedToken; - } else - if ((jjtoSkip[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) { - if ((jjtoSpecial[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) { - matchedToken = jjFillToken(); - if (specialToken == null) - specialToken = matchedToken; - else { - matchedToken.specialToken = specialToken; - specialToken = (specialToken.next = matchedToken); - } - SkipLexicalActions(matchedToken); - } else - SkipLexicalActions(null); - if (jjnewLexState[jjmatchedKind] != -1) - curLexState = jjnewLexState[jjmatchedKind]; - continue EOFLoop; - } - MoreLexicalActions(); - if (jjnewLexState[jjmatchedKind] != -1) - curLexState = jjnewLexState[jjmatchedKind]; - curPos = 0; - jjmatchedKind = 0x7fffffff; - try { - curChar = input_stream.readChar(); - continue; - } - catch (java.io.IOException e1) { - } - } - int error_line = input_stream.getEndLine(); - int error_column = input_stream.getEndColumn(); - String error_after = null; - boolean EOFSeen = false; - try { - input_stream.readChar(); - input_stream.backup(1); - } - catch (java.io.IOException e1) { - EOFSeen = true; - error_after = curPos <= 1 ? "" : input_stream.GetImage(); - if (curChar == '\n' || curChar == '\r') { - error_line++; - error_column = 0; - } else - error_column++; - } - if (!EOFSeen) { - input_stream.backup(1); - error_after = curPos <= 1 ? "" : input_stream.GetImage(); - } - throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR); - } - } - } - - void SkipLexicalActions(Token matchedToken) { - switch (jjmatchedKind) { - default: - break; - } - } - - void MoreLexicalActions() { - jjimageLen += (lengthOfMatch = jjmatchedPos + 1); - switch (jjmatchedKind) { - case 1: - if (image == null) - image = new StringBuffer(); - image.append(input_stream.GetSuffix(jjimageLen)); - jjimageLen = 0; - input_stream.backup(1); - break; - default: - break; - } - } - - void TokenLexicalActions(Token matchedToken) { - switch (jjmatchedKind) { - case 120: - if (image == null) - image = new StringBuffer(); - image.append(jjstrLiteralImages[120]); - matchedToken.kind = GT; - ((Token.GTToken) matchedToken).realKind = RUNSIGNEDSHIFT; - input_stream.backup(2); - matchedToken.image = ">"; - break; - case 121: - if (image == null) - image = new StringBuffer(); - image.append(jjstrLiteralImages[121]); - matchedToken.kind = GT; - ((Token.GTToken) matchedToken).realKind = RSIGNEDSHIFT; - input_stream.backup(1); - matchedToken.image = ">"; - break; - default: - break; - } - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParserTokenManager.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParserTokenManager.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParserTokenManager.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParserTokenManager.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,2092 @@ +/* Generated By:JJTree&JavaCC: Do not edit this line. JavaParserTokenManager.java */ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.java.parser; + +public class JavaParserTokenManager implements JavaParserConstants { + public java.io.PrintStream debugStream = System.out; + + public void setDebugStream(java.io.PrintStream ds) { + debugStream = ds; + } + + private int jjStopStringLiteralDfa_0(int pos, long active0, long active1) { + switch (pos) { + case 0: + if ((active0 & 0x4L) != 0L || (active1 & 0x804000000000L) != 0L) + return 48; + if ((active1 & 0x80000000080000L) != 0L) + return 5; + if ((active0 & 0x1fffffffffffff00L) != 0L) { + jjmatchedKind = 72; + return 29; + } + return -1; + case 1: + if ((active0 & 0x4L) != 0L) + return 46; + if ((active0 & 0x1fffffff7fcfff00L) != 0L) { + if (jjmatchedPos != 1) { + jjmatchedKind = 72; + jjmatchedPos = 1; + } + return 29; + } + if ((active0 & 0x80300000L) != 0L) + return 29; + return -1; + case 2: + if ((active0 & 0x1dffff675fefff00L) != 0L) { + if (jjmatchedPos != 2) { + jjmatchedKind = 72; + jjmatchedPos = 2; + } + return 29; + } + if ((active0 & 0x200009820000000L) != 0L) + return 29; + return -1; + case 3: + if ((active0 & 0x18effe571f2f4f00L) != 0L) { + jjmatchedKind = 72; + jjmatchedPos = 3; + return 29; + } + if ((active0 & 0x510012040c0b000L) != 0L) + return 29; + return -1; + case 4: + if ((active0 & 0x88dbe57012c0700L) != 0L) { + if (jjmatchedPos != 4) { + jjmatchedKind = 72; + jjmatchedPos = 4; + } + return 29; + } + if ((active0 & 0x106240001e034800L) != 0L) + return 29; + return -1; + case 5: + if ((active0 & 0x8890e15090c0500L) != 0L) { + jjmatchedKind = 72; + jjmatchedPos = 5; + return 29; + } + if ((active0 & 0x44b04200200200L) != 0L) + return 29; + return -1; + case 6: + if ((active0 & 0x889081500040100L) != 0L) { + jjmatchedKind = 72; + jjmatchedPos = 6; + return 29; + } + if ((active0 & 0x60009080400L) != 0L) + return 29; + return -1; + case 7: + if ((active0 & 0x801000000040100L) != 0L) + return 29; + if ((active0 & 0x88081500000000L) != 0L) { + jjmatchedKind = 72; + jjmatchedPos = 7; + return 29; + } + return -1; + case 8: + if ((active0 & 0x8000500000000L) != 0L) { + jjmatchedKind = 72; + jjmatchedPos = 8; + return 29; + } + if ((active0 & 0x80081000000000L) != 0L) + return 29; + return -1; + case 9: + if ((active0 & 0x8000000000000L) != 0L) { + jjmatchedKind = 72; + jjmatchedPos = 9; + return 29; + } + if ((active0 & 0x500000000L) != 0L) + return 29; + return -1; + case 10: + if ((active0 & 0x8000000000000L) != 0L) { + jjmatchedKind = 72; + jjmatchedPos = 10; + return 29; + } + return -1; + default: + return -1; + } + } + + private int jjStartNfa_0(int pos, long active0, long active1) { + return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0, active1), pos + 1); + } + + private int jjStopAtPos(int pos, int kind) { + jjmatchedKind = kind; + jjmatchedPos = pos; + return pos + 1; + } + + private int jjStartNfaWithStates_0(int pos, int kind, int state) { + jjmatchedKind = kind; + jjmatchedPos = pos; + try { + curChar = input_stream.readChar(); + } + catch (java.io.IOException e) { + return pos + 1; + } + return jjMoveNfa_0(state, pos + 1); + } + + private int jjMoveStringLiteralDfa0_0() { + switch (curChar) { + case 26: + return jjStopAtPos(0, 123); + case 33: + jjmatchedKind = 87; + return jjMoveStringLiteralDfa1_0(0x0L, 0x40000000L); + case 37: + jjmatchedKind = 106; + return jjMoveStringLiteralDfa1_0(0x0L, 0x8000000000000L); + case 38: + jjmatchedKind = 103; + return jjMoveStringLiteralDfa1_0(0x0L, 0x1000100000000L); + case 40: + return jjStopAtPos(0, 75); + case 41: + return jjStopAtPos(0, 76); + case 42: + jjmatchedKind = 101; + return jjMoveStringLiteralDfa1_0(0x0L, 0x400000000000L); + case 43: + jjmatchedKind = 99; + return jjMoveStringLiteralDfa1_0(0x0L, 0x100200000000L); + case 44: + return jjStopAtPos(0, 82); + case 45: + jjmatchedKind = 100; + return jjMoveStringLiteralDfa1_0(0x0L, 0x200400000000L); + case 46: + jjmatchedKind = 83; + return jjMoveStringLiteralDfa1_0(0x0L, 0x80000000000000L); + case 47: + jjmatchedKind = 102; + return jjMoveStringLiteralDfa1_0(0x4L, 0x800000000000L); + case 58: + return jjStopAtPos(0, 90); + case 59: + return jjStopAtPos(0, 81); + case 60: + jjmatchedKind = 86; + return jjMoveStringLiteralDfa1_0(0x0L, 0x10080010000000L); + case 61: + jjmatchedKind = 85; + return jjMoveStringLiteralDfa1_0(0x0L, 0x8000000L); + case 62: + jjmatchedKind = 122; + return jjMoveStringLiteralDfa1_0(0x0L, 0x360000020000000L); + case 63: + return jjStopAtPos(0, 89); + case 64: + return jjStopAtPos(0, 84); + case 91: + return jjStopAtPos(0, 79); + case 93: + return jjStopAtPos(0, 80); + case 94: + jjmatchedKind = 105; + return jjMoveStringLiteralDfa1_0(0x0L, 0x4000000000000L); + case 97: + return jjMoveStringLiteralDfa1_0(0x300L, 0x0L); + case 98: + return jjMoveStringLiteralDfa1_0(0x1c00L, 0x0L); + case 99: + return jjMoveStringLiteralDfa1_0(0x7e000L, 0x0L); + case 100: + return jjMoveStringLiteralDfa1_0(0x380000L, 0x0L); + case 101: + return jjMoveStringLiteralDfa1_0(0x1c00000L, 0x0L); + case 102: + return jjMoveStringLiteralDfa1_0(0x3e000000L, 0x0L); + case 103: + return jjMoveStringLiteralDfa1_0(0x40000000L, 0x0L); + case 105: + return jjMoveStringLiteralDfa1_0(0x1f80000000L, 0x0L); + case 108: + return jjMoveStringLiteralDfa1_0(0x2000000000L, 0x0L); + case 110: + return jjMoveStringLiteralDfa1_0(0x1c000000000L, 0x0L); + case 112: + return jjMoveStringLiteralDfa1_0(0x1e0000000000L, 0x0L); + case 114: + return jjMoveStringLiteralDfa1_0(0x200000000000L, 0x0L); + case 115: + return jjMoveStringLiteralDfa1_0(0xfc00000000000L, 0x0L); + case 116: + return jjMoveStringLiteralDfa1_0(0x3f0000000000000L, 0x0L); + case 118: + return jjMoveStringLiteralDfa1_0(0xc00000000000000L, 0x0L); + case 119: + return jjMoveStringLiteralDfa1_0(0x1000000000000000L, 0x0L); + case 123: + return jjStopAtPos(0, 77); + case 124: + jjmatchedKind = 104; + return jjMoveStringLiteralDfa1_0(0x0L, 0x2000080000000L); + case 125: + return jjStopAtPos(0, 78); + case 126: + return jjStopAtPos(0, 88); + default: + return jjMoveNfa_0(1, 0); + } + } + + private int jjMoveStringLiteralDfa1_0(long active0, long active1) { + try { + curChar = input_stream.readChar(); + } + catch (java.io.IOException e) { + jjStopStringLiteralDfa_0(0, active0, active1); + return 1; + } + switch (curChar) { + case 38: + if ((active1 & 0x100000000L) != 0L) + return jjStopAtPos(1, 96); + break; + case 42: + if ((active0 & 0x4L) != 0L) + return jjStartNfaWithStates_0(1, 2, 46); + break; + case 43: + if ((active1 & 0x200000000L) != 0L) + return jjStopAtPos(1, 97); + break; + case 45: + if ((active1 & 0x400000000L) != 0L) + return jjStopAtPos(1, 98); + break; + case 46: + return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x80000000000000L); + case 60: + if ((active1 & 0x80000000000L) != 0L) { + jjmatchedKind = 107; + jjmatchedPos = 1; + } + return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x10000000000000L); + case 61: + if ((active1 & 0x8000000L) != 0L) + return jjStopAtPos(1, 91); + else if ((active1 & 0x10000000L) != 0L) + return jjStopAtPos(1, 92); + else if ((active1 & 0x20000000L) != 0L) + return jjStopAtPos(1, 93); + else if ((active1 & 0x40000000L) != 0L) + return jjStopAtPos(1, 94); + else if ((active1 & 0x100000000000L) != 0L) + return jjStopAtPos(1, 108); + else if ((active1 & 0x200000000000L) != 0L) + return jjStopAtPos(1, 109); + else if ((active1 & 0x400000000000L) != 0L) + return jjStopAtPos(1, 110); + else if ((active1 & 0x800000000000L) != 0L) + return jjStopAtPos(1, 111); + else if ((active1 & 0x1000000000000L) != 0L) + return jjStopAtPos(1, 112); + else if ((active1 & 0x2000000000000L) != 0L) + return jjStopAtPos(1, 113); + else if ((active1 & 0x4000000000000L) != 0L) + return jjStopAtPos(1, 114); + else if ((active1 & 0x8000000000000L) != 0L) + return jjStopAtPos(1, 115); + break; + case 62: + if ((active1 & 0x200000000000000L) != 0L) { + jjmatchedKind = 121; + jjmatchedPos = 1; + } + return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x160000000000000L); + case 97: + return jjMoveStringLiteralDfa2_0(active0, 0x24002006000L, active1, 0L); + case 98: + return jjMoveStringLiteralDfa2_0(active0, 0x100L, active1, 0L); + case 101: + return jjMoveStringLiteralDfa2_0(active0, 0x208000080000L, active1, 0L); + case 102: + if ((active0 & 0x80000000L) != 0L) + return jjStartNfaWithStates_0(1, 31, 29); + break; + case 104: + return jjMoveStringLiteralDfa2_0(active0, 0x1070400000008000L, active1, 0L); + case 105: + return jjMoveStringLiteralDfa2_0(active0, 0xc000000L, active1, 0L); + case 108: + return jjMoveStringLiteralDfa2_0(active0, 0x10410000L, active1, 0L); + case 109: + return jjMoveStringLiteralDfa2_0(active0, 0x300000000L, active1, 0L); + case 110: + return jjMoveStringLiteralDfa2_0(active0, 0x1c00800000L, active1, 0L); + case 111: + if ((active0 & 0x100000L) != 0L) { + jjmatchedKind = 20; + jjmatchedPos = 1; + } + return jjMoveStringLiteralDfa2_0(active0, 0xc00002060260400L, active1, 0L); + case 114: + return jjMoveStringLiteralDfa2_0(active0, 0x3800c0000000800L, active1, 0L); + case 115: + return jjMoveStringLiteralDfa2_0(active0, 0x200L, active1, 0L); + case 116: + return jjMoveStringLiteralDfa2_0(active0, 0x1800000000000L, active1, 0L); + case 117: + return jjMoveStringLiteralDfa2_0(active0, 0x2110000000000L, active1, 0L); + case 119: + return jjMoveStringLiteralDfa2_0(active0, 0x4000000000000L, active1, 0L); + case 120: + return jjMoveStringLiteralDfa2_0(active0, 0x1000000L, active1, 0L); + case 121: + return jjMoveStringLiteralDfa2_0(active0, 0x8000000001000L, active1, 0L); + case 124: + if ((active1 & 0x80000000L) != 0L) + return jjStopAtPos(1, 95); + break; + default: + break; + } + return jjStartNfa_0(0, active0, active1); + } + + private int jjMoveStringLiteralDfa2_0(long old0, long active0, long old1, long active1) { + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(0, old0, old1); + try { + curChar = input_stream.readChar(); + } + catch (java.io.IOException e) { + jjStopStringLiteralDfa_0(1, active0, active1); + return 2; + } + switch (curChar) { + case 46: + if ((active1 & 0x80000000000000L) != 0L) + return jjStopAtPos(2, 119); + break; + case 61: + if ((active1 & 0x10000000000000L) != 0L) + return jjStopAtPos(2, 116); + else if ((active1 & 0x20000000000000L) != 0L) + return jjStopAtPos(2, 117); + break; + case 62: + if ((active1 & 0x100000000000000L) != 0L) { + jjmatchedKind = 120; + jjmatchedPos = 2; + } + return jjMoveStringLiteralDfa3_0(active0, 0L, active1, 0x40000000000000L); + case 97: + return jjMoveStringLiteralDfa3_0(active0, 0x80800000018000L, active1, 0L); + case 98: + return jjMoveStringLiteralDfa3_0(active0, 0x100000000000L, active1, 0L); + case 99: + return jjMoveStringLiteralDfa3_0(active0, 0x20000000000L, active1, 0L); + case 101: + return jjMoveStringLiteralDfa3_0(active0, 0x800L, active1, 0L); + case 102: + return jjMoveStringLiteralDfa3_0(active0, 0x80000L, active1, 0L); + case 105: + return jjMoveStringLiteralDfa3_0(active0, 0x1414040000000000L, active1, 0L); + case 108: + return jjMoveStringLiteralDfa3_0(active0, 0x800010002000000L, active1, 0L); + case 110: + return jjMoveStringLiteralDfa3_0(active0, 0x800200c060000L, active1, 0L); + case 111: + return jjMoveStringLiteralDfa3_0(active0, 0x480010000400L, active1, 0L); + case 112: + return jjMoveStringLiteralDfa3_0(active0, 0x2000300000000L, active1, 0L); + case 114: + if ((active0 & 0x20000000L) != 0L) + return jjStartNfaWithStates_0(2, 29, 29); + return jjMoveStringLiteralDfa3_0(active0, 0x61000000000000L, active1, 0L); + case 115: + return jjMoveStringLiteralDfa3_0(active0, 0x400402300L, active1, 0L); + case 116: + if ((active0 & 0x800000000L) != 0L) { + jjmatchedKind = 35; + jjmatchedPos = 2; + } + return jjMoveStringLiteralDfa3_0(active0, 0x205041005000L, active1, 0L); + case 117: + return jjMoveStringLiteralDfa3_0(active0, 0x100000000a00000L, active1, 0L); + case 119: + if ((active0 & 0x8000000000L) != 0L) + return jjStartNfaWithStates_0(2, 39, 29); + break; + case 121: + if ((active0 & 0x200000000000000L) != 0L) + return jjStartNfaWithStates_0(2, 57, 29); + break; + default: + break; + } + return jjStartNfa_0(1, active0, active1); + } + + private int jjMoveStringLiteralDfa3_0(long old0, long active0, long old1, long active1) { + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(1, old0, old1); + try { + curChar = input_stream.readChar(); + } + catch (java.io.IOException e) { + jjStopStringLiteralDfa_0(2, active0, active1); + return 3; + } + switch (curChar) { + case 61: + if ((active1 & 0x40000000000000L) != 0L) + return jjStopAtPos(3, 118); + break; + case 97: + return jjMoveStringLiteralDfa4_0(active0, 0x80000001c080800L, active1, 0L); + case 98: + return jjMoveStringLiteralDfa4_0(active0, 0x200000L, active1, 0L); + case 99: + return jjMoveStringLiteralDfa4_0(active0, 0x8000000004000L, active1, 0L); + case 100: + if ((active0 & 0x400000000000000L) != 0L) + return jjStartNfaWithStates_0(3, 58, 29); + break; + case 101: + if ((active0 & 0x1000L) != 0L) + return jjStartNfaWithStates_0(3, 12, 29); + else if ((active0 & 0x2000L) != 0L) + return jjStartNfaWithStates_0(3, 13, 29); + else if ((active0 & 0x400000L) != 0L) + return jjStartNfaWithStates_0(3, 22, 29); + else if ((active0 & 0x100000000000000L) != 0L) + return jjStartNfaWithStates_0(3, 56, 29); + return jjMoveStringLiteralDfa4_0(active0, 0x2001001000200L, active1, 0L); + case 103: + if ((active0 & 0x2000000000L) != 0L) + return jjStartNfaWithStates_0(3, 37, 29); + break; + case 105: + return jjMoveStringLiteralDfa4_0(active0, 0x1004000000000L, active1, 0L); + case 107: + return jjMoveStringLiteralDfa4_0(active0, 0x20000000000L, active1, 0L); + case 108: + if ((active0 & 0x10000000000L) != 0L) + return jjStartNfaWithStates_0(3, 40, 29); + return jjMoveStringLiteralDfa4_0(active0, 0x1000100100000400L, active1, 0L); + case 109: + if ((active0 & 0x800000L) != 0L) + return jjStartNfaWithStates_0(3, 23, 29); + break; + case 110: + return jjMoveStringLiteralDfa4_0(active0, 0x80000000000000L, active1, 0L); + case 111: + if ((active0 & 0x40000000L) != 0L) + return jjStartNfaWithStates_0(3, 30, 29); + return jjMoveStringLiteralDfa4_0(active0, 0x60000200000000L, active1, 0L); + case 114: + if ((active0 & 0x8000L) != 0L) + return jjStartNfaWithStates_0(3, 15, 29); + return jjMoveStringLiteralDfa4_0(active0, 0x400000000000L, active1, 0L); + case 115: + if ((active0 & 0x10000000000000L) != 0L) + return jjStartNfaWithStates_0(3, 52, 29); + return jjMoveStringLiteralDfa4_0(active0, 0x2030000L, active1, 0L); + case 116: + return jjMoveStringLiteralDfa4_0(active0, 0x4880400040100L, active1, 0L); + case 117: + return jjMoveStringLiteralDfa4_0(active0, 0x200000000000L, active1, 0L); + case 118: + return jjMoveStringLiteralDfa4_0(active0, 0x40000000000L, active1, 0L); + default: + break; + } + return jjStartNfa_0(2, active0, active1); + } + + private int jjMoveStringLiteralDfa4_0(long old0, long active0, long old1, long active1) { + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(2, old0, old1); + try { + curChar = input_stream.readChar(); + } + catch (java.io.IOException e) { + jjStopStringLiteralDfa_0(3, active0, 0L); + return 4; + } + switch (curChar) { + case 97: + return jjMoveStringLiteralDfa5_0(active0, 0x60400000000L); + case 99: + return jjMoveStringLiteralDfa5_0(active0, 0x5000000000000L); + case 101: + if ((active0 & 0x2000000L) != 0L) + return jjStartNfaWithStates_0(4, 25, 29); + else if ((active0 & 0x1000000000000000L) != 0L) + return jjStartNfaWithStates_0(4, 60, 29); + return jjMoveStringLiteralDfa5_0(active0, 0x80100000400L); + case 104: + if ((active0 & 0x4000L) != 0L) + return jjStartNfaWithStates_0(4, 14, 29); + return jjMoveStringLiteralDfa5_0(active0, 0x8000000000000L); + case 105: + return jjMoveStringLiteralDfa5_0(active0, 0x900000040000L); + case 107: + if ((active0 & 0x800L) != 0L) + return jjStartNfaWithStates_0(4, 11, 29); + break; + case 108: + if ((active0 & 0x4000000L) != 0L) { + jjmatchedKind = 26; + jjmatchedPos = 4; + } + return jjMoveStringLiteralDfa5_0(active0, 0x8200000L); + case 110: + return jjMoveStringLiteralDfa5_0(active0, 0x1000000L); + case 114: + if ((active0 & 0x2000000000000L) != 0L) + return jjStartNfaWithStates_0(4, 49, 29); + return jjMoveStringLiteralDfa5_0(active0, 0x201200000300L); + case 115: + if ((active0 & 0x10000L) != 0L) + return jjStartNfaWithStates_0(4, 16, 29); + return jjMoveStringLiteralDfa5_0(active0, 0x80000000000000L); + case 116: + if ((active0 & 0x20000L) != 0L) + return jjStartNfaWithStates_0(4, 17, 29); + else if ((active0 & 0x10000000L) != 0L) + return jjStartNfaWithStates_0(4, 28, 29); + else if ((active0 & 0x400000000000L) != 0L) + return jjStartNfaWithStates_0(4, 46, 29); + return jjMoveStringLiteralDfa5_0(active0, 0x800000000000000L); + case 117: + return jjMoveStringLiteralDfa5_0(active0, 0x80000L); + case 118: + return jjMoveStringLiteralDfa5_0(active0, 0x4000000000L); + case 119: + if ((active0 & 0x20000000000000L) != 0L) { + jjmatchedKind = 53; + jjmatchedPos = 4; + } + return jjMoveStringLiteralDfa5_0(active0, 0x40000000000000L); + default: + break; + } + return jjStartNfa_0(3, active0, 0L); + } + + private int jjMoveStringLiteralDfa5_0(long old0, long active0) { + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(3, old0, 0L); + try { + curChar = input_stream.readChar(); + } + catch (java.io.IOException e) { + jjStopStringLiteralDfa_0(4, active0, 0L); + return 5; + } + switch (curChar) { + case 97: + return jjMoveStringLiteralDfa6_0(active0, 0x500L); + case 99: + if ((active0 & 0x100000000000L) != 0L) + return jjStartNfaWithStates_0(5, 44, 29); + else if ((active0 & 0x800000000000L) != 0L) + return jjStartNfaWithStates_0(5, 47, 29); + return jjMoveStringLiteralDfa6_0(active0, 0x80000000000L); + case 100: + return jjMoveStringLiteralDfa6_0(active0, 0x1000000L); + case 101: + if ((active0 & 0x200000L) != 0L) + return jjStartNfaWithStates_0(5, 21, 29); + else if ((active0 & 0x4000000000L) != 0L) + return jjStartNfaWithStates_0(5, 38, 29); + break; + case 102: + return jjMoveStringLiteralDfa6_0(active0, 0x1000000000L); + case 103: + return jjMoveStringLiteralDfa6_0(active0, 0x20000000000L); + case 104: + if ((active0 & 0x4000000000000L) != 0L) + return jjStartNfaWithStates_0(5, 50, 29); + break; + case 105: + return jjMoveStringLiteralDfa6_0(active0, 0x880000000000000L); + case 108: + return jjMoveStringLiteralDfa6_0(active0, 0x8080000L); + case 109: + return jjMoveStringLiteralDfa6_0(active0, 0x100000000L); + case 110: + if ((active0 & 0x200000000000L) != 0L) + return jjStartNfaWithStates_0(5, 45, 29); + return jjMoveStringLiteralDfa6_0(active0, 0x400040000L); + case 114: + return jjMoveStringLiteralDfa6_0(active0, 0x8000000000000L); + case 115: + if ((active0 & 0x40000000000000L) != 0L) + return jjStartNfaWithStates_0(5, 54, 29); + break; + case 116: + if ((active0 & 0x200L) != 0L) + return jjStartNfaWithStates_0(5, 9, 29); + else if ((active0 & 0x200000000L) != 0L) + return jjStartNfaWithStates_0(5, 33, 29); + return jjMoveStringLiteralDfa6_0(active0, 0x1040000000000L); + default: + break; + } + return jjStartNfa_0(4, active0, 0L); + } + + private int jjMoveStringLiteralDfa6_0(long old0, long active0) { + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(4, old0, 0L); + try { + curChar = input_stream.readChar(); + } + catch (java.io.IOException e) { + jjStopStringLiteralDfa_0(5, active0, 0L); + return 6; + } + switch (curChar) { + case 97: + return jjMoveStringLiteralDfa7_0(active0, 0x1000000000L); + case 99: + return jjMoveStringLiteralDfa7_0(active0, 0x400000100L); + case 101: + if ((active0 & 0x20000000000L) != 0L) + return jjStartNfaWithStates_0(6, 41, 29); + else if ((active0 & 0x40000000000L) != 0L) + return jjStartNfaWithStates_0(6, 42, 29); + return jjMoveStringLiteralDfa7_0(active0, 0x80000100000000L); + case 102: + return jjMoveStringLiteralDfa7_0(active0, 0x1000000000000L); + case 108: + return jjMoveStringLiteralDfa7_0(active0, 0x800000000000000L); + case 110: + if ((active0 & 0x400L) != 0L) + return jjStartNfaWithStates_0(6, 10, 29); + break; + case 111: + return jjMoveStringLiteralDfa7_0(active0, 0x8000000000000L); + case 115: + if ((active0 & 0x1000000L) != 0L) + return jjStartNfaWithStates_0(6, 24, 29); + break; + case 116: + if ((active0 & 0x80000L) != 0L) + return jjStartNfaWithStates_0(6, 19, 29); + return jjMoveStringLiteralDfa7_0(active0, 0x80000000000L); + case 117: + return jjMoveStringLiteralDfa7_0(active0, 0x40000L); + case 121: + if ((active0 & 0x8000000L) != 0L) + return jjStartNfaWithStates_0(6, 27, 29); + break; + default: + break; + } + return jjStartNfa_0(5, active0, 0L); + } + + private int jjMoveStringLiteralDfa7_0(long old0, long active0) { + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(5, old0, 0L); + try { + curChar = input_stream.readChar(); + } + catch (java.io.IOException e) { + jjStopStringLiteralDfa_0(6, active0, 0L); + return 7; + } + switch (curChar) { + case 99: + return jjMoveStringLiteralDfa8_0(active0, 0x1000000000L); + case 101: + if ((active0 & 0x40000L) != 0L) + return jjStartNfaWithStates_0(7, 18, 29); + else if ((active0 & 0x800000000000000L) != 0L) + return jjStartNfaWithStates_0(7, 59, 29); + return jjMoveStringLiteralDfa8_0(active0, 0x80400000000L); + case 110: + return jjMoveStringLiteralDfa8_0(active0, 0x88000100000000L); + case 112: + if ((active0 & 0x1000000000000L) != 0L) + return jjStartNfaWithStates_0(7, 48, 29); + break; + case 116: + if ((active0 & 0x100L) != 0L) + return jjStartNfaWithStates_0(7, 8, 29); + break; + default: + break; + } + return jjStartNfa_0(6, active0, 0L); + } + + private int jjMoveStringLiteralDfa8_0(long old0, long active0) { + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(6, old0, 0L); + try { + curChar = input_stream.readChar(); + } + catch (java.io.IOException e) { + jjStopStringLiteralDfa_0(7, active0, 0L); + return 8; + } + switch (curChar) { + case 100: + if ((active0 & 0x80000000000L) != 0L) + return jjStartNfaWithStates_0(8, 43, 29); + break; + case 101: + if ((active0 & 0x1000000000L) != 0L) + return jjStartNfaWithStates_0(8, 36, 29); + break; + case 105: + return jjMoveStringLiteralDfa9_0(active0, 0x8000000000000L); + case 111: + return jjMoveStringLiteralDfa9_0(active0, 0x400000000L); + case 116: + if ((active0 & 0x80000000000000L) != 0L) + return jjStartNfaWithStates_0(8, 55, 29); + return jjMoveStringLiteralDfa9_0(active0, 0x100000000L); + default: + break; + } + return jjStartNfa_0(7, active0, 0L); + } + + private int jjMoveStringLiteralDfa9_0(long old0, long active0) { + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(7, old0, 0L); + try { + curChar = input_stream.readChar(); + } + catch (java.io.IOException e) { + jjStopStringLiteralDfa_0(8, active0, 0L); + return 9; + } + switch (curChar) { + case 102: + if ((active0 & 0x400000000L) != 0L) + return jjStartNfaWithStates_0(9, 34, 29); + break; + case 115: + if ((active0 & 0x100000000L) != 0L) + return jjStartNfaWithStates_0(9, 32, 29); + break; + case 122: + return jjMoveStringLiteralDfa10_0(active0, 0x8000000000000L); + default: + break; + } + return jjStartNfa_0(8, active0, 0L); + } + + private int jjMoveStringLiteralDfa10_0(long old0, long active0) { + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(8, old0, 0L); + try { + curChar = input_stream.readChar(); + } + catch (java.io.IOException e) { + jjStopStringLiteralDfa_0(9, active0, 0L); + return 10; + } + switch (curChar) { + case 101: + return jjMoveStringLiteralDfa11_0(active0, 0x8000000000000L); + default: + break; + } + return jjStartNfa_0(9, active0, 0L); + } + + private int jjMoveStringLiteralDfa11_0(long old0, long active0) { + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(9, old0, 0L); + try { + curChar = input_stream.readChar(); + } + catch (java.io.IOException e) { + jjStopStringLiteralDfa_0(10, active0, 0L); + return 11; + } + switch (curChar) { + case 100: + if ((active0 & 0x8000000000000L) != 0L) + return jjStartNfaWithStates_0(11, 51, 29); + break; + default: + break; + } + return jjStartNfa_0(10, active0, 0L); + } + + private void jjCheckNAdd(int state) { + if (jjrounds[state] != jjround) { + jjstateSet[jjnewStateCnt++] = state; + jjrounds[state] = jjround; + } + } + + private void jjAddStates(int start, int end) { + do { + jjstateSet[jjnewStateCnt++] = jjnextStates[start]; + } while (start++ != end); + } + + private void jjCheckNAddTwoStates(int state1, int state2) { + jjCheckNAdd(state1); + jjCheckNAdd(state2); + } + + private void jjCheckNAddStates(int start, int end) { + do { + jjCheckNAdd(jjnextStates[start]); + } while (start++ != end); + } + + private void jjCheckNAddStates(int start) { + jjCheckNAdd(jjnextStates[start]); + jjCheckNAdd(jjnextStates[start + 1]); + } + + static final long[] jjbitVec0 = { + 0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL + }; + static final long[] jjbitVec2 = { + 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL + }; + static final long[] jjbitVec3 = { + 0xfff0000000200002L, 0xffffffffffffdfffL, 0xfffff00f7fffffffL, 0x12000000007fffffL + }; + static final long[] jjbitVec4 = { + 0x0L, 0x0L, 0x420043c00000000L, 0xff7fffffff7fffffL + }; + static final long[] jjbitVec5 = { + 0xffffcffffffffL, 0xffffffffffff0000L, 0xf9ff3fffffffffffL, 0x401f00030003L + }; + static final long[] jjbitVec6 = { + 0x0L, 0x400000000000000L, 0xfffffffbffffd740L, 0xffffffcff7fffL + }; + static final long[] jjbitVec7 = { + 0xffffffffffffffffL, 0xffffffffffffffffL, 0xfffffffffffff003L, 0x33fffffffff199fL + }; + static final long[] jjbitVec8 = { + 0xfffe000000000000L, 0xfffffffe027fffffL, 0xffL, 0x707ffffff0000L + }; + static final long[] jjbitVec9 = { + 0x7fffffe00000000L, 0xfffe0000000007ffL, 0xffffffffffffffffL, 0x1c000060002fffffL + }; + static final long[] jjbitVec10 = { + 0x1ffffffd0000L, 0x0L, 0x3fffffffffL, 0x0L + }; + static final long[] jjbitVec11 = { + 0x23ffffffffffffe0L, 0x3ff010000L, 0x3c5fdfffff99fe0L, 0xf0003b0000000L + }; + static final long[] jjbitVec12 = { + 0x36dfdfffff987e0L, 0x1c00005e000000L, 0x23edfdfffffbafe0L, 0x100010000L + }; + static final long[] jjbitVec13 = { + 0x23cdfdfffff99fe0L, 0x3b0000000L, 0x3bfc718d63dc7e0L, 0x0L + }; + static final long[] jjbitVec14 = { + 0x3effdfffffddfe0L, 0x300000000L, 0x3effdfffffddfe0L, 0x340000000L + }; + static final long[] jjbitVec15 = { + 0x3fffdfffffddfe0L, 0x300000000L, 0x2ffbfffffc7fffe0L, 0x7fL + }; + static final long[] jjbitVec16 = { + 0x800dfffffffffffeL, 0x7fL, 0x200decaefef02596L, 0x3000005fL + }; + static final long[] jjbitVec17 = { + 0x1L, 0x7fffffffeffL, 0xf00L, 0x0L + }; + static final long[] jjbitVec18 = { + 0x6fbffffffffL, 0x3f0000L, 0xffffffff00000000L, 0x7fffffffff003fL + }; + static final long[] jjbitVec19 = { + 0xffffffffffffffffL, 0xffffffff83ffffffL, 0xffffff07ffffffffL, 0x3ffffffffffffffL + }; + static final long[] jjbitVec20 = { + 0xffffffffffffff7fL, 0xffffffff3d7f3d7fL, 0x7f3d7fffffff3d7fL, 0xffff7fffff7f7f3dL + }; + static final long[] jjbitVec21 = { + 0xffffffff7f3d7fffL, 0x7ffff7fL, 0xffffffff00000000L, 0x1fffffffffffffL + }; + static final long[] jjbitVec22 = { + 0xffffffffffffffffL, 0x7f9fffffffffffL, 0xffffffff07fffffeL, 0x7ffffffffffL + }; + static final long[] jjbitVec23 = { + 0x0L, 0x0L, 0xfffffffffffffL, 0x8000000L + }; + static final long[] jjbitVec24 = { + 0xffffffff00000000L, 0xffffffffffffffL, 0x1ffffffffffL, 0x0L + }; + static final long[] jjbitVec25 = { + 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffff0fffffffL, 0x3ffffffffffffffL + }; + static final long[] jjbitVec26 = { + 0xffffffff3f3fffffL, 0x3fffffffaaff3f3fL, 0x5fdfffffffffffffL, 0x1fdc1fff0fcf1fdcL + }; + static final long[] jjbitVec27 = { + 0x8000000000000000L, 0x8000000000000001L, 0xffff00000000L, 0x0L + }; + static final long[] jjbitVec28 = { + 0x3fbbd503e2ffc84L, 0xffffffff00000000L, 0xfL, 0x0L + }; + static final long[] jjbitVec29 = { + 0x73e03fe000000e0L, 0xfffffffffffffffeL, 0xfffffffe601fffffL, 0x7fffffffffffffffL + }; + static final long[] jjbitVec30 = { + 0xfffe1fffffffffe0L, 0xffffffffffffffffL, 0xffffff00007fffL, 0x0L + }; + static final long[] jjbitVec31 = { + 0xffffffffffffffffL, 0xffffffffffffffffL, 0x3fffffffffffffL, 0x0L + }; + static final long[] jjbitVec32 = { + 0xffffffffffffffffL, 0xffffffffffffffffL, 0x3fffffffffL, 0x0L + }; + static final long[] jjbitVec33 = { + 0xffffffffffffffffL, 0xffffffffffffffffL, 0x1fffL, 0x0L + }; + static final long[] jjbitVec34 = { + 0xffffffffffffffffL, 0xffffffffffffffffL, 0xfffffffffL, 0x0L + }; + static final long[] jjbitVec35 = { + 0x3fffffffffffL, 0x0L, 0x0L, 0x0L + }; + static final long[] jjbitVec36 = { + 0x5f7ffdffa0f8007fL, 0xffffffffffffffdbL, 0x3ffffffffffffL, 0xfffffffffff80000L + }; + static final long[] jjbitVec37 = { + 0x3fffffffffffffffL, 0xffffffffffff0000L, 0xfffffffffffcffffL, 0xfff0000000000ffL + }; + static final long[] jjbitVec38 = { + 0x18000000000000L, 0xffd702000000e000L, 0xffffffffffffffffL, 0x1fffffffffffffffL + }; + static final long[] jjbitVec39 = { + 0x87fffffe00000010L, 0xffffffe007fffffeL, 0x7fffffffffffffffL, 0x631cfcfcfcL + }; + static final long[] jjbitVec40 = { + 0x0L, 0x0L, 0x420043cffffffffL, 0xff7fffffff7fffffL + }; + static final long[] jjbitVec41 = { + 0xffffffffffffffffL, 0x400000700007fffL, 0xfffffffbffffd740L, 0xffffffcff7fffL + }; + static final long[] jjbitVec42 = { + 0xffffffffffffffffL, 0xffffffffffffffffL, 0xfffffffffffff07bL, 0x33fffffffff199fL + }; + static final long[] jjbitVec43 = { + 0xfffe000000000000L, 0xfffffffe027fffffL, 0xbbfffffbfffe00ffL, 0x707ffffff0016L + }; + static final long[] jjbitVec44 = { + 0x7fffffe00000000L, 0xffff03ff003fffffL, 0xffffffffffffffffL, 0x1fff3dff9fefffffL + }; + static final long[] jjbitVec45 = { + 0xffff1fffffff8000L, 0x7ffL, 0x1ffffffffffffL, 0x0L + }; + static final long[] jjbitVec46 = { + 0xf3ffffffffffffeeL, 0xffcfff1f3fffL, 0xd3c5fdfffff99feeL, 0xfffcfb080399fL + }; + static final long[] jjbitVec47 = { + 0xd36dfdfffff987e4L, 0x1fffc05e003987L, 0xf3edfdfffffbafeeL, 0xffc100013bbfL + }; + static final long[] jjbitVec48 = { + 0xf3cdfdfffff99feeL, 0xffc3b0c0398fL, 0xc3bfc718d63dc7ecL, 0xff8000803dc7L + }; + static final long[] jjbitVec49 = { + 0xc3effdfffffddfeeL, 0xffc300603ddfL, 0xc3effdfffffddfecL, 0xffc340603ddfL + }; + static final long[] jjbitVec50 = { + 0xc3fffdfffffddfecL, 0xffc300803dcfL, 0x2ffbfffffc7fffecL, 0xc0000ff5f847fL + }; + static final long[] jjbitVec51 = { + 0x87fffffffffffffeL, 0x3ff7fffL, 0x3bffecaefef02596L, 0x33ff3f5fL + }; + static final long[] jjbitVec52 = { + 0xc2a003ff03000001L, 0xfffe07fffffffeffL, 0x1ffffffffeff0fdfL, 0x40L + }; + static final long[] jjbitVec53 = { + 0x3c7f6fbffffffffL, 0x3ff03ffL, 0xffffffff00000000L, 0x7fffffffff003fL + }; + static final long[] jjbitVec54 = { + 0xffffffff7f3d7fffL, 0x3fe0007ffff7fL, 0xffffffff00000000L, 0x1fffffffffffffL + }; + static final long[] jjbitVec55 = { + 0x0L, 0x0L, 0xffffffffffffffffL, 0x3ff080fffffL + }; + static final long[] jjbitVec56 = { + 0xffffffff03ff7800L, 0xffffffffffffffL, 0x3ffffffffffL, 0x0L + }; + static final long[] jjbitVec57 = { + 0x80007c000000f000L, 0x8000fc0000000001L, 0xffff00000000L, 0x21fff0000L + }; + static final long[] jjbitVec58 = { + 0x73efffe000000e0L, 0xfffffffffffffffeL, 0xfffffffe661fffffL, 0x7fffffffffffffffL + }; + static final long[] jjbitVec59 = { + 0x5f7ffdffe0f8007fL, 0xffffffffffffffdbL, 0x3ffffffffffffL, 0xfffffffffff80000L + }; + static final long[] jjbitVec60 = { + 0x18000f00000000L, 0xffd702000000e000L, 0xffffffffffffffffL, 0x9fffffffffffffffL + }; + static final long[] jjbitVec61 = { + 0x87fffffe03ff0010L, 0xffffffe007fffffeL, 0x7fffffffffffffffL, 0xe0000631cfcfcfcL + }; + + private int jjMoveNfa_0(int startState, int curPos) { + int[] nextStates; + int startsAt = 0; + jjnewStateCnt = 71; + int i = 1; + jjstateSet[0] = startState; + int j, kind = 0x7fffffff; + for (; ;) { + if (++jjround == 0x7fffffff) + ReInitRounds(); + if (curChar < 64) { + long l = 1L << curChar; + MatchLoop: + do { + switch (jjstateSet[--i]) { + case 1: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(0, 6); + else if ((0x100003600L & l) != 0L) { + if (kind > 3) + kind = 3; + jjCheckNAdd(0); + } else if (curChar == 47) + jjAddStates(7, 8); + else if (curChar == 36) { + if (kind > 72) + kind = 72; + jjCheckNAdd(29); + } else if (curChar == 34) + jjCheckNAddStates(9, 11); + else if (curChar == 39) + jjAddStates(12, 13); + else if (curChar == 46) + jjCheckNAdd(5); + if ((0x3fe000000000000L & l) != 0L) { + if (kind > 61) + kind = 61; + jjCheckNAddTwoStates(2, 3); + } else if (curChar == 48) { + if (kind > 61) + kind = 61; + jjCheckNAddStates(14, 18); + } + break; + case 48: + if (curChar == 47) { + if (kind > 4) + kind = 4; + jjCheckNAddStates(19, 21); + } else if (curChar == 42) + jjstateSet[jjnewStateCnt++] = 46; + break; + case 0: + if ((0x100003600L & l) == 0L) + break; + if (kind > 3) + kind = 3; + jjCheckNAdd(0); + break; + case 2: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 61) + kind = 61; + jjCheckNAddTwoStates(2, 3); + break; + case 4: + if (curChar == 46) + jjCheckNAdd(5); + break; + case 5: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 65) + kind = 65; + jjCheckNAddStates(22, 24); + break; + case 7: + if ((0x280000000000L & l) != 0L) + jjCheckNAdd(8); + break; + case 8: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 65) + kind = 65; + jjCheckNAddTwoStates(8, 9); + break; + case 10: + if (curChar == 39) + jjAddStates(12, 13); + break; + case 11: + if ((0xffffff7fffffdbffL & l) != 0L) + jjCheckNAdd(12); + break; + case 12: + if (curChar == 39 && kind > 70) + kind = 70; + break; + case 14: + if ((0x8400000000L & l) != 0L) + jjCheckNAdd(12); + break; + case 15: + if ((0xff000000000000L & l) != 0L) + jjCheckNAddTwoStates(16, 12); + break; + case 16: + if ((0xff000000000000L & l) != 0L) + jjCheckNAdd(12); + break; + case 17: + if ((0xf000000000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 18; + break; + case 18: + if ((0xff000000000000L & l) != 0L) + jjCheckNAdd(16); + break; + case 19: + if (curChar == 34) + jjCheckNAddStates(9, 11); + break; + case 20: + if ((0xfffffffbffffdbffL & l) != 0L) + jjCheckNAddStates(9, 11); + break; + case 22: + if ((0x8400000000L & l) != 0L) + jjCheckNAddStates(9, 11); + break; + case 23: + if (curChar == 34 && kind > 71) + kind = 71; + break; + case 24: + if ((0xff000000000000L & l) != 0L) + jjCheckNAddStates(25, 28); + break; + case 25: + if ((0xff000000000000L & l) != 0L) + jjCheckNAddStates(9, 11); + break; + case 26: + if ((0xf000000000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 27; + break; + case 27: + if ((0xff000000000000L & l) != 0L) + jjCheckNAdd(25); + break; + case 28: + if (curChar != 36) + break; + if (kind > 72) + kind = 72; + jjCheckNAdd(29); + break; + case 29: + if ((0x3ff00100fffc1ffL & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAdd(29); + break; + case 30: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(0, 6); + break; + case 31: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(29, 31); + break; + case 33: + if ((0x280000000000L & l) != 0L) + jjCheckNAdd(34); + break; + case 34: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(34, 9); + break; + case 35: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(35, 36); + break; + case 37: + if ((0x280000000000L & l) != 0L) + jjCheckNAdd(38); + break; + case 38: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 65) + kind = 65; + jjCheckNAddTwoStates(38, 9); + break; + case 39: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(39, 40); + break; + case 40: + if (curChar != 46) + break; + if (kind > 65) + kind = 65; + jjCheckNAddStates(32, 34); + break; + case 41: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 65) + kind = 65; + jjCheckNAddStates(32, 34); + break; + case 43: + if ((0x280000000000L & l) != 0L) + jjCheckNAdd(44); + break; + case 44: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 65) + kind = 65; + jjCheckNAddTwoStates(44, 9); + break; + case 45: + if (curChar == 47) + jjAddStates(7, 8); + break; + case 46: + if (curChar == 42) + jjstateSet[jjnewStateCnt++] = 47; + break; + case 47: + if ((0xffff7fffffffffffL & l) != 0L && kind > 1) + kind = 1; + break; + case 49: + if (curChar != 47) + break; + if (kind > 4) + kind = 4; + jjCheckNAddStates(19, 21); + break; + case 50: + if ((0xffffffffffffdbffL & l) == 0L) + break; + if (kind > 4) + kind = 4; + jjCheckNAddStates(19, 21); + break; + case 51: + if ((0x2400L & l) != 0L && kind > 4) + kind = 4; + break; + case 52: + if (curChar == 10 && kind > 4) + kind = 4; + break; + case 53: + if (curChar == 13) + jjstateSet[jjnewStateCnt++] = 52; + break; + case 54: + if (curChar != 48) + break; + if (kind > 61) + kind = 61; + jjCheckNAddStates(14, 18); + break; + case 56: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 61) + kind = 61; + jjCheckNAddTwoStates(56, 3); + break; + case 57: + if ((0xff000000000000L & l) == 0L) + break; + if (kind > 61) + kind = 61; + jjCheckNAddTwoStates(57, 3); + break; + case 59: + if ((0x3ff000000000000L & l) != 0L) + jjAddStates(35, 36); + break; + case 60: + if (curChar == 46) + jjCheckNAdd(61); + break; + case 61: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(61, 62); + break; + case 63: + if ((0x280000000000L & l) != 0L) + jjCheckNAdd(64); + break; + case 64: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 65) + kind = 65; + jjCheckNAddTwoStates(64, 9); + break; + case 66: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(37, 39); + break; + case 67: + if (curChar == 46) + jjCheckNAdd(68); + break; + case 69: + if ((0x280000000000L & l) != 0L) + jjCheckNAdd(70); + break; + case 70: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 65) + kind = 65; + jjCheckNAddTwoStates(70, 9); + break; + default: + break; + } + } while (i != startsAt); + } else if (curChar < 128) { + long l = 1L << (curChar & 077); + MatchLoop: + do { + switch (jjstateSet[--i]) { + case 1: + if ((0x7fffffe87fffffeL & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAdd(29); + break; + case 3: + if ((0x100000001000L & l) != 0L && kind > 61) + kind = 61; + break; + case 6: + if ((0x2000000020L & l) != 0L) + jjAddStates(40, 41); + break; + case 9: + if ((0x5000000050L & l) != 0L && kind > 65) + kind = 65; + break; + case 11: + if ((0xffffffffefffffffL & l) != 0L) + jjCheckNAdd(12); + break; + case 13: + if (curChar == 92) + jjAddStates(42, 44); + break; + case 14: + if ((0x14404410000000L & l) != 0L) + jjCheckNAdd(12); + break; + case 20: + if ((0xffffffffefffffffL & l) != 0L) + jjCheckNAddStates(9, 11); + break; + case 21: + if (curChar == 92) + jjAddStates(45, 47); + break; + case 22: + if ((0x14404410000000L & l) != 0L) + jjCheckNAddStates(9, 11); + break; + case 29: + if ((0x87fffffe87fffffeL & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAdd(29); + break; + case 32: + if ((0x2000000020L & l) != 0L) + jjAddStates(48, 49); + break; + case 36: + if ((0x2000000020L & l) != 0L) + jjAddStates(50, 51); + break; + case 42: + if ((0x2000000020L & l) != 0L) + jjAddStates(52, 53); + break; + case 47: + if (kind > 1) + kind = 1; + break; + case 50: + if (kind > 4) + kind = 4; + jjAddStates(19, 21); + break; + case 55: + if ((0x100000001000000L & l) != 0L) + jjCheckNAdd(56); + break; + case 56: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 61) + kind = 61; + jjCheckNAddTwoStates(56, 3); + break; + case 58: + if ((0x100000001000000L & l) != 0L) + jjCheckNAddTwoStates(59, 60); + break; + case 59: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddTwoStates(59, 60); + break; + case 61: + if ((0x7e0000007eL & l) != 0L) + jjAddStates(54, 55); + break; + case 62: + if ((0x1000000010000L & l) != 0L) + jjAddStates(56, 57); + break; + case 65: + if ((0x100000001000000L & l) != 0L) + jjCheckNAdd(66); + break; + case 66: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(37, 39); + break; + case 68: + if ((0x1000000010000L & l) != 0L) + jjAddStates(58, 59); + break; + default: + break; + } + } while (i != startsAt); + } else { + int hiByte = (int) (curChar >> 8); + int i1 = hiByte >> 6; + long l1 = 1L << (hiByte & 077); + int i2 = (curChar & 0xff) >> 6; + long l2 = 1L << (curChar & 077); + MatchLoop: + do { + switch (jjstateSet[--i]) { + case 1: + if (!jjCanMove_1(hiByte, i1, i2, l1, l2)) + break; + if (kind > 72) + kind = 72; + jjCheckNAdd(29); + break; + case 11: + if (jjCanMove_0(hiByte, i1, i2, l1, l2)) + jjstateSet[jjnewStateCnt++] = 12; + break; + case 20: + if (jjCanMove_0(hiByte, i1, i2, l1, l2)) + jjAddStates(9, 11); + break; + case 29: + if (!jjCanMove_2(hiByte, i1, i2, l1, l2)) + break; + if (kind > 72) + kind = 72; + jjCheckNAdd(29); + break; + case 47: + if (jjCanMove_0(hiByte, i1, i2, l1, l2) && kind > 1) + kind = 1; + break; + case 50: + if (!jjCanMove_0(hiByte, i1, i2, l1, l2)) + break; + if (kind > 4) + kind = 4; + jjAddStates(19, 21); + break; + default: + break; + } + } while (i != startsAt); + } + if (kind != 0x7fffffff) { + jjmatchedKind = kind; + jjmatchedPos = curPos; + kind = 0x7fffffff; + } + ++curPos; + if ((i = jjnewStateCnt) == (startsAt = 71 - (jjnewStateCnt = startsAt))) + return curPos; + try { + curChar = input_stream.readChar(); + } + catch (java.io.IOException e) { + return curPos; + } + } + } + + private int jjMoveStringLiteralDfa0_2() { + switch (curChar) { + case 42: + return jjMoveStringLiteralDfa1_2(0x40L); + default: + return 1; + } + } + + private int jjMoveStringLiteralDfa1_2(long active0) { + try { + curChar = input_stream.readChar(); + } + catch (java.io.IOException e) { + return 1; + } + switch (curChar) { + case 47: + if ((active0 & 0x40L) != 0L) + return jjStopAtPos(1, 6); + break; + default: + return 2; + } + return 2; + } + + private int jjMoveStringLiteralDfa0_1() { + switch (curChar) { + case 42: + return jjMoveStringLiteralDfa1_1(0x20L); + default: + return 1; + } + } + + private int jjMoveStringLiteralDfa1_1(long active0) { + try { + curChar = input_stream.readChar(); + } + catch (java.io.IOException e) { + return 1; + } + switch (curChar) { + case 47: + if ((active0 & 0x20L) != 0L) + return jjStopAtPos(1, 5); + break; + default: + return 2; + } + return 2; + } + + static final int[] jjnextStates = { + 31, 32, 9, 35, 36, 39, 40, 48, 49, 20, 21, 23, 11, 13, 55, 57, + 3, 58, 65, 50, 51, 53, 5, 6, 9, 20, 21, 25, 23, 31, 32, 9, + 41, 42, 9, 59, 60, 66, 67, 68, 7, 8, 14, 15, 17, 22, 24, 26, + 33, 34, 37, 38, 43, 44, 61, 62, 63, 64, 69, 70, + }; + + private static boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2) { + switch (hiByte) { + case 0: + return ((jjbitVec2[i2] & l2) != 0L); + default: + if ((jjbitVec0[i1] & l1) != 0L) + return true; + return false; + } + } + + private static boolean jjCanMove_1(int hiByte, int i1, int i2, long l1, long l2) { + switch (hiByte) { + case 0: + return ((jjbitVec4[i2] & l2) != 0L); + case 2: + return ((jjbitVec5[i2] & l2) != 0L); + case 3: + return ((jjbitVec6[i2] & l2) != 0L); + case 4: + return ((jjbitVec7[i2] & l2) != 0L); + case 5: + return ((jjbitVec8[i2] & l2) != 0L); + case 6: + return ((jjbitVec9[i2] & l2) != 0L); + case 7: + return ((jjbitVec10[i2] & l2) != 0L); + case 9: + return ((jjbitVec11[i2] & l2) != 0L); + case 10: + return ((jjbitVec12[i2] & l2) != 0L); + case 11: + return ((jjbitVec13[i2] & l2) != 0L); + case 12: + return ((jjbitVec14[i2] & l2) != 0L); + case 13: + return ((jjbitVec15[i2] & l2) != 0L); + case 14: + return ((jjbitVec16[i2] & l2) != 0L); + case 15: + return ((jjbitVec17[i2] & l2) != 0L); + case 16: + return ((jjbitVec18[i2] & l2) != 0L); + case 17: + return ((jjbitVec19[i2] & l2) != 0L); + case 18: + return ((jjbitVec20[i2] & l2) != 0L); + case 19: + return ((jjbitVec21[i2] & l2) != 0L); + case 20: + return ((jjbitVec0[i2] & l2) != 0L); + case 22: + return ((jjbitVec22[i2] & l2) != 0L); + case 23: + return ((jjbitVec23[i2] & l2) != 0L); + case 24: + return ((jjbitVec24[i2] & l2) != 0L); + case 30: + return ((jjbitVec25[i2] & l2) != 0L); + case 31: + return ((jjbitVec26[i2] & l2) != 0L); + case 32: + return ((jjbitVec27[i2] & l2) != 0L); + case 33: + return ((jjbitVec28[i2] & l2) != 0L); + case 48: + return ((jjbitVec29[i2] & l2) != 0L); + case 49: + return ((jjbitVec30[i2] & l2) != 0L); + case 77: + return ((jjbitVec31[i2] & l2) != 0L); + case 159: + return ((jjbitVec32[i2] & l2) != 0L); + case 164: + return ((jjbitVec33[i2] & l2) != 0L); + case 215: + return ((jjbitVec34[i2] & l2) != 0L); + case 250: + return ((jjbitVec35[i2] & l2) != 0L); + case 251: + return ((jjbitVec36[i2] & l2) != 0L); + case 253: + return ((jjbitVec37[i2] & l2) != 0L); + case 254: + return ((jjbitVec38[i2] & l2) != 0L); + case 255: + return ((jjbitVec39[i2] & l2) != 0L); + default: + if ((jjbitVec3[i1] & l1) != 0L) + return true; + return false; + } + } + + private static boolean jjCanMove_2(int hiByte, int i1, int i2, long l1, long l2) { + switch (hiByte) { + case 0: + return ((jjbitVec40[i2] & l2) != 0L); + case 2: + return ((jjbitVec5[i2] & l2) != 0L); + case 3: + return ((jjbitVec41[i2] & l2) != 0L); + case 4: + return ((jjbitVec42[i2] & l2) != 0L); + case 5: + return ((jjbitVec43[i2] & l2) != 0L); + case 6: + return ((jjbitVec44[i2] & l2) != 0L); + case 7: + return ((jjbitVec45[i2] & l2) != 0L); + case 9: + return ((jjbitVec46[i2] & l2) != 0L); + case 10: + return ((jjbitVec47[i2] & l2) != 0L); + case 11: + return ((jjbitVec48[i2] & l2) != 0L); + case 12: + return ((jjbitVec49[i2] & l2) != 0L); + case 13: + return ((jjbitVec50[i2] & l2) != 0L); + case 14: + return ((jjbitVec51[i2] & l2) != 0L); + case 15: + return ((jjbitVec52[i2] & l2) != 0L); + case 16: + return ((jjbitVec53[i2] & l2) != 0L); + case 17: + return ((jjbitVec19[i2] & l2) != 0L); + case 18: + return ((jjbitVec20[i2] & l2) != 0L); + case 19: + return ((jjbitVec54[i2] & l2) != 0L); + case 20: + return ((jjbitVec0[i2] & l2) != 0L); + case 22: + return ((jjbitVec22[i2] & l2) != 0L); + case 23: + return ((jjbitVec55[i2] & l2) != 0L); + case 24: + return ((jjbitVec56[i2] & l2) != 0L); + case 30: + return ((jjbitVec25[i2] & l2) != 0L); + case 31: + return ((jjbitVec26[i2] & l2) != 0L); + case 32: + return ((jjbitVec57[i2] & l2) != 0L); + case 33: + return ((jjbitVec28[i2] & l2) != 0L); + case 48: + return ((jjbitVec58[i2] & l2) != 0L); + case 49: + return ((jjbitVec30[i2] & l2) != 0L); + case 77: + return ((jjbitVec31[i2] & l2) != 0L); + case 159: + return ((jjbitVec32[i2] & l2) != 0L); + case 164: + return ((jjbitVec33[i2] & l2) != 0L); + case 215: + return ((jjbitVec34[i2] & l2) != 0L); + case 250: + return ((jjbitVec35[i2] & l2) != 0L); + case 251: + return ((jjbitVec59[i2] & l2) != 0L); + case 253: + return ((jjbitVec37[i2] & l2) != 0L); + case 254: + return ((jjbitVec60[i2] & l2) != 0L); + case 255: + return ((jjbitVec61[i2] & l2) != 0L); + default: + if ((jjbitVec3[i1] & l1) != 0L) + return true; + return false; + } + } + + public static final String[] jjstrLiteralImages = { + "", null, null, null, null, null, null, null, + "\141\142\163\164\162\141\143\164", "\141\163\163\145\162\164", "\142\157\157\154\145\141\156", + "\142\162\145\141\153", "\142\171\164\145", "\143\141\163\145", "\143\141\164\143\150", + "\143\150\141\162", "\143\154\141\163\163", "\143\157\156\163\164", + "\143\157\156\164\151\156\165\145", "\144\145\146\141\165\154\164", "\144\157", "\144\157\165\142\154\145", + "\145\154\163\145", "\145\156\165\155", "\145\170\164\145\156\144\163", "\146\141\154\163\145", + "\146\151\156\141\154", "\146\151\156\141\154\154\171", "\146\154\157\141\164", "\146\157\162", + "\147\157\164\157", "\151\146", "\151\155\160\154\145\155\145\156\164\163", + "\151\155\160\157\162\164", "\151\156\163\164\141\156\143\145\157\146", "\151\156\164", + "\151\156\164\145\162\146\141\143\145", "\154\157\156\147", "\156\141\164\151\166\145", "\156\145\167", + "\156\165\154\154", "\160\141\143\153\141\147\145", "\160\162\151\166\141\164\145", + "\160\162\157\164\145\143\164\145\144", "\160\165\142\154\151\143", "\162\145\164\165\162\156", + "\163\150\157\162\164", "\163\164\141\164\151\143", "\163\164\162\151\143\164\146\160", + "\163\165\160\145\162", "\163\167\151\164\143\150", + "\163\171\156\143\150\162\157\156\151\172\145\144", "\164\150\151\163", "\164\150\162\157\167", "\164\150\162\157\167\163", + "\164\162\141\156\163\151\145\156\164", "\164\162\165\145", "\164\162\171", "\166\157\151\144", + "\166\157\154\141\164\151\154\145", "\167\150\151\154\145", null, null, null, null, null, null, null, null, null, + null, null, null, null, null, "\50", "\51", "\173", "\175", "\133", "\135", "\73", + "\54", "\56", "\100", "\75", "\74", "\41", "\176", "\77", "\72", "\75\75", "\74\75", + "\76\75", "\41\75", "\174\174", "\46\46", "\53\53", "\55\55", "\53", "\55", "\52", + "\57", "\46", "\174", "\136", "\45", "\74\74", "\53\75", "\55\75", "\52\75", + "\57\75", "\46\75", "\174\75", "\136\75", "\45\75", "\74\74\75", "\76\76\75", + "\76\76\76\75", "\56\56\56", "\76\76\76", "\76\76", "\76", "\32", null,}; + public static final String[] lexStateNames = { + "DEFAULT", + "IN_FORMAL_COMMENT", + "IN_MULTI_LINE_COMMENT", + }; + public static final int[] jjnewLexState = { + -1, 1, 2, -1, -1, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + }; + static final long[] jjtoToken = { + 0x3fffffffffffff01L, 0x1ffffffffffff9c2L, + }; + static final long[] jjtoSkip = { + 0x78L, 0x0L, + }; + static final long[] jjtoSpecial = { + 0x78L, 0x0L, + }; + static final long[] jjtoMore = { + 0x86L, 0x0L, + }; + protected JavaCharStream input_stream; + private final int[] jjrounds = new int[71]; + private final int[] jjstateSet = new int[142]; + StringBuffer image; + int jjimageLen; + int lengthOfMatch; + protected char curChar; + + public JavaParserTokenManager(JavaCharStream stream) { + if (JavaCharStream.staticFlag) + throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); + input_stream = stream; + } + + public JavaParserTokenManager(JavaCharStream stream, int lexState) { + this(stream); + SwitchTo(lexState); + } + + public void ReInit(JavaCharStream stream) { + jjmatchedPos = jjnewStateCnt = 0; + curLexState = defaultLexState; + input_stream = stream; + ReInitRounds(); + } + + private void ReInitRounds() { + int i; + jjround = 0x80000001; + for (i = 71; i-- > 0;) + jjrounds[i] = 0x80000000; + } + + public void ReInit(JavaCharStream stream, int lexState) { + ReInit(stream); + SwitchTo(lexState); + } + + public void SwitchTo(int lexState) { + if (lexState >= 3 || lexState < 0) + throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); + else + curLexState = lexState; + } + + protected Token jjFillToken() { + Token t = Token.newToken(jjmatchedKind); + t.kind = jjmatchedKind; + String im = jjstrLiteralImages[jjmatchedKind]; + t.image = (im == null) ? input_stream.GetImage() : im; + t.beginLine = input_stream.getBeginLine(); + t.beginColumn = input_stream.getBeginColumn(); + t.endLine = input_stream.getEndLine(); + t.endColumn = input_stream.getEndColumn(); + return t; + } + + int curLexState = 0; + int defaultLexState = 0; + int jjnewStateCnt; + int jjround; + int jjmatchedPos; + int jjmatchedKind; + + public Token getNextToken() { + int kind; + Token specialToken = null; + Token matchedToken; + int curPos = 0; + + EOFLoop: + for (; ;) { + try { + curChar = input_stream.BeginToken(); + } + catch (java.io.IOException e) { + jjmatchedKind = 0; + matchedToken = jjFillToken(); + matchedToken.specialToken = specialToken; + return matchedToken; + } + image = null; + jjimageLen = 0; + + for (; ;) { + switch (curLexState) { + case 0: + jjmatchedKind = 0x7fffffff; + jjmatchedPos = 0; + curPos = jjMoveStringLiteralDfa0_0(); + if (jjmatchedPos == 0 && jjmatchedKind > 124) { + jjmatchedKind = 124; + } + break; + case 1: + jjmatchedKind = 0x7fffffff; + jjmatchedPos = 0; + curPos = jjMoveStringLiteralDfa0_1(); + if (jjmatchedPos == 0 && jjmatchedKind > 7) { + jjmatchedKind = 7; + } + break; + case 2: + jjmatchedKind = 0x7fffffff; + jjmatchedPos = 0; + curPos = jjMoveStringLiteralDfa0_2(); + if (jjmatchedPos == 0 && jjmatchedKind > 7) { + jjmatchedKind = 7; + } + break; + } + if (jjmatchedKind != 0x7fffffff) { + if (jjmatchedPos + 1 < curPos) + input_stream.backup(curPos - jjmatchedPos - 1); + if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) { + matchedToken = jjFillToken(); + matchedToken.specialToken = specialToken; + TokenLexicalActions(matchedToken); + if (jjnewLexState[jjmatchedKind] != -1) + curLexState = jjnewLexState[jjmatchedKind]; + return matchedToken; + } else + if ((jjtoSkip[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) { + if ((jjtoSpecial[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) { + matchedToken = jjFillToken(); + if (specialToken == null) + specialToken = matchedToken; + else { + matchedToken.specialToken = specialToken; + specialToken = (specialToken.next = matchedToken); + } + SkipLexicalActions(matchedToken); + } else + SkipLexicalActions(null); + if (jjnewLexState[jjmatchedKind] != -1) + curLexState = jjnewLexState[jjmatchedKind]; + continue EOFLoop; + } + MoreLexicalActions(); + if (jjnewLexState[jjmatchedKind] != -1) + curLexState = jjnewLexState[jjmatchedKind]; + curPos = 0; + jjmatchedKind = 0x7fffffff; + try { + curChar = input_stream.readChar(); + continue; + } + catch (java.io.IOException e1) { + } + } + int error_line = input_stream.getEndLine(); + int error_column = input_stream.getEndColumn(); + String error_after = null; + boolean EOFSeen = false; + try { + input_stream.readChar(); + input_stream.backup(1); + } + catch (java.io.IOException e1) { + EOFSeen = true; + error_after = curPos <= 1 ? "" : input_stream.GetImage(); + if (curChar == '\n' || curChar == '\r') { + error_line++; + error_column = 0; + } else + error_column++; + } + if (!EOFSeen) { + input_stream.backup(1); + error_after = curPos <= 1 ? "" : input_stream.GetImage(); + } + throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR); + } + } + } + + void SkipLexicalActions(Token matchedToken) { + switch (jjmatchedKind) { + default: + break; + } + } + + void MoreLexicalActions() { + jjimageLen += (lengthOfMatch = jjmatchedPos + 1); + switch (jjmatchedKind) { + case 1: + if (image == null) + image = new StringBuffer(); + image.append(input_stream.GetSuffix(jjimageLen)); + jjimageLen = 0; + input_stream.backup(1); + break; + default: + break; + } + } + + void TokenLexicalActions(Token matchedToken) { + switch (jjmatchedKind) { + case 120: + if (image == null) + image = new StringBuffer(); + image.append(jjstrLiteralImages[120]); + matchedToken.kind = GT; + ((Token.GTToken) matchedToken).realKind = RUNSIGNEDSHIFT; + input_stream.backup(2); + matchedToken.image = ">"; + break; + case 121: + if (image == null) + image = new StringBuffer(); + image.append(jjstrLiteralImages[121]); + matchedToken.kind = GT; + ((Token.GTToken) matchedToken).realKind = RSIGNEDSHIFT; + input_stream.backup(1); + matchedToken.image = ">"; + break; + default: + break; + } + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParserTreeConstants.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParserTreeConstants.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParserTreeConstants.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,250 +0,0 @@ -/* Generated By:JJTree: Do not edit this line. ./JavaParserTreeConstants.java */ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ - -package jaxx.compiler.java.parser; - -public interface JavaParserTreeConstants { - public int JJTLINE = 0; - public int JJTCOMPILATIONUNIT = 1; - public int JJTPACKAGEDECLARATION = 2; - public int JJTIMPORTDECLARATION = 3; - public int JJTMODIFIERS = 4; - public int JJTTYPEDECLARATION = 5; - public int JJTCLASSORINTERFACEDECLARATION = 6; - public int JJTEXTENDSLIST = 7; - public int JJTIMPLEMENTSLIST = 8; - public int JJTENUMDECLARATION = 9; - public int JJTENUMBODY = 10; - public int JJTENUMCONSTANT = 11; - public int JJTTYPEPARAMETERS = 12; - public int JJTTYPEPARAMETER = 13; - public int JJTTYPEBOUND = 14; - public int JJTCLASSORINTERFACEBODY = 15; - public int JJTCLASSORINTERFACEBODYDECLARATION = 16; - public int JJTFIELDDECLARATION = 17; - public int JJTVARIABLEDECLARATOR = 18; - public int JJTVARIABLEDECLARATORID = 19; - public int JJTVARIABLEINITIALIZER = 20; - public int JJTARRAYINITIALIZER = 21; - public int JJTMETHODDECLARATION = 22; - public int JJTMETHODDECLARATOR = 23; - public int JJTFORMALPARAMETERS = 24; - public int JJTFORMALPARAMETER = 25; - public int JJTCONSTRUCTORDECLARATION = 26; - public int JJTEXPLICITCONSTRUCTORINVOCATION = 27; - public int JJTINITIALIZER = 28; - public int JJTTYPE = 29; - public int JJTREFERENCETYPE = 30; - public int JJTCLASSORINTERFACETYPE = 31; - public int JJTTYPEARGUMENTS = 32; - public int JJTTYPEARGUMENT = 33; - public int JJTWILDCARDBOUNDS = 34; - public int JJTPRIMITIVETYPE = 35; - public int JJTRESULTTYPE = 36; - public int JJTNAME = 37; - public int JJTNAMELIST = 38; - public int JJTEXPRESSION = 39; - public int JJTASSIGNMENTOPERATOR = 40; - public int JJTASSIGNMENTEXPRESSION = 41; - public int JJTCONDITIONALEXPRESSION = 42; - public int JJTCONDITIONALOREXPRESSION = 43; - public int JJTCONDITIONALANDEXPRESSION = 44; - public int JJTINCLUSIVEOREXPRESSION = 45; - public int JJTEXCLUSIVEOREXPRESSION = 46; - public int JJTANDEXPRESSION = 47; - public int JJTEQUALITYEXPRESSION = 48; - public int JJTINSTANCEOFEXPRESSION = 49; - public int JJTRELATIONALEXPRESSION = 50; - public int JJTSHIFTEXPRESSION = 51; - public int JJTADDITIVEEXPRESSION = 52; - public int JJTMULTIPLICATIVEEXPRESSION = 53; - public int JJTUNARYEXPRESSION = 54; - public int JJTPREINCREMENTEXPRESSION = 55; - public int JJTPREDECREMENTEXPRESSION = 56; - public int JJTUNARYEXPRESSIONNOTPLUSMINUS = 57; - public int JJTCASTLOOKAHEAD = 58; - public int JJTPOSTFIXEXPRESSION = 59; - public int JJTPOSTFIXOPERATOR = 60; - public int JJTCASTEXPRESSION = 61; - public int JJTPRIMARYEXPRESSION = 62; - public int JJTMEMBERSELECTOR = 63; - public int JJTPRIMARYPREFIX = 64; - public int JJTPRIMARYSUFFIX = 65; - public int JJTLITERAL = 66; - public int JJTBOOLEANLITERAL = 67; - public int JJTNULLLITERAL = 68; - public int JJTARGUMENTS = 69; - public int JJTARGUMENTLIST = 70; - public int JJTALLOCATIONEXPRESSION = 71; - public int JJTARRAYDIMSANDINITS = 72; - public int JJTSTATEMENT = 73; - public int JJTASSERTSTATEMENT = 74; - public int JJTLABELEDSTATEMENT = 75; - public int JJTBLOCK = 76; - public int JJTBLOCKSTATEMENT = 77; - public int JJTLOCALVARIABLEDECLARATION = 78; - public int JJTEMPTYSTATEMENT = 79; - public int JJTSTATEMENTEXPRESSION = 80; - public int JJTSWITCHSTATEMENT = 81; - public int JJTSWITCHLABEL = 82; - public int JJTIFSTATEMENT = 83; - public int JJTWHILESTATEMENT = 84; - public int JJTDOSTATEMENT = 85; - public int JJTFORSTATEMENT = 86; - public int JJTFORINIT = 87; - public int JJTSTATEMENTEXPRESSIONLIST = 88; - public int JJTFORUPDATE = 89; - public int JJTBREAKSTATEMENT = 90; - public int JJTCONTINUESTATEMENT = 91; - public int JJTRETURNSTATEMENT = 92; - public int JJTTHROWSTATEMENT = 93; - public int JJTSYNCHRONIZEDSTATEMENT = 94; - public int JJTTRYSTATEMENT = 95; - public int JJTRUNSIGNEDSHIFT = 96; - public int JJTRSIGNEDSHIFT = 97; - public int JJTANNOTATION = 98; - public int JJTNORMALANNOTATION = 99; - public int JJTMARKERANNOTATION = 100; - public int JJTSINGLEMEMBERANNOTATION = 101; - public int JJTMEMBERVALUEPAIRS = 102; - public int JJTMEMBERVALUEPAIR = 103; - public int JJTMEMBERVALUE = 104; - public int JJTMEMBERVALUEARRAYINITIALIZER = 105; - public int JJTANNOTATIONTYPEDECLARATION = 106; - public int JJTANNOTATIONTYPEBODY = 107; - public int JJTANNOTATIONTYPEMEMBERDECLARATION = 108; - public int JJTDEFAULTVALUE = 109; - - - public String[] jjtNodeName = { - "Line", - "CompilationUnit", - "PackageDeclaration", - "ImportDeclaration", - "Modifiers", - "TypeDeclaration", - "ClassOrInterfaceDeclaration", - "ExtendsList", - "ImplementsList", - "EnumDeclaration", - "EnumBody", - "EnumConstant", - "TypeParameters", - "TypeParameter", - "TypeBound", - "ClassOrInterfaceBody", - "ClassOrInterfaceBodyDeclaration", - "FieldDeclaration", - "VariableDeclarator", - "VariableDeclaratorId", - "VariableInitializer", - "ArrayInitializer", - "MethodDeclaration", - "MethodDeclarator", - "FormalParameters", - "FormalParameter", - "ConstructorDeclaration", - "ExplicitConstructorInvocation", - "Initializer", - "Type", - "ReferenceType", - "ClassOrInterfaceType", - "TypeArguments", - "TypeArgument", - "WildcardBounds", - "PrimitiveType", - "ResultType", - "Name", - "NameList", - "Expression", - "AssignmentOperator", - "AssignmentExpression", - "ConditionalExpression", - "ConditionalOrExpression", - "ConditionalAndExpression", - "InclusiveOrExpression", - "ExclusiveOrExpression", - "AndExpression", - "EqualityExpression", - "InstanceOfExpression", - "RelationalExpression", - "ShiftExpression", - "AdditiveExpression", - "MultiplicativeExpression", - "UnaryExpression", - "PreIncrementExpression", - "PreDecrementExpression", - "UnaryExpressionNotPlusMinus", - "CastLookahead", - "PostfixExpression", - "PostfixOperator", - "CastExpression", - "PrimaryExpression", - "MemberSelector", - "PrimaryPrefix", - "PrimarySuffix", - "Literal", - "BooleanLiteral", - "NullLiteral", - "Arguments", - "ArgumentList", - "AllocationExpression", - "ArrayDimsAndInits", - "Statement", - "AssertStatement", - "LabeledStatement", - "Block", - "BlockStatement", - "LocalVariableDeclaration", - "EmptyStatement", - "StatementExpression", - "SwitchStatement", - "SwitchLabel", - "IfStatement", - "WhileStatement", - "DoStatement", - "ForStatement", - "ForInit", - "StatementExpressionList", - "ForUpdate", - "BreakStatement", - "ContinueStatement", - "ReturnStatement", - "ThrowStatement", - "SynchronizedStatement", - "TryStatement", - "RUNSIGNEDSHIFT", - "RSIGNEDSHIFT", - "Annotation", - "NormalAnnotation", - "MarkerAnnotation", - "SingleMemberAnnotation", - "MemberValuePairs", - "MemberValuePair", - "MemberValue", - "MemberValueArrayInitializer", - "AnnotationTypeDeclaration", - "AnnotationTypeBody", - "AnnotationTypeMemberDeclaration", - "DefaultValue", - }; -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParserTreeConstants.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParserTreeConstants.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParserTreeConstants.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParserTreeConstants.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,250 @@ +/* Generated By:JJTree: Do not edit this line. ./JavaParserTreeConstants.java */ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ + +package jaxx.compiler.java.parser; + +public interface JavaParserTreeConstants { + public int JJTLINE = 0; + public int JJTCOMPILATIONUNIT = 1; + public int JJTPACKAGEDECLARATION = 2; + public int JJTIMPORTDECLARATION = 3; + public int JJTMODIFIERS = 4; + public int JJTTYPEDECLARATION = 5; + public int JJTCLASSORINTERFACEDECLARATION = 6; + public int JJTEXTENDSLIST = 7; + public int JJTIMPLEMENTSLIST = 8; + public int JJTENUMDECLARATION = 9; + public int JJTENUMBODY = 10; + public int JJTENUMCONSTANT = 11; + public int JJTTYPEPARAMETERS = 12; + public int JJTTYPEPARAMETER = 13; + public int JJTTYPEBOUND = 14; + public int JJTCLASSORINTERFACEBODY = 15; + public int JJTCLASSORINTERFACEBODYDECLARATION = 16; + public int JJTFIELDDECLARATION = 17; + public int JJTVARIABLEDECLARATOR = 18; + public int JJTVARIABLEDECLARATORID = 19; + public int JJTVARIABLEINITIALIZER = 20; + public int JJTARRAYINITIALIZER = 21; + public int JJTMETHODDECLARATION = 22; + public int JJTMETHODDECLARATOR = 23; + public int JJTFORMALPARAMETERS = 24; + public int JJTFORMALPARAMETER = 25; + public int JJTCONSTRUCTORDECLARATION = 26; + public int JJTEXPLICITCONSTRUCTORINVOCATION = 27; + public int JJTINITIALIZER = 28; + public int JJTTYPE = 29; + public int JJTREFERENCETYPE = 30; + public int JJTCLASSORINTERFACETYPE = 31; + public int JJTTYPEARGUMENTS = 32; + public int JJTTYPEARGUMENT = 33; + public int JJTWILDCARDBOUNDS = 34; + public int JJTPRIMITIVETYPE = 35; + public int JJTRESULTTYPE = 36; + public int JJTNAME = 37; + public int JJTNAMELIST = 38; + public int JJTEXPRESSION = 39; + public int JJTASSIGNMENTOPERATOR = 40; + public int JJTASSIGNMENTEXPRESSION = 41; + public int JJTCONDITIONALEXPRESSION = 42; + public int JJTCONDITIONALOREXPRESSION = 43; + public int JJTCONDITIONALANDEXPRESSION = 44; + public int JJTINCLUSIVEOREXPRESSION = 45; + public int JJTEXCLUSIVEOREXPRESSION = 46; + public int JJTANDEXPRESSION = 47; + public int JJTEQUALITYEXPRESSION = 48; + public int JJTINSTANCEOFEXPRESSION = 49; + public int JJTRELATIONALEXPRESSION = 50; + public int JJTSHIFTEXPRESSION = 51; + public int JJTADDITIVEEXPRESSION = 52; + public int JJTMULTIPLICATIVEEXPRESSION = 53; + public int JJTUNARYEXPRESSION = 54; + public int JJTPREINCREMENTEXPRESSION = 55; + public int JJTPREDECREMENTEXPRESSION = 56; + public int JJTUNARYEXPRESSIONNOTPLUSMINUS = 57; + public int JJTCASTLOOKAHEAD = 58; + public int JJTPOSTFIXEXPRESSION = 59; + public int JJTPOSTFIXOPERATOR = 60; + public int JJTCASTEXPRESSION = 61; + public int JJTPRIMARYEXPRESSION = 62; + public int JJTMEMBERSELECTOR = 63; + public int JJTPRIMARYPREFIX = 64; + public int JJTPRIMARYSUFFIX = 65; + public int JJTLITERAL = 66; + public int JJTBOOLEANLITERAL = 67; + public int JJTNULLLITERAL = 68; + public int JJTARGUMENTS = 69; + public int JJTARGUMENTLIST = 70; + public int JJTALLOCATIONEXPRESSION = 71; + public int JJTARRAYDIMSANDINITS = 72; + public int JJTSTATEMENT = 73; + public int JJTASSERTSTATEMENT = 74; + public int JJTLABELEDSTATEMENT = 75; + public int JJTBLOCK = 76; + public int JJTBLOCKSTATEMENT = 77; + public int JJTLOCALVARIABLEDECLARATION = 78; + public int JJTEMPTYSTATEMENT = 79; + public int JJTSTATEMENTEXPRESSION = 80; + public int JJTSWITCHSTATEMENT = 81; + public int JJTSWITCHLABEL = 82; + public int JJTIFSTATEMENT = 83; + public int JJTWHILESTATEMENT = 84; + public int JJTDOSTATEMENT = 85; + public int JJTFORSTATEMENT = 86; + public int JJTFORINIT = 87; + public int JJTSTATEMENTEXPRESSIONLIST = 88; + public int JJTFORUPDATE = 89; + public int JJTBREAKSTATEMENT = 90; + public int JJTCONTINUESTATEMENT = 91; + public int JJTRETURNSTATEMENT = 92; + public int JJTTHROWSTATEMENT = 93; + public int JJTSYNCHRONIZEDSTATEMENT = 94; + public int JJTTRYSTATEMENT = 95; + public int JJTRUNSIGNEDSHIFT = 96; + public int JJTRSIGNEDSHIFT = 97; + public int JJTANNOTATION = 98; + public int JJTNORMALANNOTATION = 99; + public int JJTMARKERANNOTATION = 100; + public int JJTSINGLEMEMBERANNOTATION = 101; + public int JJTMEMBERVALUEPAIRS = 102; + public int JJTMEMBERVALUEPAIR = 103; + public int JJTMEMBERVALUE = 104; + public int JJTMEMBERVALUEARRAYINITIALIZER = 105; + public int JJTANNOTATIONTYPEDECLARATION = 106; + public int JJTANNOTATIONTYPEBODY = 107; + public int JJTANNOTATIONTYPEMEMBERDECLARATION = 108; + public int JJTDEFAULTVALUE = 109; + + + public String[] jjtNodeName = { + "Line", + "CompilationUnit", + "PackageDeclaration", + "ImportDeclaration", + "Modifiers", + "TypeDeclaration", + "ClassOrInterfaceDeclaration", + "ExtendsList", + "ImplementsList", + "EnumDeclaration", + "EnumBody", + "EnumConstant", + "TypeParameters", + "TypeParameter", + "TypeBound", + "ClassOrInterfaceBody", + "ClassOrInterfaceBodyDeclaration", + "FieldDeclaration", + "VariableDeclarator", + "VariableDeclaratorId", + "VariableInitializer", + "ArrayInitializer", + "MethodDeclaration", + "MethodDeclarator", + "FormalParameters", + "FormalParameter", + "ConstructorDeclaration", + "ExplicitConstructorInvocation", + "Initializer", + "Type", + "ReferenceType", + "ClassOrInterfaceType", + "TypeArguments", + "TypeArgument", + "WildcardBounds", + "PrimitiveType", + "ResultType", + "Name", + "NameList", + "Expression", + "AssignmentOperator", + "AssignmentExpression", + "ConditionalExpression", + "ConditionalOrExpression", + "ConditionalAndExpression", + "InclusiveOrExpression", + "ExclusiveOrExpression", + "AndExpression", + "EqualityExpression", + "InstanceOfExpression", + "RelationalExpression", + "ShiftExpression", + "AdditiveExpression", + "MultiplicativeExpression", + "UnaryExpression", + "PreIncrementExpression", + "PreDecrementExpression", + "UnaryExpressionNotPlusMinus", + "CastLookahead", + "PostfixExpression", + "PostfixOperator", + "CastExpression", + "PrimaryExpression", + "MemberSelector", + "PrimaryPrefix", + "PrimarySuffix", + "Literal", + "BooleanLiteral", + "NullLiteral", + "Arguments", + "ArgumentList", + "AllocationExpression", + "ArrayDimsAndInits", + "Statement", + "AssertStatement", + "LabeledStatement", + "Block", + "BlockStatement", + "LocalVariableDeclaration", + "EmptyStatement", + "StatementExpression", + "SwitchStatement", + "SwitchLabel", + "IfStatement", + "WhileStatement", + "DoStatement", + "ForStatement", + "ForInit", + "StatementExpressionList", + "ForUpdate", + "BreakStatement", + "ContinueStatement", + "ReturnStatement", + "ThrowStatement", + "SynchronizedStatement", + "TryStatement", + "RUNSIGNEDSHIFT", + "RSIGNEDSHIFT", + "Annotation", + "NormalAnnotation", + "MarkerAnnotation", + "SingleMemberAnnotation", + "MemberValuePairs", + "MemberValuePair", + "MemberValue", + "MemberValueArrayInitializer", + "AnnotationTypeDeclaration", + "AnnotationTypeBody", + "AnnotationTypeMemberDeclaration", + "DefaultValue", + }; +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Node.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Node.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Node.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,71 +0,0 @@ -/* Generated By:JJTree: Do not edit this line. Node.java */ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ - -package jaxx.compiler.java.parser; - -/* All AST nodes must implement this interface. It provides basic - machinery for constructing the parent and child relationships - between nodes. */ - -public interface Node { - - /** - * This method is called after the node has been made the current - * node. It indicates that child nodes can now be added to it. - */ - public void jjtOpen(); - - /** - * This method is called after all the child nodes have been - * added. - */ - public void jjtClose(); - - /** - * This pair of methods are used to inform the node of its - * parent. - * - * @param n node - */ - public void jjtSetParent(Node n); - - public Node jjtGetParent(); - - /** - * This method tells the node to add its argument to the node's - * list of children. - * - * @param n node - * @param i index ? - */ - public void jjtAddChild(Node n, int i); - - /** - * @param i index of child - * @return a child node. The children are numbered - * from zero, left to right. - */ - public Node jjtGetChild(int i); - - /** @return the number of children the node has. */ - public int jjtGetNumChildren(); -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Node.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Node.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Node.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Node.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,71 @@ +/* Generated By:JJTree: Do not edit this line. Node.java */ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ + +package jaxx.compiler.java.parser; + +/* All AST nodes must implement this interface. It provides basic + machinery for constructing the parent and child relationships + between nodes. */ + +public interface Node { + + /** + * This method is called after the node has been made the current + * node. It indicates that child nodes can now be added to it. + */ + public void jjtOpen(); + + /** + * This method is called after all the child nodes have been + * added. + */ + public void jjtClose(); + + /** + * This pair of methods are used to inform the node of its + * parent. + * + * @param n node + */ + public void jjtSetParent(Node n); + + public Node jjtGetParent(); + + /** + * This method tells the node to add its argument to the node's + * list of children. + * + * @param n node + * @param i index ? + */ + public void jjtAddChild(Node n, int i); + + /** + * @param i index of child + * @return a child node. The children are numbered + * from zero, left to right. + */ + public Node jjtGetChild(int i); + + /** @return the number of children the node has. */ + public int jjtGetNumChildren(); +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/ParseException.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/ParseException.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/ParseException.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,234 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 3.0 */ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.java.parser; - -/** - * This exception is thrown when parse errors are encountered. - * You can explicitly create objects of this exception type by - * calling the method generateParseException in the generated - * parser. - * <p/> - * You can modify this class to customize your error reporting - * mechanisms so long as you retain the public fields. - */ -public class ParseException extends jaxx.compiler.CompilerException { - int line; - int column; - private static final long serialVersionUID = 6179854408401024700L; - - /** - * This constructor is used by the method "generateParseException" - * in the generated parser. Calling this constructor generates - * a new object of this type with the fields "currentToken", - * "expectedTokenSequences", and "tokenImage" set. The boolean - * flag "specialConstructor" is also set to true to indicate that - * this constructor was used to create this object. - * This constructor calls its super class with the empty string - * to force the "toString" method of parent class "Throwable" to - * print the error message in the form: - * ParseException: <result of getMessage> - * - * @param currentTokenVal ? - * @param expectedTokenSequencesVal ? - * @param tokenImageVal ? - */ - public ParseException(Token currentTokenVal, - int[][] expectedTokenSequencesVal, - String[] tokenImageVal - ) { - super(""); - specialConstructor = true; - currentToken = currentTokenVal; - expectedTokenSequences = expectedTokenSequencesVal; - tokenImage = tokenImageVal; - } - - /** - * The following constructors are for use by you for whatever - * purpose you can think of. Constructing the exception in this - * manner makes the exception behave in the normal way - i.e., as - * documented in the class "Throwable". The fields "errorToken", - * "expectedTokenSequences", and "tokenImage" do not contain - * relevant information. The JavaCC generated code does not use - * these constructors. - */ - - public ParseException() { - super(); - specialConstructor = false; - } - - public ParseException(String message) { - super(message); - specialConstructor = false; - } - - public ParseException(String message, int line, int column) { - super(message); - specialConstructor = false; - this.line = line; - this.column = column; - } - - - /** - * This variable determines which constructor was used to create - * this object and thereby affects the semantics of the - * "getMessage" method (see below). - */ - protected boolean specialConstructor; - - /** - * This is the last token that has been consumed successfully. If - * this object has been created due to a parse error, the token - * followng this token will (therefore) be the first error token. - */ - public Token currentToken; - - /** - * Each entry in this array is an array of integers. Each array - * of integers represents a sequence of tokens (by their ordinal - * values) that is expected at this point of the parse. - */ - public int[][] expectedTokenSequences; - - /** - * This is a reference to the "tokenImage" array of the generated - * parser within which the parse error occurred. This array is - * defined in the generated ...Constants interface. - */ - public String[] tokenImage; - - /** - * This method has the standard behavior when this object has been - * created using the standard constructors. Otherwise, it uses - * "currentToken" and "expectedTokenSequences" to generate a parse - * error message and returns it. If this object has been created - * due to a parse error, and you do not catch it (it gets thrown - * from the parser), then this method is called during the printing - * of the final stack trace, and hence the correct error message - * gets displayed. - */ - public String getMessage() { - if (!specialConstructor) { - return super.getMessage(); - } - StringBuffer expected = new StringBuffer(); - int maxSize = 0; - for (int[] expectedTokenSequence : expectedTokenSequences) { - if (maxSize < expectedTokenSequence.length) { - maxSize = expectedTokenSequence.length; - } - for (int anExpectedTokenSequence : expectedTokenSequence) { - expected.append(tokenImage[anExpectedTokenSequence]).append(" "); - } - if (expectedTokenSequence[expectedTokenSequence.length - 1] != 0) { - expected.append("..."); - } - expected.append(eol).append(" "); - } - String retval = "Encountered \""; - Token tok = currentToken.next; - for (int i = 0; i < maxSize; i++) { - if (i != 0) retval += " "; - if (tok.kind == 0) { - retval += tokenImage[0]; - break; - } - retval += add_escapes(tok.image); - tok = tok.next; - } - retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn; - retval += "." + eol; - if (expectedTokenSequences.length == 1) { - retval += "Was expecting:" + eol + " "; - } else { - retval += "Was expecting one of:" + eol + " "; - } - retval += expected.toString(); - return retval; - } - - - public int getLine() { - return line; - } - - public int getColumn() { - return column; - } - - /** The end of line string for this machine. */ - protected String eol = System.getProperty("line.separator", "\n"); - - /** - * Used to convert raw characters to their escaped version - * when these raw version cannot be used as part of an ASCII - * string literal. - * - * @param str text to treate - * @return the escaped version of text - */ - protected String add_escapes(String str) { - StringBuffer retval = new StringBuffer(); - char ch; - for (int i = 0; i < str.length(); i++) { - switch (str.charAt(i)) { - case 0: - continue; - case '\b': - retval.append("\\b"); - continue; - case '\t': - retval.append("\\t"); - continue; - case '\n': - retval.append("\\n"); - continue; - case '\f': - retval.append("\\f"); - continue; - case '\r': - retval.append("\\r"); - continue; - case '\"': - retval.append("\\\""); - continue; - case '\'': - retval.append("\\\'"); - continue; - case '\\': - retval.append("\\\\"); - continue; - default: - if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { - String s = "0000" + Integer.toString(ch, 16); - retval.append("\\u").append(s.substring(s.length() - 4, s.length())); - } else { - retval.append(ch); - } - } - } - return retval.toString(); - } - -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/ParseException.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/ParseException.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/ParseException.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/ParseException.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,234 @@ +/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 3.0 */ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.java.parser; + +/** + * This exception is thrown when parse errors are encountered. + * You can explicitly create objects of this exception type by + * calling the method generateParseException in the generated + * parser. + * <p/> + * You can modify this class to customize your error reporting + * mechanisms so long as you retain the public fields. + */ +public class ParseException extends jaxx.compiler.CompilerException { + int line; + int column; + private static final long serialVersionUID = 6179854408401024700L; + + /** + * This constructor is used by the method "generateParseException" + * in the generated parser. Calling this constructor generates + * a new object of this type with the fields "currentToken", + * "expectedTokenSequences", and "tokenImage" set. The boolean + * flag "specialConstructor" is also set to true to indicate that + * this constructor was used to create this object. + * This constructor calls its super class with the empty string + * to force the "toString" method of parent class "Throwable" to + * print the error message in the form: + * ParseException: <result of getMessage> + * + * @param currentTokenVal ? + * @param expectedTokenSequencesVal ? + * @param tokenImageVal ? + */ + public ParseException(Token currentTokenVal, + int[][] expectedTokenSequencesVal, + String[] tokenImageVal + ) { + super(""); + specialConstructor = true; + currentToken = currentTokenVal; + expectedTokenSequences = expectedTokenSequencesVal; + tokenImage = tokenImageVal; + } + + /** + * The following constructors are for use by you for whatever + * purpose you can think of. Constructing the exception in this + * manner makes the exception behave in the normal way - i.e., as + * documented in the class "Throwable". The fields "errorToken", + * "expectedTokenSequences", and "tokenImage" do not contain + * relevant information. The JavaCC generated code does not use + * these constructors. + */ + + public ParseException() { + super(); + specialConstructor = false; + } + + public ParseException(String message) { + super(message); + specialConstructor = false; + } + + public ParseException(String message, int line, int column) { + super(message); + specialConstructor = false; + this.line = line; + this.column = column; + } + + + /** + * This variable determines which constructor was used to create + * this object and thereby affects the semantics of the + * "getMessage" method (see below). + */ + protected boolean specialConstructor; + + /** + * This is the last token that has been consumed successfully. If + * this object has been created due to a parse error, the token + * followng this token will (therefore) be the first error token. + */ + public Token currentToken; + + /** + * Each entry in this array is an array of integers. Each array + * of integers represents a sequence of tokens (by their ordinal + * values) that is expected at this point of the parse. + */ + public int[][] expectedTokenSequences; + + /** + * This is a reference to the "tokenImage" array of the generated + * parser within which the parse error occurred. This array is + * defined in the generated ...Constants interface. + */ + public String[] tokenImage; + + /** + * This method has the standard behavior when this object has been + * created using the standard constructors. Otherwise, it uses + * "currentToken" and "expectedTokenSequences" to generate a parse + * error message and returns it. If this object has been created + * due to a parse error, and you do not catch it (it gets thrown + * from the parser), then this method is called during the printing + * of the final stack trace, and hence the correct error message + * gets displayed. + */ + public String getMessage() { + if (!specialConstructor) { + return super.getMessage(); + } + StringBuffer expected = new StringBuffer(); + int maxSize = 0; + for (int[] expectedTokenSequence : expectedTokenSequences) { + if (maxSize < expectedTokenSequence.length) { + maxSize = expectedTokenSequence.length; + } + for (int anExpectedTokenSequence : expectedTokenSequence) { + expected.append(tokenImage[anExpectedTokenSequence]).append(" "); + } + if (expectedTokenSequence[expectedTokenSequence.length - 1] != 0) { + expected.append("..."); + } + expected.append(eol).append(" "); + } + String retval = "Encountered \""; + Token tok = currentToken.next; + for (int i = 0; i < maxSize; i++) { + if (i != 0) retval += " "; + if (tok.kind == 0) { + retval += tokenImage[0]; + break; + } + retval += add_escapes(tok.image); + tok = tok.next; + } + retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn; + retval += "." + eol; + if (expectedTokenSequences.length == 1) { + retval += "Was expecting:" + eol + " "; + } else { + retval += "Was expecting one of:" + eol + " "; + } + retval += expected.toString(); + return retval; + } + + + public int getLine() { + return line; + } + + public int getColumn() { + return column; + } + + /** The end of line string for this machine. */ + protected String eol = System.getProperty("line.separator", "\n"); + + /** + * Used to convert raw characters to their escaped version + * when these raw version cannot be used as part of an ASCII + * string literal. + * + * @param str text to treate + * @return the escaped version of text + */ + protected String add_escapes(String str) { + StringBuffer retval = new StringBuffer(); + char ch; + for (int i = 0; i < str.length(); i++) { + switch (str.charAt(i)) { + case 0: + continue; + case '\b': + retval.append("\\b"); + continue; + case '\t': + retval.append("\\t"); + continue; + case '\n': + retval.append("\\n"); + continue; + case '\f': + retval.append("\\f"); + continue; + case '\r': + retval.append("\\r"); + continue; + case '\"': + retval.append("\\\""); + continue; + case '\'': + retval.append("\\\'"); + continue; + case '\\': + retval.append("\\\\"); + continue; + default: + if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { + String s = "0000" + Integer.toString(ch, 16); + retval.append("\\u").append(s.substring(s.length() - 4, s.length())); + } else { + retval.append(ch); + } + } + } + return retval.toString(); + } + +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/SimpleNode.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/SimpleNode.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/SimpleNode.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,155 +0,0 @@ -/* Generated By:JJTree: Do not edit this line. SimpleNode.java */ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ - -package jaxx.compiler.java.parser; - -import jaxx.compiler.reflect.ClassDescriptor; - -public class SimpleNode implements Node { - protected Node parent; - protected Node[] children; - protected int id; - protected JavaParser parser; - public Token firstToken; - public Token lastToken; - private ClassDescriptor javaType; - - - public SimpleNode(int i) { - id = i; - } - - public SimpleNode(JavaParser p, int i) { - this(i); - parser = p; - } - - - public int getId() { - return id; - } - - public void jjtOpen() { - } - - public void jjtClose() { - } - - public void jjtSetParent(Node n) { - parent = n; - } - - public Node jjtGetParent() { - return parent; - } - - public SimpleNode getParent() { - return (SimpleNode) parent; - } - - - public ClassDescriptor getJavaType() { - return javaType; - } - - - public void setJavaType(ClassDescriptor javaType) { - this.javaType = javaType; - } - - public void jjtAddChild(Node n, int i) { - if (children == null) { - children = new Node[i + 1]; - } else if (i >= children.length) { - Node c[] = new Node[i + 1]; - System.arraycopy(children, 0, c, 0, children.length); - children = c; - } - children[i] = n; - } - - public Node jjtGetChild(int i) { - return children[i]; - } - - public SimpleNode getChild(int i) { - return (SimpleNode) children[i]; - } - - public int jjtGetNumChildren() { - return (children == null) ? 0 : children.length; - } - - /* You can override these two methods in subclasses of SimpleNode to -customize the way the node appears when the tree is dumped. If -your output uses more than one line you should override -toString(String), otherwise overriding toString() is probably all -you need to do. */ - - @Override - public String toString() { - return getClass().getName() + "[" + getText() + "]"; - } - - public String toString(String prefix) { - return prefix + toString(); - } - - /* Override this method if you want to customize how the node dumps - out its children. */ - - public void dump(String prefix) { - System.out.println(toString(prefix)); - if (children != null) { - for (Node aChildren : children) { - SimpleNode n = (SimpleNode) aChildren; - if (n != null) { - n.dump(prefix + " "); - } - } - } - } - - private void appendSpecialTokens(StringBuffer s, Token st) { - if (st != null) { - appendSpecialTokens(s, st.specialToken); - s.append(st.image); - } - } - - - /** @return the text of the tokens comprising this node. */ - public String getText() { - StringBuffer text = new StringBuffer(); - Token t = firstToken; - while (t != null) { - appendSpecialTokens(text, t.specialToken); - text.append(t.image); - if (t == lastToken) - break; - t = t.next; - } - - return text.toString(); - } -} - Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/SimpleNode.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/SimpleNode.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/SimpleNode.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/SimpleNode.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,155 @@ +/* Generated By:JJTree: Do not edit this line. SimpleNode.java */ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ + +package jaxx.compiler.java.parser; + +import jaxx.compiler.reflect.ClassDescriptor; + +public class SimpleNode implements Node { + protected Node parent; + protected Node[] children; + protected int id; + protected JavaParser parser; + public Token firstToken; + public Token lastToken; + private ClassDescriptor javaType; + + + public SimpleNode(int i) { + id = i; + } + + public SimpleNode(JavaParser p, int i) { + this(i); + parser = p; + } + + + public int getId() { + return id; + } + + public void jjtOpen() { + } + + public void jjtClose() { + } + + public void jjtSetParent(Node n) { + parent = n; + } + + public Node jjtGetParent() { + return parent; + } + + public SimpleNode getParent() { + return (SimpleNode) parent; + } + + + public ClassDescriptor getJavaType() { + return javaType; + } + + + public void setJavaType(ClassDescriptor javaType) { + this.javaType = javaType; + } + + public void jjtAddChild(Node n, int i) { + if (children == null) { + children = new Node[i + 1]; + } else if (i >= children.length) { + Node c[] = new Node[i + 1]; + System.arraycopy(children, 0, c, 0, children.length); + children = c; + } + children[i] = n; + } + + public Node jjtGetChild(int i) { + return children[i]; + } + + public SimpleNode getChild(int i) { + return (SimpleNode) children[i]; + } + + public int jjtGetNumChildren() { + return (children == null) ? 0 : children.length; + } + + /* You can override these two methods in subclasses of SimpleNode to +customize the way the node appears when the tree is dumped. If +your output uses more than one line you should override +toString(String), otherwise overriding toString() is probably all +you need to do. */ + + @Override + public String toString() { + return getClass().getName() + "[" + getText() + "]"; + } + + public String toString(String prefix) { + return prefix + toString(); + } + + /* Override this method if you want to customize how the node dumps + out its children. */ + + public void dump(String prefix) { + System.out.println(toString(prefix)); + if (children != null) { + for (Node aChildren : children) { + SimpleNode n = (SimpleNode) aChildren; + if (n != null) { + n.dump(prefix + " "); + } + } + } + } + + private void appendSpecialTokens(StringBuffer s, Token st) { + if (st != null) { + appendSpecialTokens(s, st.specialToken); + s.append(st.image); + } + } + + + /** @return the text of the tokens comprising this node. */ + public String getText() { + StringBuffer text = new StringBuffer(); + Token t = firstToken; + while (t != null) { + appendSpecialTokens(text, t.specialToken); + text.append(t.image); + if (t == lastToken) + break; + t = t.next; + } + + return text.toString(); + } +} + Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Token.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Token.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Token.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,99 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.java.parser; - -/** Describes the input token stream. */ - -public class Token { - /** - * An integer that describes the kind of this token. This numbering - * system is determined by JavaCCParser, and a table of these numbers is - * stored in the file ...Constants.java. - */ - public int kind; - - /** - * beginLine and beginColumn describe the position of the first character - * of this token; endLine and endColumn describe the position of the - * last character of this token. - */ - public int beginLine, beginColumn, endLine, endColumn; - - /** The string image of the token. */ - public String image; - - /** - * A reference to the next regular (non-special) token from the input - * stream. If this is the last token from the input stream, or if the - * token manager has not read tokens beyond this one, this field is - * set to null. This is true only if this token is also a regular - * token. Otherwise, see below for a description of the contents of - * this field. - */ - public Token next; - - /** - * This field is used to access special tokens that occur prior to this - * token, but after the immediately preceding regular (non-special) token. - * If there are no such special tokens, this field is set to null. - * When there are more than one such special token, this field refers - * to the last of these special tokens, which in turn refers to the next - * previous special token through its specialToken field, and so on - * until the first special token (whose specialToken field is null). - * The next fields of special tokens refer to other special tokens that - * immediately follow it (without an intervening regular token). If there - * is no such token, this field is null. - */ - public Token specialToken; - - /** Returns the image. */ - public String toString() { - return image; - } - - /** - * Returns a new Token object, by default. However, if you want, you - * can create and return subclass objects based on the value of ofKind. - * Simply add the cases to the switch for all those special cases. - * For example, if you have a subclass of Token called IDToken that - * you want to create if ofKind is ID, simlpy add something like : - * <p/> - * case MyParserConstants.ID : return new IDToken(); - * <p/> - * to the following switch statement. Then you can cast matchedToken - * variable to the appropriate type and use it in your lexical actions. - */ - public static final Token newToken(int ofKind) { - switch (ofKind) { - default: - return new Token(); - case JavaParserConstants.RUNSIGNEDSHIFT: - case JavaParserConstants.RSIGNEDSHIFT: - case JavaParserConstants.GT: - return new GTToken(); - } - } - - public static class GTToken extends Token { - int realKind = JavaParserConstants.GT; - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Token.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Token.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Token.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/Token.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,99 @@ +/* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.java.parser; + +/** Describes the input token stream. */ + +public class Token { + /** + * An integer that describes the kind of this token. This numbering + * system is determined by JavaCCParser, and a table of these numbers is + * stored in the file ...Constants.java. + */ + public int kind; + + /** + * beginLine and beginColumn describe the position of the first character + * of this token; endLine and endColumn describe the position of the + * last character of this token. + */ + public int beginLine, beginColumn, endLine, endColumn; + + /** The string image of the token. */ + public String image; + + /** + * A reference to the next regular (non-special) token from the input + * stream. If this is the last token from the input stream, or if the + * token manager has not read tokens beyond this one, this field is + * set to null. This is true only if this token is also a regular + * token. Otherwise, see below for a description of the contents of + * this field. + */ + public Token next; + + /** + * This field is used to access special tokens that occur prior to this + * token, but after the immediately preceding regular (non-special) token. + * If there are no such special tokens, this field is set to null. + * When there are more than one such special token, this field refers + * to the last of these special tokens, which in turn refers to the next + * previous special token through its specialToken field, and so on + * until the first special token (whose specialToken field is null). + * The next fields of special tokens refer to other special tokens that + * immediately follow it (without an intervening regular token). If there + * is no such token, this field is null. + */ + public Token specialToken; + + /** Returns the image. */ + public String toString() { + return image; + } + + /** + * Returns a new Token object, by default. However, if you want, you + * can create and return subclass objects based on the value of ofKind. + * Simply add the cases to the switch for all those special cases. + * For example, if you have a subclass of Token called IDToken that + * you want to create if ofKind is ID, simlpy add something like : + * <p/> + * case MyParserConstants.ID : return new IDToken(); + * <p/> + * to the following switch statement. Then you can cast matchedToken + * variable to the appropriate type and use it in your lexical actions. + */ + public static final Token newToken(int ofKind) { + switch (ofKind) { + default: + return new Token(); + case JavaParserConstants.RUNSIGNEDSHIFT: + case JavaParserConstants.RSIGNEDSHIFT: + case JavaParserConstants.GT: + return new GTToken(); + } + } + + public static class GTToken extends Token { + int realKind = JavaParserConstants.GT; + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/TokenMgrError.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/TokenMgrError.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/TokenMgrError.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,146 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 */ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.java.parser; - -public class TokenMgrError extends Error { - /* - * Ordinals for various reasons why an Error of this type can be thrown. - */ - - /** Lexical error occured. */ - static final int LEXICAL_ERROR = 0; - - /** An attempt wass made to create a second instance of a static token manager. */ - static final int STATIC_LEXER_ERROR = 1; - - /** Tried to change to an invalid lexical state. */ - static final int INVALID_LEXICAL_STATE = 2; - - /** Detected (and bailed out of) an infinite loop in the token manager. */ - static final int LOOP_DETECTED = 3; - - /** - * Indicates the reason why the exception is thrown. It will have - * one of the above 4 values. - */ - int errorCode; - private static final long serialVersionUID = -9131500865453532454L; - - /** - * Replaces unprintable characters by their espaced (or unicode escaped) - * equivalents in the given string - * - * @param str text to treate - * @return the treated text - */ - protected static String addEscapes(String str) { - StringBuffer retval = new StringBuffer(); - char ch; - for (int i = 0; i < str.length(); i++) { - switch (str.charAt(i)) { - case 0: - continue; - case '\b': - retval.append("\\b"); - continue; - case '\t': - retval.append("\\t"); - continue; - case '\n': - retval.append("\\n"); - continue; - case '\f': - retval.append("\\f"); - continue; - case '\r': - retval.append("\\r"); - continue; - case '\"': - retval.append("\\\""); - continue; - case '\'': - retval.append("\\\'"); - continue; - case '\\': - retval.append("\\\\"); - continue; - default: - if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { - String s = "0000" + Integer.toString(ch, 16); - retval.append("\\u").append(s.substring(s.length() - 4, s.length())); - } else { - retval.append(ch); - } - } - } - return retval.toString(); - } - - /** - * @param EOFSeen : indicates if EOF caused the lexicl error - * @param lexState : lexical state in which this error occured - * @param errorLine : line number when the error occured - * @param errorColumn : column number when the error occured - * @param errorAfter : prefix that was seen before this error occured - * @param curChar : the offending character - * Note: You can customize the lexical error message by modifying this method. - * @return a detailed message for the Error when it is thrown by the - * token manager to indicate a lexical error. - */ - protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { - return ("Lexical error at line " + - errorLine + ", column " + - errorColumn + ". Encountered: " + - (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int) curChar + "), ") + - "after : \"" + addEscapes(errorAfter) + "\""); - } - - /** - * You can also modify the body of this method to customize your error messages. - * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not - * of end-users concern, so you can return something like : - * <p/> - * "Internal Error : Please file a bug report .... " - * <p/> - * from this method for such cases in the release version of your parser. - */ - @Override - public String getMessage() { - return super.getMessage(); - } - - /* - * Constructors of various flavors follow. - */ - - public TokenMgrError() { - } - - public TokenMgrError(String message, int reason) { - super(message); - errorCode = reason; - } - - public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { - this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/TokenMgrError.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/TokenMgrError.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/TokenMgrError.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/TokenMgrError.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,146 @@ +/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 */ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.java.parser; + +public class TokenMgrError extends Error { + /* + * Ordinals for various reasons why an Error of this type can be thrown. + */ + + /** Lexical error occured. */ + static final int LEXICAL_ERROR = 0; + + /** An attempt wass made to create a second instance of a static token manager. */ + static final int STATIC_LEXER_ERROR = 1; + + /** Tried to change to an invalid lexical state. */ + static final int INVALID_LEXICAL_STATE = 2; + + /** Detected (and bailed out of) an infinite loop in the token manager. */ + static final int LOOP_DETECTED = 3; + + /** + * Indicates the reason why the exception is thrown. It will have + * one of the above 4 values. + */ + int errorCode; + private static final long serialVersionUID = -9131500865453532454L; + + /** + * Replaces unprintable characters by their espaced (or unicode escaped) + * equivalents in the given string + * + * @param str text to treate + * @return the treated text + */ + protected static String addEscapes(String str) { + StringBuffer retval = new StringBuffer(); + char ch; + for (int i = 0; i < str.length(); i++) { + switch (str.charAt(i)) { + case 0: + continue; + case '\b': + retval.append("\\b"); + continue; + case '\t': + retval.append("\\t"); + continue; + case '\n': + retval.append("\\n"); + continue; + case '\f': + retval.append("\\f"); + continue; + case '\r': + retval.append("\\r"); + continue; + case '\"': + retval.append("\\\""); + continue; + case '\'': + retval.append("\\\'"); + continue; + case '\\': + retval.append("\\\\"); + continue; + default: + if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { + String s = "0000" + Integer.toString(ch, 16); + retval.append("\\u").append(s.substring(s.length() - 4, s.length())); + } else { + retval.append(ch); + } + } + } + return retval.toString(); + } + + /** + * @param EOFSeen : indicates if EOF caused the lexicl error + * @param lexState : lexical state in which this error occured + * @param errorLine : line number when the error occured + * @param errorColumn : column number when the error occured + * @param errorAfter : prefix that was seen before this error occured + * @param curChar : the offending character + * Note: You can customize the lexical error message by modifying this method. + * @return a detailed message for the Error when it is thrown by the + * token manager to indicate a lexical error. + */ + protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { + return ("Lexical error at line " + + errorLine + ", column " + + errorColumn + ". Encountered: " + + (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int) curChar + "), ") + + "after : \"" + addEscapes(errorAfter) + "\""); + } + + /** + * You can also modify the body of this method to customize your error messages. + * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not + * of end-users concern, so you can return something like : + * <p/> + * "Internal Error : Please file a bug report .... " + * <p/> + * from this method for such cases in the release version of your parser. + */ + @Override + public String getMessage() { + return super.getMessage(); + } + + /* + * Constructors of various flavors follow. + */ + + public TokenMgrError() { + } + + public TokenMgrError(String message, int reason) { + super(message); + errorCode = reason; + } + + public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { + this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptor.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptor.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptor.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,169 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.reflect; - -import jaxx.runtime.JAXXObjectDescriptor; - -import java.util.Arrays; - -/** - * Mirrors the class <code>java.lang.Class</code>. JAXX uses <code>ClassDescriptor</code> instead of <code>Class</code> - * almost everywhere so that it can handle circular dependencies (there can't be a <code>Class</code> object for an uncompiled - * JAXX or Java source file, and a compiler must be allow references to symbols in uncompiled source files in order to handle - * circular dependencies). - */ -public abstract class ClassDescriptor { - - private String name; - private String packageName; - private String superclass; - private String[] interfaces; - private boolean isInterface; - private boolean isArray; - private String componentType; - private JAXXObjectDescriptor jaxxObjectDescriptor; - private ClassLoader classLoader; - private MethodDescriptor[] methodDescriptors; - private FieldDescriptor[] fieldDescriptors; - - public abstract MethodDescriptor getDeclaredMethodDescriptor(String name, ClassDescriptor... parameterTypes) throws NoSuchMethodException; - - public abstract FieldDescriptor getDeclaredFieldDescriptor(String name) throws NoSuchFieldException; - - ClassDescriptor(String name, String packageName, String superclass, String[] interfaces, boolean isInterface, - boolean isArray, String componentType, JAXXObjectDescriptor jaxxObjectDescriptor, - ClassLoader classLoader, MethodDescriptor[] methodDescriptors, FieldDescriptor[] fieldDescriptors) { - this.name = name; - this.packageName = packageName; - this.superclass = superclass; - this.interfaces = interfaces; - this.isInterface = isInterface; - this.isArray = isArray; - this.componentType = componentType; - this.jaxxObjectDescriptor = jaxxObjectDescriptor; - this.classLoader = classLoader; - this.methodDescriptors = methodDescriptors; - this.fieldDescriptors = fieldDescriptors; - } - - public String getName() { - return name; - } - - public String getSimpleName() { - int dot = name.lastIndexOf("."); - return dot == -1 ? name : name.substring(dot + 1); - } - - public String getPackageName() { - return packageName; - } - - public ClassDescriptor getSuperclass() { - try { - return superclass != null ? ClassDescriptorLoader.getClassDescriptor(superclass, getClassLoader()) : null; - } catch (ClassNotFoundException e) { - throw new RuntimeException(e); - } - } - - public ClassDescriptor[] getInterfaces() { - try { - ClassDescriptor[] result = new ClassDescriptor[interfaces.length]; - for (int i = 0; i < result.length; i++) { - result[i] = ClassDescriptorLoader.getClassDescriptor(interfaces[i], getClassLoader()); - } - return result; - } catch (ClassNotFoundException e) { - throw new RuntimeException(e); - } - } - - public boolean isInterface() { - return isInterface; - } - - public boolean isArray() { - return isArray; - } - - public ClassDescriptor getComponentType() { - try { - return componentType != null ? ClassDescriptorLoader.getClassDescriptor(componentType, getClassLoader()) : null; - } catch (ClassNotFoundException e) { - throw new RuntimeException(e); - } - } - - public ClassLoader getClassLoader() { - return classLoader; - } - - public MethodDescriptor[] getMethodDescriptors() { - return methodDescriptors; - } - - public MethodDescriptor getMethodDescriptor(String name, ClassDescriptor... parameterTypes) throws NoSuchMethodException { - for (MethodDescriptor methodDescriptor : methodDescriptors) { - if (methodDescriptor.getName().equals(name) && methodDescriptor.getParameterTypes().length == parameterTypes.length && Arrays.equals(methodDescriptor.getParameterTypes(), parameterTypes)) { - return methodDescriptor; - } - } - throw new NoSuchMethodException("Could not find method " + name + "(" + Arrays.asList(parameterTypes) + ") in " + getName()); - } - - public FieldDescriptor[] getFieldDescriptors() { - return fieldDescriptors; - } - - public FieldDescriptor getFieldDescriptor(String name) throws NoSuchFieldException { - for (FieldDescriptor fieldDescriptor : fieldDescriptors) { - if (fieldDescriptor.getName().equals(name)) { - return fieldDescriptor; - } - } - throw new NoSuchFieldException("Could not find field " + name + " in " + getName()); - } - - public JAXXObjectDescriptor getJAXXObjectDescriptor() { - return jaxxObjectDescriptor; - } - - public boolean isAssignableFrom(ClassDescriptor descriptor) { - while (descriptor != null) { - if (descriptor == this) { - return true; - } - for (ClassDescriptor anInterface : descriptor.getInterfaces()) { - if (anInterface == this) { - return true; - } - } - descriptor = descriptor.getSuperclass(); - } - return false; - } - - @Override - public String toString() { - return "ClassDescriptor[" + getName() + "]"; - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptor.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptor.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptor.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptor.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,169 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.reflect; + +import jaxx.runtime.JAXXObjectDescriptor; + +import java.util.Arrays; + +/** + * Mirrors the class <code>java.lang.Class</code>. JAXX uses <code>ClassDescriptor</code> instead of <code>Class</code> + * almost everywhere so that it can handle circular dependencies (there can't be a <code>Class</code> object for an uncompiled + * JAXX or Java source file, and a compiler must be allow references to symbols in uncompiled source files in order to handle + * circular dependencies). + */ +public abstract class ClassDescriptor { + + private String name; + private String packageName; + private String superclass; + private String[] interfaces; + private boolean isInterface; + private boolean isArray; + private String componentType; + private JAXXObjectDescriptor jaxxObjectDescriptor; + private ClassLoader classLoader; + private MethodDescriptor[] methodDescriptors; + private FieldDescriptor[] fieldDescriptors; + + public abstract MethodDescriptor getDeclaredMethodDescriptor(String name, ClassDescriptor... parameterTypes) throws NoSuchMethodException; + + public abstract FieldDescriptor getDeclaredFieldDescriptor(String name) throws NoSuchFieldException; + + ClassDescriptor(String name, String packageName, String superclass, String[] interfaces, boolean isInterface, + boolean isArray, String componentType, JAXXObjectDescriptor jaxxObjectDescriptor, + ClassLoader classLoader, MethodDescriptor[] methodDescriptors, FieldDescriptor[] fieldDescriptors) { + this.name = name; + this.packageName = packageName; + this.superclass = superclass; + this.interfaces = interfaces; + this.isInterface = isInterface; + this.isArray = isArray; + this.componentType = componentType; + this.jaxxObjectDescriptor = jaxxObjectDescriptor; + this.classLoader = classLoader; + this.methodDescriptors = methodDescriptors; + this.fieldDescriptors = fieldDescriptors; + } + + public String getName() { + return name; + } + + public String getSimpleName() { + int dot = name.lastIndexOf("."); + return dot == -1 ? name : name.substring(dot + 1); + } + + public String getPackageName() { + return packageName; + } + + public ClassDescriptor getSuperclass() { + try { + return superclass != null ? ClassDescriptorLoader.getClassDescriptor(superclass, getClassLoader()) : null; + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } + } + + public ClassDescriptor[] getInterfaces() { + try { + ClassDescriptor[] result = new ClassDescriptor[interfaces.length]; + for (int i = 0; i < result.length; i++) { + result[i] = ClassDescriptorLoader.getClassDescriptor(interfaces[i], getClassLoader()); + } + return result; + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } + } + + public boolean isInterface() { + return isInterface; + } + + public boolean isArray() { + return isArray; + } + + public ClassDescriptor getComponentType() { + try { + return componentType != null ? ClassDescriptorLoader.getClassDescriptor(componentType, getClassLoader()) : null; + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } + } + + public ClassLoader getClassLoader() { + return classLoader; + } + + public MethodDescriptor[] getMethodDescriptors() { + return methodDescriptors; + } + + public MethodDescriptor getMethodDescriptor(String name, ClassDescriptor... parameterTypes) throws NoSuchMethodException { + for (MethodDescriptor methodDescriptor : methodDescriptors) { + if (methodDescriptor.getName().equals(name) && methodDescriptor.getParameterTypes().length == parameterTypes.length && Arrays.equals(methodDescriptor.getParameterTypes(), parameterTypes)) { + return methodDescriptor; + } + } + throw new NoSuchMethodException("Could not find method " + name + "(" + Arrays.asList(parameterTypes) + ") in " + getName()); + } + + public FieldDescriptor[] getFieldDescriptors() { + return fieldDescriptors; + } + + public FieldDescriptor getFieldDescriptor(String name) throws NoSuchFieldException { + for (FieldDescriptor fieldDescriptor : fieldDescriptors) { + if (fieldDescriptor.getName().equals(name)) { + return fieldDescriptor; + } + } + throw new NoSuchFieldException("Could not find field " + name + " in " + getName()); + } + + public JAXXObjectDescriptor getJAXXObjectDescriptor() { + return jaxxObjectDescriptor; + } + + public boolean isAssignableFrom(ClassDescriptor descriptor) { + while (descriptor != null) { + if (descriptor == this) { + return true; + } + for (ClassDescriptor anInterface : descriptor.getInterfaces()) { + if (anInterface == this) { + return true; + } + } + descriptor = descriptor.getSuperclass(); + } + return false; + } + + @Override + public String toString() { + return "ClassDescriptor[" + getName() + "]"; + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptorLoader.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptorLoader.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptorLoader.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,447 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.reflect; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.JAXXEngine; -import jaxx.compiler.SymbolTable; -import jaxx.runtime.JAXXObject; -import jaxx.runtime.JAXXObjectDescriptor; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.net.URL; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * Mirrors the class <code>java.lang.ClassLoader</code>. JAXX uses <code>ClassDescriptor</code> instead of <code>Class</code> - * almost everywhere so that it can handle circular dependencies (there can't be a <code>Class</code> object for an uncompiled - * JAXX or Java source file, and a compiler must be allow references to symbols in uncompiled source files in order to handle - * circular dependencies). - */ -public class ClassDescriptorLoader { - - private static Map<String, ClassDescriptor> descriptors = new HashMap<String, ClassDescriptor>(); - - private ClassDescriptorLoader() { - } - - public static synchronized ClassDescriptor getClassDescriptor(String className) throws ClassNotFoundException { - return getClassDescriptor(className, Thread.currentThread().getContextClassLoader()); - //return getClassDescriptor(className, ClassDescriptorLoader.class.getClassLoader()); - } - - public static synchronized ClassDescriptor getClassDescriptor(String className, ClassLoader classLoader) throws ClassNotFoundException { - ClassDescriptor result = descriptors.get(className); - if (result != null) { - return result; - } - -// if (result == null) { - if (JAXXEngine.isRegistred() && JAXXEngine.get().getSymbolTable(className) != null) { - result = createClassDescriptorFromSymbolTable(className, classLoader); - } else { - if (classLoader == null) { - classLoader = ClassDescriptorLoader.class.getClassLoader(); - } - - String relativePath = className.replaceAll("\\.", "/"); - String relativePathPattern = ".*";// + className + ".*"; // used to ensure that the located resource has the right character cases - - // find the most recently updated source for the class -- Java source, JAXX source, or compiled class file - long javaLastModified = -1; - URL javaFile = classLoader.getResource(relativePath + ".java"); - if (javaFile != null && javaFile.toString().startsWith("file:") && javaFile.toString().matches(relativePathPattern)) { - javaLastModified = JAXXCompiler.URLtoFile(javaFile).lastModified(); - } - - long classLastModified = -1; - URL classFile = classLoader.getResource(relativePath + ".class"); - if (classFile != null && classFile.toString().startsWith("file:") && classFile.toString().matches(relativePathPattern)) { - classLastModified = JAXXCompiler.URLtoFile(classFile).lastModified(); - } - - long jaxxLastModified = -1; - URL jaxxFile = classLoader.getResource(relativePath + ".jaxx"); - if (jaxxFile != null && jaxxFile.toString().startsWith("file:") && jaxxFile.toString().matches(relativePathPattern)) { - File jaxxFilePath = JAXXCompiler.URLtoFile(jaxxFile); - jaxxLastModified = jaxxFilePath.lastModified(); - String simplePath = jaxxFilePath.getPath(); - simplePath = simplePath.substring(0, simplePath.length() - ".jaxx".length()); - File cssFilePath = new File(simplePath + ".css"); - if (cssFilePath.exists()) { - jaxxLastModified = Math.max(jaxxLastModified, cssFilePath.lastModified()); - } - File scriptFilePath = new File(simplePath + ".script"); - if (scriptFilePath.exists()) { - jaxxLastModified = Math.max(jaxxLastModified, scriptFilePath.lastModified()); - } - } - - if (jaxxLastModified != -1 && JAXXEngine.isRegistred() && JAXXEngine.get().getSymbolTable(className) == null) { - jaxxLastModified = -1; // file has been modified, but wasn't included in this - } - // compilation set so we don't have a symbol table - - if (javaLastModified != -1 || classLastModified != -1 || jaxxLastModified != -1) { - if (jaxxLastModified > classLastModified && jaxxLastModified > javaLastModified) { - result = createClassDescriptorFromSymbolTable(className, classLoader); - } else if (javaLastModified > classLastModified && javaLastModified > jaxxLastModified) { - result = createClassDescriptorFromJavaSource(javaFile, classLoader); - } - } - // else work off of the class file. This also handles the case where the class is available, but wasn't in a location where - // we could check its last modified date (in a JAR, over the network, etc.) - if (result == null) { - Class<?> javaClass = getClass(className, classLoader); - result = createClassDescriptorFromClass(javaClass); - } - } - descriptors.put(className, result); -// } - return result; - } - - public static ClassDescriptor getClassDescriptor(Class<?> javaClass) { - try { - return getClassDescriptor(javaClass.getName(), javaClass.getClassLoader()); - } catch (ClassNotFoundException e) { - throw new RuntimeException(e); - } - } - - public static Class<?> getPrimitiveBoxedClass(String className) throws ClassNotFoundException { - if (className.equals("boolean")) { - return Boolean.class; - } - if (className.equals("byte")) { - return Byte.class; - } - if (className.equals("short")) { - return Short.class; - } - if (className.equals("int")) { - return Integer.class; - } - if (className.equals("long")) { - return Long.class; - } - if (className.equals("float")) { - return Float.class; - } - if (className.equals("double")) { - return Double.class; - } - if (className.equals("char")) { - return Character.class; - } - if (className.equals("void")) { - return Void.class; - } - return null; - } - - public static Class<?> getPrimitiveClass(String className) throws ClassNotFoundException { - if (className.equals("boolean")) { - return boolean.class; - } - if (className.equals("byte")) { - return byte.class; - } - if (className.equals("short")) { - return short.class; - } - if (className.equals("int")) { - return int.class; - } - if (className.equals("long")) { - return long.class; - } - if (className.equals("float")) { - return float.class; - } - if (className.equals("double")) { - return double.class; - } - if (className.equals("char")) { - return char.class; - } - if (className.equals("void")) { - return void.class; - } - // detect arrays - int arrayCount = 0; - while (className.endsWith("[]")) { - arrayCount++; - className = className.substring(0, className.length() - 2); - } - Class<?> klass; - if (arrayCount > 0) { - klass = getPrimitiveClass(className); - if (klass == null) { - // none primitive array - return null; - } - // must take the boxed class, other it does not works - // to make a Class.forName("[Lchar;"); but works - // with Class.forName("[LCharacter;"); ... - klass = getPrimitiveBoxedClass(className); - className = klass.getName(); - - className = "L" + className + ";"; - while (arrayCount > 0) { - className = "[" + className; - arrayCount--; - } - //System.out.println("primitive array class "+className); - return Class.forName(className); - } - return null; - } - - public static Class<?> getClass(String className, ClassLoader classLoader) throws ClassNotFoundException { - Class<?> klass = getPrimitiveClass(className); - if (klass != null) { - return klass; - } - // try an array of none primitive classes - int arrayCount = 0; - while (className.endsWith("[]")) { - arrayCount++; - className = className.substring(0, className.length() - 2); - } - if (arrayCount > 0) { - className = "L" + className + ";"; - while (arrayCount > 0) { - className = "[" + className; - arrayCount--; - } - } - try { - return classLoader != null ? Class.forName(className, true, classLoader) : Class.forName(className); - } catch (ClassNotFoundException e) { - // perharps we are in a inner class ? - int dotIndex = className.lastIndexOf("."); - if (dotIndex > -1) { - String parentFQN = className.substring(0, dotIndex); - String simpleName = className.substring(dotIndex + 1); - try { - Class<?> parentClass = classLoader != null ? Class.forName(parentFQN, true, classLoader) : Class.forName(parentFQN); - for (Class<?> innerClass : parentClass.getClasses()) { - if (simpleName.equals(innerClass.getSimpleName())) { - return innerClass; - } - } - } catch (ClassNotFoundException e1) { - // no super class,so let the first exception throw... - } - } - throw e; - } catch (NoClassDefFoundError e) { - - throw new ClassNotFoundException(e.toString()); - } - } - - private static MethodDescriptor createMethodDescriptor(Method javaMethod, ClassLoader classLoader) { - String methodName = javaMethod.getName(); - int modifiers = javaMethod.getModifiers(); - String returnType = javaMethod.getReturnType().getName(); - Class<?>[] javaParameters = javaMethod.getParameterTypes(); - String[] parameters = new String[javaParameters.length]; - for (int i = 0; i < parameters.length; i++) { - parameters[i] = javaParameters[i].getName(); - } - return new MethodDescriptor(methodName, modifiers, returnType, parameters, classLoader); - } - - private static FieldDescriptor createFieldDescriptor(Field javaField, ClassLoader classLoader) { - String fieldName = javaField.getName(); - int modifiers = javaField.getModifiers(); - String type = javaField.getType().getName(); - return new FieldDescriptor(fieldName, modifiers, type, classLoader); - } - - private static JAXXObjectDescriptor getJAXXObjectDescriptor(Class<?> jaxxClass) { - if (!JAXXObject.class.isAssignableFrom(jaxxClass) || jaxxClass == JAXXObject.class) { - return null; - } - try { - Method getJAXXObjectDescriptor = jaxxClass.getMethod("$getJAXXObjectDescriptor"); -// Method getJAXXObjectDescriptor = jaxxClass.getMethod("$getJAXXObjectDescriptor", new Class<?>[0]); - return (JAXXObjectDescriptor) getJAXXObjectDescriptor.invoke(null); - } catch (NoSuchMethodException e) { - throw new CompilerException("Expected JAXXObject " + jaxxClass.getName() + " to have a static method named $getJAXXObjectDescriptor"); - } catch (IllegalAccessException e) { - throw new CompilerException("Expected JAXXObject " + jaxxClass.getName() + "'s $getJAXXObjectDescriptor method to be public"); - } catch (InvocationTargetException e) { - throw new RuntimeException(e); - } - } - - private static ClassDescriptor createClassDescriptorFromJavaSource(URL javaSource, ClassLoader classLoader) throws ClassNotFoundException { - try { - InputStream in = javaSource.openStream(); - Reader reader = new InputStreamReader(in, "utf-8"); - ClassDescriptor result = JavaFileParser.parseJavaFile(javaSource.toString(), reader, classLoader); - reader.close(); - return result; - } catch (IOException e) { - throw new ClassNotFoundException(e.toString()); - } - } - - private static ClassDescriptor createClassDescriptorFromSymbolTable(String className, ClassLoader classLoader) throws ClassNotFoundException { - final JAXXCompiler compiler = JAXXEngine.get().getJAXXCompiler(className); - final SymbolTable symbolTable = JAXXEngine.get().getSymbolTable(className); - if (symbolTable == null) { - throw new CompilerException("Internal error: no symbol table was generated for class '" + className + "'"); - } - ClassDescriptor superclass = getClassDescriptor(symbolTable.getSuperclassName(), classLoader); - List<MethodDescriptor> publicMethods = symbolTable.getScriptMethods(); - List<FieldDescriptor> publicFields = symbolTable.getScriptFields(); - //List<MethodDescriptor> declaredMethods = new ArrayList<MethodDescriptor>(publicMethods); - //List<FieldDescriptor> declaredFields = new ArrayList<FieldDescriptor>(publicFields); - Iterator<MethodDescriptor> methods = publicMethods.iterator(); - while (methods.hasNext()) { - MethodDescriptor method = methods.next(); - if (!Modifier.isPublic(method.getModifiers())) { - methods.remove(); - } - } - Iterator<FieldDescriptor> fields = publicFields.iterator(); - while (fields.hasNext()) { - FieldDescriptor field = fields.next(); - if (!Modifier.isPublic(field.getModifiers())) { - fields.remove(); - } - } - publicMethods.addAll(Arrays.asList(superclass.getMethodDescriptors())); - publicFields.addAll(Arrays.asList(superclass.getFieldDescriptors())); - int dotPos = className.lastIndexOf("."); - String packageName = dotPos != -1 ? className.substring(0, dotPos) : null; - Set<String> interfaces = new HashSet<String>(); - ClassDescriptor[] superclassInterfaces = superclass.getInterfaces(); - for (ClassDescriptor superclassInterface : superclassInterfaces) { - interfaces.add(superclassInterface.getName()); - } - interfaces.add(JAXXObject.class.getName()); - return new ClassDescriptor(className, packageName, symbolTable.getSuperclassName(), - interfaces.toArray(new String[interfaces.size()]), false, false, null, null, classLoader, - publicMethods.toArray(new MethodDescriptor[publicMethods.size()]), - publicFields.toArray(new FieldDescriptor[publicFields.size()])) { - - @Override - public FieldDescriptor getDeclaredFieldDescriptor(String name) throws NoSuchFieldException { - String type = symbolTable.getClassTagIds().get(name); - if (type != null) { - return new FieldDescriptor(name, Modifier.PROTECTED, type, compiler.getClassLoader()); - } - throw new NoSuchFieldException(name); - } - - @Override - public MethodDescriptor getDeclaredMethodDescriptor(String name, ClassDescriptor... parameterTypes) throws NoSuchMethodException { - throw new NoSuchMethodException(name); - } - - @Override - public JAXXObjectDescriptor getJAXXObjectDescriptor() { - return compiler.getJAXXObjectDescriptor(); - } - }; - } - - private static ClassDescriptor createClassDescriptorFromClass(final Class<?> javaClass) { - String name = javaClass.getName(); - Package p = javaClass.getPackage(); - String packageName = p != null ? p.getName() : null; - Class<?> superclass = javaClass.getSuperclass(); - String superclassName = superclass != null ? superclass.getName() : null; - Class<?>[] interfaces = javaClass.getInterfaces(); - String[] interfaceNames = new String[interfaces.length]; - for (int i = 0; i < interfaces.length; i++) { - interfaceNames[i] = interfaces[i].getName(); - } - boolean isInterface = javaClass.isInterface(); - boolean isArray = javaClass.isArray(); - String componentTypeName = isArray ? javaClass.getComponentType().getName() : null; - JAXXObjectDescriptor jaxxObjectDescriptor = getJAXXObjectDescriptor(javaClass); - ClassLoader classLoader = javaClass.getClassLoader(); - Method[] javaMethods = javaClass.getMethods(); - MethodDescriptor[] methods = new MethodDescriptor[javaMethods.length]; - for (int i = 0; i < methods.length; i++) { - methods[i] = createMethodDescriptor(javaMethods[i], javaClass.getClassLoader()); - } - Field[] javaFields = javaClass.getFields(); - FieldDescriptor[] fields = new FieldDescriptor[javaFields.length]; - for (int i = 0; i < fields.length; i++) { - fields[i] = createFieldDescriptor(javaFields[i], javaClass.getClassLoader()); - } - return new ClassDescriptor(name, packageName, superclassName, interfaceNames, isInterface, isArray, componentTypeName, jaxxObjectDescriptor, classLoader, methods, fields) { - - @Override - public FieldDescriptor getDeclaredFieldDescriptor(String name) throws NoSuchFieldException { - return createFieldDescriptor(javaClass.getDeclaredField(name), javaClass.getClassLoader()); - } - - @Override - public MethodDescriptor getDeclaredMethodDescriptor(String name, ClassDescriptor... parameterTypes) throws NoSuchMethodException { - try { - Class[] parameterTypeClasses = new Class[parameterTypes.length]; - for (int i = 0; i < parameterTypes.length; i++) { - parameterTypeClasses[i] = Class.forName(parameterTypes[i].getName()); - } - return createMethodDescriptor(javaClass.getDeclaredMethod(name, parameterTypeClasses), javaClass.getClassLoader()); - } catch (ClassNotFoundException e) { - throw new RuntimeException(e); - } - } - }; - } - - public static void checkSupportClass(Class<?> handlerClass, ClassDescriptor beanClass, Class<?>... tagClasses) { - for (Class<?> tagClass : tagClasses) { - if (getClassDescriptor(tagClass).isAssignableFrom(beanClass)) { - return; - } - } - throw new IllegalArgumentException(handlerClass.getName() + " does not support the class " + beanClass.getName()); - } - - public static void reset() { - descriptors.clear(); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptorLoader.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptorLoader.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptorLoader.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptorLoader.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,447 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.reflect; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.JAXXEngine; +import jaxx.compiler.SymbolTable; +import jaxx.runtime.JAXXObject; +import jaxx.runtime.JAXXObjectDescriptor; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.net.URL; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * Mirrors the class <code>java.lang.ClassLoader</code>. JAXX uses <code>ClassDescriptor</code> instead of <code>Class</code> + * almost everywhere so that it can handle circular dependencies (there can't be a <code>Class</code> object for an uncompiled + * JAXX or Java source file, and a compiler must be allow references to symbols in uncompiled source files in order to handle + * circular dependencies). + */ +public class ClassDescriptorLoader { + + private static Map<String, ClassDescriptor> descriptors = new HashMap<String, ClassDescriptor>(); + + private ClassDescriptorLoader() { + } + + public static synchronized ClassDescriptor getClassDescriptor(String className) throws ClassNotFoundException { + return getClassDescriptor(className, Thread.currentThread().getContextClassLoader()); + //return getClassDescriptor(className, ClassDescriptorLoader.class.getClassLoader()); + } + + public static synchronized ClassDescriptor getClassDescriptor(String className, ClassLoader classLoader) throws ClassNotFoundException { + ClassDescriptor result = descriptors.get(className); + if (result != null) { + return result; + } + +// if (result == null) { + if (JAXXEngine.isRegistred() && JAXXEngine.get().getSymbolTable(className) != null) { + result = createClassDescriptorFromSymbolTable(className, classLoader); + } else { + if (classLoader == null) { + classLoader = ClassDescriptorLoader.class.getClassLoader(); + } + + String relativePath = className.replaceAll("\\.", "/"); + String relativePathPattern = ".*";// + className + ".*"; // used to ensure that the located resource has the right character cases + + // find the most recently updated source for the class -- Java source, JAXX source, or compiled class file + long javaLastModified = -1; + URL javaFile = classLoader.getResource(relativePath + ".java"); + if (javaFile != null && javaFile.toString().startsWith("file:") && javaFile.toString().matches(relativePathPattern)) { + javaLastModified = JAXXCompiler.URLtoFile(javaFile).lastModified(); + } + + long classLastModified = -1; + URL classFile = classLoader.getResource(relativePath + ".class"); + if (classFile != null && classFile.toString().startsWith("file:") && classFile.toString().matches(relativePathPattern)) { + classLastModified = JAXXCompiler.URLtoFile(classFile).lastModified(); + } + + long jaxxLastModified = -1; + URL jaxxFile = classLoader.getResource(relativePath + ".jaxx"); + if (jaxxFile != null && jaxxFile.toString().startsWith("file:") && jaxxFile.toString().matches(relativePathPattern)) { + File jaxxFilePath = JAXXCompiler.URLtoFile(jaxxFile); + jaxxLastModified = jaxxFilePath.lastModified(); + String simplePath = jaxxFilePath.getPath(); + simplePath = simplePath.substring(0, simplePath.length() - ".jaxx".length()); + File cssFilePath = new File(simplePath + ".css"); + if (cssFilePath.exists()) { + jaxxLastModified = Math.max(jaxxLastModified, cssFilePath.lastModified()); + } + File scriptFilePath = new File(simplePath + ".script"); + if (scriptFilePath.exists()) { + jaxxLastModified = Math.max(jaxxLastModified, scriptFilePath.lastModified()); + } + } + + if (jaxxLastModified != -1 && JAXXEngine.isRegistred() && JAXXEngine.get().getSymbolTable(className) == null) { + jaxxLastModified = -1; // file has been modified, but wasn't included in this + } + // compilation set so we don't have a symbol table + + if (javaLastModified != -1 || classLastModified != -1 || jaxxLastModified != -1) { + if (jaxxLastModified > classLastModified && jaxxLastModified > javaLastModified) { + result = createClassDescriptorFromSymbolTable(className, classLoader); + } else if (javaLastModified > classLastModified && javaLastModified > jaxxLastModified) { + result = createClassDescriptorFromJavaSource(javaFile, classLoader); + } + } + // else work off of the class file. This also handles the case where the class is available, but wasn't in a location where + // we could check its last modified date (in a JAR, over the network, etc.) + if (result == null) { + Class<?> javaClass = getClass(className, classLoader); + result = createClassDescriptorFromClass(javaClass); + } + } + descriptors.put(className, result); +// } + return result; + } + + public static ClassDescriptor getClassDescriptor(Class<?> javaClass) { + try { + return getClassDescriptor(javaClass.getName(), javaClass.getClassLoader()); + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } + } + + public static Class<?> getPrimitiveBoxedClass(String className) throws ClassNotFoundException { + if (className.equals("boolean")) { + return Boolean.class; + } + if (className.equals("byte")) { + return Byte.class; + } + if (className.equals("short")) { + return Short.class; + } + if (className.equals("int")) { + return Integer.class; + } + if (className.equals("long")) { + return Long.class; + } + if (className.equals("float")) { + return Float.class; + } + if (className.equals("double")) { + return Double.class; + } + if (className.equals("char")) { + return Character.class; + } + if (className.equals("void")) { + return Void.class; + } + return null; + } + + public static Class<?> getPrimitiveClass(String className) throws ClassNotFoundException { + if (className.equals("boolean")) { + return boolean.class; + } + if (className.equals("byte")) { + return byte.class; + } + if (className.equals("short")) { + return short.class; + } + if (className.equals("int")) { + return int.class; + } + if (className.equals("long")) { + return long.class; + } + if (className.equals("float")) { + return float.class; + } + if (className.equals("double")) { + return double.class; + } + if (className.equals("char")) { + return char.class; + } + if (className.equals("void")) { + return void.class; + } + // detect arrays + int arrayCount = 0; + while (className.endsWith("[]")) { + arrayCount++; + className = className.substring(0, className.length() - 2); + } + Class<?> klass; + if (arrayCount > 0) { + klass = getPrimitiveClass(className); + if (klass == null) { + // none primitive array + return null; + } + // must take the boxed class, other it does not works + // to make a Class.forName("[Lchar;"); but works + // with Class.forName("[LCharacter;"); ... + klass = getPrimitiveBoxedClass(className); + className = klass.getName(); + + className = "L" + className + ";"; + while (arrayCount > 0) { + className = "[" + className; + arrayCount--; + } + //System.out.println("primitive array class "+className); + return Class.forName(className); + } + return null; + } + + public static Class<?> getClass(String className, ClassLoader classLoader) throws ClassNotFoundException { + Class<?> klass = getPrimitiveClass(className); + if (klass != null) { + return klass; + } + // try an array of none primitive classes + int arrayCount = 0; + while (className.endsWith("[]")) { + arrayCount++; + className = className.substring(0, className.length() - 2); + } + if (arrayCount > 0) { + className = "L" + className + ";"; + while (arrayCount > 0) { + className = "[" + className; + arrayCount--; + } + } + try { + return classLoader != null ? Class.forName(className, true, classLoader) : Class.forName(className); + } catch (ClassNotFoundException e) { + // perharps we are in a inner class ? + int dotIndex = className.lastIndexOf("."); + if (dotIndex > -1) { + String parentFQN = className.substring(0, dotIndex); + String simpleName = className.substring(dotIndex + 1); + try { + Class<?> parentClass = classLoader != null ? Class.forName(parentFQN, true, classLoader) : Class.forName(parentFQN); + for (Class<?> innerClass : parentClass.getClasses()) { + if (simpleName.equals(innerClass.getSimpleName())) { + return innerClass; + } + } + } catch (ClassNotFoundException e1) { + // no super class,so let the first exception throw... + } + } + throw e; + } catch (NoClassDefFoundError e) { + + throw new ClassNotFoundException(e.toString()); + } + } + + private static MethodDescriptor createMethodDescriptor(Method javaMethod, ClassLoader classLoader) { + String methodName = javaMethod.getName(); + int modifiers = javaMethod.getModifiers(); + String returnType = javaMethod.getReturnType().getName(); + Class<?>[] javaParameters = javaMethod.getParameterTypes(); + String[] parameters = new String[javaParameters.length]; + for (int i = 0; i < parameters.length; i++) { + parameters[i] = javaParameters[i].getName(); + } + return new MethodDescriptor(methodName, modifiers, returnType, parameters, classLoader); + } + + private static FieldDescriptor createFieldDescriptor(Field javaField, ClassLoader classLoader) { + String fieldName = javaField.getName(); + int modifiers = javaField.getModifiers(); + String type = javaField.getType().getName(); + return new FieldDescriptor(fieldName, modifiers, type, classLoader); + } + + private static JAXXObjectDescriptor getJAXXObjectDescriptor(Class<?> jaxxClass) { + if (!JAXXObject.class.isAssignableFrom(jaxxClass) || jaxxClass == JAXXObject.class) { + return null; + } + try { + Method getJAXXObjectDescriptor = jaxxClass.getMethod("$getJAXXObjectDescriptor"); +// Method getJAXXObjectDescriptor = jaxxClass.getMethod("$getJAXXObjectDescriptor", new Class<?>[0]); + return (JAXXObjectDescriptor) getJAXXObjectDescriptor.invoke(null); + } catch (NoSuchMethodException e) { + throw new CompilerException("Expected JAXXObject " + jaxxClass.getName() + " to have a static method named $getJAXXObjectDescriptor"); + } catch (IllegalAccessException e) { + throw new CompilerException("Expected JAXXObject " + jaxxClass.getName() + "'s $getJAXXObjectDescriptor method to be public"); + } catch (InvocationTargetException e) { + throw new RuntimeException(e); + } + } + + private static ClassDescriptor createClassDescriptorFromJavaSource(URL javaSource, ClassLoader classLoader) throws ClassNotFoundException { + try { + InputStream in = javaSource.openStream(); + Reader reader = new InputStreamReader(in, "utf-8"); + ClassDescriptor result = JavaFileParser.parseJavaFile(javaSource.toString(), reader, classLoader); + reader.close(); + return result; + } catch (IOException e) { + throw new ClassNotFoundException(e.toString()); + } + } + + private static ClassDescriptor createClassDescriptorFromSymbolTable(String className, ClassLoader classLoader) throws ClassNotFoundException { + final JAXXCompiler compiler = JAXXEngine.get().getJAXXCompiler(className); + final SymbolTable symbolTable = JAXXEngine.get().getSymbolTable(className); + if (symbolTable == null) { + throw new CompilerException("Internal error: no symbol table was generated for class '" + className + "'"); + } + ClassDescriptor superclass = getClassDescriptor(symbolTable.getSuperclassName(), classLoader); + List<MethodDescriptor> publicMethods = symbolTable.getScriptMethods(); + List<FieldDescriptor> publicFields = symbolTable.getScriptFields(); + //List<MethodDescriptor> declaredMethods = new ArrayList<MethodDescriptor>(publicMethods); + //List<FieldDescriptor> declaredFields = new ArrayList<FieldDescriptor>(publicFields); + Iterator<MethodDescriptor> methods = publicMethods.iterator(); + while (methods.hasNext()) { + MethodDescriptor method = methods.next(); + if (!Modifier.isPublic(method.getModifiers())) { + methods.remove(); + } + } + Iterator<FieldDescriptor> fields = publicFields.iterator(); + while (fields.hasNext()) { + FieldDescriptor field = fields.next(); + if (!Modifier.isPublic(field.getModifiers())) { + fields.remove(); + } + } + publicMethods.addAll(Arrays.asList(superclass.getMethodDescriptors())); + publicFields.addAll(Arrays.asList(superclass.getFieldDescriptors())); + int dotPos = className.lastIndexOf("."); + String packageName = dotPos != -1 ? className.substring(0, dotPos) : null; + Set<String> interfaces = new HashSet<String>(); + ClassDescriptor[] superclassInterfaces = superclass.getInterfaces(); + for (ClassDescriptor superclassInterface : superclassInterfaces) { + interfaces.add(superclassInterface.getName()); + } + interfaces.add(JAXXObject.class.getName()); + return new ClassDescriptor(className, packageName, symbolTable.getSuperclassName(), + interfaces.toArray(new String[interfaces.size()]), false, false, null, null, classLoader, + publicMethods.toArray(new MethodDescriptor[publicMethods.size()]), + publicFields.toArray(new FieldDescriptor[publicFields.size()])) { + + @Override + public FieldDescriptor getDeclaredFieldDescriptor(String name) throws NoSuchFieldException { + String type = symbolTable.getClassTagIds().get(name); + if (type != null) { + return new FieldDescriptor(name, Modifier.PROTECTED, type, compiler.getClassLoader()); + } + throw new NoSuchFieldException(name); + } + + @Override + public MethodDescriptor getDeclaredMethodDescriptor(String name, ClassDescriptor... parameterTypes) throws NoSuchMethodException { + throw new NoSuchMethodException(name); + } + + @Override + public JAXXObjectDescriptor getJAXXObjectDescriptor() { + return compiler.getJAXXObjectDescriptor(); + } + }; + } + + private static ClassDescriptor createClassDescriptorFromClass(final Class<?> javaClass) { + String name = javaClass.getName(); + Package p = javaClass.getPackage(); + String packageName = p != null ? p.getName() : null; + Class<?> superclass = javaClass.getSuperclass(); + String superclassName = superclass != null ? superclass.getName() : null; + Class<?>[] interfaces = javaClass.getInterfaces(); + String[] interfaceNames = new String[interfaces.length]; + for (int i = 0; i < interfaces.length; i++) { + interfaceNames[i] = interfaces[i].getName(); + } + boolean isInterface = javaClass.isInterface(); + boolean isArray = javaClass.isArray(); + String componentTypeName = isArray ? javaClass.getComponentType().getName() : null; + JAXXObjectDescriptor jaxxObjectDescriptor = getJAXXObjectDescriptor(javaClass); + ClassLoader classLoader = javaClass.getClassLoader(); + Method[] javaMethods = javaClass.getMethods(); + MethodDescriptor[] methods = new MethodDescriptor[javaMethods.length]; + for (int i = 0; i < methods.length; i++) { + methods[i] = createMethodDescriptor(javaMethods[i], javaClass.getClassLoader()); + } + Field[] javaFields = javaClass.getFields(); + FieldDescriptor[] fields = new FieldDescriptor[javaFields.length]; + for (int i = 0; i < fields.length; i++) { + fields[i] = createFieldDescriptor(javaFields[i], javaClass.getClassLoader()); + } + return new ClassDescriptor(name, packageName, superclassName, interfaceNames, isInterface, isArray, componentTypeName, jaxxObjectDescriptor, classLoader, methods, fields) { + + @Override + public FieldDescriptor getDeclaredFieldDescriptor(String name) throws NoSuchFieldException { + return createFieldDescriptor(javaClass.getDeclaredField(name), javaClass.getClassLoader()); + } + + @Override + public MethodDescriptor getDeclaredMethodDescriptor(String name, ClassDescriptor... parameterTypes) throws NoSuchMethodException { + try { + Class[] parameterTypeClasses = new Class[parameterTypes.length]; + for (int i = 0; i < parameterTypes.length; i++) { + parameterTypeClasses[i] = Class.forName(parameterTypes[i].getName()); + } + return createMethodDescriptor(javaClass.getDeclaredMethod(name, parameterTypeClasses), javaClass.getClassLoader()); + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } + } + }; + } + + public static void checkSupportClass(Class<?> handlerClass, ClassDescriptor beanClass, Class<?>... tagClasses) { + for (Class<?> tagClass : tagClasses) { + if (getClassDescriptor(tagClass).isAssignableFrom(beanClass)) { + return; + } + } + throw new IllegalArgumentException(handlerClass.getName() + " does not support the class " + beanClass.getName()); + } + + public static void reset() { + descriptors.clear(); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/FieldDescriptor.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/FieldDescriptor.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/FieldDescriptor.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,50 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.reflect; - -/** - * Mirrors the class <code>java.lang.ref.Field</code>. JAXX uses <code>ClassDescriptor</code> instead of <code>Class</code> - * almost everywhere so that it can handle circular dependencies (there can't be a <code>Class</code> object for an uncompiled - * JAXX or Java source file, and a compiler must be allow references to symbols in uncompiled source files in order to handle - * circular dependencies). - */ -public class FieldDescriptor extends MemberDescriptor { - - private String type; - - public FieldDescriptor(String name, int modifiers, String type, ClassLoader classLoader) { - super(name, modifiers, classLoader); - this.type = type; - } - - public ClassDescriptor getType() { - try { - return ClassDescriptorLoader.getClassDescriptor(type, getClassLoader()); - } catch (ClassNotFoundException e) { - throw new RuntimeException(e); - } - } - - @Override - public String toString() { - return super.toString() + " type : [" + type + "]"; - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/FieldDescriptor.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/FieldDescriptor.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/FieldDescriptor.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/FieldDescriptor.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,50 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.reflect; + +/** + * Mirrors the class <code>java.lang.ref.Field</code>. JAXX uses <code>ClassDescriptor</code> instead of <code>Class</code> + * almost everywhere so that it can handle circular dependencies (there can't be a <code>Class</code> object for an uncompiled + * JAXX or Java source file, and a compiler must be allow references to symbols in uncompiled source files in order to handle + * circular dependencies). + */ +public class FieldDescriptor extends MemberDescriptor { + + private String type; + + public FieldDescriptor(String name, int modifiers, String type, ClassLoader classLoader) { + super(name, modifiers, classLoader); + this.type = type; + } + + public ClassDescriptor getType() { + try { + return ClassDescriptorLoader.getClassDescriptor(type, getClassLoader()); + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } + } + + @Override + public String toString() { + return super.toString() + " type : [" + type + "]"; + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/JavaFileParser.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/JavaFileParser.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/JavaFileParser.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,237 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.reflect; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.JAXXEngine; -import jaxx.compiler.java.parser.JavaParser; -import jaxx.compiler.java.parser.JavaParserTreeConstants; -import jaxx.compiler.java.parser.ParseException; -import jaxx.compiler.java.parser.SimpleNode; -import jaxx.compiler.tags.TagManager; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.io.Reader; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; - -// TODO: need to unify this implementation with the parsing in ScriptManager -public class JavaFileParser { - - /** to use log facility, just put in your code: log.info(\"...\"); */ - static private final Log log = LogFactory.getLog(JavaFileParser.class); - private JAXXCompiler compiler; - private String className; - private String packageName = null; - private String superclass = "java.lang.Object"; - private List<MethodDescriptor> methods = new ArrayList<MethodDescriptor>(); - private List<FieldDescriptor> fields = new ArrayList<FieldDescriptor>(); - - private JavaFileParser(ClassLoader classLoader) { - compiler = JAXXEngine.createDummyCompiler(classLoader); - } - - public static ClassDescriptor parseJavaFile(String displayName, Reader src, ClassLoader classLoader) throws ClassNotFoundException { - // has some limitations -- it reports all members as public, leaves getDeclaredMethod and getDeclaredField - // undefined, and doesn't report interfaces. It's safe to leave those the way they are for now, because - // JAXX doesn't look at any of those for non-JAXX classes. - JavaFileParser parser = new JavaFileParser(classLoader); - if (log.isDebugEnabled()) { - log.debug("starting parsing : " + displayName); - } - try { - parser.doParse(displayName, src); - } catch (Exception e) { - log.error(e.getMessage()); - throw new RuntimeException(e); - } - - List<MethodDescriptor> publicMethods = parser.methods; - List<FieldDescriptor> publicFields = parser.fields; - //List/*<MethodDescriptor>*/ declaredMethods = new ArrayList/*<MethodDescriptor>*/(publicMethods); - //List/*<FieldDescriptor>*/ declaredFields = new ArrayList/*<FieldDescriptor>*/(publicFields); - Iterator<MethodDescriptor> methods = publicMethods.iterator(); - while (methods.hasNext()) { - MethodDescriptor method = methods.next(); - if (!Modifier.isPublic(method.getModifiers())) { - methods.remove(); - } - } - Iterator<FieldDescriptor> fields = publicFields.iterator(); - while (fields.hasNext()) { - FieldDescriptor field = fields.next(); - if (!Modifier.isPublic(field.getModifiers())) { - fields.remove(); - } - } - ClassDescriptor superclassDescriptor = ClassDescriptorLoader.getClassDescriptor(parser.superclass, classLoader); - publicMethods.addAll(Arrays.asList(superclassDescriptor.getMethodDescriptors())); - publicFields.addAll(Arrays.asList(superclassDescriptor.getFieldDescriptors())); - //Set<String> interfaces = new HashSet<String>(); - //ClassDescriptor[] superclassInterfaces = superclassDescriptor.getInterfaces(); - //for (ClassDescriptor superclassInterface : superclassInterfaces) { - //interfaces.add(superclassInterface.getName()); - //} - return new ClassDescriptor(parser.className, parser.packageName, parser.superclass, new String[0], false, false, null, null, classLoader, - publicMethods.toArray(new MethodDescriptor[publicMethods.size()]), - publicFields.toArray(new FieldDescriptor[publicFields.size()])) { - - @Override - public FieldDescriptor getDeclaredFieldDescriptor(String name) throws NoSuchFieldException { - throw new NoSuchFieldException(name); - } - - @Override - public MethodDescriptor getDeclaredMethodDescriptor(String name, ClassDescriptor... parameterTypes) throws NoSuchMethodException { - throw new NoSuchMethodException(name); - } - }; - } - - private void doParse(String displayName, Reader src) { - try { - JavaParser p = new JavaParser(src); - p.CompilationUnit(); - SimpleNode node = p.popNode(); - if (node != null) { - scanCompilationUnit(node); - return; - } - throw new CompilerException("Internal error: null node parsing Java file from " + src); - } catch (ParseException e) { - throw new CompilerException("Error parsing Java source code " + displayName + ": " + e.getMessage()); - } - } - - private void scanCompilationUnit(SimpleNode node) { - for (int i = 0; i < node.jjtGetNumChildren(); i++) { - SimpleNode child = node.getChild(i); - int nodeType = child.getId(); - if (nodeType == JavaParserTreeConstants.JJTPACKAGEDECLARATION) { - packageName = child.getChild(1).getText().trim(); - compiler.addImport(packageName + ".*"); - } else if (nodeType == JavaParserTreeConstants.JJTIMPORTDECLARATION) { - String text = child.getText().trim(); - if (text.startsWith("import")) { - text = text.substring("import".length()).trim(); - } - if (text.endsWith(";")) { - text = text.substring(0, text.length() - 1); - } - compiler.addImport(text); - } else if (nodeType == JavaParserTreeConstants.JJTTYPEDECLARATION) { - scanCompilationUnit(child); - } else if (nodeType == JavaParserTreeConstants.JJTCLASSORINTERFACEDECLARATION) { - scanClass(child); - } - } - } - - // scans the main ClassOrInterfaceDeclaration - private void scanClass(SimpleNode node) { - boolean isInterface = node.firstToken.image.equals("interface"); - className = node.firstToken.next.image; - if (packageName != null) { - className = packageName + "." + className; - } - for (int i = 0; i < node.jjtGetNumChildren(); i++) { - SimpleNode child = node.getChild(i); - int nodeType = child.getId(); - if (nodeType == JavaParserTreeConstants.JJTEXTENDSLIST) { - if (!isInterface) { - assert child.jjtGetNumChildren() == 1 : "expected ExtendsList to have exactly one child for a non-interface class"; - String rawName = child.getChild(0).getText().trim(); - superclass = TagManager.resolveClassName(rawName, compiler); - if (superclass == null) { - throw new CompilerException("Could not find class: " + rawName); - } - } - } else if (nodeType == JavaParserTreeConstants.JJTCLASSORINTERFACEBODY) { - scanClassNode(child); - } - } - } - - // scans class body nodes - private void scanClassNode(SimpleNode node) { - int nodeType = node.getId(); - if (nodeType == JavaParserTreeConstants.JJTMETHODDECLARATION) { - String returnType = null; - String name = null; - List<String> parameterTypes = new ArrayList<String>(); - //List<String> parameterNames = new ArrayList<String>(); - for (int i = 0; i < node.jjtGetNumChildren(); i++) { - SimpleNode child = node.getChild(i); - int type = child.getId(); - if (type == JavaParserTreeConstants.JJTRESULTTYPE) { - returnType = TagManager.resolveClassName(child.getText().trim(), compiler); - } else if (type == JavaParserTreeConstants.JJTMETHODDECLARATOR) { - name = child.firstToken.image.trim(); - SimpleNode formalParameters = child.getChild(0); - assert formalParameters.getId() == JavaParserTreeConstants.JJTFORMALPARAMETERS; - for (int j = 0; j < formalParameters.jjtGetNumChildren(); j++) { - SimpleNode parameter = formalParameters.getChild(j); - String rawParameterType = parameter.getChild(1).getText().trim().replaceAll("\\.\\.\\.", "[]"); - String parameterType = TagManager.resolveClassName(rawParameterType, compiler); - if (parameterType == null && JAXXCompiler.STRICT_CHECKS) { - throw new CompilerException("could not find class '" + rawParameterType + "'"); - } - parameterTypes.add(parameterType); - //parameterNames.add(parameter.getChild(2).getText().trim()); - } - } - } - methods.add(new MethodDescriptor(name, Modifier.PUBLIC, returnType, parameterTypes.toArray(new String[parameterTypes.size()]), compiler.getClassLoader())); // TODO: determine the actual modifiers - } else if (nodeType == JavaParserTreeConstants.JJTCLASSORINTERFACEDECLARATION) { - // TODO: handle inner classes - } else if (nodeType == JavaParserTreeConstants.JJTCONSTRUCTORDECLARATION) { - // TODO: handle constructors - } else if (nodeType == JavaParserTreeConstants.JJTFIELDDECLARATION) { - String text = node.getText(); - String declaration = text; - int equals = text.indexOf("="); - if (equals != -1) { - declaration = declaration.substring(0, equals); - } - declaration = declaration.trim(); - String[] declarationTokens = declaration.split("\\s"); - //boolean isFinal = Arrays.asList(declarationTokens).contains("final"); - //boolean isStatic = Arrays.asList(declarationTokens).contains("static"); - String name = declarationTokens[declarationTokens.length - 1]; - if (name.endsWith(";")) { - name = name.substring(0, name.length() - 1).trim(); - } - String cName = declarationTokens[declarationTokens.length - 2]; - String type = TagManager.resolveClassName(cName, compiler); - fields.add(new FieldDescriptor(name, Modifier.PUBLIC, type, compiler.getClassLoader())); // TODO: determine the actual modifiers - } else { - for (int i = 0; i < node.jjtGetNumChildren(); i++) { - SimpleNode child = node.getChild(i); - scanClassNode(child); - } - } - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/JavaFileParser.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/JavaFileParser.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/JavaFileParser.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/JavaFileParser.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,237 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.reflect; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.JAXXEngine; +import jaxx.compiler.java.parser.JavaParser; +import jaxx.compiler.java.parser.JavaParserTreeConstants; +import jaxx.compiler.java.parser.ParseException; +import jaxx.compiler.java.parser.SimpleNode; +import jaxx.compiler.tags.TagManager; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.io.Reader; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; + +// TODO: need to unify this implementation with the parsing in ScriptManager +public class JavaFileParser { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private final Log log = LogFactory.getLog(JavaFileParser.class); + private JAXXCompiler compiler; + private String className; + private String packageName = null; + private String superclass = "java.lang.Object"; + private List<MethodDescriptor> methods = new ArrayList<MethodDescriptor>(); + private List<FieldDescriptor> fields = new ArrayList<FieldDescriptor>(); + + private JavaFileParser(ClassLoader classLoader) { + compiler = JAXXEngine.createDummyCompiler(classLoader); + } + + public static ClassDescriptor parseJavaFile(String displayName, Reader src, ClassLoader classLoader) throws ClassNotFoundException { + // has some limitations -- it reports all members as public, leaves getDeclaredMethod and getDeclaredField + // undefined, and doesn't report interfaces. It's safe to leave those the way they are for now, because + // JAXX doesn't look at any of those for non-JAXX classes. + JavaFileParser parser = new JavaFileParser(classLoader); + if (log.isDebugEnabled()) { + log.debug("starting parsing : " + displayName); + } + try { + parser.doParse(displayName, src); + } catch (Exception e) { + log.error(e.getMessage()); + throw new RuntimeException(e); + } + + List<MethodDescriptor> publicMethods = parser.methods; + List<FieldDescriptor> publicFields = parser.fields; + //List/*<MethodDescriptor>*/ declaredMethods = new ArrayList/*<MethodDescriptor>*/(publicMethods); + //List/*<FieldDescriptor>*/ declaredFields = new ArrayList/*<FieldDescriptor>*/(publicFields); + Iterator<MethodDescriptor> methods = publicMethods.iterator(); + while (methods.hasNext()) { + MethodDescriptor method = methods.next(); + if (!Modifier.isPublic(method.getModifiers())) { + methods.remove(); + } + } + Iterator<FieldDescriptor> fields = publicFields.iterator(); + while (fields.hasNext()) { + FieldDescriptor field = fields.next(); + if (!Modifier.isPublic(field.getModifiers())) { + fields.remove(); + } + } + ClassDescriptor superclassDescriptor = ClassDescriptorLoader.getClassDescriptor(parser.superclass, classLoader); + publicMethods.addAll(Arrays.asList(superclassDescriptor.getMethodDescriptors())); + publicFields.addAll(Arrays.asList(superclassDescriptor.getFieldDescriptors())); + //Set<String> interfaces = new HashSet<String>(); + //ClassDescriptor[] superclassInterfaces = superclassDescriptor.getInterfaces(); + //for (ClassDescriptor superclassInterface : superclassInterfaces) { + //interfaces.add(superclassInterface.getName()); + //} + return new ClassDescriptor(parser.className, parser.packageName, parser.superclass, new String[0], false, false, null, null, classLoader, + publicMethods.toArray(new MethodDescriptor[publicMethods.size()]), + publicFields.toArray(new FieldDescriptor[publicFields.size()])) { + + @Override + public FieldDescriptor getDeclaredFieldDescriptor(String name) throws NoSuchFieldException { + throw new NoSuchFieldException(name); + } + + @Override + public MethodDescriptor getDeclaredMethodDescriptor(String name, ClassDescriptor... parameterTypes) throws NoSuchMethodException { + throw new NoSuchMethodException(name); + } + }; + } + + private void doParse(String displayName, Reader src) { + try { + JavaParser p = new JavaParser(src); + p.CompilationUnit(); + SimpleNode node = p.popNode(); + if (node != null) { + scanCompilationUnit(node); + return; + } + throw new CompilerException("Internal error: null node parsing Java file from " + src); + } catch (ParseException e) { + throw new CompilerException("Error parsing Java source code " + displayName + ": " + e.getMessage()); + } + } + + private void scanCompilationUnit(SimpleNode node) { + for (int i = 0; i < node.jjtGetNumChildren(); i++) { + SimpleNode child = node.getChild(i); + int nodeType = child.getId(); + if (nodeType == JavaParserTreeConstants.JJTPACKAGEDECLARATION) { + packageName = child.getChild(1).getText().trim(); + compiler.addImport(packageName + ".*"); + } else if (nodeType == JavaParserTreeConstants.JJTIMPORTDECLARATION) { + String text = child.getText().trim(); + if (text.startsWith("import")) { + text = text.substring("import".length()).trim(); + } + if (text.endsWith(";")) { + text = text.substring(0, text.length() - 1); + } + compiler.addImport(text); + } else if (nodeType == JavaParserTreeConstants.JJTTYPEDECLARATION) { + scanCompilationUnit(child); + } else if (nodeType == JavaParserTreeConstants.JJTCLASSORINTERFACEDECLARATION) { + scanClass(child); + } + } + } + + // scans the main ClassOrInterfaceDeclaration + private void scanClass(SimpleNode node) { + boolean isInterface = node.firstToken.image.equals("interface"); + className = node.firstToken.next.image; + if (packageName != null) { + className = packageName + "." + className; + } + for (int i = 0; i < node.jjtGetNumChildren(); i++) { + SimpleNode child = node.getChild(i); + int nodeType = child.getId(); + if (nodeType == JavaParserTreeConstants.JJTEXTENDSLIST) { + if (!isInterface) { + assert child.jjtGetNumChildren() == 1 : "expected ExtendsList to have exactly one child for a non-interface class"; + String rawName = child.getChild(0).getText().trim(); + superclass = TagManager.resolveClassName(rawName, compiler); + if (superclass == null) { + throw new CompilerException("Could not find class: " + rawName); + } + } + } else if (nodeType == JavaParserTreeConstants.JJTCLASSORINTERFACEBODY) { + scanClassNode(child); + } + } + } + + // scans class body nodes + private void scanClassNode(SimpleNode node) { + int nodeType = node.getId(); + if (nodeType == JavaParserTreeConstants.JJTMETHODDECLARATION) { + String returnType = null; + String name = null; + List<String> parameterTypes = new ArrayList<String>(); + //List<String> parameterNames = new ArrayList<String>(); + for (int i = 0; i < node.jjtGetNumChildren(); i++) { + SimpleNode child = node.getChild(i); + int type = child.getId(); + if (type == JavaParserTreeConstants.JJTRESULTTYPE) { + returnType = TagManager.resolveClassName(child.getText().trim(), compiler); + } else if (type == JavaParserTreeConstants.JJTMETHODDECLARATOR) { + name = child.firstToken.image.trim(); + SimpleNode formalParameters = child.getChild(0); + assert formalParameters.getId() == JavaParserTreeConstants.JJTFORMALPARAMETERS; + for (int j = 0; j < formalParameters.jjtGetNumChildren(); j++) { + SimpleNode parameter = formalParameters.getChild(j); + String rawParameterType = parameter.getChild(1).getText().trim().replaceAll("\\.\\.\\.", "[]"); + String parameterType = TagManager.resolveClassName(rawParameterType, compiler); + if (parameterType == null && JAXXCompiler.STRICT_CHECKS) { + throw new CompilerException("could not find class '" + rawParameterType + "'"); + } + parameterTypes.add(parameterType); + //parameterNames.add(parameter.getChild(2).getText().trim()); + } + } + } + methods.add(new MethodDescriptor(name, Modifier.PUBLIC, returnType, parameterTypes.toArray(new String[parameterTypes.size()]), compiler.getClassLoader())); // TODO: determine the actual modifiers + } else if (nodeType == JavaParserTreeConstants.JJTCLASSORINTERFACEDECLARATION) { + // TODO: handle inner classes + } else if (nodeType == JavaParserTreeConstants.JJTCONSTRUCTORDECLARATION) { + // TODO: handle constructors + } else if (nodeType == JavaParserTreeConstants.JJTFIELDDECLARATION) { + String text = node.getText(); + String declaration = text; + int equals = text.indexOf("="); + if (equals != -1) { + declaration = declaration.substring(0, equals); + } + declaration = declaration.trim(); + String[] declarationTokens = declaration.split("\\s"); + //boolean isFinal = Arrays.asList(declarationTokens).contains("final"); + //boolean isStatic = Arrays.asList(declarationTokens).contains("static"); + String name = declarationTokens[declarationTokens.length - 1]; + if (name.endsWith(";")) { + name = name.substring(0, name.length() - 1).trim(); + } + String cName = declarationTokens[declarationTokens.length - 2]; + String type = TagManager.resolveClassName(cName, compiler); + fields.add(new FieldDescriptor(name, Modifier.PUBLIC, type, compiler.getClassLoader())); // TODO: determine the actual modifiers + } else { + for (int i = 0; i < node.jjtGetNumChildren(); i++) { + SimpleNode child = node.getChild(i); + scanClassNode(child); + } + } + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MemberDescriptor.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MemberDescriptor.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MemberDescriptor.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,57 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.reflect; - -/** - * Mirrors the class <code>java.lang.ref.Member</code>. JAXX uses <code>ClassDescriptor</code> instead of <code>Class</code> - * almost everywhere so that it can handle circular dependencies (there can't be a <code>Class</code> object for an uncompiled - * JAXX or Java source file, and a compiler must be allow references to symbols in uncompiled source files in order to handle - * circular dependencies). - */ -public abstract class MemberDescriptor { - - private String name; - private int modifiers; - private ClassLoader classLoader; - - MemberDescriptor(String name, int modifiers, ClassLoader classLoader) { - this.name = name; - this.modifiers = modifiers; - this.classLoader = classLoader; - } - - public String getName() { - return name; - } - - public int getModifiers() { - return modifiers; - } - - protected ClassLoader getClassLoader() { - return classLoader; - } - - @Override - public String toString() { - return getClass().getName() + "[" + getName() + "]"; - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MemberDescriptor.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MemberDescriptor.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MemberDescriptor.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MemberDescriptor.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,57 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.reflect; + +/** + * Mirrors the class <code>java.lang.ref.Member</code>. JAXX uses <code>ClassDescriptor</code> instead of <code>Class</code> + * almost everywhere so that it can handle circular dependencies (there can't be a <code>Class</code> object for an uncompiled + * JAXX or Java source file, and a compiler must be allow references to symbols in uncompiled source files in order to handle + * circular dependencies). + */ +public abstract class MemberDescriptor { + + private String name; + private int modifiers; + private ClassLoader classLoader; + + MemberDescriptor(String name, int modifiers, ClassLoader classLoader) { + this.name = name; + this.modifiers = modifiers; + this.classLoader = classLoader; + } + + public String getName() { + return name; + } + + public int getModifiers() { + return modifiers; + } + + protected ClassLoader getClassLoader() { + return classLoader; + } + + @Override + public String toString() { + return getClass().getName() + "[" + getName() + "]"; + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MethodDescriptor.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MethodDescriptor.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MethodDescriptor.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,70 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.reflect; - -import jaxx.compiler.JAXXCompiler; - -/** - * Mirrors the class <code>java.lang.ref.Method</code>. JAXX uses <code>ClassDescriptor</code> instead of <code>Class</code> - * almost everywhere so that it can handle circular dependencies (there can't be a <code>Class</code> object for an uncompiled - * JAXX or Java source file, and a compiler must be allow references to symbols in uncompiled source files in order to handle - * circular dependencies). - */ -public class MethodDescriptor extends MemberDescriptor { - - private String returnType; - private String[] parameterTypes; - - public MethodDescriptor(String name, int modifiers, String returnType, String[] parameterTypes, ClassLoader classLoader) { - super(name, modifiers, classLoader); - this.returnType = returnType; - this.parameterTypes = parameterTypes; - if (JAXXCompiler.STRICT_CHECKS && java.util.Arrays.asList(parameterTypes).contains(null)) { - throw new NullPointerException(name); - } - } - - public ClassDescriptor getReturnType() { - try { - //TC 20090228 : fix bug when no return type defined (constructor method) - if (returnType == null) { - return null; - } - return ClassDescriptorLoader.getClassDescriptor(returnType); - } catch (ClassNotFoundException e) { - throw new RuntimeException("could not find return type " + returnType, e); - } - } - - public ClassDescriptor[] getParameterTypes() { - ClassDescriptor[] result = new ClassDescriptor[parameterTypes.length]; - try { - for (int i = 0; i < result.length; i++) { - if (parameterTypes[i] != null) { - result[i] = ClassDescriptorLoader.getClassDescriptor(parameterTypes[i], getClassLoader()); - } - } - return result; - } catch (ClassNotFoundException e) { - throw new RuntimeException("could not find the parameter types " + java.util.Arrays.toString(parameterTypes), e); - } - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MethodDescriptor.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MethodDescriptor.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MethodDescriptor.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MethodDescriptor.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,70 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.reflect; + +import jaxx.compiler.JAXXCompiler; + +/** + * Mirrors the class <code>java.lang.ref.Method</code>. JAXX uses <code>ClassDescriptor</code> instead of <code>Class</code> + * almost everywhere so that it can handle circular dependencies (there can't be a <code>Class</code> object for an uncompiled + * JAXX or Java source file, and a compiler must be allow references to symbols in uncompiled source files in order to handle + * circular dependencies). + */ +public class MethodDescriptor extends MemberDescriptor { + + private String returnType; + private String[] parameterTypes; + + public MethodDescriptor(String name, int modifiers, String returnType, String[] parameterTypes, ClassLoader classLoader) { + super(name, modifiers, classLoader); + this.returnType = returnType; + this.parameterTypes = parameterTypes; + if (JAXXCompiler.STRICT_CHECKS && java.util.Arrays.asList(parameterTypes).contains(null)) { + throw new NullPointerException(name); + } + } + + public ClassDescriptor getReturnType() { + try { + //TC 20090228 : fix bug when no return type defined (constructor method) + if (returnType == null) { + return null; + } + return ClassDescriptorLoader.getClassDescriptor(returnType); + } catch (ClassNotFoundException e) { + throw new RuntimeException("could not find return type " + returnType, e); + } + } + + public ClassDescriptor[] getParameterTypes() { + ClassDescriptor[] result = new ClassDescriptor[parameterTypes.length]; + try { + for (int i = 0; i < result.length; i++) { + if (parameterTypes[i] != null) { + result[i] = ClassDescriptorLoader.getClassDescriptor(parameterTypes[i], getClassLoader()); + } + } + return result; + } catch (ClassNotFoundException e) { + throw new RuntimeException("could not find the parameter types " + java.util.Arrays.toString(parameterTypes), e); + } + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/script/ScriptInitializer.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/script/ScriptInitializer.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/script/ScriptInitializer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,40 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.script; - -import jaxx.compiler.CompiledObject; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.reflect.ClassDescriptorLoader; - -/** - * A dummy CompiledObject which serves to initialize scripted field. This is handled by - * a CompiledObject rather than (say) simply inlining the initialization code in order to - * ensure that the field is initialized in document order. - */ -public class ScriptInitializer extends CompiledObject { - - public ScriptInitializer(String initializer, JAXXCompiler compiler) { -// super(compiler.getAutoId(ClassDescriptorLoader.getClassDescriptor(ScriptInitializer.class)), - super(compiler.getAutoId(ScriptInitializer.class.getSimpleName()), - ClassDescriptorLoader.getClassDescriptor(ScriptInitializer.class), compiler, false); - appendInitializationCode(initializer); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/script/ScriptInitializer.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/script/ScriptInitializer.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/script/ScriptInitializer.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/script/ScriptInitializer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,40 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.script; + +import jaxx.compiler.CompiledObject; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.reflect.ClassDescriptorLoader; + +/** + * A dummy CompiledObject which serves to initialize scripted field. This is handled by + * a CompiledObject rather than (say) simply inlining the initialization code in order to + * ensure that the field is initialized in document order. + */ +public class ScriptInitializer extends CompiledObject { + + public ScriptInitializer(String initializer, JAXXCompiler compiler) { +// super(compiler.getAutoId(ClassDescriptorLoader.getClassDescriptor(ScriptInitializer.class)), + super(compiler.getAutoId(ScriptInitializer.class.getSimpleName()), + ClassDescriptorLoader.getClassDescriptor(ScriptInitializer.class), compiler, false); + appendInitializationCode(initializer); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/script/ScriptManager.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/script/ScriptManager.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/script/ScriptManager.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,332 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.script; - -import jaxx.compiler.*; -import jaxx.compiler.java.parser.JavaParser; -import jaxx.compiler.java.parser.JavaParserTreeConstants; -import jaxx.compiler.java.parser.SimpleNode; -import jaxx.compiler.reflect.FieldDescriptor; -import jaxx.compiler.reflect.MethodDescriptor; -import jaxx.compiler.tags.TagManager; - -import java.io.StringReader; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class ScriptManager { - - private JAXXCompiler compiler; - - public ScriptManager(JAXXCompiler compiler) { - this.compiler = compiler; - } - - /** - * Strips unnecessary curly braces from around the script, generating a warning if they are found. - * - * @param script script to trim - * @return the trimed script - */ - public String trimScript(String script) { - script = script.trim(); - if (script.startsWith("{") && script.endsWith("}")) { - compiler.reportWarning("curly braces are unnecessary for script '" + script + "'"); - script = script.substring(1, script.length() - 1); - } - return script; - } - - public void checkParse(String script) throws CompilerException { - script = trimScript(script); - JavaParser p = new JavaParser(new StringReader(script)); - while (!p.Line()) { - // ??? - } - } - - public String preprocessScript(String script) throws CompilerException { - script = trimScript(script); - StringBuffer result = new StringBuffer(); - JavaParser p = new JavaParser(new StringReader(script)); - while (!p.Line()) { - SimpleNode node = p.popNode(); - if (node != null) { - preprocessScriptNode(node, false); - result.append(node.getText()); - } - } - return result.toString(); - } - - /** - * Scans through a compound symbol (foo.bar.baz) to identify and compile the JAXX class it refers to, if any. - * - * @param symbol symbol to scan - */ - private void scanCompoundSymbol(String symbol) { - String[] tokens = symbol.split("\\."); - StringBuffer currentSymbol = new StringBuffer(); - for (String token : tokens) { - if (currentSymbol.length() > 0) { - currentSymbol.append('.'); - } - currentSymbol.append(token.trim()); - - String contextClass = TagManager.resolveClassName(currentSymbol.toString(), compiler); - if (contextClass != null) { - compiler.addDependencyClass(contextClass); - } - } - } - - private void preprocessScriptNode(SimpleNode node, boolean staticContext) throws CompilerException { - // identify static methods and initializers -- we can't fire events statically - if (node.getId() == JavaParserTreeConstants.JJTMETHODDECLARATION) { - if (node.getParent().getChild(0).getText().indexOf("static") != -1) { - staticContext = true; - } - } else if (node.getId() == JavaParserTreeConstants.JJTINITIALIZER) { - if (node.getText().trim().startsWith("static")) { - staticContext = true; - } - } - - int count = node.jjtGetNumChildren(); - for (int i = 0; i < count; i++) { - preprocessScriptNode(node.getChild(i), staticContext); - } - - int id = node.getId(); - if (id == JavaParserTreeConstants.JJTNAME || id == JavaParserTreeConstants.JJTCLASSORINTERFACETYPE) { - scanCompoundSymbol(node.getText()); - } - if (!staticContext) { - String lhs = null; - if (id == JavaParserTreeConstants.JJTASSIGNMENTEXPRESSION || (id == JavaParserTreeConstants.JJTPOSTFIXEXPRESSION && node.jjtGetNumChildren() == 2)) { - lhs = ((SimpleNode) node.jjtGetChild(0)).getText().trim(); - } else if (id == JavaParserTreeConstants.JJTPREINCREMENTEXPRESSION || id == JavaParserTreeConstants.JJTPREDECREMENTEXPRESSION) { - lhs = ((SimpleNode) node.jjtGetChild(0)).getText().trim(); - } - if (lhs != null) { - FieldDescriptor[] fields = compiler.getScriptFields(); - for (FieldDescriptor field : fields) { - if (field.getName().equals(lhs)) { - //lhs.substring(lhs.lastIndexOf(".") + 1); - node.firstToken.image = "jaxx.runtime.Util.assignment(" + node.firstToken.image; - String outputClassName = compiler.getOutputClassName(); - node.lastToken.image = node.lastToken.image + ", \"" + lhs + "\", " + outputClassName + ".this)"; - } - } - } - } - } - - /** - * Examines a Line to determine its real type. As all tokens returned by the parser are Lines, and - * they are just a tiny wrapper around the real node, this method strips off the wrapper layers to identify - * the real type of a node. - * - * @param line line to scan - * @return the line type - */ - private int getLineType(SimpleNode line) { - if (line.jjtGetNumChildren() == 1) { - SimpleNode node = line.getChild(0); - if (node.getId() == JavaParserTreeConstants.JJTBLOCKSTATEMENT) { - if (node.jjtGetNumChildren() == 1) { - return node.getChild(0).getId(); - } - } else if (node.getId() == JavaParserTreeConstants.JJTCLASSORINTERFACEBODYDECLARATION) { - int id = node.getChild(0).getId(); - if (id == JavaParserTreeConstants.JJTMODIFIERS) { - return node.getChild(1).getId(); - } - if (id == JavaParserTreeConstants.JJTINITIALIZER) { - return id; - } - } - return node.getId(); - } - return JavaParserTreeConstants.JJTLINE; // generic value implying that it's okay to put into the initializer block - } - - private SimpleNode findExplicitConstructorInvocation(SimpleNode parent) { - if (parent.getId() == JavaParserTreeConstants.JJTEXPLICITCONSTRUCTORINVOCATION) { - return parent; - } - - int count = parent.jjtGetNumChildren(); - for (int i = 0; i < count; i++) { - SimpleNode result = findExplicitConstructorInvocation(parent.getChild(i)); - if (result != null) { - return result; - } - } - return null; - } - - private void processConstructor(String modifiers, SimpleNode node) { - assert node.getId() == JavaParserTreeConstants.JJTCONSTRUCTORDECLARATION : "expected node to be ConstructorDeclaration, found " + JavaParserTreeConstants.jjtNodeName[node.getId()] + " instead"; - assert node.getChild(0).getId() == JavaParserTreeConstants.JJTFORMALPARAMETERS : "expected node 0 to be FormalParameters, found " + JavaParserTreeConstants.jjtNodeName[node.getChild(1).getId()] + " instead"; - String code = ""; - if (node.getChild(0).jjtGetNumChildren() == 0) { - compiler.reportError("The default no-argument constructor may not be redefined"); - } else { - SimpleNode explicitConstructorInvocation = findExplicitConstructorInvocation(node); - if (explicitConstructorInvocation == null || explicitConstructorInvocation.getText().trim().startsWith("super(")) { - code = "$initialize();" + JAXXCompiler.getLineSeparator(); - if (explicitConstructorInvocation == null) { - node.getChild(1).firstToken.image = node.getChild(1).firstToken.image; - } else { - explicitConstructorInvocation.lastToken.image += code; - } - } - } - - compiler.appendBodyCode(modifiers + " " + node.getText().substring(0, node.getText().length() - 1) + code + "}"); - } - - private void scanScriptNode(SimpleNode node) throws CompilerException { - int nodeType = getLineType(node); - if (nodeType == JavaParserTreeConstants.JJTIMPORTDECLARATION) { // have to handle imports early so the preprocessing takes them into account - String text = node.getChild(0).getText().trim(); - if (text.startsWith("import")) { - text = text.substring("import".length()).trim(); - } - if (text.endsWith(";")) { - text = text.substring(0, text.length() - 1); - } - compiler.addImport(text); - } - - preprocessScriptNode(node, false); - - if (nodeType == JavaParserTreeConstants.JJTIMPORTDECLARATION) { - // do nothing, already handled above - } else if (nodeType == JavaParserTreeConstants.JJTMETHODDECLARATION) { - String returnType = null; - String name = null; - List<String> parameterTypes = new ArrayList<String>(); - //List<String> parameterNames = new ArrayList<String>(); - SimpleNode methodDeclaration = node.getChild(0).getChild(1); - assert methodDeclaration.getId() == JavaParserTreeConstants.JJTMETHODDECLARATION; - for (int i = 0; i < methodDeclaration.jjtGetNumChildren(); i++) { - SimpleNode child = methodDeclaration.getChild(i); - int type = child.getId(); - if (type == JavaParserTreeConstants.JJTRESULTTYPE) { - String rawReturnType = child.getText().trim(); - returnType = TagManager.resolveClassName(rawReturnType, compiler); - // FIXME: this check fails for inner classes defined in this file - //if (returnType == null) - // throw new CompilerException("could not find class '" + rawReturnType + "'"); - } else if (type == JavaParserTreeConstants.JJTMETHODDECLARATOR) { - name = child.firstToken.image.trim(); - SimpleNode formalParameters = child.getChild(0); - assert formalParameters.getId() == JavaParserTreeConstants.JJTFORMALPARAMETERS; - for (int j = 0; j < formalParameters.jjtGetNumChildren(); j++) { - SimpleNode parameter = formalParameters.getChild(j); - String rawParameterType = parameter.getChild(1).getText().trim().replaceAll("\\.\\.\\.", "[]"); - String parameterType = TagManager.resolveClassName(rawParameterType, compiler); - // FIXME: this check fails for inner classes defined in this file - //if (parameterType == null) - // throw new CompilerException("could not find class '" + rawParameterType + "'"); - parameterTypes.add(parameterType); - //parameterNames.add(parameter.getChild(2).getText().trim()); - } - } - } - compiler.appendBodyCode(node.getText()); - compiler.addScriptMethod(new MethodDescriptor(name, Modifier.PUBLIC, returnType, parameterTypes.toArray(new String[parameterTypes.size()]), compiler.getClassLoader())); - } else if (nodeType == JavaParserTreeConstants.JJTCLASSORINTERFACEDECLARATION || - nodeType == JavaParserTreeConstants.JJTINITIALIZER) { - String str = node.getText().trim(); - if (str.endsWith(";")) { - str += ";"; - } - compiler.appendBodyCode(str); - } else if (nodeType == JavaParserTreeConstants.JJTCONSTRUCTORDECLARATION) { - processConstructor(node.getChild(0).getChild(0).getText(), node.getChild(0).getChild(1)); - } else if (nodeType == JavaParserTreeConstants.JJTLOCALVARIABLEDECLARATION || nodeType == JavaParserTreeConstants.JJTFIELDDECLARATION) { - // the "local" variable declarations in this expression aren't actually local -- they are flagged local - // just because there isn't an enclosing class scope visible to the parser. "Real" local variable - // declarations won't show up here, because they will be buried inside of methods. - String text = node.getText().trim(); - if (!text.endsWith(";")) { - text += ";"; - } - String declaration = text; - int equals = text.indexOf("="); - if (equals != -1) { - declaration = declaration.substring(0, equals); - } - declaration = declaration.trim(); - String[] declarationTokens = declaration.split("\\s"); - boolean isFinal = Arrays.asList(declarationTokens).contains("final"); - boolean isStatic = Arrays.asList(declarationTokens).contains("static"); - String name = declarationTokens[declarationTokens.length - 1]; - if (name.endsWith(";")) { - name = name.substring(0, name.length() - 1).trim(); - } - String className = declarationTokens[declarationTokens.length - 2]; - String type = TagManager.resolveClassName(className, compiler); - compiler.addScriptField(new FieldDescriptor(name, Modifier.PUBLIC, type, compiler.getClassLoader())); // TODO: determine the actual modifiers - if (equals != -1 && !isFinal && !isStatic) { // declare the field in the class body, but wait to actually initialize it - compiler.appendBodyCode(text.substring(0, equals).trim() + ";"); - String initializer = text.substring(equals + 1).trim(); - if (type.endsWith("[]")) { - initializer = "new " + type + " " + initializer; - } - final String finalInitializer = name + " = " + initializer; - compiler.registerInitializer(new Runnable() { - - @Override - public void run() { - compiler.registerCompiledObject(new ScriptInitializer(finalInitializer, compiler)); - } - }); - } else { - compiler.appendBodyCode(text); - } - compiler.appendBodyCode("\n"); - } else { - String text = node.getText().trim(); - if (text.length() > 0) { - if (!text.endsWith(";")) { - text += ";"; - } - compiler.appendInitializerCode(text); - } - } - } - - public void registerScript(String script) throws CompilerException { - JavaParser p = new JavaParser(new StringReader(script)); - while (!p.Line()) { - SimpleNode node = p.popNode(); - if (node != null) { - scanScriptNode(node); - } - } - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/script/ScriptManager.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/script/ScriptManager.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/script/ScriptManager.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/script/ScriptManager.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,332 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.script; + +import jaxx.compiler.*; +import jaxx.compiler.java.parser.JavaParser; +import jaxx.compiler.java.parser.JavaParserTreeConstants; +import jaxx.compiler.java.parser.SimpleNode; +import jaxx.compiler.reflect.FieldDescriptor; +import jaxx.compiler.reflect.MethodDescriptor; +import jaxx.compiler.tags.TagManager; + +import java.io.StringReader; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class ScriptManager { + + private JAXXCompiler compiler; + + public ScriptManager(JAXXCompiler compiler) { + this.compiler = compiler; + } + + /** + * Strips unnecessary curly braces from around the script, generating a warning if they are found. + * + * @param script script to trim + * @return the trimed script + */ + public String trimScript(String script) { + script = script.trim(); + if (script.startsWith("{") && script.endsWith("}")) { + compiler.reportWarning("curly braces are unnecessary for script '" + script + "'"); + script = script.substring(1, script.length() - 1); + } + return script; + } + + public void checkParse(String script) throws CompilerException { + script = trimScript(script); + JavaParser p = new JavaParser(new StringReader(script)); + while (!p.Line()) { + // ??? + } + } + + public String preprocessScript(String script) throws CompilerException { + script = trimScript(script); + StringBuffer result = new StringBuffer(); + JavaParser p = new JavaParser(new StringReader(script)); + while (!p.Line()) { + SimpleNode node = p.popNode(); + if (node != null) { + preprocessScriptNode(node, false); + result.append(node.getText()); + } + } + return result.toString(); + } + + /** + * Scans through a compound symbol (foo.bar.baz) to identify and compile the JAXX class it refers to, if any. + * + * @param symbol symbol to scan + */ + private void scanCompoundSymbol(String symbol) { + String[] tokens = symbol.split("\\."); + StringBuffer currentSymbol = new StringBuffer(); + for (String token : tokens) { + if (currentSymbol.length() > 0) { + currentSymbol.append('.'); + } + currentSymbol.append(token.trim()); + + String contextClass = TagManager.resolveClassName(currentSymbol.toString(), compiler); + if (contextClass != null) { + compiler.addDependencyClass(contextClass); + } + } + } + + private void preprocessScriptNode(SimpleNode node, boolean staticContext) throws CompilerException { + // identify static methods and initializers -- we can't fire events statically + if (node.getId() == JavaParserTreeConstants.JJTMETHODDECLARATION) { + if (node.getParent().getChild(0).getText().indexOf("static") != -1) { + staticContext = true; + } + } else if (node.getId() == JavaParserTreeConstants.JJTINITIALIZER) { + if (node.getText().trim().startsWith("static")) { + staticContext = true; + } + } + + int count = node.jjtGetNumChildren(); + for (int i = 0; i < count; i++) { + preprocessScriptNode(node.getChild(i), staticContext); + } + + int id = node.getId(); + if (id == JavaParserTreeConstants.JJTNAME || id == JavaParserTreeConstants.JJTCLASSORINTERFACETYPE) { + scanCompoundSymbol(node.getText()); + } + if (!staticContext) { + String lhs = null; + if (id == JavaParserTreeConstants.JJTASSIGNMENTEXPRESSION || (id == JavaParserTreeConstants.JJTPOSTFIXEXPRESSION && node.jjtGetNumChildren() == 2)) { + lhs = ((SimpleNode) node.jjtGetChild(0)).getText().trim(); + } else if (id == JavaParserTreeConstants.JJTPREINCREMENTEXPRESSION || id == JavaParserTreeConstants.JJTPREDECREMENTEXPRESSION) { + lhs = ((SimpleNode) node.jjtGetChild(0)).getText().trim(); + } + if (lhs != null) { + FieldDescriptor[] fields = compiler.getScriptFields(); + for (FieldDescriptor field : fields) { + if (field.getName().equals(lhs)) { + //lhs.substring(lhs.lastIndexOf(".") + 1); + node.firstToken.image = "jaxx.runtime.Util.assignment(" + node.firstToken.image; + String outputClassName = compiler.getOutputClassName(); + node.lastToken.image = node.lastToken.image + ", \"" + lhs + "\", " + outputClassName + ".this)"; + } + } + } + } + } + + /** + * Examines a Line to determine its real type. As all tokens returned by the parser are Lines, and + * they are just a tiny wrapper around the real node, this method strips off the wrapper layers to identify + * the real type of a node. + * + * @param line line to scan + * @return the line type + */ + private int getLineType(SimpleNode line) { + if (line.jjtGetNumChildren() == 1) { + SimpleNode node = line.getChild(0); + if (node.getId() == JavaParserTreeConstants.JJTBLOCKSTATEMENT) { + if (node.jjtGetNumChildren() == 1) { + return node.getChild(0).getId(); + } + } else if (node.getId() == JavaParserTreeConstants.JJTCLASSORINTERFACEBODYDECLARATION) { + int id = node.getChild(0).getId(); + if (id == JavaParserTreeConstants.JJTMODIFIERS) { + return node.getChild(1).getId(); + } + if (id == JavaParserTreeConstants.JJTINITIALIZER) { + return id; + } + } + return node.getId(); + } + return JavaParserTreeConstants.JJTLINE; // generic value implying that it's okay to put into the initializer block + } + + private SimpleNode findExplicitConstructorInvocation(SimpleNode parent) { + if (parent.getId() == JavaParserTreeConstants.JJTEXPLICITCONSTRUCTORINVOCATION) { + return parent; + } + + int count = parent.jjtGetNumChildren(); + for (int i = 0; i < count; i++) { + SimpleNode result = findExplicitConstructorInvocation(parent.getChild(i)); + if (result != null) { + return result; + } + } + return null; + } + + private void processConstructor(String modifiers, SimpleNode node) { + assert node.getId() == JavaParserTreeConstants.JJTCONSTRUCTORDECLARATION : "expected node to be ConstructorDeclaration, found " + JavaParserTreeConstants.jjtNodeName[node.getId()] + " instead"; + assert node.getChild(0).getId() == JavaParserTreeConstants.JJTFORMALPARAMETERS : "expected node 0 to be FormalParameters, found " + JavaParserTreeConstants.jjtNodeName[node.getChild(1).getId()] + " instead"; + String code = ""; + if (node.getChild(0).jjtGetNumChildren() == 0) { + compiler.reportError("The default no-argument constructor may not be redefined"); + } else { + SimpleNode explicitConstructorInvocation = findExplicitConstructorInvocation(node); + if (explicitConstructorInvocation == null || explicitConstructorInvocation.getText().trim().startsWith("super(")) { + code = "$initialize();" + JAXXCompiler.getLineSeparator(); + if (explicitConstructorInvocation == null) { + node.getChild(1).firstToken.image = node.getChild(1).firstToken.image; + } else { + explicitConstructorInvocation.lastToken.image += code; + } + } + } + + compiler.appendBodyCode(modifiers + " " + node.getText().substring(0, node.getText().length() - 1) + code + "}"); + } + + private void scanScriptNode(SimpleNode node) throws CompilerException { + int nodeType = getLineType(node); + if (nodeType == JavaParserTreeConstants.JJTIMPORTDECLARATION) { // have to handle imports early so the preprocessing takes them into account + String text = node.getChild(0).getText().trim(); + if (text.startsWith("import")) { + text = text.substring("import".length()).trim(); + } + if (text.endsWith(";")) { + text = text.substring(0, text.length() - 1); + } + compiler.addImport(text); + } + + preprocessScriptNode(node, false); + + if (nodeType == JavaParserTreeConstants.JJTIMPORTDECLARATION) { + // do nothing, already handled above + } else if (nodeType == JavaParserTreeConstants.JJTMETHODDECLARATION) { + String returnType = null; + String name = null; + List<String> parameterTypes = new ArrayList<String>(); + //List<String> parameterNames = new ArrayList<String>(); + SimpleNode methodDeclaration = node.getChild(0).getChild(1); + assert methodDeclaration.getId() == JavaParserTreeConstants.JJTMETHODDECLARATION; + for (int i = 0; i < methodDeclaration.jjtGetNumChildren(); i++) { + SimpleNode child = methodDeclaration.getChild(i); + int type = child.getId(); + if (type == JavaParserTreeConstants.JJTRESULTTYPE) { + String rawReturnType = child.getText().trim(); + returnType = TagManager.resolveClassName(rawReturnType, compiler); + // FIXME: this check fails for inner classes defined in this file + //if (returnType == null) + // throw new CompilerException("could not find class '" + rawReturnType + "'"); + } else if (type == JavaParserTreeConstants.JJTMETHODDECLARATOR) { + name = child.firstToken.image.trim(); + SimpleNode formalParameters = child.getChild(0); + assert formalParameters.getId() == JavaParserTreeConstants.JJTFORMALPARAMETERS; + for (int j = 0; j < formalParameters.jjtGetNumChildren(); j++) { + SimpleNode parameter = formalParameters.getChild(j); + String rawParameterType = parameter.getChild(1).getText().trim().replaceAll("\\.\\.\\.", "[]"); + String parameterType = TagManager.resolveClassName(rawParameterType, compiler); + // FIXME: this check fails for inner classes defined in this file + //if (parameterType == null) + // throw new CompilerException("could not find class '" + rawParameterType + "'"); + parameterTypes.add(parameterType); + //parameterNames.add(parameter.getChild(2).getText().trim()); + } + } + } + compiler.appendBodyCode(node.getText()); + compiler.addScriptMethod(new MethodDescriptor(name, Modifier.PUBLIC, returnType, parameterTypes.toArray(new String[parameterTypes.size()]), compiler.getClassLoader())); + } else if (nodeType == JavaParserTreeConstants.JJTCLASSORINTERFACEDECLARATION || + nodeType == JavaParserTreeConstants.JJTINITIALIZER) { + String str = node.getText().trim(); + if (str.endsWith(";")) { + str += ";"; + } + compiler.appendBodyCode(str); + } else if (nodeType == JavaParserTreeConstants.JJTCONSTRUCTORDECLARATION) { + processConstructor(node.getChild(0).getChild(0).getText(), node.getChild(0).getChild(1)); + } else if (nodeType == JavaParserTreeConstants.JJTLOCALVARIABLEDECLARATION || nodeType == JavaParserTreeConstants.JJTFIELDDECLARATION) { + // the "local" variable declarations in this expression aren't actually local -- they are flagged local + // just because there isn't an enclosing class scope visible to the parser. "Real" local variable + // declarations won't show up here, because they will be buried inside of methods. + String text = node.getText().trim(); + if (!text.endsWith(";")) { + text += ";"; + } + String declaration = text; + int equals = text.indexOf("="); + if (equals != -1) { + declaration = declaration.substring(0, equals); + } + declaration = declaration.trim(); + String[] declarationTokens = declaration.split("\\s"); + boolean isFinal = Arrays.asList(declarationTokens).contains("final"); + boolean isStatic = Arrays.asList(declarationTokens).contains("static"); + String name = declarationTokens[declarationTokens.length - 1]; + if (name.endsWith(";")) { + name = name.substring(0, name.length() - 1).trim(); + } + String className = declarationTokens[declarationTokens.length - 2]; + String type = TagManager.resolveClassName(className, compiler); + compiler.addScriptField(new FieldDescriptor(name, Modifier.PUBLIC, type, compiler.getClassLoader())); // TODO: determine the actual modifiers + if (equals != -1 && !isFinal && !isStatic) { // declare the field in the class body, but wait to actually initialize it + compiler.appendBodyCode(text.substring(0, equals).trim() + ";"); + String initializer = text.substring(equals + 1).trim(); + if (type.endsWith("[]")) { + initializer = "new " + type + " " + initializer; + } + final String finalInitializer = name + " = " + initializer; + compiler.registerInitializer(new Runnable() { + + @Override + public void run() { + compiler.registerCompiledObject(new ScriptInitializer(finalInitializer, compiler)); + } + }); + } else { + compiler.appendBodyCode(text); + } + compiler.appendBodyCode("\n"); + } else { + String text = node.getText().trim(); + if (text.length() > 0) { + if (!text.endsWith(";")) { + text += ";"; + } + compiler.appendInitializerCode(text); + } + } + } + + public void registerScript(String script) throws CompilerException { + JavaParser p = new JavaParser(new StringReader(script)); + while (!p.Line()) { + SimpleNode node = p.popNode(); + if (node != null) { + scanScriptNode(node); + } + } + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/spi/DefaultInitializer.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/spi/DefaultInitializer.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/spi/DefaultInitializer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,219 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.spi; - -import java.awt.Component; -import javax.swing.JCheckBox; -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JComboBox; -import javax.swing.JDialog; -import javax.swing.JEditorPane; -import javax.swing.JFormattedTextField; -import javax.swing.JFrame; -import javax.swing.JInternalFrame; -import javax.swing.JList; -import javax.swing.JMenu; -import javax.swing.JPasswordField; -import javax.swing.JPopupMenu; -import javax.swing.JProgressBar; -import javax.swing.JRadioButton; -import javax.swing.JRadioButtonMenuItem; -import javax.swing.JScrollPane; -import javax.swing.JSlider; -import javax.swing.JSpinner; -import javax.swing.JSplitPane; -import javax.swing.JTabbedPane; -import javax.swing.JTextArea; -import javax.swing.JTextField; -import javax.swing.JTextPane; -import javax.swing.JToggleButton; -import javax.swing.JToolBar; -import javax.swing.JTree; -import javax.swing.JWindow; -import javax.swing.text.JTextComponent; - -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.beans.BeanInfoUtil; - -import jaxx.compiler.reflect.ClassDescriptorLoader; - -import jaxx.compiler.tags.DefaultComponentHandler; -import jaxx.compiler.tags.DefaultObjectHandler; -import jaxx.compiler.tags.ScriptHandler; -import jaxx.compiler.tags.StyleHandler; -import jaxx.compiler.tags.TagHandler; -import jaxx.compiler.tags.TagManager; -import jaxx.compiler.tags.swing.ApplicationHandler; -import jaxx.compiler.tags.swing.CellHandler; -import jaxx.compiler.tags.swing.ItemHandler; -import jaxx.compiler.tags.swing.JAXXComboBoxHandler; -import jaxx.compiler.tags.swing.JAXXListHandler; -import jaxx.compiler.tags.swing.JAXXTabHandler; -import jaxx.compiler.tags.swing.JAXXTreeHandler; -import jaxx.compiler.tags.swing.JCheckBoxHandler; -import jaxx.compiler.tags.swing.JComboBoxHandler; -import jaxx.compiler.tags.swing.JInternalFrameHandler; -import jaxx.compiler.tags.swing.JListHandler; -import jaxx.compiler.tags.swing.JMenuHandler; -import jaxx.compiler.tags.swing.JPasswordFieldHandler; -import jaxx.compiler.tags.swing.JPopupMenuHandler; -import jaxx.compiler.tags.swing.JProgressBarHandler; -import jaxx.compiler.tags.swing.JRadioButtonHandler; -import jaxx.compiler.tags.swing.JScrollPaneHandler; -import jaxx.compiler.tags.swing.JSliderHandler; -import jaxx.compiler.tags.swing.JSpinnerHandler; -import jaxx.compiler.tags.swing.JSplitPaneHandler; -import jaxx.compiler.tags.swing.JTabbedPaneHandler; -import jaxx.compiler.tags.swing.JTextComponentHandler; -import jaxx.compiler.tags.swing.JToolBarHandler; -import jaxx.compiler.tags.swing.JTreeHandler; -import jaxx.compiler.tags.swing.JWindowHandler; -import jaxx.compiler.tags.swing.RowHandler; -import jaxx.compiler.tags.swing.TabHandler; -import jaxx.compiler.tags.swing.TableHandler; -import jaxx.compiler.tags.validator.BeanValidatorHandler; -import jaxx.compiler.tags.validator.ExcludeFieldValidatorHandler; -import jaxx.compiler.tags.validator.FieldValidatorHandler; - - -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.runtime.swing.editor.EnumEditor; -import jaxx.runtime.swing.editor.LocaleEditor; -import jaxx.runtime.validator.swing.SwingValidator; - -/** - * Initializes support provided from JAXX (java, swing and validation). - * - */ -public class DefaultInitializer implements Initializer { - - @Override - public void initialize() { - - BeanInfoUtil.addJaxxBeanInfoPath("jaxx.runtime.swing"); - - registerDefaultNamespace("javax.swing.*", - JEditorPane.class, - JFormattedTextField.class, - JPasswordField.class, - JTextArea.class, - JTextField.class, - JTextPane.class); - - // - // Register tags - // - - registerTag(JAXXCompiler.JAXX_NAMESPACE, "script", new ScriptHandler()); - registerTag(JAXXCompiler.JAXX_NAMESPACE, "style", new StyleHandler()); - - //TC-20091005 why the namespace was on awt ? ButtonGroup is from javax.swing - registerTag("javax.swing.*", "ButtonGroup", new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(JAXXButtonGroup.class))); -// TagManager.registerTag("java.awt.*", "ButtonGroup", new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(JAXXButtonGroup.class))); - - registerTag(JAXXCompiler.JAXX_NAMESPACE, "tab", new TabHandler()); - registerTag(JAXXCompiler.JAXX_NAMESPACE, "row", new RowHandler()); - registerTag(JAXXCompiler.JAXX_NAMESPACE, "cell", new CellHandler()); - registerTag(JAXXCompiler.JAXX_NAMESPACE, "item", new ItemHandler()); - - - registerTag(JAXXCompiler.JAXX_NAMESPACE, BeanValidatorHandler.TAG, new BeanValidatorHandler(ClassDescriptorLoader.getClassDescriptor(SwingValidator.class))); - registerTag(JAXXCompiler.JAXX_NAMESPACE, FieldValidatorHandler.TAG, new FieldValidatorHandler()); - registerTag(JAXXCompiler.JAXX_NAMESPACE, ExcludeFieldValidatorHandler.TAG, new FieldValidatorHandler()); - - // - // Register beans - // - - registerBean(Object.class, DefaultObjectHandler.class); - registerBean(Component.class, DefaultComponentHandler.class); - - // check boxes - registerBean(JCheckBox.class, JCheckBoxHandler.class); - registerBean(JCheckBoxMenuItem.class, JCheckBoxHandler.class); - - // combo boxes - registerBean(JComboBox.class, JComboBoxHandler.class); - registerBean(EnumEditor.class, JComboBoxHandler.class); - registerBean(LocaleEditor.class, JComboBoxHandler.class); - registerBean(JAXXComboBox.class, JAXXComboBoxHandler.class); - - // radio boxes - registerBean(JRadioButton.class, JRadioButtonHandler.class); - registerBean(JRadioButtonMenuItem.class, JRadioButtonHandler.class); - registerBean(JToggleButton.class, JRadioButtonHandler.class); - - // Lists - registerBean(JList.class, JListHandler.class); - registerBean(JAXXList.class, JAXXListHandler.class); - - // Trees - registerBean(JTree.class, JTreeHandler.class); - registerBean(JAXXTree.class, JAXXTreeHandler.class); - - // Windows - registerBean(JDialog.class, JWindowHandler.class); - registerBean(JFrame.class, JWindowHandler.class); - registerBean(JWindow.class, JWindowHandler.class); - - registerBean(Application.class, ApplicationHandler.class); - - registerBean(JInternalFrame.class, JInternalFrameHandler.class); - registerBean(JMenu.class, JMenuHandler.class); - registerBean(JPasswordField.class, JPasswordFieldHandler.class); - registerBean(JPopupMenu.class, JPopupMenuHandler.class); - registerBean(JProgressBar.class, JProgressBarHandler.class); - registerBean(JScrollPane.class, JScrollPaneHandler.class); - registerBean(JSlider.class, JSliderHandler.class); - registerBean(JSpinner.class, JSpinnerHandler.class); - registerBean(JSplitPane.class, JSplitPaneHandler.class); - registerBean(JTabbedPane.class, JTabbedPaneHandler.class); - registerBean(JTextComponent.class, JTextComponentHandler.class); - registerBean(JToolBar.class, JToolBarHandler.class); - - registerBean(Table.class, TableHandler.class); - registerBean(JAXXTab.class, JAXXTabHandler.class); - - registerBean(SwingValidator.class, BeanValidatorHandler.class); - - } - - protected void registerBean(Class<?> beanClass, Class<? extends TagHandler> handlerClass) { - TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(beanClass), handlerClass); - } - - protected void registerTag(String namespace, String tagName, TagHandler handler) { - TagManager.registerTag(namespace, tagName, handler); - } - - protected void registerDefaultNamespace(String namespace, Class<?>... beanClass) { - - for (Class<?> c : beanClass) { - TagManager.registerDefaultNamespace(c.getSimpleName(), namespace); - } - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/spi/DefaultInitializer.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/spi/DefaultInitializer.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/spi/DefaultInitializer.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/spi/DefaultInitializer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,219 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.spi; + +import java.awt.Component; +import javax.swing.JCheckBox; +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JComboBox; +import javax.swing.JDialog; +import javax.swing.JEditorPane; +import javax.swing.JFormattedTextField; +import javax.swing.JFrame; +import javax.swing.JInternalFrame; +import javax.swing.JList; +import javax.swing.JMenu; +import javax.swing.JPasswordField; +import javax.swing.JPopupMenu; +import javax.swing.JProgressBar; +import javax.swing.JRadioButton; +import javax.swing.JRadioButtonMenuItem; +import javax.swing.JScrollPane; +import javax.swing.JSlider; +import javax.swing.JSpinner; +import javax.swing.JSplitPane; +import javax.swing.JTabbedPane; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.JTextPane; +import javax.swing.JToggleButton; +import javax.swing.JToolBar; +import javax.swing.JTree; +import javax.swing.JWindow; +import javax.swing.text.JTextComponent; + +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.beans.BeanInfoUtil; + +import jaxx.compiler.reflect.ClassDescriptorLoader; + +import jaxx.compiler.tags.DefaultComponentHandler; +import jaxx.compiler.tags.DefaultObjectHandler; +import jaxx.compiler.tags.ScriptHandler; +import jaxx.compiler.tags.StyleHandler; +import jaxx.compiler.tags.TagHandler; +import jaxx.compiler.tags.TagManager; +import jaxx.compiler.tags.swing.ApplicationHandler; +import jaxx.compiler.tags.swing.CellHandler; +import jaxx.compiler.tags.swing.ItemHandler; +import jaxx.compiler.tags.swing.JAXXComboBoxHandler; +import jaxx.compiler.tags.swing.JAXXListHandler; +import jaxx.compiler.tags.swing.JAXXTabHandler; +import jaxx.compiler.tags.swing.JAXXTreeHandler; +import jaxx.compiler.tags.swing.JCheckBoxHandler; +import jaxx.compiler.tags.swing.JComboBoxHandler; +import jaxx.compiler.tags.swing.JInternalFrameHandler; +import jaxx.compiler.tags.swing.JListHandler; +import jaxx.compiler.tags.swing.JMenuHandler; +import jaxx.compiler.tags.swing.JPasswordFieldHandler; +import jaxx.compiler.tags.swing.JPopupMenuHandler; +import jaxx.compiler.tags.swing.JProgressBarHandler; +import jaxx.compiler.tags.swing.JRadioButtonHandler; +import jaxx.compiler.tags.swing.JScrollPaneHandler; +import jaxx.compiler.tags.swing.JSliderHandler; +import jaxx.compiler.tags.swing.JSpinnerHandler; +import jaxx.compiler.tags.swing.JSplitPaneHandler; +import jaxx.compiler.tags.swing.JTabbedPaneHandler; +import jaxx.compiler.tags.swing.JTextComponentHandler; +import jaxx.compiler.tags.swing.JToolBarHandler; +import jaxx.compiler.tags.swing.JTreeHandler; +import jaxx.compiler.tags.swing.JWindowHandler; +import jaxx.compiler.tags.swing.RowHandler; +import jaxx.compiler.tags.swing.TabHandler; +import jaxx.compiler.tags.swing.TableHandler; +import jaxx.compiler.tags.validator.BeanValidatorHandler; +import jaxx.compiler.tags.validator.ExcludeFieldValidatorHandler; +import jaxx.compiler.tags.validator.FieldValidatorHandler; + + +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.runtime.swing.editor.EnumEditor; +import jaxx.runtime.swing.editor.LocaleEditor; +import jaxx.runtime.validator.swing.SwingValidator; + +/** + * Initializes support provided from JAXX (java, swing and validation). + * + */ +public class DefaultInitializer implements Initializer { + + @Override + public void initialize() { + + BeanInfoUtil.addJaxxBeanInfoPath("jaxx.runtime.swing"); + + registerDefaultNamespace("javax.swing.*", + JEditorPane.class, + JFormattedTextField.class, + JPasswordField.class, + JTextArea.class, + JTextField.class, + JTextPane.class); + + // + // Register tags + // + + registerTag(JAXXCompiler.JAXX_NAMESPACE, "script", new ScriptHandler()); + registerTag(JAXXCompiler.JAXX_NAMESPACE, "style", new StyleHandler()); + + //TC-20091005 why the namespace was on awt ? ButtonGroup is from javax.swing + registerTag("javax.swing.*", "ButtonGroup", new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(JAXXButtonGroup.class))); +// TagManager.registerTag("java.awt.*", "ButtonGroup", new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(JAXXButtonGroup.class))); + + registerTag(JAXXCompiler.JAXX_NAMESPACE, "tab", new TabHandler()); + registerTag(JAXXCompiler.JAXX_NAMESPACE, "row", new RowHandler()); + registerTag(JAXXCompiler.JAXX_NAMESPACE, "cell", new CellHandler()); + registerTag(JAXXCompiler.JAXX_NAMESPACE, "item", new ItemHandler()); + + + registerTag(JAXXCompiler.JAXX_NAMESPACE, BeanValidatorHandler.TAG, new BeanValidatorHandler(ClassDescriptorLoader.getClassDescriptor(SwingValidator.class))); + registerTag(JAXXCompiler.JAXX_NAMESPACE, FieldValidatorHandler.TAG, new FieldValidatorHandler()); + registerTag(JAXXCompiler.JAXX_NAMESPACE, ExcludeFieldValidatorHandler.TAG, new FieldValidatorHandler()); + + // + // Register beans + // + + registerBean(Object.class, DefaultObjectHandler.class); + registerBean(Component.class, DefaultComponentHandler.class); + + // check boxes + registerBean(JCheckBox.class, JCheckBoxHandler.class); + registerBean(JCheckBoxMenuItem.class, JCheckBoxHandler.class); + + // combo boxes + registerBean(JComboBox.class, JComboBoxHandler.class); + registerBean(EnumEditor.class, JComboBoxHandler.class); + registerBean(LocaleEditor.class, JComboBoxHandler.class); + registerBean(JAXXComboBox.class, JAXXComboBoxHandler.class); + + // radio boxes + registerBean(JRadioButton.class, JRadioButtonHandler.class); + registerBean(JRadioButtonMenuItem.class, JRadioButtonHandler.class); + registerBean(JToggleButton.class, JRadioButtonHandler.class); + + // Lists + registerBean(JList.class, JListHandler.class); + registerBean(JAXXList.class, JAXXListHandler.class); + + // Trees + registerBean(JTree.class, JTreeHandler.class); + registerBean(JAXXTree.class, JAXXTreeHandler.class); + + // Windows + registerBean(JDialog.class, JWindowHandler.class); + registerBean(JFrame.class, JWindowHandler.class); + registerBean(JWindow.class, JWindowHandler.class); + + registerBean(Application.class, ApplicationHandler.class); + + registerBean(JInternalFrame.class, JInternalFrameHandler.class); + registerBean(JMenu.class, JMenuHandler.class); + registerBean(JPasswordField.class, JPasswordFieldHandler.class); + registerBean(JPopupMenu.class, JPopupMenuHandler.class); + registerBean(JProgressBar.class, JProgressBarHandler.class); + registerBean(JScrollPane.class, JScrollPaneHandler.class); + registerBean(JSlider.class, JSliderHandler.class); + registerBean(JSpinner.class, JSpinnerHandler.class); + registerBean(JSplitPane.class, JSplitPaneHandler.class); + registerBean(JTabbedPane.class, JTabbedPaneHandler.class); + registerBean(JTextComponent.class, JTextComponentHandler.class); + registerBean(JToolBar.class, JToolBarHandler.class); + + registerBean(Table.class, TableHandler.class); + registerBean(JAXXTab.class, JAXXTabHandler.class); + + registerBean(SwingValidator.class, BeanValidatorHandler.class); + + } + + protected void registerBean(Class<?> beanClass, Class<? extends TagHandler> handlerClass) { + TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(beanClass), handlerClass); + } + + protected void registerTag(String namespace, String tagName, TagHandler handler) { + TagManager.registerTag(namespace, tagName, handler); + } + + protected void registerDefaultNamespace(String namespace, Class<?>... beanClass) { + + for (Class<?> c : beanClass) { + TagManager.registerDefaultNamespace(c.getSimpleName(), namespace); + } + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/spi/Initializer.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/spi/Initializer.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/spi/Initializer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,37 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.spi; - -/** - * Performs SPI initialization, typically to register new tags, beans and converter. - * <p/> - * <b>Note:</b> To load such Initializer, we use the {@link java.util.ServiceLoader} mecanism. - * - * @see DefaultInitializer - */ -public interface Initializer { - - /** - * Performs SPI initialization, typically to register new - * tags, beans and converter. - */ - void initialize(); -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/spi/Initializer.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/spi/Initializer.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/spi/Initializer.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/spi/Initializer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,37 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.spi; + +/** + * Performs SPI initialization, typically to register new tags, beans and converter. + * <p/> + * <b>Note:</b> To load such Initializer, we use the {@link java.util.ServiceLoader} mecanism. + * + * @see DefaultInitializer + */ +public interface Initializer { + + /** + * Performs SPI initialization, typically to register new + * tags, beans and converter. + */ + void initialize(); +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultComponentHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultComponentHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultComponentHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,372 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.UnsupportedAttributeException; -import jaxx.compiler.CompiledObject; -import jaxx.compiler.I18nHelper; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.runtime.SwingUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.w3c.dom.Element; - -import java.awt.Component; -import java.awt.Container; -import java.awt.event.ComponentListener; -import java.awt.event.ContainerListener; -import java.awt.event.FocusListener; -import java.beans.IntrospectionException; -import java.io.IOException; -import java.lang.reflect.Field; - -import org.w3c.dom.Attr; -import org.w3c.dom.NamedNodeMap; - -public class DefaultComponentHandler extends DefaultObjectHandler { - - public static final String ACTION_ICON_ATTRIBUTE = "actionIcon"; - public static final String CONTAINER_DELEGATE_ATTRIBUTE = "containerDelegate"; - public static final String FONT_FACE_ATTRIBUTE = "font-face"; - public static final String FONT_SIZE_ATTRIBUTE = "font-size"; - public static final String FONT_STYLE_ATTRIBUTE = "font-style"; - public static final String FONT_WEIGHT_ATTRIBUTE = "font-weight"; - public static final String HEIGHT_ATTRIBUTE = "height"; - public static final String ICON_ATTRIBUTE = "icon"; - public static final String NAME_ATTRIBUTE = "name"; - public static final String WIDTH_ATTRIBUTE = "width"; - public static final String X_ATTRIBUTE = "x"; - public static final String Y_ATTRIBUTE = "y"; - /** - * Logger - */ - protected static final Log log = LogFactory.getLog(DefaultComponentHandler.class); - /** - * container delegate (if any) - */ - private String containerDelegate; - - public DefaultComponentHandler(ClassDescriptor beanClass) { - super(beanClass); - ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, Component.class); - } - - @Override - protected void init() throws IntrospectionException { - if (jaxxBeanInfo == null) { - super.init(); - - containerDelegate = (String) getJAXXBeanInfo().getJAXXBeanDescriptor().getValue(CONTAINER_DELEGATE_ATTRIBUTE); - if (containerDelegate == null && ClassDescriptorLoader.getClassDescriptor(Container.class).isAssignableFrom(getBeanClass().getSuperclass())) { - containerDelegate = ((DefaultComponentHandler) TagManager.getTagHandler(getBeanClass().getSuperclass())).getContainerDelegate(); - } - } - } - - @Override - protected void configureProxyEventInfo() { - super.configureProxyEventInfo(); - addProxyEventInfo("hasFocus", FocusListener.class); - addProxyEventInfo("isVisible", ComponentListener.class); - addProxyEventInfo("getBounds", ComponentListener.class); - addProxyEventInfo("getLocation", ComponentListener.class); - addProxyEventInfo("getLocationOnScreen", ComponentListener.class); - addProxyEventInfo("getSize", ComponentListener.class); - addProxyEventInfo("getX", ComponentListener.class); - addProxyEventInfo("getY", ComponentListener.class); - addProxyEventInfo("getWidth", ComponentListener.class); - addProxyEventInfo("getHeight", ComponentListener.class); - if (ClassDescriptorLoader.getClassDescriptor(Container.class).isAssignableFrom(getBeanClass())) { - addProxyEventInfo("getComponentCount", ContainerListener.class); - } - } - - @Override - protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException { - super.setDefaults(object, tag, compiler); - setAttribute(object, NAME_ATTRIBUTE, object.getId(), false, compiler); - openComponent(object, tag, compiler); - } - - @Override - public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - super.compileFirstPass(tag, compiler); - } - - @Override - public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - super.compileSecondPass(tag, compiler); - closeComponent(compiler.getOpenComponent(), tag, compiler); - } - - protected void openComponent(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException { - String constraints = tag.getAttribute(CONSTRAINTS_ATTRIBUTE); - if (constraints != null && constraints.length() > 0) { - compiler.openComponent(object, constraints); - } else { - compiler.openComponent(object); - } - } - - protected void closeComponent(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException { - compiler.closeComponent(object); - } - - @Override - public boolean isPropertyInherited(String property) throws UnsupportedAttributeException { - return property.equals("font") || property.startsWith("font-") || property.equals("foreground") || property.equals("enabled"); - } - - @Override - public ClassDescriptor getPropertyType(CompiledObject object, String propertyName, JAXXCompiler compiler) throws CompilerException { - if (propertyName.equals(X_ATTRIBUTE) || - propertyName.equals(Y_ATTRIBUTE) || - propertyName.equals(WIDTH_ATTRIBUTE) || - propertyName.equals(HEIGHT_ATTRIBUTE) || - FONT_SIZE_ATTRIBUTE.equals(propertyName)) { - return ClassDescriptorLoader.getClassDescriptor(Integer.class); - } - if (propertyName.equals(FONT_FACE_ATTRIBUTE) || - propertyName.equals(FONT_STYLE_ATTRIBUTE) || - propertyName.equals(FONT_WEIGHT_ATTRIBUTE)) { - return ClassDescriptorLoader.getClassDescriptor(String.class); - } - return super.getPropertyType(object, propertyName, compiler); - } - - @Override - public String getGetPropertyCode(String id, String name, JAXXCompiler compiler) throws CompilerException { - if (name.equals(FONT_FACE_ATTRIBUTE)) { - return id + ".getFont().getFontName()"; - } - if (name.equals(FONT_SIZE_ATTRIBUTE)) { - return id + ".getFont().getSize()"; - } - if (name.equals(FONT_WEIGHT_ATTRIBUTE)) { - return "(" + id + ".getFont().getStyle() & Font.BOLD) != 0 ? \"bold\" : \"normal\""; - } - if (name.equals(FONT_STYLE_ATTRIBUTE)) { - return "(" + id + ".getFont().getStyle() & Font.ITALIC) != 0 ? \"italic\" : \"normal\""; - } - return super.getGetPropertyCode(id, name, compiler); - } - - @Override - public String getSetPropertyCode(String id, String name, String valueCode, JAXXCompiler compiler) throws CompilerException { - if (name.equals(X_ATTRIBUTE)) { - return id + ".setLocation(" + valueCode + ", " + id + ".getY());"; - } - if (name.equals(Y_ATTRIBUTE)) { - return id + ".setLocation(" + id + ".getX(), " + valueCode + ");"; - } - if (name.equals(WIDTH_ATTRIBUTE)) { - // need to optimize case when both width and height are being assigned - return SwingUtil.class.getSimpleName() + ".setComponentWidth(" + id + "," + valueCode + ");"; - } - if (name.equals(HEIGHT_ATTRIBUTE)) { - return SwingUtil.class.getSimpleName() + ".setComponentHeight(" + id + "," + valueCode + ");"; - } - if (name.equals(FONT_FACE_ATTRIBUTE)) { - return "if (" + id + ".getFont() != null) {\n " + id + ".setFont(new Font(" + valueCode + ", " + id + ".getFont().getStyle(), " + id + ".getFont().getSize()));\n}"; - } - if (name.equals(FONT_SIZE_ATTRIBUTE)) { - return "if (" + id + ".getFont() != null) {\n " + id + ".setFont(" + id + ".getFont().deriveFont((float) " + valueCode + "));\n}"; - } - if (name.equals(FONT_WEIGHT_ATTRIBUTE)) { - if (valueCode.equals("\"bold\"")) { - return "if (" + id + ".getFont() != null) {\n " + id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() | Font.BOLD));\n}"; - } - if (valueCode.equals("\"normal\"")) { - return "if (" + id + ".getFont() != null) {\n " + id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() & ~Font.BOLD));\n}"; - } - if (!valueCode.startsWith("\"")) { - return "if (" + id + ".getFont() != null) {\n if ((" + valueCode + ").equals(\"bold\")) {\n " + - id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() | Font.BOLD));\n } else {\n " + - id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() & ~Font.BOLD));\n }\n}"; - } - compiler.reportError("font-weight must be either \"normal\" or \"bold\", found " + valueCode); - return ""; - } - if (name.equals(FONT_STYLE_ATTRIBUTE)) { - if (valueCode.equals("\"italic\"")) { - return "if (" + id + ".getFont() != null) {\n " + id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() | Font.ITALIC));\n}"; - } - if (valueCode.equals("\"normal\"")) { - return "if (" + id + ".getFont() != null) {\n " + id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() & ~Font.ITALIC));\n}"; - } - if (!valueCode.startsWith("\"")) { - return "if (" + id + ".getFont() != null) {\n if ((" + valueCode + ").equals(\"italic\")) {\n " + - id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() | Font.ITALIC));\n } else {\n " + - id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() & ~Font.ITALIC));\n }\n}"; - } - compiler.reportError("font-style must be either \"normal\" or \"italic\", found " + valueCode); - return ""; - } - if (ClassDescriptorLoader.getClassDescriptor(Container.class).isAssignableFrom(getBeanClass()) && name.equals(LAYOUT_ATTRIBUTE)) { - // handle containerDelegate (e.g. contentPane on JFrame) - String cDelegate = (String) getJAXXBeanInfo().getJAXXBeanDescriptor().getValue(CONTAINER_DELEGATE_ATTRIBUTE); - if (cDelegate != null) { - return id + '.' + cDelegate + "().setLayout(" + valueCode + ");"; - } - } - // ajout du support i18n - if (I18nHelper.isI18nableAttribute(name, compiler)) { - valueCode = I18nHelper.addI18nInvocation(id, name, valueCode, compiler); - } - - return super.getSetPropertyCode(id, name, valueCode, compiler); - } - - @Override - public void setAttribute(CompiledObject object, String propertyName, String stringValue, boolean inline, JAXXCompiler compiler) { - - if (propertyName.startsWith("_")) { - // client property - if (stringValue.startsWith("{")) { - stringValue = stringValue.substring(1, stringValue.length() - 1); - } - object.addClientProperty(propertyName.substring(1), stringValue); - //TC-20090327 rather not generating code here - //object.appendAdditionCode(object.getJavaCode() + ".putClientProperty(\"" + propertyName.substring(1) + "\", " + stringValue + ");"); - return; - } - if (ICON_ATTRIBUTE.equals(propertyName)) { - if (!(stringValue.startsWith("{") || stringValue.endsWith("}"))) { - // this is a customized icon, add the icon creation code - if (compiler.getConfiguration().isUseUIManagerForIcon()) { - stringValue = "{" + SwingUtil.class.getName() + ".getUIManagerIcon(\"" + stringValue + "\")}"; - } else { - stringValue = "{" + SwingUtil.class.getName() + ".createImageIcon(\"" + stringValue + "\")}"; - } - } - } else if (ACTION_ICON_ATTRIBUTE.equals(propertyName)) { - // customized actionIcon property - if (stringValue.startsWith("{") && stringValue.endsWith("}")) { - // there is a script to define the action icon, this is forbidden - compiler.reportError("the actionIcon does not support script, remove braces..., fix the file " + compiler.getOutputClassName()); - return; - } - propertyName = ICON_ATTRIBUTE; - if (compiler.getConfiguration().isUseUIManagerForIcon()) { - stringValue = "{" + SwingUtil.class.getName() + ".getUIManagerActionIcon(\"" + stringValue + "\")}"; - } else { - stringValue = "{" + SwingUtil.class.getName() + ".createActionIcon(\"" + stringValue + "\")}"; - } - } - super.setAttribute(object, propertyName, stringValue, inline, compiler); - } - - @Override - protected void scanAttributesForDependencies(Element tag, JAXXCompiler compiler) { - super.scanAttributesForDependencies(tag, compiler); - // check for clientProperty attributes - //FIXME make this works,... it seems jaxx compiler does not come here ? - //FIXME see the the firstPassHandler in JAXXCompiler ? - NamedNodeMap children = tag.getAttributes(); - for (int i = 0, max = children.getLength(); i < max; i++) { - Attr attr = (Attr) children.item(i); - String name = attr.getName(); - if (!name.startsWith("_")) { - continue; - } - String value = attr.getValue(); - if (value.startsWith("{")) { - compiler.reportWarning(tag, "an clientProperty attribute " + name.substring(1) + " does not required curly value but was : " + value, 0); - } - } - - } - - /** - * 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 - * 'right' onto SwingConstants.LEFT, SwingConstants.CENTER, and SwingConstants.RIGHT respectively. - * <p/> - * You do not normally need to call this method yourself; it is invoked by {@link #convertFromString} when an - * int-valued property has a value which is not a valid number. By default, this method looks at the - * <code>enumerationValues</code> value of the <code>JAXXPropertyDescriptor</code>. - * - * @param key the name of the int-typed property - * @param value the non-numeric value that was specified for the property - * @throws IllegalArgumentException if the property is an enumeration, but the value is not valid - * @throws NumberFormatException if the property is not an enumeration - */ - @Override - protected int constantValue(String key, String value) { - if ((key.equals(MNEMONIC_ATTRIBUTE) || key.equals(DISPLAYED_MNEMONIC_ATTRIBUTE))) { - if (value.length() == 1) { - return value.charAt(0); - } - try { - Field vk = java.awt.event.KeyEvent.class.getField(value); - return (Integer) vk.get(null); - } catch (NoSuchFieldException e) { - throw new IllegalArgumentException("mnemonics must be either a single character or the name of a field in KeyEvent (found: '" + value + "')"); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - } - return super.constantValue(key, value); - } - - /** - * Returns <code>true</code> if this component can contain other components. For children to be - * allowed, the component must be a subclass of <code>Container</code> and its <code>JAXXBeanInfo</code> - * must not have the value <code>false</code> for its <code>isContainer</code> value. - * - * @return <code>true</code> if children are allowed - */ - public boolean isContainer() { - boolean container = ClassDescriptorLoader.getClassDescriptor(Container.class).isAssignableFrom(getBeanClass()); -// if (container) { -// try { -// init(); -// if (Boolean.FALSE.equals(getJAXXBeanInfo().getJAXXBeanDescriptor().getValue("isContainer"))) { -// container = false; -// } -// } catch (IntrospectionException e) { -// throw new RuntimeException(e); -// } -// } - safeInit(); - if (container) { - if (Boolean.FALSE.equals(getJAXXBeanInfo().getJAXXBeanDescriptor().getValue("isContainer"))) { - container = false; - } - } - return container; - } - - public String getContainerDelegate() { -// try { -// init(); -// return containerDelegate; -// } catch (IntrospectionException e) { -// throw new RuntimeException(e); -// } - safeInit(); - return containerDelegate; - - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultComponentHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultComponentHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultComponentHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultComponentHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,372 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.UnsupportedAttributeException; +import jaxx.compiler.CompiledObject; +import jaxx.compiler.I18nHelper; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.runtime.SwingUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.w3c.dom.Element; + +import java.awt.Component; +import java.awt.Container; +import java.awt.event.ComponentListener; +import java.awt.event.ContainerListener; +import java.awt.event.FocusListener; +import java.beans.IntrospectionException; +import java.io.IOException; +import java.lang.reflect.Field; + +import org.w3c.dom.Attr; +import org.w3c.dom.NamedNodeMap; + +public class DefaultComponentHandler extends DefaultObjectHandler { + + public static final String ACTION_ICON_ATTRIBUTE = "actionIcon"; + public static final String CONTAINER_DELEGATE_ATTRIBUTE = "containerDelegate"; + public static final String FONT_FACE_ATTRIBUTE = "font-face"; + public static final String FONT_SIZE_ATTRIBUTE = "font-size"; + public static final String FONT_STYLE_ATTRIBUTE = "font-style"; + public static final String FONT_WEIGHT_ATTRIBUTE = "font-weight"; + public static final String HEIGHT_ATTRIBUTE = "height"; + public static final String ICON_ATTRIBUTE = "icon"; + public static final String NAME_ATTRIBUTE = "name"; + public static final String WIDTH_ATTRIBUTE = "width"; + public static final String X_ATTRIBUTE = "x"; + public static final String Y_ATTRIBUTE = "y"; + /** + * Logger + */ + protected static final Log log = LogFactory.getLog(DefaultComponentHandler.class); + /** + * container delegate (if any) + */ + private String containerDelegate; + + public DefaultComponentHandler(ClassDescriptor beanClass) { + super(beanClass); + ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, Component.class); + } + + @Override + protected void init() throws IntrospectionException { + if (jaxxBeanInfo == null) { + super.init(); + + containerDelegate = (String) getJAXXBeanInfo().getJAXXBeanDescriptor().getValue(CONTAINER_DELEGATE_ATTRIBUTE); + if (containerDelegate == null && ClassDescriptorLoader.getClassDescriptor(Container.class).isAssignableFrom(getBeanClass().getSuperclass())) { + containerDelegate = ((DefaultComponentHandler) TagManager.getTagHandler(getBeanClass().getSuperclass())).getContainerDelegate(); + } + } + } + + @Override + protected void configureProxyEventInfo() { + super.configureProxyEventInfo(); + addProxyEventInfo("hasFocus", FocusListener.class); + addProxyEventInfo("isVisible", ComponentListener.class); + addProxyEventInfo("getBounds", ComponentListener.class); + addProxyEventInfo("getLocation", ComponentListener.class); + addProxyEventInfo("getLocationOnScreen", ComponentListener.class); + addProxyEventInfo("getSize", ComponentListener.class); + addProxyEventInfo("getX", ComponentListener.class); + addProxyEventInfo("getY", ComponentListener.class); + addProxyEventInfo("getWidth", ComponentListener.class); + addProxyEventInfo("getHeight", ComponentListener.class); + if (ClassDescriptorLoader.getClassDescriptor(Container.class).isAssignableFrom(getBeanClass())) { + addProxyEventInfo("getComponentCount", ContainerListener.class); + } + } + + @Override + protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException { + super.setDefaults(object, tag, compiler); + setAttribute(object, NAME_ATTRIBUTE, object.getId(), false, compiler); + openComponent(object, tag, compiler); + } + + @Override + public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + super.compileFirstPass(tag, compiler); + } + + @Override + public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + super.compileSecondPass(tag, compiler); + closeComponent(compiler.getOpenComponent(), tag, compiler); + } + + protected void openComponent(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException { + String constraints = tag.getAttribute(CONSTRAINTS_ATTRIBUTE); + if (constraints != null && constraints.length() > 0) { + compiler.openComponent(object, constraints); + } else { + compiler.openComponent(object); + } + } + + protected void closeComponent(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException { + compiler.closeComponent(object); + } + + @Override + public boolean isPropertyInherited(String property) throws UnsupportedAttributeException { + return property.equals("font") || property.startsWith("font-") || property.equals("foreground") || property.equals("enabled"); + } + + @Override + public ClassDescriptor getPropertyType(CompiledObject object, String propertyName, JAXXCompiler compiler) throws CompilerException { + if (propertyName.equals(X_ATTRIBUTE) || + propertyName.equals(Y_ATTRIBUTE) || + propertyName.equals(WIDTH_ATTRIBUTE) || + propertyName.equals(HEIGHT_ATTRIBUTE) || + FONT_SIZE_ATTRIBUTE.equals(propertyName)) { + return ClassDescriptorLoader.getClassDescriptor(Integer.class); + } + if (propertyName.equals(FONT_FACE_ATTRIBUTE) || + propertyName.equals(FONT_STYLE_ATTRIBUTE) || + propertyName.equals(FONT_WEIGHT_ATTRIBUTE)) { + return ClassDescriptorLoader.getClassDescriptor(String.class); + } + return super.getPropertyType(object, propertyName, compiler); + } + + @Override + public String getGetPropertyCode(String id, String name, JAXXCompiler compiler) throws CompilerException { + if (name.equals(FONT_FACE_ATTRIBUTE)) { + return id + ".getFont().getFontName()"; + } + if (name.equals(FONT_SIZE_ATTRIBUTE)) { + return id + ".getFont().getSize()"; + } + if (name.equals(FONT_WEIGHT_ATTRIBUTE)) { + return "(" + id + ".getFont().getStyle() & Font.BOLD) != 0 ? \"bold\" : \"normal\""; + } + if (name.equals(FONT_STYLE_ATTRIBUTE)) { + return "(" + id + ".getFont().getStyle() & Font.ITALIC) != 0 ? \"italic\" : \"normal\""; + } + return super.getGetPropertyCode(id, name, compiler); + } + + @Override + public String getSetPropertyCode(String id, String name, String valueCode, JAXXCompiler compiler) throws CompilerException { + if (name.equals(X_ATTRIBUTE)) { + return id + ".setLocation(" + valueCode + ", " + id + ".getY());"; + } + if (name.equals(Y_ATTRIBUTE)) { + return id + ".setLocation(" + id + ".getX(), " + valueCode + ");"; + } + if (name.equals(WIDTH_ATTRIBUTE)) { + // need to optimize case when both width and height are being assigned + return SwingUtil.class.getSimpleName() + ".setComponentWidth(" + id + "," + valueCode + ");"; + } + if (name.equals(HEIGHT_ATTRIBUTE)) { + return SwingUtil.class.getSimpleName() + ".setComponentHeight(" + id + "," + valueCode + ");"; + } + if (name.equals(FONT_FACE_ATTRIBUTE)) { + return "if (" + id + ".getFont() != null) {\n " + id + ".setFont(new Font(" + valueCode + ", " + id + ".getFont().getStyle(), " + id + ".getFont().getSize()));\n}"; + } + if (name.equals(FONT_SIZE_ATTRIBUTE)) { + return "if (" + id + ".getFont() != null) {\n " + id + ".setFont(" + id + ".getFont().deriveFont((float) " + valueCode + "));\n}"; + } + if (name.equals(FONT_WEIGHT_ATTRIBUTE)) { + if (valueCode.equals("\"bold\"")) { + return "if (" + id + ".getFont() != null) {\n " + id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() | Font.BOLD));\n}"; + } + if (valueCode.equals("\"normal\"")) { + return "if (" + id + ".getFont() != null) {\n " + id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() & ~Font.BOLD));\n}"; + } + if (!valueCode.startsWith("\"")) { + return "if (" + id + ".getFont() != null) {\n if ((" + valueCode + ").equals(\"bold\")) {\n " + + id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() | Font.BOLD));\n } else {\n " + + id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() & ~Font.BOLD));\n }\n}"; + } + compiler.reportError("font-weight must be either \"normal\" or \"bold\", found " + valueCode); + return ""; + } + if (name.equals(FONT_STYLE_ATTRIBUTE)) { + if (valueCode.equals("\"italic\"")) { + return "if (" + id + ".getFont() != null) {\n " + id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() | Font.ITALIC));\n}"; + } + if (valueCode.equals("\"normal\"")) { + return "if (" + id + ".getFont() != null) {\n " + id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() & ~Font.ITALIC));\n}"; + } + if (!valueCode.startsWith("\"")) { + return "if (" + id + ".getFont() != null) {\n if ((" + valueCode + ").equals(\"italic\")) {\n " + + id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() | Font.ITALIC));\n } else {\n " + + id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() & ~Font.ITALIC));\n }\n}"; + } + compiler.reportError("font-style must be either \"normal\" or \"italic\", found " + valueCode); + return ""; + } + if (ClassDescriptorLoader.getClassDescriptor(Container.class).isAssignableFrom(getBeanClass()) && name.equals(LAYOUT_ATTRIBUTE)) { + // handle containerDelegate (e.g. contentPane on JFrame) + String cDelegate = (String) getJAXXBeanInfo().getJAXXBeanDescriptor().getValue(CONTAINER_DELEGATE_ATTRIBUTE); + if (cDelegate != null) { + return id + '.' + cDelegate + "().setLayout(" + valueCode + ");"; + } + } + // ajout du support i18n + if (I18nHelper.isI18nableAttribute(name, compiler)) { + valueCode = I18nHelper.addI18nInvocation(id, name, valueCode, compiler); + } + + return super.getSetPropertyCode(id, name, valueCode, compiler); + } + + @Override + public void setAttribute(CompiledObject object, String propertyName, String stringValue, boolean inline, JAXXCompiler compiler) { + + if (propertyName.startsWith("_")) { + // client property + if (stringValue.startsWith("{")) { + stringValue = stringValue.substring(1, stringValue.length() - 1); + } + object.addClientProperty(propertyName.substring(1), stringValue); + //TC-20090327 rather not generating code here + //object.appendAdditionCode(object.getJavaCode() + ".putClientProperty(\"" + propertyName.substring(1) + "\", " + stringValue + ");"); + return; + } + if (ICON_ATTRIBUTE.equals(propertyName)) { + if (!(stringValue.startsWith("{") || stringValue.endsWith("}"))) { + // this is a customized icon, add the icon creation code + if (compiler.getConfiguration().isUseUIManagerForIcon()) { + stringValue = "{" + SwingUtil.class.getName() + ".getUIManagerIcon(\"" + stringValue + "\")}"; + } else { + stringValue = "{" + SwingUtil.class.getName() + ".createImageIcon(\"" + stringValue + "\")}"; + } + } + } else if (ACTION_ICON_ATTRIBUTE.equals(propertyName)) { + // customized actionIcon property + if (stringValue.startsWith("{") && stringValue.endsWith("}")) { + // there is a script to define the action icon, this is forbidden + compiler.reportError("the actionIcon does not support script, remove braces..., fix the file " + compiler.getOutputClassName()); + return; + } + propertyName = ICON_ATTRIBUTE; + if (compiler.getConfiguration().isUseUIManagerForIcon()) { + stringValue = "{" + SwingUtil.class.getName() + ".getUIManagerActionIcon(\"" + stringValue + "\")}"; + } else { + stringValue = "{" + SwingUtil.class.getName() + ".createActionIcon(\"" + stringValue + "\")}"; + } + } + super.setAttribute(object, propertyName, stringValue, inline, compiler); + } + + @Override + protected void scanAttributesForDependencies(Element tag, JAXXCompiler compiler) { + super.scanAttributesForDependencies(tag, compiler); + // check for clientProperty attributes + //FIXME make this works,... it seems jaxx compiler does not come here ? + //FIXME see the the firstPassHandler in JAXXCompiler ? + NamedNodeMap children = tag.getAttributes(); + for (int i = 0, max = children.getLength(); i < max; i++) { + Attr attr = (Attr) children.item(i); + String name = attr.getName(); + if (!name.startsWith("_")) { + continue; + } + String value = attr.getValue(); + if (value.startsWith("{")) { + compiler.reportWarning(tag, "an clientProperty attribute " + name.substring(1) + " does not required curly value but was : " + value, 0); + } + } + + } + + /** + * 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 + * 'right' onto SwingConstants.LEFT, SwingConstants.CENTER, and SwingConstants.RIGHT respectively. + * <p/> + * You do not normally need to call this method yourself; it is invoked by {@link #convertFromString} when an + * int-valued property has a value which is not a valid number. By default, this method looks at the + * <code>enumerationValues</code> value of the <code>JAXXPropertyDescriptor</code>. + * + * @param key the name of the int-typed property + * @param value the non-numeric value that was specified for the property + * @throws IllegalArgumentException if the property is an enumeration, but the value is not valid + * @throws NumberFormatException if the property is not an enumeration + */ + @Override + protected int constantValue(String key, String value) { + if ((key.equals(MNEMONIC_ATTRIBUTE) || key.equals(DISPLAYED_MNEMONIC_ATTRIBUTE))) { + if (value.length() == 1) { + return value.charAt(0); + } + try { + Field vk = java.awt.event.KeyEvent.class.getField(value); + return (Integer) vk.get(null); + } catch (NoSuchFieldException e) { + throw new IllegalArgumentException("mnemonics must be either a single character or the name of a field in KeyEvent (found: '" + value + "')"); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + } + return super.constantValue(key, value); + } + + /** + * Returns <code>true</code> if this component can contain other components. For children to be + * allowed, the component must be a subclass of <code>Container</code> and its <code>JAXXBeanInfo</code> + * must not have the value <code>false</code> for its <code>isContainer</code> value. + * + * @return <code>true</code> if children are allowed + */ + public boolean isContainer() { + boolean container = ClassDescriptorLoader.getClassDescriptor(Container.class).isAssignableFrom(getBeanClass()); +// if (container) { +// try { +// init(); +// if (Boolean.FALSE.equals(getJAXXBeanInfo().getJAXXBeanDescriptor().getValue("isContainer"))) { +// container = false; +// } +// } catch (IntrospectionException e) { +// throw new RuntimeException(e); +// } +// } + safeInit(); + if (container) { + if (Boolean.FALSE.equals(getJAXXBeanInfo().getJAXXBeanDescriptor().getValue("isContainer"))) { + container = false; + } + } + return container; + } + + public String getContainerDelegate() { +// try { +// init(); +// return containerDelegate; +// } catch (IntrospectionException e) { +// throw new RuntimeException(e); +// } + safeInit(); + return containerDelegate; + + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,1244 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags; - -import jaxx.compiler.*; -import jaxx.compiler.beans.JAXXBeanInfo; -import jaxx.compiler.beans.JAXXEventSetDescriptor; -import jaxx.compiler.beans.JAXXIntrospector; -import jaxx.compiler.beans.JAXXPropertyDescriptor; -import jaxx.compiler.binding.DataBindingHelper; -import jaxx.compiler.css.StylesheetHelper; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.reflect.FieldDescriptor; -import jaxx.compiler.reflect.MethodDescriptor; -import jaxx.compiler.types.TypeManager; -import jaxx.runtime.ComponentDescriptor; -import jaxx.runtime.JAXXObject; -import jaxx.runtime.JAXXObjectDescriptor; -import jaxx.runtime.css.Stylesheet; -import org.w3c.dom.*; - -import java.beans.IntrospectionException; -import java.beans.Introspector; -import java.io.IOException; -import java.lang.reflect.Modifier; -import java.util.*; - -/** - * Default handler for class tags. Class tags are tags which represent instances of Java classes, - * such as <code><JButton label='Close'/></code>. <code>DefaultObjectHandler</code> - * provides support for attributes and events which adhere to JavaBeans naming conventions as - * well as basic JAXX features like the <code>id</code> attribute and data binding by means of - * curly braces. - * <p/> - * Throughout this class, the word "member" refers to the name of a field or method (e.g. - * <code>"getDocument"</code>) and the word "property" refers to the JavaBeans-style simple - * name of a property (e.g. <code>"document"</code>). - */ -public class DefaultObjectHandler implements TagHandler { - - public static final String ABSTRACT_ATTRIBUTE = "abstract"; - public static final String CONSTRAINTS_ATTRIBUTE = "constraints"; - public static final String CONSTRUCTOR_PARAMS_ATTRIBUTE = "constructorParams"; - public static final String DECORATOR_ATTRIBUTE = "decorator"; - public static final String DISPLAYED_MNEMONIC_ATTRIBUTE = "displayedMnemonic"; - public static final String DISPLAYED_MNEMONIC_INDEX_ATTRIBUTE = "displayedMnemonicIndex"; - public static final String GENERICTYPE_ATTRIBUTE = "genericType"; - public static final String ID_ATTRIBUTE = "id"; - public static final String IMPLEMENTS_ATTRIBUTE = "implements"; - public static final String INITIALIZER_ATTRIBUTE = "initializer"; - public static final String JAVA_BEAN_ATTRIBUTE = "javaBean"; - public static final String LAYOUT_ATTRIBUTE = "layout"; - public static final String MNEMONIC_ATTRIBUTE = "mnemonic"; - public static final String STYLE_CLASS_ATTRIBUTE = "styleClass"; - public static final String SUPER_GENERIC_TYPE_ATTRIBUTE = "superGenericType"; - /** - * 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>(); - - public ProxyEventInfo getEventInfo(String memberName) { - return eventInfos != null ? eventInfos.get(memberName) : null; - } - - /** - * Encapsulates information about a "proxy event handler", which is an event handler that - * fires PropertyChangeEvents when it is triggered. ProxyEventInfos simplify the data binding - * system by allowing all dependencies to fire the same kind of event even if they would - * normally throw something else, like <code>DocumentEvent</code>. - */ - public static 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 - * found, e.g. "document" (which is turned into a call to "getDocument()"). This property - * is also treated as a dependency of the data binding expression, and any updates to it - * (assuming it is bound) will cause the listener to be removed from the old value and - * 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; - - public String getAddMethod() { - return addMethod; - } - - public ClassDescriptor getListenerClass() { - return listenerClass; - } - - public String getMemberName() { - return memberName; - } - - public String getModelName() { - return modelName; - } - - public String getRemoveMethod() { - return 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. - * - * @param beanClass the class which this handler supports - */ - public DefaultObjectHandler(ClassDescriptor beanClass) { - this.beanClass = beanClass; - } - - /** - * Performs introspection on the beanClass and stores the results. - * - * @throws java.beans.IntrospectionException - * if any pb - */ - protected void init() throws IntrospectionException { - if (jaxxBeanInfo == null) { - // perform introspection & cache the results - jaxxBeanInfo = getJAXXBeanInfo(beanClass); - - JAXXPropertyDescriptor[] propertiesArray = jaxxBeanInfo.getJAXXPropertyDescriptors(); - properties = new HashMap<String, JAXXPropertyDescriptor>(); - for (int i = propertiesArray.length - 1; i >= 0; i--) { - properties.put(propertiesArray[i].getName(), propertiesArray[i]); - } - - JAXXEventSetDescriptor[] eventsArray = jaxxBeanInfo.getJAXXEventSetDescriptors(); - events = new HashMap<String, JAXXEventSetDescriptor>(); - for (int i = eventsArray.length - 1; i >= 0; i--) { - MethodDescriptor[] methods = eventsArray[i].getListenerMethods(); - for (MethodDescriptor method : methods) { - events.put(method.getName(), eventsArray[i]); - } - } - - configureProxyEventInfo(); - } - } - - /** - * @return the class which this <code>DefaultObjectHandler</code> supports. - */ - public ClassDescriptor getBeanClass() { - return beanClass; - } - - /** - * @return the <code>JAXXBeanInfo</code> for the class which this <code>DefaultObjectHandler</code> - * supports. - */ - public JAXXBeanInfo getJAXXBeanInfo() { - try { - init(); - } catch (IntrospectionException e) { - throw new RuntimeException(e); - } - return jaxxBeanInfo; - } - - /** - * Returns the <code>JAXXBeanInfo</code> for the specified class. - * - * @param beanClass the bean class for which to retrieve <code>JAXXBeanInfo</code> - * @return the class' <code>JAXXBeanInfo</code> - * @throws java.beans.IntrospectionException - * if any pb - */ - public static JAXXBeanInfo getJAXXBeanInfo(ClassDescriptor beanClass) throws IntrospectionException { - 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>. - * - * @param object the object being compiled - * @param propertyName the simple JavaBeans-style name of the property - * @param compiler the current <code>JAXXCompiler</code> - * @return the property's type - * @throws CompilerException if the type cannot be determined - */ - public ClassDescriptor getPropertyType(CompiledObject object, String propertyName, JAXXCompiler compiler) { - safeInit(); - - JAXXPropertyDescriptor property = properties.get(propertyName); - if (property != null) { - return property.getPropertyType(); - } - throw new UnsupportedAttributeException("property '" + propertyName + "' not found in " + object); - } - - /** - * @param name name of the property - * @return <code>true</code> if the named member is <i>bound</i> (fires <code>PropertyChangeEvent</code> - * when modified). Members are either fields (represented by the simple name of the field) or <code>get/is</code> - * methods (represented by the simple name of the method, <b>not</b> the simplified JavaBeans-style name). - * Methods which are not actually bound in their native class, but for which proxy events have been - * configured (such as <code>JTextField.getText</code>, return <code>true</code>. - * @throws UnsupportedAttributeException if attribute is not supported - */ - public boolean isMemberBound(String name) throws UnsupportedAttributeException { - safeInit(); - - if (eventInfos != null && eventInfos.containsKey(name)) { - return true; - } - - if (name.equals("getClass")) { - return false; - } - - String propertyName = null; - if (name.startsWith("get")) { - propertyName = Introspector.decapitalize(name.substring("get".length())); - } else if (name.startsWith("is")) { - propertyName = Introspector.decapitalize(name.substring("is".length())); - } - JAXXPropertyDescriptor property = propertyName != null ? properties.get(propertyName) : null; - if (property != null) { - return property.isBound(); - } - try { - FieldDescriptor field = getBeanClass().getFieldDescriptor(name); - return Modifier.isFinal(field.getModifiers()); // final fields might as well be considered bound -- they can't be modified anyway - } catch (NoSuchFieldException e) { - throw new UnsupportedAttributeException("cannot find property '" + name + "' of " + getBeanClass()); - } - } - - public 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 -// * example, the JTextField.getText() member depends upon the getModel() -// * member. Returns <code>null</code> if there are no dependencies. -// */ -// public String[] getMemberDependencies(String memberName) { -// ProxyEventInfo eventInfo = eventInfos != null ? eventInfos.get(memberName) : null; -// 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 -// * of a Java code snippet that evaluates to a listener object. -// * <p/> -// * For ordinary bound JavaBeans properties, the Java code returned is a simple call to -// * <code>addPropertyChangeListener</code>. Fields and methods which do not actually fire -// * <code>PropertyChangeEvents</code> when they change necessitate more complex code. -// * -// * @param objectCode Java code which evaluates to the object to which to add the listener -// * *@param dataBinding the name of the data binding this listener is a part of -// * @param dataBinding databinding -// * @param memberName the name of the field or method to listen to -// * @param propertyChangeListenerCode Java code which evaluates to a <code>PropertyChangeListener</code> -// * @param compiler the current <code>JAXXCompiler</code> -// * @return Java code snippet which causes the listener to be added to the object -// */ -// public String getAddMemberListenerCode(String objectCode, String dataBinding, String memberName, String propertyChangeListenerCode, JAXXCompiler compiler) { -// if ("getClass".equals(memberName)) { -// return null; -// } -// -// ProxyEventInfo eventInfo = eventInfos != null ? eventInfos.get(memberName) : null; -// if (eventInfo != null) { -// // a "proxied" event is one that doesn't fire PropertyChangeEvent, so we need to convert its native event type into PropertyChangeEvents -// StringBuffer result = new StringBuffer(); -// String methodName = "$pr" + compiler.getUniqueId(propertyChangeListenerCode); -// boolean methodExists = compiler.hasMethod(methodName); -// ClassDescriptor eventClass = getEventClass(eventInfo.listenerClass); -// if (!methodExists) { -// compiler.getJavaFile().addMethod(new JavaMethod(Modifier.PUBLIC, "void", methodName, -// new JavaArgument[]{new JavaArgument(JAXXCompiler.getCanonicalName(eventClass), "event")}, null, -// propertyChangeListenerCode + ".propertyChange(null);", false)); -// } -// String code = objectCode + (eventInfo.modelName != null ? ".get" + StringUtils.capitalize(eventInfo.modelName) + "()" : ""); -// result.append("$bindingSources.put(\"").append(code).append("\", ").append(code).append(");").append(JAXXCompiler.getLineSeparator()); -// //TC-20091105 Util.getEventListener is generic, no more need cast and use simple listener name -// result.append(code).append('.').append(eventInfo.addMethod).append("( Util.getEventListener(").append(eventInfo.listenerClass.getSimpleName()).append(".class, ").append(compiler.getRootObject().getJavaCode()).append(", ").append(TypeManager.getJavaCode(methodName)).append("));"); -// result.append(JAXXCompiler.getLineSeparator()); -// if (eventInfo.modelName != null) { -// result.append(getAddMemberListenerCode(objectCode, dataBinding, "get" + StringUtils.capitalize(eventInfo.modelName), -// Util.class.getSimpleName() + ".getDataBindingUpdateListener(this , " + dataBinding + ")", -//// Util.class.getSimpleName() + ".getDataBindingUpdateListener(this , \"" + dataBinding + "\")", -// compiler)); -// } -// return result.toString(); -// } else { -// String propertyName = null; -// if (memberName.startsWith("get")) { -// propertyName = Introspector.decapitalize(memberName.substring("get".length())); -// } else if (memberName.startsWith("is")) { -// propertyName = Introspector.decapitalize(memberName.substring("is".length())); -// } else { -// try { -// getBeanClass().getFieldDescriptor(memberName); -// propertyName = memberName; -// } catch (NoSuchFieldException e) { -// // ignore ? -// } -// } -// if (propertyName != null) { -// //TC-20091026 when on root object, do not prefix with objectCode -// String prefix = objectCode.trim() + "."; -// if (objectCode.equals(compiler.getRootObject().getJavaCode())) { -// prefix = ""; -// } -// try { -// // check for property-specific addPropertyChangeListener method -// getBeanClass().getMethodDescriptor("addPropertyChangeListener", ClassDescriptorLoader.getClassDescriptor(String.class), -// ClassDescriptorLoader.getClassDescriptor(PropertyChangeListener.class)); -// return prefix + "addPropertyChangeListener(\"" + propertyName + "\", " + propertyChangeListenerCode + ");\n"; -// } catch (NoSuchMethodException e) { -// // no property-specific method, use general one -// return prefix + "addPropertyChangeListener(" + propertyChangeListenerCode + ");\n"; -// } -// } -// return null; -// } -// } -// -// public String getRemoveMemberListenerCode(String objectCode, String dataBinding, String memberName, String propertyChangeListenerCode, JAXXCompiler compiler) { -// if ("getClass".equals(memberName)) { -// return null; -// } -// -// ProxyEventInfo eventInfo = eventInfos != null ? eventInfos.get(memberName) : null; -// if (eventInfo != null) { -// // a "proxied" event is one that doesn't fire PropertyChangeEvent, -// // so we need to convert its native event type into PropertyChangeEvents -// StringBuffer result = new StringBuffer(); -// String methodName = "$pr" + compiler.getUniqueId(propertyChangeListenerCode); -// boolean methodExists = compiler.hasMethod(methodName); -// if (!methodExists) { -// ClassDescriptor eventClass = getEventClass(eventInfo.listenerClass); -// compiler.getJavaFile().addMethod(new JavaMethod(Modifier.PUBLIC, "void", methodName, -// new JavaArgument[]{new JavaArgument(JAXXCompiler.getCanonicalName(eventClass), "event")}, null, -// propertyChangeListenerCode + ".propertyChange(null);", false)); -// } -// try { -// String modelMemberName = eventInfo.modelName != null ? "get" + StringUtils.capitalize(eventInfo.modelName) : null; -// String modelClassName = modelMemberName != null ? getBeanClass().getMethodDescriptor(modelMemberName).getReturnType().getName() : JAXXCompiler.getCanonicalName(getBeanClass()); -// String code = objectCode + (eventInfo.modelName != null ? "." + modelMemberName + "()" : ""); -// String eol = JAXXCompiler.getLineSeparator(); -// result.append(modelClassName).append(" $target = ((").append(modelClassName).append(") $bindingSources.remove(\"").append(code).append("\"));").append(eol); -// //TC-20091105 test if $target is not null -// result.append("if ($target != null) {").append(eol); -// //TC-20091105 Util.getEventListener is generic, no more need cast and use simple listener name -// result.append(" $target.").append(eventInfo.removeMethod).append("( Util.getEventListener(").append(eventInfo.listenerClass.getSimpleName()).append(".class, ").append(compiler.getRootObject().getJavaCode()).append(", ").append(TypeManager.getJavaCode(methodName)).append("));").append(eol); -// result.append("}").append(eol); -// if (eventInfo.modelName != null) { -//// String bi = dataBinding.startsWith("this.") ? dataBinding : ("\"" + dataBinding + "\""); -// result.append(getRemoveMemberListenerCode(objectCode, dataBinding, "get" + StringUtils.capitalize(eventInfo.modelName), -// Util.class.getSimpleName() + ".getDataBindingUpdateListener(this, " + dataBinding + ")", -//// Util.class.getSimpleName() + ".getDataBindingUpdateListener(this, \"" + dataBinding + "\")", -// compiler)); -// } -// return result.toString(); -// } catch (NoSuchMethodException e) { -// throw new CompilerException("Internal error: " + e); -// } -// } else { -// String propertyName = null; -// if (memberName.startsWith("get")) { -// propertyName = Introspector.decapitalize(memberName.substring("get".length())); -// } else if (memberName.startsWith("is")) { -// propertyName = Introspector.decapitalize(memberName.substring("is".length())); -// } else { -// try { -// getBeanClass().getFieldDescriptor(memberName); -// propertyName = memberName; -// } catch (NoSuchFieldException e) { -// // ignore ? -// } -// } -// if (propertyName != null) { -// //TC-20091026 when on root object, do not prefix with objectCode -// String prefix = objectCode.trim() + "."; -// if (objectCode.equals(compiler.getRootObject().getJavaCode())) { -// prefix = ""; -// } -// try { -// // check for property-specific removePropertyChangeListener method -// getBeanClass().getMethodDescriptor("removePropertyChangeListener", ClassDescriptorLoader.getClassDescriptor(String.class), -// ClassDescriptorLoader.getClassDescriptor(PropertyChangeListener.class)); -// return prefix + "removePropertyChangeListener(\"" + propertyName + "\", " + propertyChangeListenerCode + ");\n"; -// } catch (NoSuchMethodException e) { -// // no property-specific method, use general one -// return prefix + "removePropertyChangeListener(" + propertyChangeListenerCode + ");\n"; -// } -// } -// return null; -// } -// } - - /** - * 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 - * <code>addProxyEventInfo</code> for each member which requires special handling. - */ - 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 - * not bound property <code>get</code> methods. The proxy event handler will attach the specified kind - * of listener to the class and fire a <code>PropertyChangeEvent</code> whenever the listener receives - * any kind of event. - * <p/> - * Even though this method can theoretically be applied to fields (in addition to methods), it would be an - * unusual situation in which that would actually work -- as fields cannot fire events when modified, it would - * be difficult to have a listener that was always notified when a field value changed. - * - * @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) { - 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 - * not bound property <code>get</code> methods. This variant attaches a listener to a property of the - * object (such as <code>model</code>) and not the object itself, which is useful when there is a model - * that is the "real" container of the information. The proxy event handler will attach the specified kind - * of listener to the property's value (retrieved using the property's <code>get</code> method) and fire - * a <code>PropertyChangeEvent</code> whenever the listener receives any kind of event. - * <p/> - * If the property is itself bound (typically the case with models), any updates to the property's value will - * cause the listener to be removed from the old property value and reattached to the new property value, - * as well as cause a <code>PropertyChangeEvent</code> to be fired. - * <p/> - * Even though this method can theoretically be applied to fields (in addition to methods), it would be an - * unusual situation in which that would actually work -- as fields cannot fire events when modified, it would - * be difficult to have a listener that was always notified when a field value changed. - * - * @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 - * @param modelName the JavaBeans-style name of the model property - */ - 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) { - try { - addProxyEventInfo(memberName, ClassDescriptorLoader.getClassDescriptor(listenerClass.getName()), modelName, addMethod, removeMethod); - } catch (ClassNotFoundException e) { - throw new RuntimeException(e); - } - } - - /** - * 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 - * not bound property <code>get</code> methods. This variant attaches a listener to a property of the - * object (such as <code>model</code>) and not the object itself, which is useful when there is a model - * that is the "real" container of the information. The proxy event handler will attach the specified kind - * of listener to the property's value (retrieved using the property's <code>get</code> method) and fire - * a <code>PropertyChangeEvent</code> whenever the listener receives any kind of event. - * <p/> - * If the property is itself bound (typically the case with models), any updates to the property's value will - * cause the listener to be removed from the old property value and reattached to the new property value, - * as well as cause a <code>PropertyChangeEvent</code> to be fired. - * <p/> - * This variant of <code>addProxyEventInfo</code> allows the names of the methods that add and remove - * the event listener to be specified, in cases where the names are not simply <code>add<listenerClassName></code> - * and <code>remove<listenerClassName></code>. - * <p/> - * Even though this method can theoretically be applied to fields (in addition to methods), it would be an - * unusual situation in which that would actually work -- as fields cannot fire events when modified, it would - * be difficult to have a listener that was always notified when a field value changed. - * - * @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 - * @param modelName the JavaBeans-style name of the model property - * @param addMethod add method name - * @param removeMethod remove method name - */ - public void addProxyEventInfo(String memberName, ClassDescriptor listenerClass, - String modelName, String addMethod, String removeMethod) { - ProxyEventInfo info = new ProxyEventInfo(); - info.memberName = memberName; - info.listenerClass = listenerClass; - info.modelName = modelName; - info.addMethod = addMethod; - info.removeMethod = removeMethod; - if (eventInfos == null) { - eventInfos = new HashMap<String, ProxyEventInfo>(); - } - 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 { - safeInit(); - CompiledObject object = objectMap.get(tag); - if (object == null) { - throw new IllegalStateException("unable to find CompiledObject associated with tag <" + tag.getTagName() + ">; should have been registered before second pass"); - } - compiler.checkOverride(object); - String constructorParams = tag.getAttribute(CONSTRUCTOR_PARAMS_ATTRIBUTE); - if (constructorParams != null && constructorParams.length() > 0) { - object.setConstructorParams(compiler.getScriptManager().trimScript(constructorParams)); - } - - setDefaults(object, tag, compiler); - setAttributes(object, tag, compiler); - //TC-20091105, can apply genericType everyWhere, should just test that class is generic (not possible actually) -// if (object.getGenericTypesLength() > 0 && !(object == compiler.getRootObject() || object.isJavaBean())) { -// // can ony be apply to root object or javaBean object -// compiler.reportWarning("'genericType' attribute can only be found on root, or a javaBean object tag but was found on tag " + tag); -// object.setGenericTypes(null); -// return; -// } - compileChildrenSecondPass(tag, compiler); - } - - public void registerCompiledObject(Element tag, JAXXCompiler compiler) { - String id = tag.getAttribute(ID_ATTRIBUTE); - if (id == null || id.length() == 0) { - id = compiler.getAutoId(getBeanClass().getSimpleName()); -// id = compiler.getAutoId(getBeanClass()); - } - CompiledObject object = createCompiledObject(id, compiler); - objectMap.put(tag, object); - String styleClass = tag.getAttribute(STYLE_CLASS_ATTRIBUTE).trim(); - if (styleClass.length() > 0) { - object.setStyleClass(styleClass); - } - compiler.registerCompiledObject(object); - } - - /** - * Creates the <code>CompiledObject</code> which will represent the object - * created by this <code>TagHandler</code>. - * - * @param id the <code>CompiledObject's</code> ID. - * @param compiler compiler to use - * @return the <code>CompiledObject</code> to use - */ - protected CompiledObject createCompiledObject(String id, JAXXCompiler compiler) { - return new CompiledObject(id, getBeanClass(), compiler); - } - - /** - * Initializes the default settings of the object, prior to setting its - * attribute values. The default implementation does nothing. - * - * @param object the object to initialize - * @param tag the tag being compiled - * @param compiler the current <code>JAXXCompiler</code> - */ - 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 - * via CSS. - * @throws UnsupportedAttributeException if attribute is not supported - */ - public boolean isPropertyInherited(String property) throws UnsupportedAttributeException { - return false; - } - - /** - * @param name name of event - * @return <code>true</code> if the specified name has the form of an event handler attribute - * (e.g. "onActionPerformed"). - */ - public boolean isEventHandlerName(String name) { - 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 - * pass 1 is complete). - * - * @param tag tag to scan - * @param compiler compiler to use - */ - protected void scanAttributesForDependencies(Element tag, JAXXCompiler compiler) { - List<Attr> attributes = new ArrayList<Attr>(); - NamedNodeMap children = tag.getAttributes(); - for (int i = 0; i < children.getLength(); i++) { - attributes.add((Attr) children.item(i)); - } - Collections.sort(attributes, getAttributeComparator()); - - for (Attr attribute : attributes) { - String name = attribute.getName(); - String value = attribute.getValue(); - if (name.equals(JAVA_BEAN_ATTRIBUTE)) { - //compiler.preprocessScript(value); - continue; - } - if (name.equals(CONSTRAINTS_ATTRIBUTE) || isEventHandlerName(name)) { - // adds dependencies as a side effect - compiler.preprocessScript(value); - } else if (name.equals(CONSTRUCTOR_PARAMS_ATTRIBUTE)) { - for (String param : value.split("\\s*,\\s*")) { - compiler.preprocessScript(param); - } - } else if (value.startsWith("{") && value.endsWith("}")) { - compiler.preprocessScript(value.substring(1, value.length() - 1)); - } - } - } - - /** - * 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 - * pairs), event listeners (attributes starting with 'on', such as 'onActionPerformed'), and JAXX-defined properties - * such as 'id'. - * - * @param object the object to be modified - * @param tag the tag from which to pull attributes - * @param compiler the current <code>JAXXCompiler</code> - */ - public void setAttributes(CompiledObject object, Element tag, JAXXCompiler compiler) { - List<Attr> attributes = new ArrayList<Attr>(); - NamedNodeMap children = tag.getAttributes(); - for (int i = 0; i < children.getLength(); i++) { - attributes.add((Attr) children.item(i)); - } - Collections.sort(attributes, getAttributeComparator()); - - for (Attr attribute : attributes) { - String name = attribute.getName(); - String value = attribute.getValue().trim(); - if (name.equals(ID_ATTRIBUTE) || - name.equals(CONSTRAINTS_ATTRIBUTE) || - name.equals(CONSTRUCTOR_PARAMS_ATTRIBUTE) || - name.equals(STYLE_CLASS_ATTRIBUTE) || - name.startsWith(XMLNS_ATTRIBUTE) || - JAXXCompiler.JAXX_INTERNAL_NAMESPACE.equals(attribute.getNamespaceURI())) { - // ignore, already handled - continue; - } - if (name.equals(JAVA_BEAN_ATTRIBUTE)) { - object.setJavaBean(true); - if (!value.isEmpty()) { - object.setJavaBeanInitCode(value); - } - continue; - } - if (name.equals(INITIALIZER_ATTRIBUTE)) { - if (!value.isEmpty()) { - object.setInitializer(value); - } else { - object.setInitializer("null"); - } - continue; - } - if (name.equals(IMPLEMENTS_ATTRIBUTE)) { - if (object != compiler.getRootObject()) { - // can ony be apply to root object - compiler.reportError("'" + IMPLEMENTS_ATTRIBUTE + "' attribute can only be found on root tag but was found on tag " + tag); - return; - } - String[] interfaces = value.split(","); - compiler.setExtraInterfaces(interfaces); - continue; - } - - if (name.equals(ABSTRACT_ATTRIBUTE)) { - if (object != compiler.getRootObject()) { - // can ony be apply to root object - compiler.reportError("'" + ABSTRACT_ATTRIBUTE + "' attribute can only be found on root tag but was found on tag " + tag); - return; - } - compiler.setAbstractClass(true); - continue; - } - - if (name.equals(GENERICTYPE_ATTRIBUTE)) { - //TC-20090313 check after all atributes been processed - if (object == compiler.getRootObject()) { - compiler.setGenericType(value); - } else { - object.setGenericTypes(value.split(",")); - } - continue; - } - - if (name.equals(SUPER_GENERIC_TYPE_ATTRIBUTE)) { - if (object != compiler.getRootObject()) { - // can ony be apply to root object - compiler.reportError("'" + SUPER_GENERIC_TYPE_ATTRIBUTE + "' attribute can only be found on root tag but was found on tag " + tag); - return; - } - compiler.setSuperGenericType(value); - continue; - } - - if (name.equals(DECORATOR_ATTRIBUTE)) { - if (!value.isEmpty()) { - CompiledObjectDecorator decorator = compiler.getEngine().getDecorator(value); - object.setDecorator(decorator); - } - continue; - } - - if (isEventHandlerName(name)) { - // event handler - if (!value.endsWith(";")) { - value += ";"; - } - addEventHandler(object, Introspector.decapitalize(name.substring(2)), value, compiler); - continue; - } - // simple property - setAttribute(object, name, value, true, compiler); - } - } - - /** - * 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. - * - * @return a <code>Comparator</code> defining the order of attribute processing - */ - protected Comparator<Attr> getAttributeComparator() { - return new Comparator<Attr>() { - - @Override - public int compare(Attr a, Attr b) { - int aOrder = getAttributeOrdering(a); - int bOrder = getAttributeOrdering(b); - - return aOrder - bOrder; - } - }; - } - - /** - * 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. - * - * @param attr the attribute to treate - * @return the attribute's priority - */ - protected int getAttributeOrdering(Attr attr) { - if (attr.getName().equals(DISPLAYED_MNEMONIC_INDEX_ATTRIBUTE) || - attr.getName().equals(DISPLAYED_MNEMONIC_ATTRIBUTE) || - attr.getName().equals(MNEMONIC_ATTRIBUTE)) { - return 1; - } - return 0; - } - -// public String getApplyPropertyOrDataBindingCode(CompiledObject object, String propertyName, String stringValue, JAXXCompiler compiler) { -// ClassDescriptor type = getPropertyType(object, propertyName, compiler); -// String binding = compiler.processDataBindings(stringValue); -// if (binding != null) { -// return ""; -// } -// try { -// Class<?> typeClass = type != null ? ClassDescriptorLoader.getClass(type.getName(), type.getClassLoader()) : null; -// Object value = convertFromString(propertyName, stringValue, typeClass); -// return getSetPropertyCode(object.getJavaCode(), propertyName, compiler.getJavaCode(value), compiler); -// } catch (NumberFormatException e) { -// compiler.reportError("could not convert literal string '" + stringValue + "' to type " + type.getName()); -// } catch (IllegalArgumentException e) { -// compiler.reportError("could not convert literal string '" + stringValue + "' to type " + type.getName()); -// } catch (ClassNotFoundException e) { -// compiler.reportError("could not find class " + type.getName()); -// } -// 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}. - * - * @param object the object on which to set the property - * @param propertyName the name of the property to set - * @param stringValue the raw string value of the property from the XML - * @param inline <code>true</code> if the value was directly specified as an inline class tag attribute, <code>false</code> otherwise (a default value, specified in CSS, etc.) - * @param compiler the current <code>JAXXCompiler</code> - */ - public void setAttribute(CompiledObject object, String propertyName, String stringValue, boolean inline, JAXXCompiler compiler) { - try { - //--------------------------------------------------------------------- - // BE WARE, Test if removing this code hurts..., anyway we have a bug on it: - // For some component (example : jaxx.runtime.swing.editor.NumberEditor) we do not have one component - // This is disturbing, must find how why... And this happens only on a mvn clean install on all project - // Everything is fine otherwise... - // - // With new binding design, we will know if there is a binding on the property - // of the jaxxObject, and could add it only if required... - //--------------------------------------------------------------------- - //FIXME TC-20091105 we should to this later when all binding are compiled - // because we don't know yet if this is a databinding -// if (ClassDescriptorLoader.getClassDescriptor(JAXXObject.class).isAssignableFrom(object.getObjectClass())) { -// // check for data binding & remove if found -// JAXXObjectDescriptor jaxxObjectDescriptor = object.getObjectClass().getJAXXObjectDescriptor(); -// if (jaxxObjectDescriptor.getComponentDescriptors().length == 0) { -// compiler.reportWarning("JAXXObject component " + object.getObjectClass() + " should have at least one component!"); -//// throw new IllegalStateException("JAXXObject component " + object.getObjectClass() + " should have at least one component!"); -// } else { -// ComponentDescriptor root = jaxxObjectDescriptor.getComponentDescriptors()[0]; -// //TC-20091026 do not prefix binding by object id if on root object -// String prefix; -// if (object == compiler.getRootObject()) { -// prefix = ""; -// } else { -// prefix = object.getJavaCode() + "."; -// } -// object.appendInitializationCode(prefix + "removeDataBinding(" + compiler.getJavaCode(root.getId() + "." + propertyName) + ");"); -// } -// } - object.addProperty(propertyName, stringValue); - ClassDescriptor type = getPropertyType(object, propertyName, compiler); - String binding = DataBindingHelper.processDataBindings(stringValue); - boolean withBinding = binding != null; - - if (inline) { - compiler.addInlineStyle(object, propertyName, withBinding); - } - if (!withBinding) { - // no bindings, convert from string - try { - Class<?> typeClass = type != null ? ClassDescriptorLoader.getClass(type.getName(), type.getClassLoader()) : null; - Object value = convertFromString(propertyName, stringValue, typeClass); - setProperty(object, propertyName, value, compiler); - return; - } catch (NumberFormatException e) { - compiler.reportError("could not convert literal string '" + stringValue + "' to type " + type.getName()); - } catch (IllegalArgumentException e) { - compiler.reportError("could not convert literal string '" + stringValue + "' to type " + type.getName()); - } catch (ClassNotFoundException e) { - compiler.reportError("could not find class " + type.getName()); - } - } - String setPropertyCode = getSetPropertyCode(object.getJavaCode(), propertyName, binding, compiler); - if (propertyName.equals(LAYOUT_ATTRIBUTE)) { - // handle containerDelegate (e.g. contentPane on JFrame) - // have to set layout early, before children are added - object.appendInitializationCode(setPropertyCode); - } - compiler.getBindingHelper().registerDataBinding(object.getId() + "." + propertyName, binding, setPropertyCode); -// compiler.getBindingHelper().registerDataBinding(binding, object.getId() + "." + propertyName, setPropertyCode); - } catch (UnsupportedAttributeException e) { - compiler.reportError("class " + object.getObjectClass().getName() + " does not support attribute '" + propertyName + "'"); - } - } - - 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(); - ClassDescriptor objectClass = object.getObjectClass(); - if (recurse && ClassDescriptorLoader.getClassDescriptor(JAXXObject.class).isAssignableFrom(objectClass)) { - JAXXObjectDescriptor jaxxObjectDescriptor = objectClass.getJAXXObjectDescriptor(); - ComponentDescriptor[] descriptors = jaxxObjectDescriptor.getComponentDescriptors(); - for (ComponentDescriptor descriptor : descriptors) { - ClassDescriptor classDescriptor = ClassDescriptorLoader.getClassDescriptor(descriptor.getJavaClassName()); - boolean isRoot = classDescriptor != objectClass; - 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()) + "))", - classDescriptor, - compiler, - true); - ComponentDescriptor parentDescriptor = descriptor.getParent(); - CompiledObject currentObject = child; - while (parentDescriptor != null) { - CompiledObject parent = new CompiledObject("internal", ClassDescriptorLoader.getClassDescriptor(parentDescriptor.getJavaClassName()), compiler); - currentObject.setParent(parent); - currentObject = parent; - parentDescriptor = parentDescriptor.getParent(); - } - currentObject.setParent(object); - String styleClass = object.getStyleClass(); - if (styleClass == null) { - styleClass = descriptor.getStyleClass(); - } - child.setStyleClass(styleClass); - Stylesheet mergedStylesheet = overrides; - Stylesheet childOverrides = jaxxObjectDescriptor.getStylesheet(); - if (childOverrides != null) { - if (mergedStylesheet == null) { - mergedStylesheet = childOverrides; - } else { - mergedStylesheet.add(childOverrides.getRules()); - } - } - TagManager.getTagHandler(objectClass).applyStylesheets(child, compiler, mergedStylesheet, isRoot); - object.appendInitializationCode(child.getInitializationCode(compiler)); - } - } else if (stylesheet != null) { - StylesheetHelper.applyTo(object, compiler, stylesheet, overrides); - } - } 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. - * - * @param object the <code>CompiledObject</code> to which the event listener should be added - * @param name the name of the event listener, such as <code>"actionPerformed"</code> - * @param value the Java code snippet to execute when the event is fired - * @param compiler the current <code>JAXXCompiler</code> - */ - public void addEventHandler(CompiledObject object, String name, String value, JAXXCompiler compiler) { - JAXXEventSetDescriptor JAXXEventSetDescriptor = events.get(name); - if (JAXXEventSetDescriptor != null) { - MethodDescriptor[] listenerMethods = JAXXEventSetDescriptor.getListenerMethods(); - MethodDescriptor listenerMethod = null; - for (MethodDescriptor listenerMethod1 : listenerMethods) { - if (listenerMethod1.getName().equals(name)) { - listenerMethod = listenerMethod1; - break; - } - } - if (listenerMethod == null) { - throw new RuntimeException("expected to find method '" + name + "' in JAXXEventSetDescriptor.getListenerMethods()"); - } - try { - value = compiler.preprocessScript(value); - object.addEventHandler(name, JAXXEventSetDescriptor.getAddListenerMethod(), listenerMethod, value, compiler); - } catch (CompilerException e) { - compiler.reportError("While parsing event handler for '" + name + "': " + e.getMessage()); - } - } else { - compiler.reportError("could not find event '" + name + "' for object " + object); - } - } - - /** - * 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. - * - * @param javaCode Java code for the object whose property is being retrieved - * @param name the name of the property to retrieve - * @param compiler the current <code>JAXXCompiler</code> - * @return the snippet - * @throws CompilerException if a compilation error occurs - */ - public String getGetPropertyCode(String javaCode, String name, JAXXCompiler compiler) { - safeInit(); - - JAXXPropertyDescriptor property = properties.get(name); - if (property != null) { - if (property.getReadMethodDescriptor() != null) { - return javaCode + '.' + property.getReadMethodDescriptor().getName() + "()"; - } - throw new UnsupportedAttributeException("property '" + name + "' of " + getBeanClass().getName() + " has no read method"); - } - 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. - * - * @param javaCode Java code for the object whose property is being set - * @param name the name of the property to set - * @param valueCode Java expression representing the value to set the property to - * @param compiler the current <code>JAXXCompiler</code> - * @return the snippet - * @throws CompilerException if a compilation error occurs - */ - public String getSetPropertyCode(String javaCode, String name, String valueCode, JAXXCompiler compiler) { - JAXXPropertyDescriptor property = properties.get(name); - if (property != null) { - if (property.getWriteMethodDescriptor() != null) { - //TC-20091026 do not prefix by javaCode if on root object - String prefix; - if (compiler.getRootObject().getJavaCode().equals(javaCode)) { - prefix = ""; - } else { - prefix = javaCode + "."; - } - return prefix + property.getWriteMethodDescriptor().getName() + '(' + valueCode + ");"; - } - throw new UnsupportedAttributeException("property '" + name + "' of " + getBeanClass().getName() + " is read-only"); - } - 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 - * complicated cases, like data bindings or event handlers). - * <p/> - * By the time it reaches this method, the <code>value</code> has already been converted from its XML - * string representation to the appropriate destination type for the property (i.e. if - * <code>JLabel.foreground</code> is being set, <code>value</code> will be a <code>Color</code>). - * - * @param object the object being modified - * @param name the name of the property to set - * @param value the value to set the property to - * @param compiler the current <code>JAXXCompiler</code> - * @throws CompilerException if a compilation error occurs - */ - public void setProperty(CompiledObject object, String name, Object value, JAXXCompiler compiler) { - 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 - * 'right' onto SwingConstants.LEFT, SwingConstants.CENTER, and SwingConstants.RIGHT respectively. - * <p/> - * You do not normally need to call this method yourself; it is invoked by {@link #convertFromString} when an - * int-valued property has a value which is not a valid number. By default, this method looks at the - * <code>enumerationValues</code> value of the <code>JAXXPropertyDescriptor</code>. - * - * @param key the name of the int-typed property - * @param value the non-numeric value that was specified for the property - * @return the constant integer value - * @throws IllegalArgumentException if the property is an enumeration, but the value is not valid - * @throws NumberFormatException if the property is not an enumeration - */ - protected int constantValue(String key, String value) { - JAXXBeanInfo JAXXBeanInfo = getJAXXBeanInfo(); - JAXXPropertyDescriptor[] props = JAXXBeanInfo.getJAXXPropertyDescriptors(); - String lowercaseValue = value.toLowerCase(); - for (JAXXPropertyDescriptor property : props) { - if (property.getName().equals(key)) { - Object[] values = (Object[]) property.getValue("enumerationValues"); - if (values != null) { - for (int j = 0; j < values.length - 2; j += 3) { - if (((String) values[j]).toLowerCase().equals(lowercaseValue)) { - return (Integer) values[j + 1]; - } - } - - StringBuffer message = new StringBuffer("value of '" + key + "' must be one of: ["); - for (int j = 0; j < values.length - 2; j += 3) { - if (j != 0) { - message.append(", "); - } - message.append(((String) values[j]).toLowerCase()); - } - message.append("] (found '").append(value).append("')"); - throw new IllegalArgumentException(message.toString()); - } - } - } - throw new NumberFormatException(value); - } - - /** - * As {@link TypeManager#convertFromString(String, Class)}, except that it additionally supports constant names - * for <code>int</code>-valued types. - * - * @param key the name of the property whose value is being converted - * @param value the raw string value of the property as it appears in the XML - * @param type the datatype to convert the string into - * @return the converted object - * @see #constantValue - */ - protected Object convertFromString(String key, String value, Class<?> type) { - if (type == null || type == Object.class) { - return value; - } - - try { - return TypeManager.convertFromString(value, type); - } catch (NumberFormatException e) { - if (type == int.class || type == Integer.class) { - return constantValue(key, value); - } - throw e; - } - } - - /** - * Compiles the child tags of the current tag. The default implementation invokes {@link #compileChildTagFirstPass} - * for each child tag. - * - * @param tag the tag whose children to run - * @param compiler the current <code>JAXXCompiler</code> - * @throws CompilerException if a compilation error occurs - * @throws IOException if an I/O error occurs - */ - protected void compileChildrenFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - NodeList children = tag.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { - Node node = children.item(i); - int nodeType = node.getNodeType(); - if (nodeType == Node.ELEMENT_NODE) { - Element child = (Element) node; - compileChildTagFirstPass(child, compiler); - } - } - } - - /** - * Compiles the child tags of the current tag. The default implementation invokes {@link #compileChildTagFirstPass} - * for each child tag. - * - * @param tag the tag whose children to run - * @param compiler the current <code>JAXXCompiler</code> - * @throws CompilerException if a compilation error occurs - * @throws IOException if an I/O error occurs - */ - protected void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - NodeList children = tag.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { - Node node = children.item(i); - int nodeType = node.getNodeType(); - if (nodeType == Node.ELEMENT_NODE) { - Element child = (Element) node; - compileChildTagSecondPass(child, compiler); - } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) { - String text = ((Text) node).getData().trim(); - if (text.length() > 0) { - compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')"); - } - } - } - } - - /** - * Compiles a child of the current tag. The default implementation calls {@link JAXXCompiler#compileFirstPass - * JAXXCompiler.compileFirstPass}. - * - * @param tag the child tag to run - * @param compiler the current <code>JAXXCompiler</code> - * @throws CompilerException if a compilation error occurs - * @throws IOException if an I/O error occurs - */ - protected void compileChildTagFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - compiler.compileFirstPass(tag); - } - - /** - * Compiles a child of the current tag. The default implementation calls {@link JAXXCompiler#compileFirstPass - * JAXXCompiler.compileSecondPass}. - * - * @param tag the child tag to run - * @param compiler the current <code>JAXXCompiler</code> - * @throws CompilerException if a compilation error occurs - * @throws IOException if an I/O error occurs - */ - protected void compileChildTagSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - compiler.compileSecondPass(tag); - } - - @Override - public String toString() { - return getClass().getName() + "[" + getBeanClass().getName() + "]"; - } - - protected void safeInit() { - try { - init(); - } catch (IntrospectionException e) { - throw new RuntimeException(e); - } - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,1244 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags; + +import jaxx.compiler.*; +import jaxx.compiler.beans.JAXXBeanInfo; +import jaxx.compiler.beans.JAXXEventSetDescriptor; +import jaxx.compiler.beans.JAXXIntrospector; +import jaxx.compiler.beans.JAXXPropertyDescriptor; +import jaxx.compiler.binding.DataBindingHelper; +import jaxx.compiler.css.StylesheetHelper; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.reflect.FieldDescriptor; +import jaxx.compiler.reflect.MethodDescriptor; +import jaxx.compiler.types.TypeManager; +import jaxx.runtime.ComponentDescriptor; +import jaxx.runtime.JAXXObject; +import jaxx.runtime.JAXXObjectDescriptor; +import jaxx.runtime.css.Stylesheet; +import org.w3c.dom.*; + +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.io.IOException; +import java.lang.reflect.Modifier; +import java.util.*; + +/** + * Default handler for class tags. Class tags are tags which represent instances of Java classes, + * such as <code><JButton label='Close'/></code>. <code>DefaultObjectHandler</code> + * provides support for attributes and events which adhere to JavaBeans naming conventions as + * well as basic JAXX features like the <code>id</code> attribute and data binding by means of + * curly braces. + * <p/> + * Throughout this class, the word "member" refers to the name of a field or method (e.g. + * <code>"getDocument"</code>) and the word "property" refers to the JavaBeans-style simple + * name of a property (e.g. <code>"document"</code>). + */ +public class DefaultObjectHandler implements TagHandler { + + public static final String ABSTRACT_ATTRIBUTE = "abstract"; + public static final String CONSTRAINTS_ATTRIBUTE = "constraints"; + public static final String CONSTRUCTOR_PARAMS_ATTRIBUTE = "constructorParams"; + public static final String DECORATOR_ATTRIBUTE = "decorator"; + public static final String DISPLAYED_MNEMONIC_ATTRIBUTE = "displayedMnemonic"; + public static final String DISPLAYED_MNEMONIC_INDEX_ATTRIBUTE = "displayedMnemonicIndex"; + public static final String GENERICTYPE_ATTRIBUTE = "genericType"; + public static final String ID_ATTRIBUTE = "id"; + public static final String IMPLEMENTS_ATTRIBUTE = "implements"; + public static final String INITIALIZER_ATTRIBUTE = "initializer"; + public static final String JAVA_BEAN_ATTRIBUTE = "javaBean"; + public static final String LAYOUT_ATTRIBUTE = "layout"; + public static final String MNEMONIC_ATTRIBUTE = "mnemonic"; + public static final String STYLE_CLASS_ATTRIBUTE = "styleClass"; + public static final String SUPER_GENERIC_TYPE_ATTRIBUTE = "superGenericType"; + /** + * 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>(); + + public ProxyEventInfo getEventInfo(String memberName) { + return eventInfos != null ? eventInfos.get(memberName) : null; + } + + /** + * Encapsulates information about a "proxy event handler", which is an event handler that + * fires PropertyChangeEvents when it is triggered. ProxyEventInfos simplify the data binding + * system by allowing all dependencies to fire the same kind of event even if they would + * normally throw something else, like <code>DocumentEvent</code>. + */ + public static 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 + * found, e.g. "document" (which is turned into a call to "getDocument()"). This property + * is also treated as a dependency of the data binding expression, and any updates to it + * (assuming it is bound) will cause the listener to be removed from the old value and + * 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; + + public String getAddMethod() { + return addMethod; + } + + public ClassDescriptor getListenerClass() { + return listenerClass; + } + + public String getMemberName() { + return memberName; + } + + public String getModelName() { + return modelName; + } + + public String getRemoveMethod() { + return 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. + * + * @param beanClass the class which this handler supports + */ + public DefaultObjectHandler(ClassDescriptor beanClass) { + this.beanClass = beanClass; + } + + /** + * Performs introspection on the beanClass and stores the results. + * + * @throws java.beans.IntrospectionException + * if any pb + */ + protected void init() throws IntrospectionException { + if (jaxxBeanInfo == null) { + // perform introspection & cache the results + jaxxBeanInfo = getJAXXBeanInfo(beanClass); + + JAXXPropertyDescriptor[] propertiesArray = jaxxBeanInfo.getJAXXPropertyDescriptors(); + properties = new HashMap<String, JAXXPropertyDescriptor>(); + for (int i = propertiesArray.length - 1; i >= 0; i--) { + properties.put(propertiesArray[i].getName(), propertiesArray[i]); + } + + JAXXEventSetDescriptor[] eventsArray = jaxxBeanInfo.getJAXXEventSetDescriptors(); + events = new HashMap<String, JAXXEventSetDescriptor>(); + for (int i = eventsArray.length - 1; i >= 0; i--) { + MethodDescriptor[] methods = eventsArray[i].getListenerMethods(); + for (MethodDescriptor method : methods) { + events.put(method.getName(), eventsArray[i]); + } + } + + configureProxyEventInfo(); + } + } + + /** + * @return the class which this <code>DefaultObjectHandler</code> supports. + */ + public ClassDescriptor getBeanClass() { + return beanClass; + } + + /** + * @return the <code>JAXXBeanInfo</code> for the class which this <code>DefaultObjectHandler</code> + * supports. + */ + public JAXXBeanInfo getJAXXBeanInfo() { + try { + init(); + } catch (IntrospectionException e) { + throw new RuntimeException(e); + } + return jaxxBeanInfo; + } + + /** + * Returns the <code>JAXXBeanInfo</code> for the specified class. + * + * @param beanClass the bean class for which to retrieve <code>JAXXBeanInfo</code> + * @return the class' <code>JAXXBeanInfo</code> + * @throws java.beans.IntrospectionException + * if any pb + */ + public static JAXXBeanInfo getJAXXBeanInfo(ClassDescriptor beanClass) throws IntrospectionException { + 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>. + * + * @param object the object being compiled + * @param propertyName the simple JavaBeans-style name of the property + * @param compiler the current <code>JAXXCompiler</code> + * @return the property's type + * @throws CompilerException if the type cannot be determined + */ + public ClassDescriptor getPropertyType(CompiledObject object, String propertyName, JAXXCompiler compiler) { + safeInit(); + + JAXXPropertyDescriptor property = properties.get(propertyName); + if (property != null) { + return property.getPropertyType(); + } + throw new UnsupportedAttributeException("property '" + propertyName + "' not found in " + object); + } + + /** + * @param name name of the property + * @return <code>true</code> if the named member is <i>bound</i> (fires <code>PropertyChangeEvent</code> + * when modified). Members are either fields (represented by the simple name of the field) or <code>get/is</code> + * methods (represented by the simple name of the method, <b>not</b> the simplified JavaBeans-style name). + * Methods which are not actually bound in their native class, but for which proxy events have been + * configured (such as <code>JTextField.getText</code>, return <code>true</code>. + * @throws UnsupportedAttributeException if attribute is not supported + */ + public boolean isMemberBound(String name) throws UnsupportedAttributeException { + safeInit(); + + if (eventInfos != null && eventInfos.containsKey(name)) { + return true; + } + + if (name.equals("getClass")) { + return false; + } + + String propertyName = null; + if (name.startsWith("get")) { + propertyName = Introspector.decapitalize(name.substring("get".length())); + } else if (name.startsWith("is")) { + propertyName = Introspector.decapitalize(name.substring("is".length())); + } + JAXXPropertyDescriptor property = propertyName != null ? properties.get(propertyName) : null; + if (property != null) { + return property.isBound(); + } + try { + FieldDescriptor field = getBeanClass().getFieldDescriptor(name); + return Modifier.isFinal(field.getModifiers()); // final fields might as well be considered bound -- they can't be modified anyway + } catch (NoSuchFieldException e) { + throw new UnsupportedAttributeException("cannot find property '" + name + "' of " + getBeanClass()); + } + } + + public 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 +// * example, the JTextField.getText() member depends upon the getModel() +// * member. Returns <code>null</code> if there are no dependencies. +// */ +// public String[] getMemberDependencies(String memberName) { +// ProxyEventInfo eventInfo = eventInfos != null ? eventInfos.get(memberName) : null; +// 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 +// * of a Java code snippet that evaluates to a listener object. +// * <p/> +// * For ordinary bound JavaBeans properties, the Java code returned is a simple call to +// * <code>addPropertyChangeListener</code>. Fields and methods which do not actually fire +// * <code>PropertyChangeEvents</code> when they change necessitate more complex code. +// * +// * @param objectCode Java code which evaluates to the object to which to add the listener +// * *@param dataBinding the name of the data binding this listener is a part of +// * @param dataBinding databinding +// * @param memberName the name of the field or method to listen to +// * @param propertyChangeListenerCode Java code which evaluates to a <code>PropertyChangeListener</code> +// * @param compiler the current <code>JAXXCompiler</code> +// * @return Java code snippet which causes the listener to be added to the object +// */ +// public String getAddMemberListenerCode(String objectCode, String dataBinding, String memberName, String propertyChangeListenerCode, JAXXCompiler compiler) { +// if ("getClass".equals(memberName)) { +// return null; +// } +// +// ProxyEventInfo eventInfo = eventInfos != null ? eventInfos.get(memberName) : null; +// if (eventInfo != null) { +// // a "proxied" event is one that doesn't fire PropertyChangeEvent, so we need to convert its native event type into PropertyChangeEvents +// StringBuffer result = new StringBuffer(); +// String methodName = "$pr" + compiler.getUniqueId(propertyChangeListenerCode); +// boolean methodExists = compiler.hasMethod(methodName); +// ClassDescriptor eventClass = getEventClass(eventInfo.listenerClass); +// if (!methodExists) { +// compiler.getJavaFile().addMethod(new JavaMethod(Modifier.PUBLIC, "void", methodName, +// new JavaArgument[]{new JavaArgument(JAXXCompiler.getCanonicalName(eventClass), "event")}, null, +// propertyChangeListenerCode + ".propertyChange(null);", false)); +// } +// String code = objectCode + (eventInfo.modelName != null ? ".get" + StringUtils.capitalize(eventInfo.modelName) + "()" : ""); +// result.append("$bindingSources.put(\"").append(code).append("\", ").append(code).append(");").append(JAXXCompiler.getLineSeparator()); +// //TC-20091105 Util.getEventListener is generic, no more need cast and use simple listener name +// result.append(code).append('.').append(eventInfo.addMethod).append("( Util.getEventListener(").append(eventInfo.listenerClass.getSimpleName()).append(".class, ").append(compiler.getRootObject().getJavaCode()).append(", ").append(TypeManager.getJavaCode(methodName)).append("));"); +// result.append(JAXXCompiler.getLineSeparator()); +// if (eventInfo.modelName != null) { +// result.append(getAddMemberListenerCode(objectCode, dataBinding, "get" + StringUtils.capitalize(eventInfo.modelName), +// Util.class.getSimpleName() + ".getDataBindingUpdateListener(this , " + dataBinding + ")", +//// Util.class.getSimpleName() + ".getDataBindingUpdateListener(this , \"" + dataBinding + "\")", +// compiler)); +// } +// return result.toString(); +// } else { +// String propertyName = null; +// if (memberName.startsWith("get")) { +// propertyName = Introspector.decapitalize(memberName.substring("get".length())); +// } else if (memberName.startsWith("is")) { +// propertyName = Introspector.decapitalize(memberName.substring("is".length())); +// } else { +// try { +// getBeanClass().getFieldDescriptor(memberName); +// propertyName = memberName; +// } catch (NoSuchFieldException e) { +// // ignore ? +// } +// } +// if (propertyName != null) { +// //TC-20091026 when on root object, do not prefix with objectCode +// String prefix = objectCode.trim() + "."; +// if (objectCode.equals(compiler.getRootObject().getJavaCode())) { +// prefix = ""; +// } +// try { +// // check for property-specific addPropertyChangeListener method +// getBeanClass().getMethodDescriptor("addPropertyChangeListener", ClassDescriptorLoader.getClassDescriptor(String.class), +// ClassDescriptorLoader.getClassDescriptor(PropertyChangeListener.class)); +// return prefix + "addPropertyChangeListener(\"" + propertyName + "\", " + propertyChangeListenerCode + ");\n"; +// } catch (NoSuchMethodException e) { +// // no property-specific method, use general one +// return prefix + "addPropertyChangeListener(" + propertyChangeListenerCode + ");\n"; +// } +// } +// return null; +// } +// } +// +// public String getRemoveMemberListenerCode(String objectCode, String dataBinding, String memberName, String propertyChangeListenerCode, JAXXCompiler compiler) { +// if ("getClass".equals(memberName)) { +// return null; +// } +// +// ProxyEventInfo eventInfo = eventInfos != null ? eventInfos.get(memberName) : null; +// if (eventInfo != null) { +// // a "proxied" event is one that doesn't fire PropertyChangeEvent, +// // so we need to convert its native event type into PropertyChangeEvents +// StringBuffer result = new StringBuffer(); +// String methodName = "$pr" + compiler.getUniqueId(propertyChangeListenerCode); +// boolean methodExists = compiler.hasMethod(methodName); +// if (!methodExists) { +// ClassDescriptor eventClass = getEventClass(eventInfo.listenerClass); +// compiler.getJavaFile().addMethod(new JavaMethod(Modifier.PUBLIC, "void", methodName, +// new JavaArgument[]{new JavaArgument(JAXXCompiler.getCanonicalName(eventClass), "event")}, null, +// propertyChangeListenerCode + ".propertyChange(null);", false)); +// } +// try { +// String modelMemberName = eventInfo.modelName != null ? "get" + StringUtils.capitalize(eventInfo.modelName) : null; +// String modelClassName = modelMemberName != null ? getBeanClass().getMethodDescriptor(modelMemberName).getReturnType().getName() : JAXXCompiler.getCanonicalName(getBeanClass()); +// String code = objectCode + (eventInfo.modelName != null ? "." + modelMemberName + "()" : ""); +// String eol = JAXXCompiler.getLineSeparator(); +// result.append(modelClassName).append(" $target = ((").append(modelClassName).append(") $bindingSources.remove(\"").append(code).append("\"));").append(eol); +// //TC-20091105 test if $target is not null +// result.append("if ($target != null) {").append(eol); +// //TC-20091105 Util.getEventListener is generic, no more need cast and use simple listener name +// result.append(" $target.").append(eventInfo.removeMethod).append("( Util.getEventListener(").append(eventInfo.listenerClass.getSimpleName()).append(".class, ").append(compiler.getRootObject().getJavaCode()).append(", ").append(TypeManager.getJavaCode(methodName)).append("));").append(eol); +// result.append("}").append(eol); +// if (eventInfo.modelName != null) { +//// String bi = dataBinding.startsWith("this.") ? dataBinding : ("\"" + dataBinding + "\""); +// result.append(getRemoveMemberListenerCode(objectCode, dataBinding, "get" + StringUtils.capitalize(eventInfo.modelName), +// Util.class.getSimpleName() + ".getDataBindingUpdateListener(this, " + dataBinding + ")", +//// Util.class.getSimpleName() + ".getDataBindingUpdateListener(this, \"" + dataBinding + "\")", +// compiler)); +// } +// return result.toString(); +// } catch (NoSuchMethodException e) { +// throw new CompilerException("Internal error: " + e); +// } +// } else { +// String propertyName = null; +// if (memberName.startsWith("get")) { +// propertyName = Introspector.decapitalize(memberName.substring("get".length())); +// } else if (memberName.startsWith("is")) { +// propertyName = Introspector.decapitalize(memberName.substring("is".length())); +// } else { +// try { +// getBeanClass().getFieldDescriptor(memberName); +// propertyName = memberName; +// } catch (NoSuchFieldException e) { +// // ignore ? +// } +// } +// if (propertyName != null) { +// //TC-20091026 when on root object, do not prefix with objectCode +// String prefix = objectCode.trim() + "."; +// if (objectCode.equals(compiler.getRootObject().getJavaCode())) { +// prefix = ""; +// } +// try { +// // check for property-specific removePropertyChangeListener method +// getBeanClass().getMethodDescriptor("removePropertyChangeListener", ClassDescriptorLoader.getClassDescriptor(String.class), +// ClassDescriptorLoader.getClassDescriptor(PropertyChangeListener.class)); +// return prefix + "removePropertyChangeListener(\"" + propertyName + "\", " + propertyChangeListenerCode + ");\n"; +// } catch (NoSuchMethodException e) { +// // no property-specific method, use general one +// return prefix + "removePropertyChangeListener(" + propertyChangeListenerCode + ");\n"; +// } +// } +// return null; +// } +// } + + /** + * 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 + * <code>addProxyEventInfo</code> for each member which requires special handling. + */ + 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 + * not bound property <code>get</code> methods. The proxy event handler will attach the specified kind + * of listener to the class and fire a <code>PropertyChangeEvent</code> whenever the listener receives + * any kind of event. + * <p/> + * Even though this method can theoretically be applied to fields (in addition to methods), it would be an + * unusual situation in which that would actually work -- as fields cannot fire events when modified, it would + * be difficult to have a listener that was always notified when a field value changed. + * + * @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) { + 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 + * not bound property <code>get</code> methods. This variant attaches a listener to a property of the + * object (such as <code>model</code>) and not the object itself, which is useful when there is a model + * that is the "real" container of the information. The proxy event handler will attach the specified kind + * of listener to the property's value (retrieved using the property's <code>get</code> method) and fire + * a <code>PropertyChangeEvent</code> whenever the listener receives any kind of event. + * <p/> + * If the property is itself bound (typically the case with models), any updates to the property's value will + * cause the listener to be removed from the old property value and reattached to the new property value, + * as well as cause a <code>PropertyChangeEvent</code> to be fired. + * <p/> + * Even though this method can theoretically be applied to fields (in addition to methods), it would be an + * unusual situation in which that would actually work -- as fields cannot fire events when modified, it would + * be difficult to have a listener that was always notified when a field value changed. + * + * @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 + * @param modelName the JavaBeans-style name of the model property + */ + 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) { + try { + addProxyEventInfo(memberName, ClassDescriptorLoader.getClassDescriptor(listenerClass.getName()), modelName, addMethod, removeMethod); + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } + } + + /** + * 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 + * not bound property <code>get</code> methods. This variant attaches a listener to a property of the + * object (such as <code>model</code>) and not the object itself, which is useful when there is a model + * that is the "real" container of the information. The proxy event handler will attach the specified kind + * of listener to the property's value (retrieved using the property's <code>get</code> method) and fire + * a <code>PropertyChangeEvent</code> whenever the listener receives any kind of event. + * <p/> + * If the property is itself bound (typically the case with models), any updates to the property's value will + * cause the listener to be removed from the old property value and reattached to the new property value, + * as well as cause a <code>PropertyChangeEvent</code> to be fired. + * <p/> + * This variant of <code>addProxyEventInfo</code> allows the names of the methods that add and remove + * the event listener to be specified, in cases where the names are not simply <code>add<listenerClassName></code> + * and <code>remove<listenerClassName></code>. + * <p/> + * Even though this method can theoretically be applied to fields (in addition to methods), it would be an + * unusual situation in which that would actually work -- as fields cannot fire events when modified, it would + * be difficult to have a listener that was always notified when a field value changed. + * + * @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 + * @param modelName the JavaBeans-style name of the model property + * @param addMethod add method name + * @param removeMethod remove method name + */ + public void addProxyEventInfo(String memberName, ClassDescriptor listenerClass, + String modelName, String addMethod, String removeMethod) { + ProxyEventInfo info = new ProxyEventInfo(); + info.memberName = memberName; + info.listenerClass = listenerClass; + info.modelName = modelName; + info.addMethod = addMethod; + info.removeMethod = removeMethod; + if (eventInfos == null) { + eventInfos = new HashMap<String, ProxyEventInfo>(); + } + 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 { + safeInit(); + CompiledObject object = objectMap.get(tag); + if (object == null) { + throw new IllegalStateException("unable to find CompiledObject associated with tag <" + tag.getTagName() + ">; should have been registered before second pass"); + } + compiler.checkOverride(object); + String constructorParams = tag.getAttribute(CONSTRUCTOR_PARAMS_ATTRIBUTE); + if (constructorParams != null && constructorParams.length() > 0) { + object.setConstructorParams(compiler.getScriptManager().trimScript(constructorParams)); + } + + setDefaults(object, tag, compiler); + setAttributes(object, tag, compiler); + //TC-20091105, can apply genericType everyWhere, should just test that class is generic (not possible actually) +// if (object.getGenericTypesLength() > 0 && !(object == compiler.getRootObject() || object.isJavaBean())) { +// // can ony be apply to root object or javaBean object +// compiler.reportWarning("'genericType' attribute can only be found on root, or a javaBean object tag but was found on tag " + tag); +// object.setGenericTypes(null); +// return; +// } + compileChildrenSecondPass(tag, compiler); + } + + public void registerCompiledObject(Element tag, JAXXCompiler compiler) { + String id = tag.getAttribute(ID_ATTRIBUTE); + if (id == null || id.length() == 0) { + id = compiler.getAutoId(getBeanClass().getSimpleName()); +// id = compiler.getAutoId(getBeanClass()); + } + CompiledObject object = createCompiledObject(id, compiler); + objectMap.put(tag, object); + String styleClass = tag.getAttribute(STYLE_CLASS_ATTRIBUTE).trim(); + if (styleClass.length() > 0) { + object.setStyleClass(styleClass); + } + compiler.registerCompiledObject(object); + } + + /** + * Creates the <code>CompiledObject</code> which will represent the object + * created by this <code>TagHandler</code>. + * + * @param id the <code>CompiledObject's</code> ID. + * @param compiler compiler to use + * @return the <code>CompiledObject</code> to use + */ + protected CompiledObject createCompiledObject(String id, JAXXCompiler compiler) { + return new CompiledObject(id, getBeanClass(), compiler); + } + + /** + * Initializes the default settings of the object, prior to setting its + * attribute values. The default implementation does nothing. + * + * @param object the object to initialize + * @param tag the tag being compiled + * @param compiler the current <code>JAXXCompiler</code> + */ + 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 + * via CSS. + * @throws UnsupportedAttributeException if attribute is not supported + */ + public boolean isPropertyInherited(String property) throws UnsupportedAttributeException { + return false; + } + + /** + * @param name name of event + * @return <code>true</code> if the specified name has the form of an event handler attribute + * (e.g. "onActionPerformed"). + */ + public boolean isEventHandlerName(String name) { + 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 + * pass 1 is complete). + * + * @param tag tag to scan + * @param compiler compiler to use + */ + protected void scanAttributesForDependencies(Element tag, JAXXCompiler compiler) { + List<Attr> attributes = new ArrayList<Attr>(); + NamedNodeMap children = tag.getAttributes(); + for (int i = 0; i < children.getLength(); i++) { + attributes.add((Attr) children.item(i)); + } + Collections.sort(attributes, getAttributeComparator()); + + for (Attr attribute : attributes) { + String name = attribute.getName(); + String value = attribute.getValue(); + if (name.equals(JAVA_BEAN_ATTRIBUTE)) { + //compiler.preprocessScript(value); + continue; + } + if (name.equals(CONSTRAINTS_ATTRIBUTE) || isEventHandlerName(name)) { + // adds dependencies as a side effect + compiler.preprocessScript(value); + } else if (name.equals(CONSTRUCTOR_PARAMS_ATTRIBUTE)) { + for (String param : value.split("\\s*,\\s*")) { + compiler.preprocessScript(param); + } + } else if (value.startsWith("{") && value.endsWith("}")) { + compiler.preprocessScript(value.substring(1, value.length() - 1)); + } + } + } + + /** + * 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 + * pairs), event listeners (attributes starting with 'on', such as 'onActionPerformed'), and JAXX-defined properties + * such as 'id'. + * + * @param object the object to be modified + * @param tag the tag from which to pull attributes + * @param compiler the current <code>JAXXCompiler</code> + */ + public void setAttributes(CompiledObject object, Element tag, JAXXCompiler compiler) { + List<Attr> attributes = new ArrayList<Attr>(); + NamedNodeMap children = tag.getAttributes(); + for (int i = 0; i < children.getLength(); i++) { + attributes.add((Attr) children.item(i)); + } + Collections.sort(attributes, getAttributeComparator()); + + for (Attr attribute : attributes) { + String name = attribute.getName(); + String value = attribute.getValue().trim(); + if (name.equals(ID_ATTRIBUTE) || + name.equals(CONSTRAINTS_ATTRIBUTE) || + name.equals(CONSTRUCTOR_PARAMS_ATTRIBUTE) || + name.equals(STYLE_CLASS_ATTRIBUTE) || + name.startsWith(XMLNS_ATTRIBUTE) || + JAXXCompiler.JAXX_INTERNAL_NAMESPACE.equals(attribute.getNamespaceURI())) { + // ignore, already handled + continue; + } + if (name.equals(JAVA_BEAN_ATTRIBUTE)) { + object.setJavaBean(true); + if (!value.isEmpty()) { + object.setJavaBeanInitCode(value); + } + continue; + } + if (name.equals(INITIALIZER_ATTRIBUTE)) { + if (!value.isEmpty()) { + object.setInitializer(value); + } else { + object.setInitializer("null"); + } + continue; + } + if (name.equals(IMPLEMENTS_ATTRIBUTE)) { + if (object != compiler.getRootObject()) { + // can ony be apply to root object + compiler.reportError("'" + IMPLEMENTS_ATTRIBUTE + "' attribute can only be found on root tag but was found on tag " + tag); + return; + } + String[] interfaces = value.split(","); + compiler.setExtraInterfaces(interfaces); + continue; + } + + if (name.equals(ABSTRACT_ATTRIBUTE)) { + if (object != compiler.getRootObject()) { + // can ony be apply to root object + compiler.reportError("'" + ABSTRACT_ATTRIBUTE + "' attribute can only be found on root tag but was found on tag " + tag); + return; + } + compiler.setAbstractClass(true); + continue; + } + + if (name.equals(GENERICTYPE_ATTRIBUTE)) { + //TC-20090313 check after all atributes been processed + if (object == compiler.getRootObject()) { + compiler.setGenericType(value); + } else { + object.setGenericTypes(value.split(",")); + } + continue; + } + + if (name.equals(SUPER_GENERIC_TYPE_ATTRIBUTE)) { + if (object != compiler.getRootObject()) { + // can ony be apply to root object + compiler.reportError("'" + SUPER_GENERIC_TYPE_ATTRIBUTE + "' attribute can only be found on root tag but was found on tag " + tag); + return; + } + compiler.setSuperGenericType(value); + continue; + } + + if (name.equals(DECORATOR_ATTRIBUTE)) { + if (!value.isEmpty()) { + CompiledObjectDecorator decorator = compiler.getEngine().getDecorator(value); + object.setDecorator(decorator); + } + continue; + } + + if (isEventHandlerName(name)) { + // event handler + if (!value.endsWith(";")) { + value += ";"; + } + addEventHandler(object, Introspector.decapitalize(name.substring(2)), value, compiler); + continue; + } + // simple property + setAttribute(object, name, value, true, compiler); + } + } + + /** + * 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. + * + * @return a <code>Comparator</code> defining the order of attribute processing + */ + protected Comparator<Attr> getAttributeComparator() { + return new Comparator<Attr>() { + + @Override + public int compare(Attr a, Attr b) { + int aOrder = getAttributeOrdering(a); + int bOrder = getAttributeOrdering(b); + + return aOrder - bOrder; + } + }; + } + + /** + * 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. + * + * @param attr the attribute to treate + * @return the attribute's priority + */ + protected int getAttributeOrdering(Attr attr) { + if (attr.getName().equals(DISPLAYED_MNEMONIC_INDEX_ATTRIBUTE) || + attr.getName().equals(DISPLAYED_MNEMONIC_ATTRIBUTE) || + attr.getName().equals(MNEMONIC_ATTRIBUTE)) { + return 1; + } + return 0; + } + +// public String getApplyPropertyOrDataBindingCode(CompiledObject object, String propertyName, String stringValue, JAXXCompiler compiler) { +// ClassDescriptor type = getPropertyType(object, propertyName, compiler); +// String binding = compiler.processDataBindings(stringValue); +// if (binding != null) { +// return ""; +// } +// try { +// Class<?> typeClass = type != null ? ClassDescriptorLoader.getClass(type.getName(), type.getClassLoader()) : null; +// Object value = convertFromString(propertyName, stringValue, typeClass); +// return getSetPropertyCode(object.getJavaCode(), propertyName, compiler.getJavaCode(value), compiler); +// } catch (NumberFormatException e) { +// compiler.reportError("could not convert literal string '" + stringValue + "' to type " + type.getName()); +// } catch (IllegalArgumentException e) { +// compiler.reportError("could not convert literal string '" + stringValue + "' to type " + type.getName()); +// } catch (ClassNotFoundException e) { +// compiler.reportError("could not find class " + type.getName()); +// } +// 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}. + * + * @param object the object on which to set the property + * @param propertyName the name of the property to set + * @param stringValue the raw string value of the property from the XML + * @param inline <code>true</code> if the value was directly specified as an inline class tag attribute, <code>false</code> otherwise (a default value, specified in CSS, etc.) + * @param compiler the current <code>JAXXCompiler</code> + */ + public void setAttribute(CompiledObject object, String propertyName, String stringValue, boolean inline, JAXXCompiler compiler) { + try { + //--------------------------------------------------------------------- + // BE WARE, Test if removing this code hurts..., anyway we have a bug on it: + // For some component (example : jaxx.runtime.swing.editor.NumberEditor) we do not have one component + // This is disturbing, must find how why... And this happens only on a mvn clean install on all project + // Everything is fine otherwise... + // + // With new binding design, we will know if there is a binding on the property + // of the jaxxObject, and could add it only if required... + //--------------------------------------------------------------------- + //FIXME TC-20091105 we should to this later when all binding are compiled + // because we don't know yet if this is a databinding +// if (ClassDescriptorLoader.getClassDescriptor(JAXXObject.class).isAssignableFrom(object.getObjectClass())) { +// // check for data binding & remove if found +// JAXXObjectDescriptor jaxxObjectDescriptor = object.getObjectClass().getJAXXObjectDescriptor(); +// if (jaxxObjectDescriptor.getComponentDescriptors().length == 0) { +// compiler.reportWarning("JAXXObject component " + object.getObjectClass() + " should have at least one component!"); +//// throw new IllegalStateException("JAXXObject component " + object.getObjectClass() + " should have at least one component!"); +// } else { +// ComponentDescriptor root = jaxxObjectDescriptor.getComponentDescriptors()[0]; +// //TC-20091026 do not prefix binding by object id if on root object +// String prefix; +// if (object == compiler.getRootObject()) { +// prefix = ""; +// } else { +// prefix = object.getJavaCode() + "."; +// } +// object.appendInitializationCode(prefix + "removeDataBinding(" + compiler.getJavaCode(root.getId() + "." + propertyName) + ");"); +// } +// } + object.addProperty(propertyName, stringValue); + ClassDescriptor type = getPropertyType(object, propertyName, compiler); + String binding = DataBindingHelper.processDataBindings(stringValue); + boolean withBinding = binding != null; + + if (inline) { + compiler.addInlineStyle(object, propertyName, withBinding); + } + if (!withBinding) { + // no bindings, convert from string + try { + Class<?> typeClass = type != null ? ClassDescriptorLoader.getClass(type.getName(), type.getClassLoader()) : null; + Object value = convertFromString(propertyName, stringValue, typeClass); + setProperty(object, propertyName, value, compiler); + return; + } catch (NumberFormatException e) { + compiler.reportError("could not convert literal string '" + stringValue + "' to type " + type.getName()); + } catch (IllegalArgumentException e) { + compiler.reportError("could not convert literal string '" + stringValue + "' to type " + type.getName()); + } catch (ClassNotFoundException e) { + compiler.reportError("could not find class " + type.getName()); + } + } + String setPropertyCode = getSetPropertyCode(object.getJavaCode(), propertyName, binding, compiler); + if (propertyName.equals(LAYOUT_ATTRIBUTE)) { + // handle containerDelegate (e.g. contentPane on JFrame) + // have to set layout early, before children are added + object.appendInitializationCode(setPropertyCode); + } + compiler.getBindingHelper().registerDataBinding(object.getId() + "." + propertyName, binding, setPropertyCode); +// compiler.getBindingHelper().registerDataBinding(binding, object.getId() + "." + propertyName, setPropertyCode); + } catch (UnsupportedAttributeException e) { + compiler.reportError("class " + object.getObjectClass().getName() + " does not support attribute '" + propertyName + "'"); + } + } + + 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(); + ClassDescriptor objectClass = object.getObjectClass(); + if (recurse && ClassDescriptorLoader.getClassDescriptor(JAXXObject.class).isAssignableFrom(objectClass)) { + JAXXObjectDescriptor jaxxObjectDescriptor = objectClass.getJAXXObjectDescriptor(); + ComponentDescriptor[] descriptors = jaxxObjectDescriptor.getComponentDescriptors(); + for (ComponentDescriptor descriptor : descriptors) { + ClassDescriptor classDescriptor = ClassDescriptorLoader.getClassDescriptor(descriptor.getJavaClassName()); + boolean isRoot = classDescriptor != objectClass; + 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()) + "))", + classDescriptor, + compiler, + true); + ComponentDescriptor parentDescriptor = descriptor.getParent(); + CompiledObject currentObject = child; + while (parentDescriptor != null) { + CompiledObject parent = new CompiledObject("internal", ClassDescriptorLoader.getClassDescriptor(parentDescriptor.getJavaClassName()), compiler); + currentObject.setParent(parent); + currentObject = parent; + parentDescriptor = parentDescriptor.getParent(); + } + currentObject.setParent(object); + String styleClass = object.getStyleClass(); + if (styleClass == null) { + styleClass = descriptor.getStyleClass(); + } + child.setStyleClass(styleClass); + Stylesheet mergedStylesheet = overrides; + Stylesheet childOverrides = jaxxObjectDescriptor.getStylesheet(); + if (childOverrides != null) { + if (mergedStylesheet == null) { + mergedStylesheet = childOverrides; + } else { + mergedStylesheet.add(childOverrides.getRules()); + } + } + TagManager.getTagHandler(objectClass).applyStylesheets(child, compiler, mergedStylesheet, isRoot); + object.appendInitializationCode(child.getInitializationCode(compiler)); + } + } else if (stylesheet != null) { + StylesheetHelper.applyTo(object, compiler, stylesheet, overrides); + } + } 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. + * + * @param object the <code>CompiledObject</code> to which the event listener should be added + * @param name the name of the event listener, such as <code>"actionPerformed"</code> + * @param value the Java code snippet to execute when the event is fired + * @param compiler the current <code>JAXXCompiler</code> + */ + public void addEventHandler(CompiledObject object, String name, String value, JAXXCompiler compiler) { + JAXXEventSetDescriptor JAXXEventSetDescriptor = events.get(name); + if (JAXXEventSetDescriptor != null) { + MethodDescriptor[] listenerMethods = JAXXEventSetDescriptor.getListenerMethods(); + MethodDescriptor listenerMethod = null; + for (MethodDescriptor listenerMethod1 : listenerMethods) { + if (listenerMethod1.getName().equals(name)) { + listenerMethod = listenerMethod1; + break; + } + } + if (listenerMethod == null) { + throw new RuntimeException("expected to find method '" + name + "' in JAXXEventSetDescriptor.getListenerMethods()"); + } + try { + value = compiler.preprocessScript(value); + object.addEventHandler(name, JAXXEventSetDescriptor.getAddListenerMethod(), listenerMethod, value, compiler); + } catch (CompilerException e) { + compiler.reportError("While parsing event handler for '" + name + "': " + e.getMessage()); + } + } else { + compiler.reportError("could not find event '" + name + "' for object " + object); + } + } + + /** + * 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. + * + * @param javaCode Java code for the object whose property is being retrieved + * @param name the name of the property to retrieve + * @param compiler the current <code>JAXXCompiler</code> + * @return the snippet + * @throws CompilerException if a compilation error occurs + */ + public String getGetPropertyCode(String javaCode, String name, JAXXCompiler compiler) { + safeInit(); + + JAXXPropertyDescriptor property = properties.get(name); + if (property != null) { + if (property.getReadMethodDescriptor() != null) { + return javaCode + '.' + property.getReadMethodDescriptor().getName() + "()"; + } + throw new UnsupportedAttributeException("property '" + name + "' of " + getBeanClass().getName() + " has no read method"); + } + 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. + * + * @param javaCode Java code for the object whose property is being set + * @param name the name of the property to set + * @param valueCode Java expression representing the value to set the property to + * @param compiler the current <code>JAXXCompiler</code> + * @return the snippet + * @throws CompilerException if a compilation error occurs + */ + public String getSetPropertyCode(String javaCode, String name, String valueCode, JAXXCompiler compiler) { + JAXXPropertyDescriptor property = properties.get(name); + if (property != null) { + if (property.getWriteMethodDescriptor() != null) { + //TC-20091026 do not prefix by javaCode if on root object + String prefix; + if (compiler.getRootObject().getJavaCode().equals(javaCode)) { + prefix = ""; + } else { + prefix = javaCode + "."; + } + return prefix + property.getWriteMethodDescriptor().getName() + '(' + valueCode + ");"; + } + throw new UnsupportedAttributeException("property '" + name + "' of " + getBeanClass().getName() + " is read-only"); + } + 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 + * complicated cases, like data bindings or event handlers). + * <p/> + * By the time it reaches this method, the <code>value</code> has already been converted from its XML + * string representation to the appropriate destination type for the property (i.e. if + * <code>JLabel.foreground</code> is being set, <code>value</code> will be a <code>Color</code>). + * + * @param object the object being modified + * @param name the name of the property to set + * @param value the value to set the property to + * @param compiler the current <code>JAXXCompiler</code> + * @throws CompilerException if a compilation error occurs + */ + public void setProperty(CompiledObject object, String name, Object value, JAXXCompiler compiler) { + 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 + * 'right' onto SwingConstants.LEFT, SwingConstants.CENTER, and SwingConstants.RIGHT respectively. + * <p/> + * You do not normally need to call this method yourself; it is invoked by {@link #convertFromString} when an + * int-valued property has a value which is not a valid number. By default, this method looks at the + * <code>enumerationValues</code> value of the <code>JAXXPropertyDescriptor</code>. + * + * @param key the name of the int-typed property + * @param value the non-numeric value that was specified for the property + * @return the constant integer value + * @throws IllegalArgumentException if the property is an enumeration, but the value is not valid + * @throws NumberFormatException if the property is not an enumeration + */ + protected int constantValue(String key, String value) { + JAXXBeanInfo JAXXBeanInfo = getJAXXBeanInfo(); + JAXXPropertyDescriptor[] props = JAXXBeanInfo.getJAXXPropertyDescriptors(); + String lowercaseValue = value.toLowerCase(); + for (JAXXPropertyDescriptor property : props) { + if (property.getName().equals(key)) { + Object[] values = (Object[]) property.getValue("enumerationValues"); + if (values != null) { + for (int j = 0; j < values.length - 2; j += 3) { + if (((String) values[j]).toLowerCase().equals(lowercaseValue)) { + return (Integer) values[j + 1]; + } + } + + StringBuffer message = new StringBuffer("value of '" + key + "' must be one of: ["); + for (int j = 0; j < values.length - 2; j += 3) { + if (j != 0) { + message.append(", "); + } + message.append(((String) values[j]).toLowerCase()); + } + message.append("] (found '").append(value).append("')"); + throw new IllegalArgumentException(message.toString()); + } + } + } + throw new NumberFormatException(value); + } + + /** + * As {@link TypeManager#convertFromString(String, Class)}, except that it additionally supports constant names + * for <code>int</code>-valued types. + * + * @param key the name of the property whose value is being converted + * @param value the raw string value of the property as it appears in the XML + * @param type the datatype to convert the string into + * @return the converted object + * @see #constantValue + */ + protected Object convertFromString(String key, String value, Class<?> type) { + if (type == null || type == Object.class) { + return value; + } + + try { + return TypeManager.convertFromString(value, type); + } catch (NumberFormatException e) { + if (type == int.class || type == Integer.class) { + return constantValue(key, value); + } + throw e; + } + } + + /** + * Compiles the child tags of the current tag. The default implementation invokes {@link #compileChildTagFirstPass} + * for each child tag. + * + * @param tag the tag whose children to run + * @param compiler the current <code>JAXXCompiler</code> + * @throws CompilerException if a compilation error occurs + * @throws IOException if an I/O error occurs + */ + protected void compileChildrenFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + NodeList children = tag.getChildNodes(); + for (int i = 0; i < children.getLength(); i++) { + Node node = children.item(i); + int nodeType = node.getNodeType(); + if (nodeType == Node.ELEMENT_NODE) { + Element child = (Element) node; + compileChildTagFirstPass(child, compiler); + } + } + } + + /** + * Compiles the child tags of the current tag. The default implementation invokes {@link #compileChildTagFirstPass} + * for each child tag. + * + * @param tag the tag whose children to run + * @param compiler the current <code>JAXXCompiler</code> + * @throws CompilerException if a compilation error occurs + * @throws IOException if an I/O error occurs + */ + protected void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + NodeList children = tag.getChildNodes(); + for (int i = 0; i < children.getLength(); i++) { + Node node = children.item(i); + int nodeType = node.getNodeType(); + if (nodeType == Node.ELEMENT_NODE) { + Element child = (Element) node; + compileChildTagSecondPass(child, compiler); + } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) { + String text = ((Text) node).getData().trim(); + if (text.length() > 0) { + compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')"); + } + } + } + } + + /** + * Compiles a child of the current tag. The default implementation calls {@link JAXXCompiler#compileFirstPass + * JAXXCompiler.compileFirstPass}. + * + * @param tag the child tag to run + * @param compiler the current <code>JAXXCompiler</code> + * @throws CompilerException if a compilation error occurs + * @throws IOException if an I/O error occurs + */ + protected void compileChildTagFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + compiler.compileFirstPass(tag); + } + + /** + * Compiles a child of the current tag. The default implementation calls {@link JAXXCompiler#compileFirstPass + * JAXXCompiler.compileSecondPass}. + * + * @param tag the child tag to run + * @param compiler the current <code>JAXXCompiler</code> + * @throws CompilerException if a compilation error occurs + * @throws IOException if an I/O error occurs + */ + protected void compileChildTagSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + compiler.compileSecondPass(tag); + } + + @Override + public String toString() { + return getClass().getName() + "[" + getBeanClass().getName() + "]"; + } + + protected void safeInit() { + try { + init(); + } catch (IntrospectionException e) { + throw new RuntimeException(e); + } + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/ScriptHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/ScriptHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/ScriptHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,101 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.UnsupportedAttributeException; -import jaxx.compiler.JAXXCompiler; -import org.w3c.dom.Attr; -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.Text; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.io.StringWriter; - -/** - * Handles the <code><script></code> tag. - * - * @author Ethan Nicholas - */ -public class ScriptHandler implements TagHandler { - - public static final String SOURCE_ATTRIBUTE = "source"; - - @Override - public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - File scriptFile = null; - NamedNodeMap attributes = tag.getAttributes(); - for (int i = 0; i < attributes.getLength(); i++) { - Attr attribute = (Attr) attributes.item(i); - String name = attribute.getName(); - String attrValue = attribute.getValue(); - if (name.equals(SOURCE_ATTRIBUTE)) { - scriptFile = new File(compiler.getBaseDir(), attrValue.replace('/', File.separatorChar)); - StringWriter scriptBuffer = new StringWriter(); - try { - FileReader in = new FileReader(scriptFile); - char[] readBuffer = new char[2048]; - int c; - while ((c = in.read(readBuffer)) > 0) { - scriptBuffer.write(readBuffer, 0, c); - } - } catch (FileNotFoundException e) { - compiler.reportError("script file not found: " + scriptFile); - } - compiler.registerScript(scriptBuffer.toString(), scriptFile); - } else if (!name.startsWith(XMLNS_ATTRIBUTE) && - !JAXXCompiler.JAXX_INTERNAL_NAMESPACE.equals(attribute.getNamespaceURI())) { - throw new UnsupportedAttributeException(name); - } - } - - StringBuffer script = new StringBuffer(); - NodeList children = tag.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { - Node child = children.item(i); - switch (child.getNodeType()) { - case Node.ELEMENT_NODE: - compiler.reportError("<script> tag may not contain child elements: " + tag); - case Node.TEXT_NODE: // fall through - case Node.CDATA_SECTION_NODE: - script.append(((Text) child).getData()); - } - } - - String scriptString = script.toString().trim(); - if (scriptString.length() > 0) { - if (scriptFile != null) { - compiler.reportError("<script> tag has both a source attribute and an inline script"); - } - compiler.registerScript(script.toString()); - } - } - - @Override - public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/ScriptHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/ScriptHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/ScriptHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/ScriptHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,101 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.UnsupportedAttributeException; +import jaxx.compiler.JAXXCompiler; +import org.w3c.dom.Attr; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.Text; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.io.StringWriter; + +/** + * Handles the <code><script></code> tag. + * + * @author Ethan Nicholas + */ +public class ScriptHandler implements TagHandler { + + public static final String SOURCE_ATTRIBUTE = "source"; + + @Override + public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + File scriptFile = null; + NamedNodeMap attributes = tag.getAttributes(); + for (int i = 0; i < attributes.getLength(); i++) { + Attr attribute = (Attr) attributes.item(i); + String name = attribute.getName(); + String attrValue = attribute.getValue(); + if (name.equals(SOURCE_ATTRIBUTE)) { + scriptFile = new File(compiler.getBaseDir(), attrValue.replace('/', File.separatorChar)); + StringWriter scriptBuffer = new StringWriter(); + try { + FileReader in = new FileReader(scriptFile); + char[] readBuffer = new char[2048]; + int c; + while ((c = in.read(readBuffer)) > 0) { + scriptBuffer.write(readBuffer, 0, c); + } + } catch (FileNotFoundException e) { + compiler.reportError("script file not found: " + scriptFile); + } + compiler.registerScript(scriptBuffer.toString(), scriptFile); + } else if (!name.startsWith(XMLNS_ATTRIBUTE) && + !JAXXCompiler.JAXX_INTERNAL_NAMESPACE.equals(attribute.getNamespaceURI())) { + throw new UnsupportedAttributeException(name); + } + } + + StringBuffer script = new StringBuffer(); + NodeList children = tag.getChildNodes(); + for (int i = 0; i < children.getLength(); i++) { + Node child = children.item(i); + switch (child.getNodeType()) { + case Node.ELEMENT_NODE: + compiler.reportError("<script> tag may not contain child elements: " + tag); + case Node.TEXT_NODE: // fall through + case Node.CDATA_SECTION_NODE: + script.append(((Text) child).getData()); + } + } + + String scriptString = script.toString().trim(); + if (scriptString.length() > 0) { + if (scriptFile != null) { + compiler.reportError("<script> tag has both a source attribute and an inline script"); + } + compiler.registerScript(script.toString()); + } + } + + @Override + public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/StyleHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/StyleHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/StyleHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,200 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.UnsupportedAttributeException; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.css.parser.CSSParser; -import jaxx.compiler.css.parser.CSSParserConstants; -import jaxx.compiler.css.parser.CSSParserTreeConstants; -import jaxx.compiler.css.parser.SimpleNode; -import jaxx.runtime.css.Rule; -import jaxx.runtime.css.Selector; -import jaxx.runtime.css.Stylesheet; -import org.w3c.dom.Attr; -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.Text; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.io.StringReader; -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Handles the <code><style></code> tag. - * - * @author Ethan Nicholas - */ -public class StyleHandler implements TagHandler { - public static final String SOURCE_ATTRIBUTE = "source"; - - @Override - public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - boolean source = false; - NamedNodeMap attributes = tag.getAttributes(); - for (int i = 0; i < attributes.getLength(); i++) { - Attr attribute = (Attr) attributes.item(i); - String name = attribute.getName(); - String attrValue = attribute.getValue(); - if (name.equals(SOURCE_ATTRIBUTE)) { - source = true; - File styleFile = new File(compiler.getBaseDir(), attrValue.replace('/', File.separatorChar)); - StringWriter styleBuffer = new StringWriter(); - try { - FileReader in = new FileReader(styleFile); - char[] readBuffer = new char[2048]; - int c; - while ((c = in.read(readBuffer)) > 0) { - styleBuffer.write(readBuffer, 0, c); - } - } catch (FileNotFoundException e) { - compiler.reportError("stylesheet file not found: " + styleFile); - } - compiler.getSourceFiles().push(styleFile); - compiler.registerStylesheet(processStylesheet(styleBuffer.toString())); - compiler.getSourceFiles().pop(); - } else if (!name.startsWith(XMLNS_ATTRIBUTE) && - !JAXXCompiler.JAXX_INTERNAL_NAMESPACE.equals(attribute.getNamespaceURI())) { - throw new UnsupportedAttributeException(name); - } - } - - StringBuffer style = new StringBuffer(); - NodeList children = tag.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { - Node child = children.item(i); - switch (child.getNodeType()) { - case Node.ELEMENT_NODE: - compiler.reportError("<style> tag may not contain child elements: " + tag); - case Node.TEXT_NODE: // fall through - case Node.CDATA_SECTION_NODE: - style.append(((Text) child).getData()); - } - } - - String styleString = style.toString().trim(); - if (styleString.length() > 0) { - if (source) { - compiler.reportError("<style> tag has both a source attribute and an inline stylesheet"); - } - compiler.registerStylesheet(processStylesheet(style.toString())); - } - } - - @Override - public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - } - - protected Selector processSelector(SimpleNode selector) { - if (selector.getId() != CSSParserTreeConstants.JJTSELECTOR) { - throw new IllegalArgumentException("argument node is not a Selector"); - } - String javaClassName = null; - String styleClass = null; - String pseudoClass = null; - String id = null; - - for (int i = 0; i < selector.jjtGetNumChildren(); i++) { - SimpleNode child = selector.getChild(i); - switch (child.getId()) { - case CSSParserTreeConstants.JJTJAVACLASS: - if (!child.getText().trim().equals("*")) { - javaClassName = child.getText(); - } - break; - case CSSParserTreeConstants.JJTCLASS: - styleClass = child.getText().substring(1); - break; - case CSSParserTreeConstants.JJTPSEUDOCLASS: - pseudoClass = child.getText().substring(1); - break; - case CSSParserTreeConstants.JJTID: - id = child.getText().substring(1); - break; - - default: - throw new IllegalStateException("unexpected child of Selector node, type=" + child.getId()); - } - } - - return new Selector(javaClassName, styleClass, pseudoClass, id); - } - - protected Rule processRule(SimpleNode ruleNode) { - if (ruleNode.getId() != CSSParserTreeConstants.JJTRULE) { - throw new IllegalArgumentException("argument node is not a Rule"); - } - SimpleNode selectorsNode = ruleNode.getChild(0); - assert selectorsNode.getId() == CSSParserTreeConstants.JJTSELECTORS : "expected node to be of type Selectors"; - - List<Selector> selectors = new ArrayList<Selector>(); - for (int i = 0; i < selectorsNode.jjtGetNumChildren(); i++) { - SimpleNode selectorNode = selectorsNode.getChild(i); - selectors.add(processSelector(selectorNode)); - } - - Map<String, String> properties = new HashMap<String, String>(); - for (int i = 1; i < ruleNode.jjtGetNumChildren(); i++) { - SimpleNode declarationNode = ruleNode.getChild(i); - if (declarationNode.getId() == CSSParserTreeConstants.JJTDECLARATION) { - String key = declarationNode.getChild(0).getText(); - SimpleNode valueNode = declarationNode.getChild(1); - String value = valueNode.getText(); - if (valueNode.firstToken.kind == CSSParserConstants.STRING) { - value = value.substring(1, value.length() - 1); - } - properties.put(key, value); - } - } - Rule rule; - rule = new Rule(selectors.toArray(new Selector[selectors.size()]), properties); - return rule; - } - - protected Stylesheet processStylesheet(String stylesheetText) throws CompilerException { - CSSParser p = new CSSParser(new StringReader(stylesheetText)); - SimpleNode node; - try { - node = p.Stylesheet(); - } catch (Error e) { - throw new CompilerException(e); - } - List<Rule> rules = new ArrayList<Rule>(); - for (int i = 0; i < node.jjtGetNumChildren(); i++) { - SimpleNode ruleNode = node.getChild(i); - Rule rule = processRule(ruleNode); - rules.add(rule); - } - Stylesheet stylesheet; - stylesheet = new Stylesheet(rules.toArray(new Rule[rules.size()])); - return stylesheet; - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/StyleHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/StyleHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/StyleHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/StyleHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,200 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.UnsupportedAttributeException; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.css.parser.CSSParser; +import jaxx.compiler.css.parser.CSSParserConstants; +import jaxx.compiler.css.parser.CSSParserTreeConstants; +import jaxx.compiler.css.parser.SimpleNode; +import jaxx.runtime.css.Rule; +import jaxx.runtime.css.Selector; +import jaxx.runtime.css.Stylesheet; +import org.w3c.dom.Attr; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.Text; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.io.StringReader; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Handles the <code><style></code> tag. + * + * @author Ethan Nicholas + */ +public class StyleHandler implements TagHandler { + public static final String SOURCE_ATTRIBUTE = "source"; + + @Override + public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + boolean source = false; + NamedNodeMap attributes = tag.getAttributes(); + for (int i = 0; i < attributes.getLength(); i++) { + Attr attribute = (Attr) attributes.item(i); + String name = attribute.getName(); + String attrValue = attribute.getValue(); + if (name.equals(SOURCE_ATTRIBUTE)) { + source = true; + File styleFile = new File(compiler.getBaseDir(), attrValue.replace('/', File.separatorChar)); + StringWriter styleBuffer = new StringWriter(); + try { + FileReader in = new FileReader(styleFile); + char[] readBuffer = new char[2048]; + int c; + while ((c = in.read(readBuffer)) > 0) { + styleBuffer.write(readBuffer, 0, c); + } + } catch (FileNotFoundException e) { + compiler.reportError("stylesheet file not found: " + styleFile); + } + compiler.getSourceFiles().push(styleFile); + compiler.registerStylesheet(processStylesheet(styleBuffer.toString())); + compiler.getSourceFiles().pop(); + } else if (!name.startsWith(XMLNS_ATTRIBUTE) && + !JAXXCompiler.JAXX_INTERNAL_NAMESPACE.equals(attribute.getNamespaceURI())) { + throw new UnsupportedAttributeException(name); + } + } + + StringBuffer style = new StringBuffer(); + NodeList children = tag.getChildNodes(); + for (int i = 0; i < children.getLength(); i++) { + Node child = children.item(i); + switch (child.getNodeType()) { + case Node.ELEMENT_NODE: + compiler.reportError("<style> tag may not contain child elements: " + tag); + case Node.TEXT_NODE: // fall through + case Node.CDATA_SECTION_NODE: + style.append(((Text) child).getData()); + } + } + + String styleString = style.toString().trim(); + if (styleString.length() > 0) { + if (source) { + compiler.reportError("<style> tag has both a source attribute and an inline stylesheet"); + } + compiler.registerStylesheet(processStylesheet(style.toString())); + } + } + + @Override + public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + } + + protected Selector processSelector(SimpleNode selector) { + if (selector.getId() != CSSParserTreeConstants.JJTSELECTOR) { + throw new IllegalArgumentException("argument node is not a Selector"); + } + String javaClassName = null; + String styleClass = null; + String pseudoClass = null; + String id = null; + + for (int i = 0; i < selector.jjtGetNumChildren(); i++) { + SimpleNode child = selector.getChild(i); + switch (child.getId()) { + case CSSParserTreeConstants.JJTJAVACLASS: + if (!child.getText().trim().equals("*")) { + javaClassName = child.getText(); + } + break; + case CSSParserTreeConstants.JJTCLASS: + styleClass = child.getText().substring(1); + break; + case CSSParserTreeConstants.JJTPSEUDOCLASS: + pseudoClass = child.getText().substring(1); + break; + case CSSParserTreeConstants.JJTID: + id = child.getText().substring(1); + break; + + default: + throw new IllegalStateException("unexpected child of Selector node, type=" + child.getId()); + } + } + + return new Selector(javaClassName, styleClass, pseudoClass, id); + } + + protected Rule processRule(SimpleNode ruleNode) { + if (ruleNode.getId() != CSSParserTreeConstants.JJTRULE) { + throw new IllegalArgumentException("argument node is not a Rule"); + } + SimpleNode selectorsNode = ruleNode.getChild(0); + assert selectorsNode.getId() == CSSParserTreeConstants.JJTSELECTORS : "expected node to be of type Selectors"; + + List<Selector> selectors = new ArrayList<Selector>(); + for (int i = 0; i < selectorsNode.jjtGetNumChildren(); i++) { + SimpleNode selectorNode = selectorsNode.getChild(i); + selectors.add(processSelector(selectorNode)); + } + + Map<String, String> properties = new HashMap<String, String>(); + for (int i = 1; i < ruleNode.jjtGetNumChildren(); i++) { + SimpleNode declarationNode = ruleNode.getChild(i); + if (declarationNode.getId() == CSSParserTreeConstants.JJTDECLARATION) { + String key = declarationNode.getChild(0).getText(); + SimpleNode valueNode = declarationNode.getChild(1); + String value = valueNode.getText(); + if (valueNode.firstToken.kind == CSSParserConstants.STRING) { + value = value.substring(1, value.length() - 1); + } + properties.put(key, value); + } + } + Rule rule; + rule = new Rule(selectors.toArray(new Selector[selectors.size()]), properties); + return rule; + } + + protected Stylesheet processStylesheet(String stylesheetText) throws CompilerException { + CSSParser p = new CSSParser(new StringReader(stylesheetText)); + SimpleNode node; + try { + node = p.Stylesheet(); + } catch (Error e) { + throw new CompilerException(e); + } + List<Rule> rules = new ArrayList<Rule>(); + for (int i = 0; i < node.jjtGetNumChildren(); i++) { + SimpleNode ruleNode = node.getChild(i); + Rule rule = processRule(ruleNode); + rules.add(rule); + } + Stylesheet stylesheet; + stylesheet = new Stylesheet(rules.toArray(new Rule[rules.size()])); + return stylesheet; + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,64 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.JAXXCompiler; -import org.w3c.dom.Element; - -import java.io.IOException; - -/** - * Implementations of <code>TagHandler</code> produce Java source code from XML tags. - * <code>TagHandlers</code> are mapped to particular XML tags (such as <JFrame>) in {@link JAXXCompiler}. - * There is only one <code>TagHandler</code> for any given XML tag, and therefore implementations must be - * stateless. - * - * @author Ethan Nicholas - */ -public interface TagHandler { - - String XMLNS_ATTRIBUTE = "xmlns"; - - /** - * Performs the first pass of compilation on an XML tag from a JAXX source file. - * <code>TagHandler</code> implementations affect the generated <code>.java</code> - * file by calling methods in the <code>JAXXCompiler</code>. - * - * @param tag the XML tag to compile - * @param compiler the active JAXXCompiler - * @throws CompilerException if a compilation error occurs - * @throws IOException if an I/O error occurs - */ - void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException; - - /** - * Performs the second pass of compilation on an XML tag from a JAXX source file. - * <code>TagHandler</code> implementations affect the generated <code>.java</code> - * file by calling methods in the <code>JAXXCompiler</code>. - * - * @param tag the XML tag to compile - * @param compiler the active JAXXCompiler - * @throws CompilerException if a compilation error occurs - * @throws IOException if an I/O error occurs - */ - void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException; -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,64 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.JAXXCompiler; +import org.w3c.dom.Element; + +import java.io.IOException; + +/** + * Implementations of <code>TagHandler</code> produce Java source code from XML tags. + * <code>TagHandlers</code> are mapped to particular XML tags (such as <JFrame>) in {@link JAXXCompiler}. + * There is only one <code>TagHandler</code> for any given XML tag, and therefore implementations must be + * stateless. + * + * @author Ethan Nicholas + */ +public interface TagHandler { + + String XMLNS_ATTRIBUTE = "xmlns"; + + /** + * Performs the first pass of compilation on an XML tag from a JAXX source file. + * <code>TagHandler</code> implementations affect the generated <code>.java</code> + * file by calling methods in the <code>JAXXCompiler</code>. + * + * @param tag the XML tag to compile + * @param compiler the active JAXXCompiler + * @throws CompilerException if a compilation error occurs + * @throws IOException if an I/O error occurs + */ + void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException; + + /** + * Performs the second pass of compilation on an XML tag from a JAXX source file. + * <code>TagHandler</code> implementations affect the generated <code>.java</code> + * file by calling methods in the <code>JAXXCompiler</code>. + * + * @param tag the XML tag to compile + * @param compiler the active JAXXCompiler + * @throws CompilerException if a compilation error occurs + * @throws IOException if an I/O error occurs + */ + void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException; +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagManager.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagManager.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagManager.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,493 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags; - -import jaxx.compiler.*; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.io.IOException; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.net.URL; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -/** - * Manages TagHandlers, including automatically compiling .jaxx files - * corresponding to class tags. - */ -public class TagManager { - - /** - * Logger - */ - protected static final Log log = LogFactory.getLog(TagManager.class); -// /** -// * Namespace for JAXX's non-class tags, such as <script;>. The namespace normally does not -// * need to be specified but can be used to resolve ambiguities. -// */ -// public static final String JAXX_NAMESPACE = "http://www.jaxxframework.org/"; - /** - * Maps simple tag names to their default namespaces (package names). - */ - private static Map<String, String> defaultNamespaces = new HashMap<String, String>(); - /** - * Maps qualified tag names to the TagHandlers responsible for processing them. - */ - private static Map<QName, TagHandler> registeredTags = new HashMap<QName, TagHandler>(); - /** - * Keeps track of whether or not named classes exist. - */ - private static Map<String, Boolean> classExistenceCache = new HashMap<String, Boolean>(); - /** - * Maps bean classes to their TagHandler classes. The mapping is to TagHandler classes, rather than to - * TagHandler instances, because subclasses of the bean class should be handled by the same TagHandler - * (assuming no more specific mappings exist), which requires creating a new instance of the TagHandler. - */ - private static ClassMap<Class<? extends TagHandler>> registeredBeans = new ClassMap<Class<? extends TagHandler>>(); - - // still targeting 1.4, so I can't use javax.xml.namespace.QName - private static class QName { - - private String namespaceURI; - private String localPart; - - public QName(String namespaceURI, String localPart) { - if (localPart == null) { - throw new NullPointerException(); - } - this.namespaceURI = namespaceURI; - this.localPart = localPart; - } - - public String getNamespaceURI() { - return namespaceURI; - } - - public String getLocalPart() { - return localPart; - } - - @Override - public boolean equals(Object o) { - if (o == null || !(o instanceof QName)) { - return false; - } - QName qname = (QName) o; - return qname.getNamespaceURI().equals(getNamespaceURI()) && qname.getLocalPart().equals(getLocalPart()); - } - - @Override - public int hashCode() { - return (namespaceURI != null ? namespaceURI.hashCode() : 0) ^ getLocalPart().hashCode(); - } - } - - private TagManager() { /* not instantiable */ } - - public static void reset(boolean verbose) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException { - registeredBeans.clear(); - registeredTags.clear(); - defaultNamespaces.clear(); - JAXXEngine.loadLibraries(verbose); - } - - /** - * Maps a class tag to a specific <code>TagHandler</code>. When a tag representing the bean class is - * encountered (either the class' simple name, if it is unambiguous, or its fully-qualified name), the specified - * <code>TagHandler</code> will be invoked to run it. - * - * @param <T> type of handler - * @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> - */ - public static <T extends TagHandler> void registerBean(ClassDescriptor beanClass, Class<T> handler) { - if (!DefaultObjectHandler.class.isAssignableFrom(handler)) { - throw new IllegalArgumentException("handler class must be a subclass of DefaultObjectHandler"); - } - registeredBeans.put(beanClass, handler); - if (log.isDebugEnabled()) { - log.debug(beanClass + " : " + handler); - } - String name = beanClass.getName(); - int dotPos = name.lastIndexOf("."); - String namespace = name.substring(0, dotPos + 1) + "*"; - name = name.substring(dotPos + 1); - registerDefaultNamespace(name, namespace); - } - - /** - * Sets the default namespace for a tag. When the tag is encountered with no namespace specified, - * the specified namespace will be assumed. Mapping the same tag to two or more default namespaces - * removes the mapping and marks the entry as being ambiguous (by putting a <code>null</code> - * value into the map); this causes an error to be thrown if the tag is used without a namespace being - * specified. - * <p/> - * Java package names on tags are automatically converted into namespaces (e.g. <javax.swing.JButton/> - * and <JButton xmlns="javax.swing.*"/> are equivalent), so tags with package names are considered - * to have namespaces specified. - * - * @param tag tag name - * @param namespace namespace - */ - public static void registerDefaultNamespace(String tag, String namespace) { - if (defaultNamespaces.containsKey(tag) && !defaultNamespaces.get(tag).equals(namespace)) { - defaultNamespaces.put(tag, null); // tag name is now ambiguous - } else { - defaultNamespaces.put(tag, namespace); - } - } - - /** - * Registers a <code>TagHandler</code> for a tag. When a tag with the given name and namespace - * is encountered, the <code>TagHandler's compileFirstPass</code> and <code>compileSecondPass</code> - * methods will be invoked to handle it. - * <p/> - * It is not an error to register an already-registered tag and namespace combination. The new mapping - * will replace the old mapping. - * - * @param <T> type of handler - * @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 - */ - public static <T extends TagHandler> void registerTag(String namespace, String tag, T handler) { - if (namespace == null) { - namespace = "*"; - } - //System.out.println("registerTag "+namespace+" : "+tag+" : "+handler); - if (log.isDebugEnabled()) { - log.debug(tag + " : " + handler); - } - registeredTags.put(new QName(namespace, tag), handler); - registerDefaultNamespace(tag, namespace); - } - - /** - * Returns the <code>TagHandler</code> that should be used to process the specified tag. - * If the tag represents the class name of an uncompiled <code>.jaxx</code> file, the - * <code>.jaxx</code> is first compiled. - * - * @param namespace the tag's namespace (may be <code>null</code>) - * @param tag the tag's simple name - * @param compiler the current <code>JAXXCompiler</code> - * @return the <code>TagHandler</code> for the tag - * @throws CompilerException ? - */ - public static TagHandler getTagHandler(String namespace, String tag, JAXXCompiler compiler) throws CompilerException { - return getTagHandler(namespace, tag, false, compiler); - } - - private static String getNamespace(ClassDescriptor beanClass) { - String packageName = beanClass.getPackageName(); - return packageName != null ? packageName + ".*" : "*"; - - } - - private static String getSimpleName(ClassDescriptor beanClass) { - String packageName = beanClass.getPackageName(); - if (packageName != null) { - assert beanClass.getName().startsWith(packageName); - return beanClass.getName().substring(packageName.length() + 1); - } - return beanClass.getName(); - } - - /** - * @param beanClass the tag class - * @return the <code>TagHandler</code> that should be used to process the specified class. - * Only <code>TagHandlers</code> previously registered with <code>registerBean</code> - * are considered. - * @throws CompilerException ? - */ - public static DefaultObjectHandler getTagHandler(ClassDescriptor beanClass) throws CompilerException { - try { - if (beanClass == null) { - throw new NullPointerException(); - } - String namespace = getNamespace(beanClass); - String tag = getSimpleName(beanClass); - DefaultObjectHandler handler = (DefaultObjectHandler) registeredTags.get(new QName(namespace, tag)); - if (handler == null) { - Class<? extends TagHandler> handlerClass = registeredBeans.get(beanClass); - if (handlerClass == null) { - throw new CompilerException("unable to find handler for " + beanClass); - } - Constructor<? extends TagHandler> constructor = handlerClass.getConstructor(ClassDescriptor.class); - handler = (DefaultObjectHandler) constructor.newInstance(beanClass); - registerTag(namespace, tag, handler); - } - return handler; - } catch (InstantiationException e) { - throw new RuntimeException(e); - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } catch (InvocationTargetException e) { - throw new RuntimeException(e); - } - } - - private static boolean classExists(String className, JAXXCompiler compiler) { - if (classExistenceCache.containsKey(className)) { - return classExistenceCache.get(className); - } - - boolean found = false; - ClassLoader classLoader = compiler.getClassLoader(); - try { - Class.forName(className, true, classLoader); - found = true; - } catch (ClassNotFoundException e) { - // ignore ? - } catch (NoClassDefFoundError e) { - // we obtain this instead of ClassNotFoundException on case-insensitive file systems when - // looking up a class with the wrong case - } - - if (!found) { - // couldn't find .class, check for .java - URL javaURL = classLoader.getResource(className.replace('.', '/') + ".java"); - found = javaURL != null; - } - - if (!found) { - // couldn't find .java, check for .jaxx - URL jaxxURL = classLoader.getResource(className.replace('.', '/') + ".jaxx"); - found = jaxxURL != null; - } - - classExistenceCache.put(className, found); - - return found; - } - - private static String determinePackage(String simpleClassName, String defaultPackage, JAXXCompiler compiler) { - String namespace = null; - Set<String> classes = compiler.getImportedClasses(); - for (String className : classes) { - // search class imports (e.g. import java.util.Date;) - if (className.equals(simpleClassName) || className.endsWith("." + simpleClassName)) { - namespace = className.substring(0, className.lastIndexOf(".") + 1) + "*"; - } - } - if (namespace == null) { - // search package imports (e.g. import java.util.*;) - Set<String> searchList = compiler.getImportedPackages(); - if (defaultPackage != null) { - if (!defaultPackage.endsWith("*")) { - throw new IllegalArgumentException("defaultPackage must end in '*', found '" + defaultPackage + "'"); - } - if (classExists(defaultPackage.substring(0, defaultPackage.length() - 1) + simpleClassName, compiler)) { - return defaultPackage; - } - } - for (String currentPackage : searchList) { - String className = currentPackage + simpleClassName; - if (classExists(className, compiler)) { - if (namespace != null) { - // we've already found the same name in another package - compiler.reportError("symbol '" + simpleClassName + "' is ambiguous, found matching classes " + namespace.substring(0, namespace.length() - 1) + simpleClassName + " and " + currentPackage + simpleClassName + ". Use fully-qualified name to disambiguate."); - return null; - } - namespace = currentPackage + "*"; - } - } - } - - return namespace; - } - - /** - * Returns the <code>TagHandler</code> that should be used to process the specified tag. - * <p/> - * The <code>namespacePrefix</code> parameter is used only for error checking, as it is an - * error to specify conflicting package names using both a fully-qualified tag name and a - * namespace prefix, but it is not an error to specify conflicting package names using a - * fully-qualified tag name and a <i>default</i> namespace (i.e. <awt:javax.swing.JButton xmlns:awt='java.awt.*'/> - * is an error, whereas <javax.swing.JButton xmlns='java.awt.*'/> is not). - * - * @param namespace the tag's namespace (may be <code>null</code>) - * @param tag the tag's simple name (which can include fully-qualified Java class names) - * @param namespacePrefix <code>true</code> if the namespace was specified by means of a namespace prefix (as opposed to a default namespace) - * @param compiler the current <code>JAXXCompiler</code> - * @return the <code>TagHandler</code> for the tag - * @throws CompilerException ? - */ - public static TagHandler getTagHandler(String namespace, String tag, boolean namespacePrefix, JAXXCompiler compiler) throws CompilerException { - if (tag == null) { - throw new NullPointerException(); - } - if (namespace == null && defaultNamespaces.containsKey(tag)) { - namespace = defaultNamespaces.get(tag); - if (namespace == null) { // defaultNamespaces map contains a null value, which is put there to indicate ambiguity - compiler.reportError("tag '" + tag + "' is ambiguous; specify fully-qualified name (package and class) to disambiguate"); - return null; - } - } - - TagHandler handler = registeredTags.get(new QName(namespace, tag)); - if (handler == null) { - if (namespace == null || namespace.endsWith("*")) { - String className; - if (namespace != null) { - className = resolveClassName(namespace.substring(0, namespace.length() - 1) + tag, compiler); - if (className == null) { - className = resolveClassName(tag, compiler); - if (namespacePrefix && !className.startsWith(namespace.substring(0, namespace.length() - 1))) { - className = null; // namespace was specified, but we found it in a different package - ignore - } - } - } else { - className = resolveClassName(tag, compiler); - } - if (className != null) { - int dotPos = className.lastIndexOf("."); - namespace = className.substring(0, dotPos + 1) + "*"; - tag = className.substring(dotPos + 1); - handler = registeredTags.get(new QName(namespace, tag)); - if (handler == null) { - try { - handler = getTagHandler(ClassDescriptorLoader.getClassDescriptor(className, compiler.getClassLoader())); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } - } - } - } - } - return handler; - } - - /** - * Resolves a simple class name (like <code>Object</code> or <code>String</code>) to its fully-qualified name. Inner - * classes should be represented as they would appear in Java source code (e.g. JPopupMenu.Separator). Fully-qualified names, - * such as <code>java.lang.Object</code> are legal and will be returned unmodified (and in fact it is generally impossible to - * even know whether a given reference is fully qualified until it has been resolved). Returns <code>null</code> if no matching - * class could be found. - * - * @param name name to resolve - * @param compiler run to use - * @return the resolved fqn class name - */ - public static String resolveClassName(String name, JAXXCompiler compiler) { - if (name.endsWith("[]")) { - return resolveClassName(name.substring(0, name.length() - 2), compiler) + "[]"; - } - 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")) { - return name; - } - - String result = null; - String originalName = name; - String defaultNamespace = null; - if (defaultNamespaces.containsKey(name)) { - defaultNamespace = defaultNamespaces.get(name); - if (defaultNamespace == null) { // defaultNamespaces map contains a null value, which is put there to indicate ambiguity - compiler.reportError("class '" + name + "' is ambiguous; specify fully-qualified name (package and class) to disambiguate"); - return null; - } - } - if (defaultNamespace != null && defaultNamespace.endsWith("*")) { - result = defaultNamespace.substring(0, defaultNamespace.length() - 1) + name; - } - - if (result == null) { - // Inner class names (like JPopupMenu.Separator) present a special challenge. The name before the dot might be - // a package name, or it might be a class name. If it's a class name, it might be fully qualified, or it might - // not. And it's also not actually the correct name of the class, as far as the JVM is concerned -- the correct - // name uses a dollar sign instead of a dot (javax.swing.JPopupMenu$Separator). And there could be more than - // one inner class -- it's possible to have com.mycompany.Outer$Inner$Innerer$Innerest. - // - // The basic strategy is to run by treating the part before the last dot as a package name, as that is by far - // the most likely case. If we don't find the class there, change the last dot to a dollar sign and try again. - // Suppose we have the tag <com.mycompany.Outer.Inner.Innerer.Innerest/>, matching the class above. Resolution - // proceeds like this: - // com.mycompany.Outer.Inner.Innerer.* : Innerest - // com.mycompany.Outer.Inner.* : Innerer$Innerest - // com.mycompany.Outer.* : Inner$Innerer$Innerest - // com.mycompany.* : Outer$Inner$Innerer$Innerest - // And at this point we have a match with the class Outer$Inner$Innerer$Innerest in package com.mycompany. - int dotPos = originalName.lastIndexOf('.'); - for (;;) { - String namespace = dotPos != -1 ? originalName.substring(0, dotPos) + ".*" : "*"; - name = originalName.substring(dotPos + 1).replace('.', '$'); - String packageName = determinePackage(name, namespace, compiler); - if (packageName != null) { - assert packageName.endsWith("*"); - if (packageName.equals(namespace) || namespace.equals("*")) { - // check for an alias (like javax.swing.JComboBox actually being jaxx.runtime.swing.JAXXComboBox) - TagHandler handler = registeredTags.get(new QName(namespace, name)); - if (handler != null) { // determine alias by looking at handler - ClassDescriptor alias = ((DefaultObjectHandler) handler).getBeanClass(); - // make sure the same handler is used for both the aliased and non-aliased names, in order to avoid "no CompiledObject has been registered" error - // the line below doesn't bother to handle the case where the aliased class name doesn't have a package, since it's a pretty safe assumption that - // that will never happen - assert alias.getPackageName() != null && alias.getPackageName().length() > 0 : "aliasing with no package name has not been implemented"; - registeredTags.put(new QName(alias.getPackageName() + ".*", alias.getName().substring(alias.getPackageName().length() + 1)), handler); - result = alias.getName(); - break; - } else { // no alias - result = packageName.substring(0, packageName.length() - 1) + name; - break; - } - } - // else we found a class by the same name, but in the wrong package - } - - if (dotPos <= 0) { - break; - } - dotPos = originalName.lastIndexOf('.', dotPos - 1); - } - } - - if (result != null && !result.equals(originalName)) { - result = resolveClassName(result, compiler); // check for aliases against the new name as well - } - - return result; - } - - public static ClassDescriptor resolveClass(String className, JAXXCompiler compiler) { - try { - className = resolveClassName(className, compiler); - if (className == null) { - return null; - } - return ClassDescriptorLoader.getClassDescriptor(className, compiler.getClassLoader()); - } catch (ClassNotFoundException e) { - return null; - } - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagManager.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagManager.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagManager.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagManager.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,493 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags; + +import jaxx.compiler.*; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.io.IOException; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +/** + * Manages TagHandlers, including automatically compiling .jaxx files + * corresponding to class tags. + */ +public class TagManager { + + /** + * Logger + */ + protected static final Log log = LogFactory.getLog(TagManager.class); +// /** +// * Namespace for JAXX's non-class tags, such as <script;>. The namespace normally does not +// * need to be specified but can be used to resolve ambiguities. +// */ +// public static final String JAXX_NAMESPACE = "http://www.jaxxframework.org/"; + /** + * Maps simple tag names to their default namespaces (package names). + */ + private static Map<String, String> defaultNamespaces = new HashMap<String, String>(); + /** + * Maps qualified tag names to the TagHandlers responsible for processing them. + */ + private static Map<QName, TagHandler> registeredTags = new HashMap<QName, TagHandler>(); + /** + * Keeps track of whether or not named classes exist. + */ + private static Map<String, Boolean> classExistenceCache = new HashMap<String, Boolean>(); + /** + * Maps bean classes to their TagHandler classes. The mapping is to TagHandler classes, rather than to + * TagHandler instances, because subclasses of the bean class should be handled by the same TagHandler + * (assuming no more specific mappings exist), which requires creating a new instance of the TagHandler. + */ + private static ClassMap<Class<? extends TagHandler>> registeredBeans = new ClassMap<Class<? extends TagHandler>>(); + + // still targeting 1.4, so I can't use javax.xml.namespace.QName + private static class QName { + + private String namespaceURI; + private String localPart; + + public QName(String namespaceURI, String localPart) { + if (localPart == null) { + throw new NullPointerException(); + } + this.namespaceURI = namespaceURI; + this.localPart = localPart; + } + + public String getNamespaceURI() { + return namespaceURI; + } + + public String getLocalPart() { + return localPart; + } + + @Override + public boolean equals(Object o) { + if (o == null || !(o instanceof QName)) { + return false; + } + QName qname = (QName) o; + return qname.getNamespaceURI().equals(getNamespaceURI()) && qname.getLocalPart().equals(getLocalPart()); + } + + @Override + public int hashCode() { + return (namespaceURI != null ? namespaceURI.hashCode() : 0) ^ getLocalPart().hashCode(); + } + } + + private TagManager() { /* not instantiable */ } + + public static void reset(boolean verbose) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException { + registeredBeans.clear(); + registeredTags.clear(); + defaultNamespaces.clear(); + JAXXEngine.loadLibraries(verbose); + } + + /** + * Maps a class tag to a specific <code>TagHandler</code>. When a tag representing the bean class is + * encountered (either the class' simple name, if it is unambiguous, or its fully-qualified name), the specified + * <code>TagHandler</code> will be invoked to run it. + * + * @param <T> type of handler + * @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> + */ + public static <T extends TagHandler> void registerBean(ClassDescriptor beanClass, Class<T> handler) { + if (!DefaultObjectHandler.class.isAssignableFrom(handler)) { + throw new IllegalArgumentException("handler class must be a subclass of DefaultObjectHandler"); + } + registeredBeans.put(beanClass, handler); + if (log.isDebugEnabled()) { + log.debug(beanClass + " : " + handler); + } + String name = beanClass.getName(); + int dotPos = name.lastIndexOf("."); + String namespace = name.substring(0, dotPos + 1) + "*"; + name = name.substring(dotPos + 1); + registerDefaultNamespace(name, namespace); + } + + /** + * Sets the default namespace for a tag. When the tag is encountered with no namespace specified, + * the specified namespace will be assumed. Mapping the same tag to two or more default namespaces + * removes the mapping and marks the entry as being ambiguous (by putting a <code>null</code> + * value into the map); this causes an error to be thrown if the tag is used without a namespace being + * specified. + * <p/> + * Java package names on tags are automatically converted into namespaces (e.g. <javax.swing.JButton/> + * and <JButton xmlns="javax.swing.*"/> are equivalent), so tags with package names are considered + * to have namespaces specified. + * + * @param tag tag name + * @param namespace namespace + */ + public static void registerDefaultNamespace(String tag, String namespace) { + if (defaultNamespaces.containsKey(tag) && !defaultNamespaces.get(tag).equals(namespace)) { + defaultNamespaces.put(tag, null); // tag name is now ambiguous + } else { + defaultNamespaces.put(tag, namespace); + } + } + + /** + * Registers a <code>TagHandler</code> for a tag. When a tag with the given name and namespace + * is encountered, the <code>TagHandler's compileFirstPass</code> and <code>compileSecondPass</code> + * methods will be invoked to handle it. + * <p/> + * It is not an error to register an already-registered tag and namespace combination. The new mapping + * will replace the old mapping. + * + * @param <T> type of handler + * @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 + */ + public static <T extends TagHandler> void registerTag(String namespace, String tag, T handler) { + if (namespace == null) { + namespace = "*"; + } + //System.out.println("registerTag "+namespace+" : "+tag+" : "+handler); + if (log.isDebugEnabled()) { + log.debug(tag + " : " + handler); + } + registeredTags.put(new QName(namespace, tag), handler); + registerDefaultNamespace(tag, namespace); + } + + /** + * Returns the <code>TagHandler</code> that should be used to process the specified tag. + * If the tag represents the class name of an uncompiled <code>.jaxx</code> file, the + * <code>.jaxx</code> is first compiled. + * + * @param namespace the tag's namespace (may be <code>null</code>) + * @param tag the tag's simple name + * @param compiler the current <code>JAXXCompiler</code> + * @return the <code>TagHandler</code> for the tag + * @throws CompilerException ? + */ + public static TagHandler getTagHandler(String namespace, String tag, JAXXCompiler compiler) throws CompilerException { + return getTagHandler(namespace, tag, false, compiler); + } + + private static String getNamespace(ClassDescriptor beanClass) { + String packageName = beanClass.getPackageName(); + return packageName != null ? packageName + ".*" : "*"; + + } + + private static String getSimpleName(ClassDescriptor beanClass) { + String packageName = beanClass.getPackageName(); + if (packageName != null) { + assert beanClass.getName().startsWith(packageName); + return beanClass.getName().substring(packageName.length() + 1); + } + return beanClass.getName(); + } + + /** + * @param beanClass the tag class + * @return the <code>TagHandler</code> that should be used to process the specified class. + * Only <code>TagHandlers</code> previously registered with <code>registerBean</code> + * are considered. + * @throws CompilerException ? + */ + public static DefaultObjectHandler getTagHandler(ClassDescriptor beanClass) throws CompilerException { + try { + if (beanClass == null) { + throw new NullPointerException(); + } + String namespace = getNamespace(beanClass); + String tag = getSimpleName(beanClass); + DefaultObjectHandler handler = (DefaultObjectHandler) registeredTags.get(new QName(namespace, tag)); + if (handler == null) { + Class<? extends TagHandler> handlerClass = registeredBeans.get(beanClass); + if (handlerClass == null) { + throw new CompilerException("unable to find handler for " + beanClass); + } + Constructor<? extends TagHandler> constructor = handlerClass.getConstructor(ClassDescriptor.class); + handler = (DefaultObjectHandler) constructor.newInstance(beanClass); + registerTag(namespace, tag, handler); + } + return handler; + } catch (InstantiationException e) { + throw new RuntimeException(e); + } catch (NoSuchMethodException e) { + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } catch (InvocationTargetException e) { + throw new RuntimeException(e); + } + } + + private static boolean classExists(String className, JAXXCompiler compiler) { + if (classExistenceCache.containsKey(className)) { + return classExistenceCache.get(className); + } + + boolean found = false; + ClassLoader classLoader = compiler.getClassLoader(); + try { + Class.forName(className, true, classLoader); + found = true; + } catch (ClassNotFoundException e) { + // ignore ? + } catch (NoClassDefFoundError e) { + // we obtain this instead of ClassNotFoundException on case-insensitive file systems when + // looking up a class with the wrong case + } + + if (!found) { + // couldn't find .class, check for .java + URL javaURL = classLoader.getResource(className.replace('.', '/') + ".java"); + found = javaURL != null; + } + + if (!found) { + // couldn't find .java, check for .jaxx + URL jaxxURL = classLoader.getResource(className.replace('.', '/') + ".jaxx"); + found = jaxxURL != null; + } + + classExistenceCache.put(className, found); + + return found; + } + + private static String determinePackage(String simpleClassName, String defaultPackage, JAXXCompiler compiler) { + String namespace = null; + Set<String> classes = compiler.getImportedClasses(); + for (String className : classes) { + // search class imports (e.g. import java.util.Date;) + if (className.equals(simpleClassName) || className.endsWith("." + simpleClassName)) { + namespace = className.substring(0, className.lastIndexOf(".") + 1) + "*"; + } + } + if (namespace == null) { + // search package imports (e.g. import java.util.*;) + Set<String> searchList = compiler.getImportedPackages(); + if (defaultPackage != null) { + if (!defaultPackage.endsWith("*")) { + throw new IllegalArgumentException("defaultPackage must end in '*', found '" + defaultPackage + "'"); + } + if (classExists(defaultPackage.substring(0, defaultPackage.length() - 1) + simpleClassName, compiler)) { + return defaultPackage; + } + } + for (String currentPackage : searchList) { + String className = currentPackage + simpleClassName; + if (classExists(className, compiler)) { + if (namespace != null) { + // we've already found the same name in another package + compiler.reportError("symbol '" + simpleClassName + "' is ambiguous, found matching classes " + namespace.substring(0, namespace.length() - 1) + simpleClassName + " and " + currentPackage + simpleClassName + ". Use fully-qualified name to disambiguate."); + return null; + } + namespace = currentPackage + "*"; + } + } + } + + return namespace; + } + + /** + * Returns the <code>TagHandler</code> that should be used to process the specified tag. + * <p/> + * The <code>namespacePrefix</code> parameter is used only for error checking, as it is an + * error to specify conflicting package names using both a fully-qualified tag name and a + * namespace prefix, but it is not an error to specify conflicting package names using a + * fully-qualified tag name and a <i>default</i> namespace (i.e. <awt:javax.swing.JButton xmlns:awt='java.awt.*'/> + * is an error, whereas <javax.swing.JButton xmlns='java.awt.*'/> is not). + * + * @param namespace the tag's namespace (may be <code>null</code>) + * @param tag the tag's simple name (which can include fully-qualified Java class names) + * @param namespacePrefix <code>true</code> if the namespace was specified by means of a namespace prefix (as opposed to a default namespace) + * @param compiler the current <code>JAXXCompiler</code> + * @return the <code>TagHandler</code> for the tag + * @throws CompilerException ? + */ + public static TagHandler getTagHandler(String namespace, String tag, boolean namespacePrefix, JAXXCompiler compiler) throws CompilerException { + if (tag == null) { + throw new NullPointerException(); + } + if (namespace == null && defaultNamespaces.containsKey(tag)) { + namespace = defaultNamespaces.get(tag); + if (namespace == null) { // defaultNamespaces map contains a null value, which is put there to indicate ambiguity + compiler.reportError("tag '" + tag + "' is ambiguous; specify fully-qualified name (package and class) to disambiguate"); + return null; + } + } + + TagHandler handler = registeredTags.get(new QName(namespace, tag)); + if (handler == null) { + if (namespace == null || namespace.endsWith("*")) { + String className; + if (namespace != null) { + className = resolveClassName(namespace.substring(0, namespace.length() - 1) + tag, compiler); + if (className == null) { + className = resolveClassName(tag, compiler); + if (namespacePrefix && !className.startsWith(namespace.substring(0, namespace.length() - 1))) { + className = null; // namespace was specified, but we found it in a different package - ignore + } + } + } else { + className = resolveClassName(tag, compiler); + } + if (className != null) { + int dotPos = className.lastIndexOf("."); + namespace = className.substring(0, dotPos + 1) + "*"; + tag = className.substring(dotPos + 1); + handler = registeredTags.get(new QName(namespace, tag)); + if (handler == null) { + try { + handler = getTagHandler(ClassDescriptorLoader.getClassDescriptor(className, compiler.getClassLoader())); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + } + } + } + } + return handler; + } + + /** + * Resolves a simple class name (like <code>Object</code> or <code>String</code>) to its fully-qualified name. Inner + * classes should be represented as they would appear in Java source code (e.g. JPopupMenu.Separator). Fully-qualified names, + * such as <code>java.lang.Object</code> are legal and will be returned unmodified (and in fact it is generally impossible to + * even know whether a given reference is fully qualified until it has been resolved). Returns <code>null</code> if no matching + * class could be found. + * + * @param name name to resolve + * @param compiler run to use + * @return the resolved fqn class name + */ + public static String resolveClassName(String name, JAXXCompiler compiler) { + if (name.endsWith("[]")) { + return resolveClassName(name.substring(0, name.length() - 2), compiler) + "[]"; + } + 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")) { + return name; + } + + String result = null; + String originalName = name; + String defaultNamespace = null; + if (defaultNamespaces.containsKey(name)) { + defaultNamespace = defaultNamespaces.get(name); + if (defaultNamespace == null) { // defaultNamespaces map contains a null value, which is put there to indicate ambiguity + compiler.reportError("class '" + name + "' is ambiguous; specify fully-qualified name (package and class) to disambiguate"); + return null; + } + } + if (defaultNamespace != null && defaultNamespace.endsWith("*")) { + result = defaultNamespace.substring(0, defaultNamespace.length() - 1) + name; + } + + if (result == null) { + // Inner class names (like JPopupMenu.Separator) present a special challenge. The name before the dot might be + // a package name, or it might be a class name. If it's a class name, it might be fully qualified, or it might + // not. And it's also not actually the correct name of the class, as far as the JVM is concerned -- the correct + // name uses a dollar sign instead of a dot (javax.swing.JPopupMenu$Separator). And there could be more than + // one inner class -- it's possible to have com.mycompany.Outer$Inner$Innerer$Innerest. + // + // The basic strategy is to run by treating the part before the last dot as a package name, as that is by far + // the most likely case. If we don't find the class there, change the last dot to a dollar sign and try again. + // Suppose we have the tag <com.mycompany.Outer.Inner.Innerer.Innerest/>, matching the class above. Resolution + // proceeds like this: + // com.mycompany.Outer.Inner.Innerer.* : Innerest + // com.mycompany.Outer.Inner.* : Innerer$Innerest + // com.mycompany.Outer.* : Inner$Innerer$Innerest + // com.mycompany.* : Outer$Inner$Innerer$Innerest + // And at this point we have a match with the class Outer$Inner$Innerer$Innerest in package com.mycompany. + int dotPos = originalName.lastIndexOf('.'); + for (;;) { + String namespace = dotPos != -1 ? originalName.substring(0, dotPos) + ".*" : "*"; + name = originalName.substring(dotPos + 1).replace('.', '$'); + String packageName = determinePackage(name, namespace, compiler); + if (packageName != null) { + assert packageName.endsWith("*"); + if (packageName.equals(namespace) || namespace.equals("*")) { + // check for an alias (like javax.swing.JComboBox actually being jaxx.runtime.swing.JAXXComboBox) + TagHandler handler = registeredTags.get(new QName(namespace, name)); + if (handler != null) { // determine alias by looking at handler + ClassDescriptor alias = ((DefaultObjectHandler) handler).getBeanClass(); + // make sure the same handler is used for both the aliased and non-aliased names, in order to avoid "no CompiledObject has been registered" error + // the line below doesn't bother to handle the case where the aliased class name doesn't have a package, since it's a pretty safe assumption that + // that will never happen + assert alias.getPackageName() != null && alias.getPackageName().length() > 0 : "aliasing with no package name has not been implemented"; + registeredTags.put(new QName(alias.getPackageName() + ".*", alias.getName().substring(alias.getPackageName().length() + 1)), handler); + result = alias.getName(); + break; + } else { // no alias + result = packageName.substring(0, packageName.length() - 1) + name; + break; + } + } + // else we found a class by the same name, but in the wrong package + } + + if (dotPos <= 0) { + break; + } + dotPos = originalName.lastIndexOf('.', dotPos - 1); + } + } + + if (result != null && !result.equals(originalName)) { + result = resolveClassName(result, compiler); // check for aliases against the new name as well + } + + return result; + } + + public static ClassDescriptor resolveClass(String className, JAXXCompiler compiler) { + try { + className = resolveClassName(className, compiler); + if (className == null) { + return null; + } + return ClassDescriptorLoader.getClassDescriptor(className, compiler.getClassLoader()); + } catch (ClassNotFoundException e) { + return null; + } + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ApplicationHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ApplicationHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ApplicationHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,55 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.swing; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.CompiledObject; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.runtime.swing.Application; -import jaxx.compiler.types.TypeManager; -import org.w3c.dom.Element; - -import javax.swing.WindowConstants; - -public class ApplicationHandler extends JWindowHandler { - - public ApplicationHandler(ClassDescriptor beanClass) { - super(beanClass); - ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, Application.class); - } - - @Override - public void setAttribute(CompiledObject object, String propertyName, String stringValue, boolean inline, JAXXCompiler compiler) throws CompilerException { - if (propertyName.equals("lookAndFeel") && stringValue != null && !stringValue.trim().startsWith("{")) { - compiler.appendBodyCode("{ " + object.getJavaCode() + ".setLookAndFeel(" + TypeManager.getJavaCode(stringValue) + "); }" + JAXXCompiler.getLineSeparator()); - } else { - super.setAttribute(object, propertyName, stringValue, inline, compiler); - } - } - - @Override - protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException { - super.setDefaults(object, tag, compiler); - setAttribute(object, "defaultCloseOperation", String.valueOf(WindowConstants.EXIT_ON_CLOSE), false, compiler); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ApplicationHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ApplicationHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ApplicationHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ApplicationHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,55 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.swing; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.CompiledObject; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.runtime.swing.Application; +import jaxx.compiler.types.TypeManager; +import org.w3c.dom.Element; + +import javax.swing.WindowConstants; + +public class ApplicationHandler extends JWindowHandler { + + public ApplicationHandler(ClassDescriptor beanClass) { + super(beanClass); + ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, Application.class); + } + + @Override + public void setAttribute(CompiledObject object, String propertyName, String stringValue, boolean inline, JAXXCompiler compiler) throws CompilerException { + if (propertyName.equals("lookAndFeel") && stringValue != null && !stringValue.trim().startsWith("{")) { + compiler.appendBodyCode("{ " + object.getJavaCode() + ".setLookAndFeel(" + TypeManager.getJavaCode(stringValue) + "); }" + JAXXCompiler.getLineSeparator()); + } else { + super.setAttribute(object, propertyName, stringValue, inline, compiler); + } + } + + @Override + protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException { + super.setDefaults(object, tag, compiler); + setAttribute(object, "defaultCloseOperation", String.valueOf(WindowConstants.EXIT_ON_CLOSE), false, compiler); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CellHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CellHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CellHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,166 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.swing; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.UnsupportedAttributeException; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.tags.TagHandler; -import jaxx.compiler.types.TypeManager; -import org.w3c.dom.Attr; -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.Text; - -import java.awt.GridBagConstraints; -import java.awt.Insets; -import java.io.IOException; - -public class CellHandler 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 { - Node parent = tag.getParentNode(); - if (parent.getNodeType() != Node.ELEMENT_NODE || !parent.getLocalName().equals("row")) { - compiler.reportError("cell tag may only appear within row tag"); - return; - } - - TableHandler.CompiledTable table = (TableHandler.CompiledTable) compiler.getOpenComponent(); - table.newCell(); - GridBagConstraints c = table.getCellConstraints(); - setAttributes(c, tag); - compileChildrenSecondPass(tag, compiler); - } - - public static void setAttribute(GridBagConstraints c, String name, String value) throws CompilerException { - value = value.trim(); - if (name.equals("insets")) { - c.insets = (Insets) TypeManager.convertFromString(value, Insets.class); - } else if (name.equals("weightx")) { - c.weightx = Double.parseDouble(value); - } else if (name.equals("weighty")) { - c.weighty = Double.parseDouble(value); - } else if (name.equals("columns")) { - c.gridwidth = Integer.parseInt(value); - } else if (name.equals("rows")) { - c.gridheight = Integer.parseInt(value); - } else if (name.equals("fill")) { - if (value.equals("none")) { - c.fill = GridBagConstraints.NONE; - } else if (value.equals("horizontal")) { - c.fill = GridBagConstraints.HORIZONTAL; - } else if (value.equals("vertical")) { - c.fill = GridBagConstraints.VERTICAL; - } else if (value.equals("both")) { - c.fill = GridBagConstraints.BOTH; - } else { - throw new IllegalArgumentException("invalid value for fill attribute: '" + value + "'"); - } - } else if (name.equals("anchor")) { - //todo use a converter - if (value.equals("north")) { - c.anchor = GridBagConstraints.NORTH; - } else if (value.equals("northeast")) { - c.anchor = GridBagConstraints.NORTHEAST; - } else if (value.equals("east")) { - c.anchor = GridBagConstraints.EAST; - } else if (value.equals("southeast")) { - c.anchor = GridBagConstraints.SOUTHEAST; - } else if (value.equals("south")) { - c.anchor = GridBagConstraints.SOUTH; - } else if (value.equals("southwest")) { - c.anchor = GridBagConstraints.SOUTHWEST; - } else if (value.equals("west")) { - c.anchor = GridBagConstraints.WEST; - } else if (value.equals("northwest")) { - c.anchor = GridBagConstraints.NORTHWEST; - } else if (value.equals("center")) { - c.anchor = GridBagConstraints.CENTER; - } else { - throw new IllegalArgumentException("invalid value for anchor attribute: '" + value + "'"); - } - } else { - throw new UnsupportedAttributeException(name); - } - } - - public static void setAttributes(GridBagConstraints c, Element tag) throws CompilerException { - NamedNodeMap children = tag.getAttributes(); - for (int i = 0; i < children.getLength(); i++) { - Attr attribute = (Attr) children.item(i); - String name = attribute.getName(); - String value = attribute.getValue(); - if (!name.startsWith("xmlns") && !JAXXCompiler.JAXX_INTERNAL_NAMESPACE.equals(attribute.getNamespaceURI())) { - setAttribute(c, name, value); - } - } - } - - protected void compileChildrenFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - NodeList children = tag.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { - Node node = children.item(i); - int nodeType = node.getNodeType(); - if (nodeType == Node.ELEMENT_NODE) { - Element child = (Element) node; - compileChildTagFirstPass(child, compiler); - } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) { - String text = ((Text) node).getData().trim(); - if (text.length() > 0) { - compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')"); - } - } - } - } - - protected void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - NodeList children = tag.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { - Node node = children.item(i); - int nodeType = node.getNodeType(); - if (nodeType == Node.ELEMENT_NODE) { - Element child = (Element) node; - compileChildTagSecondPass(child, compiler); - } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) { - String text = ((Text) node).getData().trim(); - if (text.length() > 0) { - compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')"); - } - } - } - } - - protected void compileChildTagFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - compiler.compileFirstPass(tag); - } - - protected void compileChildTagSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - compiler.compileSecondPass(tag); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CellHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CellHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CellHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CellHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,166 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.swing; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.UnsupportedAttributeException; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.tags.TagHandler; +import jaxx.compiler.types.TypeManager; +import org.w3c.dom.Attr; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.Text; + +import java.awt.GridBagConstraints; +import java.awt.Insets; +import java.io.IOException; + +public class CellHandler 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 { + Node parent = tag.getParentNode(); + if (parent.getNodeType() != Node.ELEMENT_NODE || !parent.getLocalName().equals("row")) { + compiler.reportError("cell tag may only appear within row tag"); + return; + } + + TableHandler.CompiledTable table = (TableHandler.CompiledTable) compiler.getOpenComponent(); + table.newCell(); + GridBagConstraints c = table.getCellConstraints(); + setAttributes(c, tag); + compileChildrenSecondPass(tag, compiler); + } + + public static void setAttribute(GridBagConstraints c, String name, String value) throws CompilerException { + value = value.trim(); + if (name.equals("insets")) { + c.insets = (Insets) TypeManager.convertFromString(value, Insets.class); + } else if (name.equals("weightx")) { + c.weightx = Double.parseDouble(value); + } else if (name.equals("weighty")) { + c.weighty = Double.parseDouble(value); + } else if (name.equals("columns")) { + c.gridwidth = Integer.parseInt(value); + } else if (name.equals("rows")) { + c.gridheight = Integer.parseInt(value); + } else if (name.equals("fill")) { + if (value.equals("none")) { + c.fill = GridBagConstraints.NONE; + } else if (value.equals("horizontal")) { + c.fill = GridBagConstraints.HORIZONTAL; + } else if (value.equals("vertical")) { + c.fill = GridBagConstraints.VERTICAL; + } else if (value.equals("both")) { + c.fill = GridBagConstraints.BOTH; + } else { + throw new IllegalArgumentException("invalid value for fill attribute: '" + value + "'"); + } + } else if (name.equals("anchor")) { + //todo use a converter + if (value.equals("north")) { + c.anchor = GridBagConstraints.NORTH; + } else if (value.equals("northeast")) { + c.anchor = GridBagConstraints.NORTHEAST; + } else if (value.equals("east")) { + c.anchor = GridBagConstraints.EAST; + } else if (value.equals("southeast")) { + c.anchor = GridBagConstraints.SOUTHEAST; + } else if (value.equals("south")) { + c.anchor = GridBagConstraints.SOUTH; + } else if (value.equals("southwest")) { + c.anchor = GridBagConstraints.SOUTHWEST; + } else if (value.equals("west")) { + c.anchor = GridBagConstraints.WEST; + } else if (value.equals("northwest")) { + c.anchor = GridBagConstraints.NORTHWEST; + } else if (value.equals("center")) { + c.anchor = GridBagConstraints.CENTER; + } else { + throw new IllegalArgumentException("invalid value for anchor attribute: '" + value + "'"); + } + } else { + throw new UnsupportedAttributeException(name); + } + } + + public static void setAttributes(GridBagConstraints c, Element tag) throws CompilerException { + NamedNodeMap children = tag.getAttributes(); + for (int i = 0; i < children.getLength(); i++) { + Attr attribute = (Attr) children.item(i); + String name = attribute.getName(); + String value = attribute.getValue(); + if (!name.startsWith("xmlns") && !JAXXCompiler.JAXX_INTERNAL_NAMESPACE.equals(attribute.getNamespaceURI())) { + setAttribute(c, name, value); + } + } + } + + protected void compileChildrenFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + NodeList children = tag.getChildNodes(); + for (int i = 0; i < children.getLength(); i++) { + Node node = children.item(i); + int nodeType = node.getNodeType(); + if (nodeType == Node.ELEMENT_NODE) { + Element child = (Element) node; + compileChildTagFirstPass(child, compiler); + } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) { + String text = ((Text) node).getData().trim(); + if (text.length() > 0) { + compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')"); + } + } + } + } + + protected void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + NodeList children = tag.getChildNodes(); + for (int i = 0; i < children.getLength(); i++) { + Node node = children.item(i); + int nodeType = node.getNodeType(); + if (nodeType == Node.ELEMENT_NODE) { + Element child = (Element) node; + compileChildTagSecondPass(child, compiler); + } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) { + String text = ((Text) node).getData().trim(); + if (text.length() > 0) { + compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')"); + } + } + } + } + + protected void compileChildTagFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + compiler.compileFirstPass(tag); + } + + protected void compileChildTagSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + compiler.compileSecondPass(tag); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CompiledItemContainer.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CompiledItemContainer.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CompiledItemContainer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,66 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.swing; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.CompiledObject; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.runtime.swing.Item; - -import java.util.ArrayList; -import java.util.List; -import java.util.Stack; - -/** Compiled representation of a class that contains Items arranged in a list or tree structure (JComboBox, JList, JTree). */ -class CompiledItemContainer extends CompiledObject { - - private List<Item> items = new ArrayList<Item>(); - private Stack<Item> openNodes = new Stack<Item>(); - - public CompiledItemContainer(String id, ClassDescriptor objectClass, JAXXCompiler compiler) throws CompilerException { - super(id, objectClass, compiler); - } - - public void openItem(Item item) { - if (openNodes.isEmpty()) { - items.add(item); - } else { - Item openNode = openNodes.peek(); - openNode.addChild(item); - } - openNodes.add(item); - } - - public void closeItem(Item item) { - if (openNodes.pop() != item) { - throw new IllegalArgumentException(item + " was not at the top of the item stack"); - } - } - - public List<Item> getItems() { - return items; - } - - public void setItems(List<Item> items) { - this.items = items; - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CompiledItemContainer.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CompiledItemContainer.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CompiledItemContainer.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CompiledItemContainer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,66 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.swing; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.CompiledObject; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.runtime.swing.Item; + +import java.util.ArrayList; +import java.util.List; +import java.util.Stack; + +/** Compiled representation of a class that contains Items arranged in a list or tree structure (JComboBox, JList, JTree). */ +class CompiledItemContainer extends CompiledObject { + + private List<Item> items = new ArrayList<Item>(); + private Stack<Item> openNodes = new Stack<Item>(); + + public CompiledItemContainer(String id, ClassDescriptor objectClass, JAXXCompiler compiler) throws CompilerException { + super(id, objectClass, compiler); + } + + public void openItem(Item item) { + if (openNodes.isEmpty()) { + items.add(item); + } else { + Item openNode = openNodes.peek(); + openNode.addChild(item); + } + openNodes.add(item); + } + + public void closeItem(Item item) { + if (openNodes.pop() != item) { + throw new IllegalArgumentException(item + " was not at the top of the item stack"); + } + } + + public List<Item> getItems() { + return items; + } + + public void setItems(List<Item> items) { + this.items = items; + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ItemHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ItemHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ItemHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,168 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.swing; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.UnsupportedAttributeException; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.binding.DataBindingHelper; -import jaxx.compiler.tags.TagHandler; -import jaxx.compiler.types.TypeManager; -import jaxx.runtime.swing.Item; -import org.w3c.dom.Attr; -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.Text; - -import java.io.IOException; -import java.util.List; - -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) { - id = compiler.getAutoId(Item.class.getSimpleName()); -// id = compiler.getAutoId(ClassDescriptorLoader.getClassDescriptor(Item.class)); - } - String label = null; - String value = null; - boolean selected = false; - NamedNodeMap children = tag.getAttributes(); - - for (int i = 0; i < children.getLength(); i++) { - Attr attribute = (Attr) children.item(i); - String name = attribute.getName(); - String attrValue = attribute.getValue(); - if (name.equals("id")) { - // already handled - continue; - } - DataBindingHelper bindingHelper = compiler.getBindingHelper(); - if (name.equals(Item.LABEL_PROPERTY)) { - String labelBinding = DataBindingHelper.processDataBindings(attrValue); - if (labelBinding != null) { - bindingHelper.registerDataBinding(id + ".label", labelBinding, id + ".setLabel(" + labelBinding + ");"); -// bindingHelper.registerDataBinding(labelBinding, id + ".label", id + ".setLabel(" + labelBinding + ");"); - } else { - label = attrValue; - } - continue; - } - if (name.equals(Item.VALUE_PROPERTY)) { - String valueBinding = DataBindingHelper.processDataBindings(attrValue); - if (valueBinding != null) { - value = DATA_BINDING; - bindingHelper.registerDataBinding(id + ".value", valueBinding, id + ".setValue(" + valueBinding + ");"); -// bindingHelper.registerDataBinding(valueBinding, id + ".value", id + ".setValue(" + valueBinding + ");"); - } else { - value = attrValue; - } - continue; - } - if (name.equals(Item.SELECTED_PROPERTY)) { - String selectedBinding = DataBindingHelper.processDataBindings(attrValue); - if (selectedBinding != null) { - bindingHelper.registerDataBinding(id + ".selected", selectedBinding, id + ".setSelected(" + selectedBinding + ");"); -// bindingHelper.registerDataBinding(selectedBinding, id + ".selected", id + ".setSelected(" + selectedBinding + ");"); - } else { - selected = (Boolean) TypeManager.convertFromString(attrValue, Boolean.class); - } - continue; - } - - if (!name.startsWith("xmlns") && !JAXXCompiler.JAXX_INTERNAL_NAMESPACE.equals(attribute.getNamespaceURI())) { - throw new UnsupportedAttributeException(name); - } - } - - Item item = new Item(id, label, value, selected); - CompiledItemContainer list = (CompiledItemContainer) compiler.getOpenComponent(); - if (value == null) { - compiler.reportError("<item> tag is missing required 'value' attribute"); - } else { - if (!value.equals(DATA_BINDING)) { - List<Item> items = list.getItems(); - for (Item item1 : items) { - if (item1.getValue().equals(value)) { - compiler.reportError("This container already has an <item> tag with the value '" + value + "'"); - break; - } - } - } - list.openItem(item); - compileChildrenSecondPass(tag, compiler); - list.closeItem(item); - } - } - - protected void compileChildrenFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - NodeList children = tag.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { - Node node = children.item(i); - int nodeType = node.getNodeType(); - if (nodeType == Node.ELEMENT_NODE) { - Element child = (Element) node; - compileChildTagFirstPass(child, compiler); - } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) { - String text = ((Text) node).getData().trim(); - if (text.length() > 0) { - compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')"); - } - } - } - } - - protected void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - NodeList children = tag.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { - Node node = children.item(i); - int nodeType = node.getNodeType(); - if (nodeType == Node.ELEMENT_NODE) { - Element child = (Element) node; - compileChildTagSecondPass(child, compiler); - } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) { - String text = ((Text) node).getData().trim(); - if (text.length() > 0) { - compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')"); - } - } - } - } - - protected void compileChildTagFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - compiler.compileFirstPass(tag); - } - - protected void compileChildTagSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - compiler.compileSecondPass(tag); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ItemHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ItemHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ItemHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ItemHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,168 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.swing; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.UnsupportedAttributeException; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.binding.DataBindingHelper; +import jaxx.compiler.tags.TagHandler; +import jaxx.compiler.types.TypeManager; +import jaxx.runtime.swing.Item; +import org.w3c.dom.Attr; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.Text; + +import java.io.IOException; +import java.util.List; + +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) { + id = compiler.getAutoId(Item.class.getSimpleName()); +// id = compiler.getAutoId(ClassDescriptorLoader.getClassDescriptor(Item.class)); + } + String label = null; + String value = null; + boolean selected = false; + NamedNodeMap children = tag.getAttributes(); + + for (int i = 0; i < children.getLength(); i++) { + Attr attribute = (Attr) children.item(i); + String name = attribute.getName(); + String attrValue = attribute.getValue(); + if (name.equals("id")) { + // already handled + continue; + } + DataBindingHelper bindingHelper = compiler.getBindingHelper(); + if (name.equals(Item.LABEL_PROPERTY)) { + String labelBinding = DataBindingHelper.processDataBindings(attrValue); + if (labelBinding != null) { + bindingHelper.registerDataBinding(id + ".label", labelBinding, id + ".setLabel(" + labelBinding + ");"); +// bindingHelper.registerDataBinding(labelBinding, id + ".label", id + ".setLabel(" + labelBinding + ");"); + } else { + label = attrValue; + } + continue; + } + if (name.equals(Item.VALUE_PROPERTY)) { + String valueBinding = DataBindingHelper.processDataBindings(attrValue); + if (valueBinding != null) { + value = DATA_BINDING; + bindingHelper.registerDataBinding(id + ".value", valueBinding, id + ".setValue(" + valueBinding + ");"); +// bindingHelper.registerDataBinding(valueBinding, id + ".value", id + ".setValue(" + valueBinding + ");"); + } else { + value = attrValue; + } + continue; + } + if (name.equals(Item.SELECTED_PROPERTY)) { + String selectedBinding = DataBindingHelper.processDataBindings(attrValue); + if (selectedBinding != null) { + bindingHelper.registerDataBinding(id + ".selected", selectedBinding, id + ".setSelected(" + selectedBinding + ");"); +// bindingHelper.registerDataBinding(selectedBinding, id + ".selected", id + ".setSelected(" + selectedBinding + ");"); + } else { + selected = (Boolean) TypeManager.convertFromString(attrValue, Boolean.class); + } + continue; + } + + if (!name.startsWith("xmlns") && !JAXXCompiler.JAXX_INTERNAL_NAMESPACE.equals(attribute.getNamespaceURI())) { + throw new UnsupportedAttributeException(name); + } + } + + Item item = new Item(id, label, value, selected); + CompiledItemContainer list = (CompiledItemContainer) compiler.getOpenComponent(); + if (value == null) { + compiler.reportError("<item> tag is missing required 'value' attribute"); + } else { + if (!value.equals(DATA_BINDING)) { + List<Item> items = list.getItems(); + for (Item item1 : items) { + if (item1.getValue().equals(value)) { + compiler.reportError("This container already has an <item> tag with the value '" + value + "'"); + break; + } + } + } + list.openItem(item); + compileChildrenSecondPass(tag, compiler); + list.closeItem(item); + } + } + + protected void compileChildrenFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + NodeList children = tag.getChildNodes(); + for (int i = 0; i < children.getLength(); i++) { + Node node = children.item(i); + int nodeType = node.getNodeType(); + if (nodeType == Node.ELEMENT_NODE) { + Element child = (Element) node; + compileChildTagFirstPass(child, compiler); + } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) { + String text = ((Text) node).getData().trim(); + if (text.length() > 0) { + compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')"); + } + } + } + } + + protected void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + NodeList children = tag.getChildNodes(); + for (int i = 0; i < children.getLength(); i++) { + Node node = children.item(i); + int nodeType = node.getNodeType(); + if (nodeType == Node.ELEMENT_NODE) { + Element child = (Element) node; + compileChildTagSecondPass(child, compiler); + } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) { + String text = ((Text) node).getData().trim(); + if (text.length() > 0) { + compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')"); + } + } + } + } + + protected void compileChildTagFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + compiler.compileFirstPass(tag); + } + + protected void compileChildTagSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + compiler.compileSecondPass(tag); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXComboBoxHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXComboBoxHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXComboBoxHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,78 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.swing; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.CompiledObject; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.tags.DefaultComponentHandler; -import jaxx.compiler.types.TypeManager; -import jaxx.runtime.swing.JAXXComboBox; -import jaxx.runtime.swing.Item; -import org.w3c.dom.Element; - -import java.awt.event.ItemListener; -import java.io.IOException; -import java.util.List; - -public class JAXXComboBoxHandler extends DefaultComponentHandler { - - public JAXXComboBoxHandler(ClassDescriptor beanClass) { - super(beanClass); - ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JAXXComboBox.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 + ");"); - } - } -} - - - Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXComboBoxHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXComboBoxHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXComboBoxHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXComboBoxHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,78 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.swing; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.CompiledObject; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.tags.DefaultComponentHandler; +import jaxx.compiler.types.TypeManager; +import jaxx.runtime.swing.JAXXComboBox; +import jaxx.runtime.swing.Item; +import org.w3c.dom.Element; + +import java.awt.event.ItemListener; +import java.io.IOException; +import java.util.List; + +public class JAXXComboBoxHandler extends DefaultComponentHandler { + + public JAXXComboBoxHandler(ClassDescriptor beanClass) { + super(beanClass); + ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JAXXComboBox.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 + ");"); + } + } +} + + + Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXListHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXListHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXListHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,81 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.swing; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.CompiledObject; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.tags.DefaultComponentHandler; -import jaxx.compiler.types.TypeManager; -import jaxx.runtime.swing.JAXXList; -import jaxx.runtime.swing.Item; -import org.w3c.dom.Element; - -import javax.swing.event.ListSelectionListener; -import java.io.IOException; -import java.util.List; - -public class JAXXListHandler extends DefaultComponentHandler { - - public JAXXListHandler(ClassDescriptor beanClass) { - super(beanClass); - ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JAXXList.class); - } - - @Override - protected void configureProxyEventInfo() { - super.configureProxyEventInfo(); - addProxyEventInfo("getSelectedIndex", ListSelectionListener.class, "selectionModel"); - addProxyEventInfo("getSelectedIndices", ListSelectionListener.class, "selectionModel"); - addProxyEventInfo("getSelectedValue", ListSelectionListener.class, "selectionModel"); - addProxyEventInfo("getSelectedValues", ListSelectionListener.class, "selectionModel"); - } - - @Override - public 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"; - //TODO Add the correct generic type - 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 + ");"); - } - } -} - - - Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXListHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXListHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXListHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXListHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,81 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.swing; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.CompiledObject; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.tags.DefaultComponentHandler; +import jaxx.compiler.types.TypeManager; +import jaxx.runtime.swing.JAXXList; +import jaxx.runtime.swing.Item; +import org.w3c.dom.Element; + +import javax.swing.event.ListSelectionListener; +import java.io.IOException; +import java.util.List; + +public class JAXXListHandler extends DefaultComponentHandler { + + public JAXXListHandler(ClassDescriptor beanClass) { + super(beanClass); + ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JAXXList.class); + } + + @Override + protected void configureProxyEventInfo() { + super.configureProxyEventInfo(); + addProxyEventInfo("getSelectedIndex", ListSelectionListener.class, "selectionModel"); + addProxyEventInfo("getSelectedIndices", ListSelectionListener.class, "selectionModel"); + addProxyEventInfo("getSelectedValue", ListSelectionListener.class, "selectionModel"); + addProxyEventInfo("getSelectedValues", ListSelectionListener.class, "selectionModel"); + } + + @Override + public 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"; + //TODO Add the correct generic type + 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 + ");"); + } + } +} + + + Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTabHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTabHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTabHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,31 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.swing; - -import jaxx.compiler.reflect.ClassDescriptor; - -/** @author chemit */ -public class JAXXTabHandler extends TableHandler { - - public JAXXTabHandler(ClassDescriptor beanClass) { - super(beanClass); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTabHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTabHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTabHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTabHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,31 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.swing; + +import jaxx.compiler.reflect.ClassDescriptor; + +/** @author chemit */ +public class JAXXTabHandler extends TableHandler { + + public JAXXTabHandler(ClassDescriptor beanClass) { + super(beanClass); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTreeHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTreeHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTreeHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,86 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.swing; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.CompiledObject; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.tags.DefaultComponentHandler; -import jaxx.compiler.types.TypeManager; -import jaxx.runtime.swing.Item; -import jaxx.runtime.swing.JAXXTree; -import org.w3c.dom.Element; - -import javax.swing.event.TreeSelectionListener; -import java.io.IOException; -import java.util.List; - -public class JAXXTreeHandler extends DefaultComponentHandler { - - public JAXXTreeHandler(ClassDescriptor beanClass) { - super(beanClass); - ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JAXXTree.class); - } - - @Override - protected void configureProxyEventInfo() { - super.configureProxyEventInfo(); - addProxyEventInfo("getSelectionCount", TreeSelectionListener.class, "selectionModel"); - addProxyEventInfo("getSelectionPath", TreeSelectionListener.class, "selectionModel"); - addProxyEventInfo("getSelectionPaths", TreeSelectionListener.class, "selectionModel"); - addProxyEventInfo("getSelectionRows", TreeSelectionListener.class, "selectionModel"); - addProxyEventInfo("getSelectionValue", TreeSelectionListener.class, "selectionModel"); - } - - @Override - public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException { - return new CompiledItemContainer(id, getBeanClass(), compiler); - } - - private void createItems(CompiledObject tree, List<Item> items, String addMethod, JAXXCompiler compiler) throws CompilerException { - 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); - tree.appendAdditionCode(addMethod + "(" + id + ");"); - createItems(tree, item.getChildren(), id + ".addChild", compiler); - } - } - - @Override - public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - super.compileChildrenSecondPass(tag, compiler); - CompiledItemContainer tree = (CompiledItemContainer) compiler.getOpenComponent(); - List<Item> items = tree.getItems(); - if (items != null && !items.isEmpty()) { - String listName = tree.getId() + "$items"; - tree.appendAdditionCode("java.util.List<jaxx.runtime.swing.Item> " + listName + " = new java.util.ArrayList<jaxx.runtime.swing.Item>();"); - createItems(tree, items, listName + ".add", compiler); - tree.appendAdditionCode(tree.getId() + ".setItems(" + listName + ");"); - } - } -} - - - Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTreeHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTreeHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTreeHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTreeHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,86 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.swing; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.CompiledObject; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.tags.DefaultComponentHandler; +import jaxx.compiler.types.TypeManager; +import jaxx.runtime.swing.Item; +import jaxx.runtime.swing.JAXXTree; +import org.w3c.dom.Element; + +import javax.swing.event.TreeSelectionListener; +import java.io.IOException; +import java.util.List; + +public class JAXXTreeHandler extends DefaultComponentHandler { + + public JAXXTreeHandler(ClassDescriptor beanClass) { + super(beanClass); + ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JAXXTree.class); + } + + @Override + protected void configureProxyEventInfo() { + super.configureProxyEventInfo(); + addProxyEventInfo("getSelectionCount", TreeSelectionListener.class, "selectionModel"); + addProxyEventInfo("getSelectionPath", TreeSelectionListener.class, "selectionModel"); + addProxyEventInfo("getSelectionPaths", TreeSelectionListener.class, "selectionModel"); + addProxyEventInfo("getSelectionRows", TreeSelectionListener.class, "selectionModel"); + addProxyEventInfo("getSelectionValue", TreeSelectionListener.class, "selectionModel"); + } + + @Override + public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException { + return new CompiledItemContainer(id, getBeanClass(), compiler); + } + + private void createItems(CompiledObject tree, List<Item> items, String addMethod, JAXXCompiler compiler) throws CompilerException { + 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); + tree.appendAdditionCode(addMethod + "(" + id + ");"); + createItems(tree, item.getChildren(), id + ".addChild", compiler); + } + } + + @Override + public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + super.compileChildrenSecondPass(tag, compiler); + CompiledItemContainer tree = (CompiledItemContainer) compiler.getOpenComponent(); + List<Item> items = tree.getItems(); + if (items != null && !items.isEmpty()) { + String listName = tree.getId() + "$items"; + tree.appendAdditionCode("java.util.List<jaxx.runtime.swing.Item> " + listName + " = new java.util.ArrayList<jaxx.runtime.swing.Item>();"); + createItems(tree, items, listName + ".add", compiler); + tree.appendAdditionCode(tree.getId() + ".setItems(" + listName + ");"); + } + } +} + + + Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JCheckBoxHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JCheckBoxHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JCheckBoxHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,42 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.swing; - -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.tags.DefaultComponentHandler; - -import javax.swing.AbstractButton; -import javax.swing.event.ChangeListener; - -public class JCheckBoxHandler extends DefaultComponentHandler { - - public JCheckBoxHandler(ClassDescriptor beanClass) { - super(beanClass); - ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, AbstractButton.class); - } - - @Override - protected void configureProxyEventInfo() { - super.configureProxyEventInfo(); - addProxyEventInfo("isSelected", ChangeListener.class, "model"); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JCheckBoxHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JCheckBoxHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JCheckBoxHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JCheckBoxHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,42 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.swing; + +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.tags.DefaultComponentHandler; + +import javax.swing.AbstractButton; +import javax.swing.event.ChangeListener; + +public class JCheckBoxHandler extends DefaultComponentHandler { + + public JCheckBoxHandler(ClassDescriptor beanClass) { + super(beanClass); + ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, AbstractButton.class); + } + + @Override + protected void configureProxyEventInfo() { + super.configureProxyEventInfo(); + addProxyEventInfo("isSelected", ChangeListener.class, "model"); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JComboBoxHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JComboBoxHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JComboBoxHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,60 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.swing; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.tags.DefaultComponentHandler; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; - -import java.io.IOException; -import java.awt.event.ItemListener; -import javax.swing.JComboBox; - -public class JComboBoxHandler extends DefaultComponentHandler { - - public JComboBoxHandler(ClassDescriptor beanClass) { - super(beanClass); - ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JComboBox.class); - } - - @Override - protected void configureProxyEventInfo() { - super.configureProxyEventInfo(); - addProxyEventInfo("getSelectedIndex", ItemListener.class); - addProxyEventInfo("getSelectedItem", ItemListener.class); - } - - @Override - public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - NodeList children = tag.getChildNodes(); - if (children.getLength() > 0) { - compiler.reportError("JComboBox does not accept childs"); - throw new CompilerException("JComboBox does not accept childs"); - } - } -} - - - Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JComboBoxHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JComboBoxHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JComboBoxHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JComboBoxHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,60 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.swing; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.tags.DefaultComponentHandler; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + +import java.io.IOException; +import java.awt.event.ItemListener; +import javax.swing.JComboBox; + +public class JComboBoxHandler extends DefaultComponentHandler { + + public JComboBoxHandler(ClassDescriptor beanClass) { + super(beanClass); + ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JComboBox.class); + } + + @Override + protected void configureProxyEventInfo() { + super.configureProxyEventInfo(); + addProxyEventInfo("getSelectedIndex", ItemListener.class); + addProxyEventInfo("getSelectedItem", ItemListener.class); + } + + @Override + public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + NodeList children = tag.getChildNodes(); + if (children.getLength() > 0) { + compiler.reportError("JComboBox does not accept childs"); + throw new CompilerException("JComboBox does not accept childs"); + } + } +} + + + Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JInternalFrameHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JInternalFrameHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JInternalFrameHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,70 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.swing; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.CompiledObject; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.tags.DefaultComponentHandler; -import org.w3c.dom.Element; - -import javax.swing.JInternalFrame; -import javax.swing.JMenuBar; -import javax.swing.WindowConstants; - -public class JInternalFrameHandler extends DefaultComponentHandler { - - public JInternalFrameHandler(ClassDescriptor beanClass) { - super(beanClass); - ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JInternalFrame.class); - } - - @Override - public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException { - return new CompiledObject(id, getBeanClass(), compiler) { - - @Override - public void addChild(CompiledObject child, String constraints, JAXXCompiler compiler) throws CompilerException { - if (ClassDescriptorLoader.getClassDescriptor(JMenuBar.class).isAssignableFrom(child.getObjectClass())) { - appendAdditionCode(getId() + ".setJMenuBar(" + child.getId() + ");"); - } else { - super.addChild(child, constraints, compiler); - } - } - }; - } - - @Override - protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException { - super.setDefaults(object, tag, compiler); - setAttribute(object, "visible", "true", false, compiler); - setAttribute(object, "closable", "true", false, compiler); - setAttribute(object, "defaultCloseOperation", String.valueOf(WindowConstants.DISPOSE_ON_CLOSE), false, compiler); - } - - @Override - public void setAttributes(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException { - super.setAttributes(object, tag, compiler); - compiler.appendInitializerCode(object.getId() + ".pack();\n"); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JInternalFrameHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JInternalFrameHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JInternalFrameHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JInternalFrameHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,70 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.swing; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.CompiledObject; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.tags.DefaultComponentHandler; +import org.w3c.dom.Element; + +import javax.swing.JInternalFrame; +import javax.swing.JMenuBar; +import javax.swing.WindowConstants; + +public class JInternalFrameHandler extends DefaultComponentHandler { + + public JInternalFrameHandler(ClassDescriptor beanClass) { + super(beanClass); + ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JInternalFrame.class); + } + + @Override + public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException { + return new CompiledObject(id, getBeanClass(), compiler) { + + @Override + public void addChild(CompiledObject child, String constraints, JAXXCompiler compiler) throws CompilerException { + if (ClassDescriptorLoader.getClassDescriptor(JMenuBar.class).isAssignableFrom(child.getObjectClass())) { + appendAdditionCode(getId() + ".setJMenuBar(" + child.getId() + ");"); + } else { + super.addChild(child, constraints, compiler); + } + } + }; + } + + @Override + protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException { + super.setDefaults(object, tag, compiler); + setAttribute(object, "visible", "true", false, compiler); + setAttribute(object, "closable", "true", false, compiler); + setAttribute(object, "defaultCloseOperation", String.valueOf(WindowConstants.DISPOSE_ON_CLOSE), false, compiler); + } + + @Override + public void setAttributes(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException { + super.setAttributes(object, tag, compiler); + compiler.appendInitializerCode(object.getId() + ".pack();\n"); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JListHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JListHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JListHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,62 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.swing; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.tags.DefaultComponentHandler; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; - -import java.io.IOException; -import javax.swing.event.ListSelectionListener; -import javax.swing.JList; - -public class JListHandler extends DefaultComponentHandler { - - public JListHandler(ClassDescriptor beanClass) { - super(beanClass); - ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JList.class); - } - - @Override - protected void configureProxyEventInfo() { - super.configureProxyEventInfo(); - addProxyEventInfo("getSelectedIndex", ListSelectionListener.class, "selectionModel"); - addProxyEventInfo("getSelectedIndices", ListSelectionListener.class, "selectionModel"); - addProxyEventInfo("getSelectedValue", ListSelectionListener.class, "selectionModel"); - addProxyEventInfo("getSelectedValues", ListSelectionListener.class, "selectionModel"); - } - - @Override - public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - NodeList children = tag.getChildNodes(); - if (children.getLength() > 0) { - compiler.reportError("JList does not accept childs"); - throw new CompilerException("JList does not accept childs"); - } - } -} - - - Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JListHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JListHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JListHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JListHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,62 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.swing; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.tags.DefaultComponentHandler; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + +import java.io.IOException; +import javax.swing.event.ListSelectionListener; +import javax.swing.JList; + +public class JListHandler extends DefaultComponentHandler { + + public JListHandler(ClassDescriptor beanClass) { + super(beanClass); + ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JList.class); + } + + @Override + protected void configureProxyEventInfo() { + super.configureProxyEventInfo(); + addProxyEventInfo("getSelectedIndex", ListSelectionListener.class, "selectionModel"); + addProxyEventInfo("getSelectedIndices", ListSelectionListener.class, "selectionModel"); + addProxyEventInfo("getSelectedValue", ListSelectionListener.class, "selectionModel"); + addProxyEventInfo("getSelectedValues", ListSelectionListener.class, "selectionModel"); + } + + @Override + public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + NodeList children = tag.getChildNodes(); + if (children.getLength() > 0) { + compiler.reportError("JList does not accept childs"); + throw new CompilerException("JList does not accept childs"); + } + } +} + + + Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JMenuHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JMenuHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JMenuHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,42 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.swing; - -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.tags.DefaultComponentHandler; - -import javax.swing.JMenu; -import javax.swing.event.MenuListener; - -public class JMenuHandler extends DefaultComponentHandler { - - public JMenuHandler(ClassDescriptor beanClass) { - super(beanClass); - ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JMenu.class); - } - - @Override - protected void configureProxyEventInfo() { - super.configureProxyEventInfo(); - addProxyEventInfo("isSelected", MenuListener.class); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JMenuHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JMenuHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JMenuHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JMenuHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,42 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.swing; + +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.tags.DefaultComponentHandler; + +import javax.swing.JMenu; +import javax.swing.event.MenuListener; + +public class JMenuHandler extends DefaultComponentHandler { + + public JMenuHandler(ClassDescriptor beanClass) { + super(beanClass); + ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JMenu.class); + } + + @Override + protected void configureProxyEventInfo() { + super.configureProxyEventInfo(); + addProxyEventInfo("isSelected", MenuListener.class); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPasswordFieldHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPasswordFieldHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPasswordFieldHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,41 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.swing; - -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; - -import javax.swing.JPasswordField; -import javax.swing.event.DocumentListener; - -public class JPasswordFieldHandler extends JTextComponentHandler { - - public JPasswordFieldHandler(ClassDescriptor beanClass) { - super(beanClass); - ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JPasswordField.class); - } - - @Override - protected void configureProxyEventInfo() { - super.configureProxyEventInfo(); - addProxyEventInfo("getPassword", DocumentListener.class, "document"); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPasswordFieldHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPasswordFieldHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPasswordFieldHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPasswordFieldHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,41 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.swing; + +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; + +import javax.swing.JPasswordField; +import javax.swing.event.DocumentListener; + +public class JPasswordFieldHandler extends JTextComponentHandler { + + public JPasswordFieldHandler(ClassDescriptor beanClass) { + super(beanClass); + ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JPasswordField.class); + } + + @Override + protected void configureProxyEventInfo() { + super.configureProxyEventInfo(); + addProxyEventInfo("getPassword", DocumentListener.class, "document"); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPopupMenuHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPopupMenuHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPopupMenuHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,48 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.swing; - -import jaxx.compiler.CompiledObject; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.tags.DefaultComponentHandler; -import org.w3c.dom.Element; - -import javax.swing.JPopupMenu; - -public class JPopupMenuHandler extends DefaultComponentHandler { - - public JPopupMenuHandler(ClassDescriptor beanClass) { - super(beanClass); - ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JPopupMenu.class); - } - - @Override - public boolean isContainer() { - return true; - } - - @Override - protected void openComponent(CompiledObject object, Element tag, JAXXCompiler compiler) { - compiler.openInvisibleComponent(object); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPopupMenuHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPopupMenuHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPopupMenuHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPopupMenuHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,48 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.swing; + +import jaxx.compiler.CompiledObject; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.tags.DefaultComponentHandler; +import org.w3c.dom.Element; + +import javax.swing.JPopupMenu; + +public class JPopupMenuHandler extends DefaultComponentHandler { + + public JPopupMenuHandler(ClassDescriptor beanClass) { + super(beanClass); + ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JPopupMenu.class); + } + + @Override + public boolean isContainer() { + return true; + } + + @Override + protected void openComponent(CompiledObject object, Element tag, JAXXCompiler compiler) { + compiler.openInvisibleComponent(object); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JProgressBarHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JProgressBarHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JProgressBarHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,42 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.swing; - -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.tags.DefaultComponentHandler; - -import javax.swing.JProgressBar; -import javax.swing.event.ChangeListener; - -public class JProgressBarHandler extends DefaultComponentHandler { - - public JProgressBarHandler(ClassDescriptor beanClass) { - super(beanClass); - ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JProgressBar.class); - } - - @Override - protected void configureProxyEventInfo() { - super.configureProxyEventInfo(); - addProxyEventInfo("getValue", ChangeListener.class, "change"); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JProgressBarHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JProgressBarHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JProgressBarHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JProgressBarHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,42 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.swing; + +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.tags.DefaultComponentHandler; + +import javax.swing.JProgressBar; +import javax.swing.event.ChangeListener; + +public class JProgressBarHandler extends DefaultComponentHandler { + + public JProgressBarHandler(ClassDescriptor beanClass) { + super(beanClass); + ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JProgressBar.class); + } + + @Override + protected void configureProxyEventInfo() { + super.configureProxyEventInfo(); + addProxyEventInfo("getValue", ChangeListener.class, "change"); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JRadioButtonHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JRadioButtonHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JRadioButtonHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,97 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.swing; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.UnsupportedAttributeException; -import jaxx.compiler.CompiledObject; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.tags.DefaultComponentHandler; -import jaxx.compiler.types.TypeManager; -import jaxx.runtime.swing.JAXXButtonGroup; - -import javax.swing.AbstractButton; -import javax.swing.event.ChangeListener; - -public class JRadioButtonHandler extends DefaultComponentHandler { - - private static final String VALUE_PROPERTY = JAXXButtonGroup.VALUE_CLIENT_PROPERTY.substring(1); - private static final String BUTTON_GROUP_PROPERTY = JAXXButtonGroup.BUTTON8GROUP_CLIENT_PROPERTY.substring(1); - - public JRadioButtonHandler(ClassDescriptor beanClass) { - super(beanClass); - ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, AbstractButton.class); - } - - @Override - protected void configureProxyEventInfo() { - super.configureProxyEventInfo(); - addProxyEventInfo("isSelected", ChangeListener.class, "model"); - } - - @Override - public ClassDescriptor getPropertyType(CompiledObject object, String name, JAXXCompiler compiler) throws CompilerException { - if (name.equals(BUTTON_GROUP_PROPERTY)) { - return null; // accepts either a String or a ButtonGroup - } else if (name.equals(VALUE_PROPERTY)) { - return ClassDescriptorLoader.getClassDescriptor(Object.class); - } else { - return super.getPropertyType(object, name, compiler); - } - } - - @Override - public boolean isMemberBound(String name) throws UnsupportedAttributeException { - return !(name.equals(BUTTON_GROUP_PROPERTY) || name.equals(VALUE_PROPERTY)) && super.isMemberBound(name); - } - - // handle buttonGroup assignment in addition block rather than initialization block - @Override - public void setProperty(CompiledObject object, String name, Object value, JAXXCompiler compiler) { - if (name.equals(BUTTON_GROUP_PROPERTY)) { - object.appendAdditionCode(getSetPropertyCode(object.getJavaCode(), name, TypeManager.getJavaCode(value), compiler)); - } else { - super.setProperty(object, name, value, compiler); - } - } - - @Override - public String getSetPropertyCode(String id, String name, String valueCode, JAXXCompiler compiler) throws CompilerException { - if (name.equals(BUTTON_GROUP_PROPERTY)) { - if (valueCode.startsWith("\"") && valueCode.endsWith("\"")) { - valueCode = valueCode.substring(1, valueCode.length() - 1); - CompiledObject buttonGroup = compiler.getCompiledObject(valueCode); - if (buttonGroup == null) { - buttonGroup = new CompiledObject(valueCode, ClassDescriptorLoader.getClassDescriptor(JAXXButtonGroup.class), compiler); - compiler.registerCompiledObject(buttonGroup); - } - } - return "{ javax.swing.ButtonGroup $buttonGroup = " + valueCode + "; " + id + ".putClientProperty(\"$buttonGroup\", $buttonGroup); $buttonGroup.add(" + id + "); }\n"; - } else if (name.equals(VALUE_PROPERTY)) { - return "{ " + id + ".putClientProperty(\"" + JAXXButtonGroup.VALUE_CLIENT_PROPERTY + "\", " + valueCode + "); Object $buttonGroup = " + id + ".getClientProperty(\"" + JAXXButtonGroup.BUTTON8GROUP_CLIENT_PROPERTY + "\");" + - " if ($buttonGroup instanceof jaxx.runtime.swing.JAXXButtonGroup) { ((jaxx.runtime.swing.JAXXButtonGroup) $buttonGroup).updateSelectedValue(); } }\n"; - } else { - return super.getSetPropertyCode(id, name, valueCode, compiler); - } - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JRadioButtonHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JRadioButtonHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JRadioButtonHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JRadioButtonHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,97 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.swing; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.UnsupportedAttributeException; +import jaxx.compiler.CompiledObject; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.tags.DefaultComponentHandler; +import jaxx.compiler.types.TypeManager; +import jaxx.runtime.swing.JAXXButtonGroup; + +import javax.swing.AbstractButton; +import javax.swing.event.ChangeListener; + +public class JRadioButtonHandler extends DefaultComponentHandler { + + private static final String VALUE_PROPERTY = JAXXButtonGroup.VALUE_CLIENT_PROPERTY.substring(1); + private static final String BUTTON_GROUP_PROPERTY = JAXXButtonGroup.BUTTON8GROUP_CLIENT_PROPERTY.substring(1); + + public JRadioButtonHandler(ClassDescriptor beanClass) { + super(beanClass); + ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, AbstractButton.class); + } + + @Override + protected void configureProxyEventInfo() { + super.configureProxyEventInfo(); + addProxyEventInfo("isSelected", ChangeListener.class, "model"); + } + + @Override + public ClassDescriptor getPropertyType(CompiledObject object, String name, JAXXCompiler compiler) throws CompilerException { + if (name.equals(BUTTON_GROUP_PROPERTY)) { + return null; // accepts either a String or a ButtonGroup + } else if (name.equals(VALUE_PROPERTY)) { + return ClassDescriptorLoader.getClassDescriptor(Object.class); + } else { + return super.getPropertyType(object, name, compiler); + } + } + + @Override + public boolean isMemberBound(String name) throws UnsupportedAttributeException { + return !(name.equals(BUTTON_GROUP_PROPERTY) || name.equals(VALUE_PROPERTY)) && super.isMemberBound(name); + } + + // handle buttonGroup assignment in addition block rather than initialization block + @Override + public void setProperty(CompiledObject object, String name, Object value, JAXXCompiler compiler) { + if (name.equals(BUTTON_GROUP_PROPERTY)) { + object.appendAdditionCode(getSetPropertyCode(object.getJavaCode(), name, TypeManager.getJavaCode(value), compiler)); + } else { + super.setProperty(object, name, value, compiler); + } + } + + @Override + public String getSetPropertyCode(String id, String name, String valueCode, JAXXCompiler compiler) throws CompilerException { + if (name.equals(BUTTON_GROUP_PROPERTY)) { + if (valueCode.startsWith("\"") && valueCode.endsWith("\"")) { + valueCode = valueCode.substring(1, valueCode.length() - 1); + CompiledObject buttonGroup = compiler.getCompiledObject(valueCode); + if (buttonGroup == null) { + buttonGroup = new CompiledObject(valueCode, ClassDescriptorLoader.getClassDescriptor(JAXXButtonGroup.class), compiler); + compiler.registerCompiledObject(buttonGroup); + } + } + return "{ javax.swing.ButtonGroup $buttonGroup = " + valueCode + "; " + id + ".putClientProperty(\"$buttonGroup\", $buttonGroup); $buttonGroup.add(" + id + "); }\n"; + } else if (name.equals(VALUE_PROPERTY)) { + return "{ " + id + ".putClientProperty(\"" + JAXXButtonGroup.VALUE_CLIENT_PROPERTY + "\", " + valueCode + "); Object $buttonGroup = " + id + ".getClientProperty(\"" + JAXXButtonGroup.BUTTON8GROUP_CLIENT_PROPERTY + "\");" + + " if ($buttonGroup instanceof jaxx.runtime.swing.JAXXButtonGroup) { ((jaxx.runtime.swing.JAXXButtonGroup) $buttonGroup).updateSelectedValue(); } }\n"; + } else { + return super.getSetPropertyCode(id, name, valueCode, compiler); + } + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JScrollPaneHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JScrollPaneHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JScrollPaneHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,58 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.swing; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.CompiledObject; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.tags.DefaultComponentHandler; - -import javax.swing.JScrollPane; - -public class JScrollPaneHandler extends DefaultComponentHandler { - - public JScrollPaneHandler(ClassDescriptor beanClass) { - super(beanClass); - ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JScrollPane.class); - } - - @Override - public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException { - return new CompiledObject(id, getBeanClass(), compiler) { - - boolean hasChild; - - @Override - public void addChild(CompiledObject child, String constraints, JAXXCompiler compiler) throws CompilerException { - if (constraints != null) { - compiler.reportError("JScrollPane does not accept constraints"); - } - if (hasChild) { - compiler.reportError("JScrollPane may only have one child"); - } - super.addChild(child, constraints, compiler); - hasChild = true; - } - }; - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JScrollPaneHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JScrollPaneHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JScrollPaneHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JScrollPaneHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,58 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.swing; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.CompiledObject; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.tags.DefaultComponentHandler; + +import javax.swing.JScrollPane; + +public class JScrollPaneHandler extends DefaultComponentHandler { + + public JScrollPaneHandler(ClassDescriptor beanClass) { + super(beanClass); + ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JScrollPane.class); + } + + @Override + public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException { + return new CompiledObject(id, getBeanClass(), compiler) { + + boolean hasChild; + + @Override + public void addChild(CompiledObject child, String constraints, JAXXCompiler compiler) throws CompilerException { + if (constraints != null) { + compiler.reportError("JScrollPane does not accept constraints"); + } + if (hasChild) { + compiler.reportError("JScrollPane may only have one child"); + } + super.addChild(child, constraints, compiler); + hasChild = true; + } + }; + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSliderHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSliderHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSliderHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,64 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.swing; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.CompiledObject; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.tags.DefaultComponentHandler; -import org.w3c.dom.Attr; -import org.w3c.dom.Element; - -import javax.swing.JSlider; -import javax.swing.event.ChangeListener; - -public class JSliderHandler extends DefaultComponentHandler { - - public JSliderHandler(ClassDescriptor beanClass) { - super(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")) { - return 1; - } else { - return super.getAttributeOrdering(attr); - } - } - - @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"); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSliderHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSliderHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSliderHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSliderHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,64 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.swing; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.CompiledObject; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.tags.DefaultComponentHandler; +import org.w3c.dom.Attr; +import org.w3c.dom.Element; + +import javax.swing.JSlider; +import javax.swing.event.ChangeListener; + +public class JSliderHandler extends DefaultComponentHandler { + + public JSliderHandler(ClassDescriptor beanClass) { + super(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")) { + return 1; + } else { + return super.getAttributeOrdering(attr); + } + } + + @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"); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSpinnerHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSpinnerHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSpinnerHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,110 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.swing; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.CompiledObject; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.tags.DefaultComponentHandler; -import org.w3c.dom.Element; - -import javax.swing.JSpinner; -import javax.swing.event.ChangeListener; - -public class JSpinnerHandler extends DefaultComponentHandler { - - public static String MINIMUM_PROPERTY = "minimum"; - public static String MAXIMUM_PROPERTY = "maximum"; - public static String VALUE_PROPERTY = "value"; - - public JSpinnerHandler(ClassDescriptor beanClass) { - super(beanClass); - ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JSpinner.class); - } - - public static class CompiledSpinner extends CompiledObject { - - Integer minimum = null; - Integer maximum = null; - Integer value = null; - - public CompiledSpinner(String id, ClassDescriptor objectClass, JAXXCompiler compiler) throws CompilerException { - super(id, objectClass, compiler); - } - } - - @Override - public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException { - return new CompiledSpinner(id, getBeanClass(), compiler); - } - - @Override - protected void configureProxyEventInfo() { - super.configureProxyEventInfo(); - addProxyEventInfo("getValue", ChangeListener.class, "model"); - } - - @Override - public ClassDescriptor getPropertyType(CompiledObject object, String propertyName, JAXXCompiler compiler) throws CompilerException { - if (propertyName.equals(MINIMUM_PROPERTY) || propertyName.equals(MAXIMUM_PROPERTY) || - propertyName.equals(VALUE_PROPERTY)) { - return ClassDescriptorLoader.getClassDescriptor(Integer.class); - } - return super.getPropertyType(object, propertyName, compiler); - } - - @Override - public void setProperty(CompiledObject object, String name, Object value, JAXXCompiler compiler) throws CompilerException { - if (name.equals(MINIMUM_PROPERTY)) { - ((CompiledSpinner) object).minimum = (Integer) value; - } else if (name.equals(MAXIMUM_PROPERTY)) { - ((CompiledSpinner) object).maximum = (Integer) value; - } else if (name.equals(VALUE_PROPERTY)) { - ((CompiledSpinner) object).value = (Integer) value; - } else { - super.setProperty(object, name, value, compiler); - } - } - - @Override - protected void closeComponent(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException { - CompiledSpinner spinner = (CompiledSpinner) object; - if (spinner.minimum != null || spinner.maximum != null || spinner.value != null) { - if (spinner.getConstructorParams() != null) { - compiler.reportError("constructorParams and minimum/maximum may not both be specified for the same JSpinner"); - } - if (spinner.minimum == null) { - spinner.minimum = Math.min(0, spinner.maximum != null ? spinner.maximum.intValue() : 0); - } - if (spinner.maximum == null) { - spinner.maximum = Math.max(100, spinner.minimum.intValue()); - } - if (spinner.value == null) { - spinner.value = spinner.minimum; - } - spinner.setConstructorParams("new SpinnerNumberModel(" + spinner.value + ", " + spinner.minimum + ", " + spinner.maximum + ", 1)"); - } - - super.closeComponent(object, tag, compiler); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSpinnerHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSpinnerHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSpinnerHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSpinnerHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,110 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.swing; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.CompiledObject; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.tags.DefaultComponentHandler; +import org.w3c.dom.Element; + +import javax.swing.JSpinner; +import javax.swing.event.ChangeListener; + +public class JSpinnerHandler extends DefaultComponentHandler { + + public static String MINIMUM_PROPERTY = "minimum"; + public static String MAXIMUM_PROPERTY = "maximum"; + public static String VALUE_PROPERTY = "value"; + + public JSpinnerHandler(ClassDescriptor beanClass) { + super(beanClass); + ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JSpinner.class); + } + + public static class CompiledSpinner extends CompiledObject { + + Integer minimum = null; + Integer maximum = null; + Integer value = null; + + public CompiledSpinner(String id, ClassDescriptor objectClass, JAXXCompiler compiler) throws CompilerException { + super(id, objectClass, compiler); + } + } + + @Override + public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException { + return new CompiledSpinner(id, getBeanClass(), compiler); + } + + @Override + protected void configureProxyEventInfo() { + super.configureProxyEventInfo(); + addProxyEventInfo("getValue", ChangeListener.class, "model"); + } + + @Override + public ClassDescriptor getPropertyType(CompiledObject object, String propertyName, JAXXCompiler compiler) throws CompilerException { + if (propertyName.equals(MINIMUM_PROPERTY) || propertyName.equals(MAXIMUM_PROPERTY) || + propertyName.equals(VALUE_PROPERTY)) { + return ClassDescriptorLoader.getClassDescriptor(Integer.class); + } + return super.getPropertyType(object, propertyName, compiler); + } + + @Override + public void setProperty(CompiledObject object, String name, Object value, JAXXCompiler compiler) throws CompilerException { + if (name.equals(MINIMUM_PROPERTY)) { + ((CompiledSpinner) object).minimum = (Integer) value; + } else if (name.equals(MAXIMUM_PROPERTY)) { + ((CompiledSpinner) object).maximum = (Integer) value; + } else if (name.equals(VALUE_PROPERTY)) { + ((CompiledSpinner) object).value = (Integer) value; + } else { + super.setProperty(object, name, value, compiler); + } + } + + @Override + protected void closeComponent(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException { + CompiledSpinner spinner = (CompiledSpinner) object; + if (spinner.minimum != null || spinner.maximum != null || spinner.value != null) { + if (spinner.getConstructorParams() != null) { + compiler.reportError("constructorParams and minimum/maximum may not both be specified for the same JSpinner"); + } + if (spinner.minimum == null) { + spinner.minimum = Math.min(0, spinner.maximum != null ? spinner.maximum.intValue() : 0); + } + if (spinner.maximum == null) { + spinner.maximum = Math.max(100, spinner.minimum.intValue()); + } + if (spinner.value == null) { + spinner.value = spinner.minimum; + } + spinner.setConstructorParams("new SpinnerNumberModel(" + spinner.value + ", " + spinner.minimum + ", " + spinner.maximum + ", 1)"); + } + + super.closeComponent(object, tag, compiler); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSplitPaneHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSplitPaneHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSplitPaneHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,87 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.swing; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.CompiledObject; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.tags.DefaultComponentHandler; -import org.w3c.dom.Element; - -import javax.swing.JSplitPane; -import java.awt.Component; - -public class JSplitPaneHandler extends DefaultComponentHandler { - - public JSplitPaneHandler(ClassDescriptor beanClass) { - super(beanClass); - ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JSplitPane.class); - } - - protected Component createRawComponent(Element tag) { - return new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); - } - - /** - * Add support for <code>orientation="vertical"</code> and <code>orientation="horizontal"</code>. The - * values required by the JAXXBeanInfo are the unwieldy <code>vertical_split</code> and <code>horizontal_split</code> - * (which are also recognized). - */ - @Override - protected int constantValue(String key, String value) { - if (key.equals("orientation")) { - value = value.trim().toLowerCase(); - if (value.equals("horizontal") || value.equals("horizontal_split")) { - return JSplitPane.HORIZONTAL_SPLIT; - } - if (value.equals("vertical") || value.equals("vertical_split")) { - return JSplitPane.VERTICAL_SPLIT; - } - throw new IllegalArgumentException("orientation must be 'horizontal' or 'vertical', found '" + value + "'"); - } - return super.constantValue(key, value); - } - - @Override - public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException { - return new CompiledObject(id, getBeanClass(), compiler) { - - private int count; - - @Override - public void addChild(CompiledObject child, String constraints, JAXXCompiler compiler) throws CompilerException { - if (constraints != null) { - compiler.reportError("JSplitPane does not accept constraints"); - } - if (count == 0) { - super.addChild(child, "JSplitPane.LEFT", compiler); - } else if (count == 1) { - super.addChild(child, "JSplitPane.RIGHT", compiler); - } else { - compiler.reportError("JSplitPane is limited to two children"); - } - count++; - } - }; - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSplitPaneHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSplitPaneHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSplitPaneHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSplitPaneHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,87 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.swing; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.CompiledObject; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.tags.DefaultComponentHandler; +import org.w3c.dom.Element; + +import javax.swing.JSplitPane; +import java.awt.Component; + +public class JSplitPaneHandler extends DefaultComponentHandler { + + public JSplitPaneHandler(ClassDescriptor beanClass) { + super(beanClass); + ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JSplitPane.class); + } + + protected Component createRawComponent(Element tag) { + return new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); + } + + /** + * Add support for <code>orientation="vertical"</code> and <code>orientation="horizontal"</code>. The + * values required by the JAXXBeanInfo are the unwieldy <code>vertical_split</code> and <code>horizontal_split</code> + * (which are also recognized). + */ + @Override + protected int constantValue(String key, String value) { + if (key.equals("orientation")) { + value = value.trim().toLowerCase(); + if (value.equals("horizontal") || value.equals("horizontal_split")) { + return JSplitPane.HORIZONTAL_SPLIT; + } + if (value.equals("vertical") || value.equals("vertical_split")) { + return JSplitPane.VERTICAL_SPLIT; + } + throw new IllegalArgumentException("orientation must be 'horizontal' or 'vertical', found '" + value + "'"); + } + return super.constantValue(key, value); + } + + @Override + public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException { + return new CompiledObject(id, getBeanClass(), compiler) { + + private int count; + + @Override + public void addChild(CompiledObject child, String constraints, JAXXCompiler compiler) throws CompilerException { + if (constraints != null) { + compiler.reportError("JSplitPane does not accept constraints"); + } + if (count == 0) { + super.addChild(child, "JSplitPane.LEFT", compiler); + } else if (count == 1) { + super.addChild(child, "JSplitPane.RIGHT", compiler); + } else { + compiler.reportError("JSplitPane is limited to two children"); + } + count++; + } + }; + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTabbedPaneHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTabbedPaneHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTabbedPaneHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,152 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.swing; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.CompiledObject; -import jaxx.compiler.I18nHelper; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.tags.DefaultComponentHandler; -import jaxx.compiler.types.TypeManager; -import jaxx.runtime.swing.TabInfo; - -import javax.swing.Icon; -import javax.swing.JTabbedPane; -import javax.swing.event.ChangeListener; -import java.awt.Color; -import java.awt.event.ContainerListener; - -public class JTabbedPaneHandler extends DefaultComponentHandler { - - public JTabbedPaneHandler(ClassDescriptor beanClass) { - super(beanClass); - ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JTabbedPane.class); - } - - public static class CompiledTabbedPane extends CompiledObject { - - private static final TabInfo USED = new TabInfo("ALREADY USED"); - int tabCount; - TabInfo tabInfo; - - public CompiledTabbedPane(String id, ClassDescriptor objectClass, JAXXCompiler compiler) throws CompilerException { - super(id, objectClass, compiler); - } - - @Override - public void addChild(CompiledObject child, String constraints, JAXXCompiler compiler) throws CompilerException { - if (constraints != null) { - compiler.reportError("JTabbedPane tabs may not have constraints"); - } - - super.addChild(child, constraints, compiler); - - if (tabInfo == null) { - compiler.reportError("JTabbedPaneHandler may only have 'tab' tags as children (found " + child.getObjectClass() + ")"); - return; - } else if (tabInfo == USED) { - compiler.reportError("<tab> tags may only have one child component"); - return; - } - - int tabIndex = ++tabCount - 1; - appendAdditionCode(tabInfo.getId() + ".addPropertyChangeListener(new jaxx.runtime.swing.TabInfoPropertyChangeListener(" + getId() + ", " + tabIndex + "));"); - - String title = tabInfo.getTitle(); - if (title != null) { - if (I18nHelper.isI18nAttribute("title")) { - if (!title.startsWith("_(\"")) { - // we did not have the invocation code, add it - title = I18nHelper.addI18nInvocation(getId(), "title", TypeManager.getJavaCode(title), compiler); - } - } else { - title = TypeManager.getJavaCode(title); - } - appendAdditionCode(getId() + ".setTitleAt(" + tabIndex + ", " + title + ");"); - } - - String toolTipText = tabInfo.getToolTipText(); - if (toolTipText != null) { - if (I18nHelper.isI18nAttribute("toolTipText")) { - if (!toolTipText.startsWith("_(\"")) { - // we did not have the invocation code, add it - toolTipText = I18nHelper.addI18nInvocation(getId(), "toolTipText", TypeManager.getJavaCode(toolTipText), compiler); - } - } else { - toolTipText = TypeManager.getJavaCode(toolTipText); - } - appendAdditionCode(getId() + ".setToolTipTextAt(" + tabIndex + ", " + toolTipText + ");"); - } - - boolean enabled = tabInfo.isEnabled(); - if (!enabled) { - appendAdditionCode(getId() + ".setEnabledAt(" + tabIndex + ", false);"); - } - - Color foreground = tabInfo.getForeground(); - if (foreground != null) { - appendAdditionCode(getId() + ".setForegroundAt(" + tabIndex + ", " + TypeManager.getJavaCode(foreground) + ");"); - } - - Color background = tabInfo.getBackground(); - if (background != null) { - appendAdditionCode(getId() + ".setBackgroundAt(" + tabIndex + ", " + TypeManager.getJavaCode(background) + ");"); - } - - int mnemonic = tabInfo.getMnemonic(); - if (mnemonic != -1) { - appendAdditionCode(getId() + ".setMnemonicAt(" + tabIndex + ", " + mnemonic + ");"); - } - - int displayedMnemonicIndex = tabInfo.getDisplayedMnemonicIndex(); - if (displayedMnemonicIndex != -1) { - appendAdditionCode(getId() + ".setDisplayedMnemonicIndexAt(" + tabIndex + ", " + displayedMnemonicIndex + ");"); - } - - Icon icon = tabInfo.getIcon(); - if (icon != null) { - appendAdditionCode(getId() + ".setIconAt(" + tabIndex + ", " + icon + ");"); - } - - Icon disabledIcon = tabInfo.getDisabledIcon(); - if (disabledIcon != null) { - appendAdditionCode(getId() + ".setDisabledIconAt(" + tabIndex + ", " + disabledIcon + ");"); - } - - tabInfo = USED; - } - } - - @Override - public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException { - return new CompiledTabbedPane(id, getBeanClass(), compiler); - } - - @Override - protected void configureProxyEventInfo() { - super.configureProxyEventInfo(); - addProxyEventInfo("getSelectedIndex", ChangeListener.class); - addProxyEventInfo("getSelectedComponent", ChangeListener.class); - addProxyEventInfo("getTabCount", ContainerListener.class); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTabbedPaneHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTabbedPaneHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTabbedPaneHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTabbedPaneHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,152 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.swing; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.CompiledObject; +import jaxx.compiler.I18nHelper; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.tags.DefaultComponentHandler; +import jaxx.compiler.types.TypeManager; +import jaxx.runtime.swing.TabInfo; + +import javax.swing.Icon; +import javax.swing.JTabbedPane; +import javax.swing.event.ChangeListener; +import java.awt.Color; +import java.awt.event.ContainerListener; + +public class JTabbedPaneHandler extends DefaultComponentHandler { + + public JTabbedPaneHandler(ClassDescriptor beanClass) { + super(beanClass); + ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JTabbedPane.class); + } + + public static class CompiledTabbedPane extends CompiledObject { + + private static final TabInfo USED = new TabInfo("ALREADY USED"); + int tabCount; + TabInfo tabInfo; + + public CompiledTabbedPane(String id, ClassDescriptor objectClass, JAXXCompiler compiler) throws CompilerException { + super(id, objectClass, compiler); + } + + @Override + public void addChild(CompiledObject child, String constraints, JAXXCompiler compiler) throws CompilerException { + if (constraints != null) { + compiler.reportError("JTabbedPane tabs may not have constraints"); + } + + super.addChild(child, constraints, compiler); + + if (tabInfo == null) { + compiler.reportError("JTabbedPaneHandler may only have 'tab' tags as children (found " + child.getObjectClass() + ")"); + return; + } else if (tabInfo == USED) { + compiler.reportError("<tab> tags may only have one child component"); + return; + } + + int tabIndex = ++tabCount - 1; + appendAdditionCode(tabInfo.getId() + ".addPropertyChangeListener(new jaxx.runtime.swing.TabInfoPropertyChangeListener(" + getId() + ", " + tabIndex + "));"); + + String title = tabInfo.getTitle(); + if (title != null) { + if (I18nHelper.isI18nAttribute("title")) { + if (!title.startsWith("_(\"")) { + // we did not have the invocation code, add it + title = I18nHelper.addI18nInvocation(getId(), "title", TypeManager.getJavaCode(title), compiler); + } + } else { + title = TypeManager.getJavaCode(title); + } + appendAdditionCode(getId() + ".setTitleAt(" + tabIndex + ", " + title + ");"); + } + + String toolTipText = tabInfo.getToolTipText(); + if (toolTipText != null) { + if (I18nHelper.isI18nAttribute("toolTipText")) { + if (!toolTipText.startsWith("_(\"")) { + // we did not have the invocation code, add it + toolTipText = I18nHelper.addI18nInvocation(getId(), "toolTipText", TypeManager.getJavaCode(toolTipText), compiler); + } + } else { + toolTipText = TypeManager.getJavaCode(toolTipText); + } + appendAdditionCode(getId() + ".setToolTipTextAt(" + tabIndex + ", " + toolTipText + ");"); + } + + boolean enabled = tabInfo.isEnabled(); + if (!enabled) { + appendAdditionCode(getId() + ".setEnabledAt(" + tabIndex + ", false);"); + } + + Color foreground = tabInfo.getForeground(); + if (foreground != null) { + appendAdditionCode(getId() + ".setForegroundAt(" + tabIndex + ", " + TypeManager.getJavaCode(foreground) + ");"); + } + + Color background = tabInfo.getBackground(); + if (background != null) { + appendAdditionCode(getId() + ".setBackgroundAt(" + tabIndex + ", " + TypeManager.getJavaCode(background) + ");"); + } + + int mnemonic = tabInfo.getMnemonic(); + if (mnemonic != -1) { + appendAdditionCode(getId() + ".setMnemonicAt(" + tabIndex + ", " + mnemonic + ");"); + } + + int displayedMnemonicIndex = tabInfo.getDisplayedMnemonicIndex(); + if (displayedMnemonicIndex != -1) { + appendAdditionCode(getId() + ".setDisplayedMnemonicIndexAt(" + tabIndex + ", " + displayedMnemonicIndex + ");"); + } + + Icon icon = tabInfo.getIcon(); + if (icon != null) { + appendAdditionCode(getId() + ".setIconAt(" + tabIndex + ", " + icon + ");"); + } + + Icon disabledIcon = tabInfo.getDisabledIcon(); + if (disabledIcon != null) { + appendAdditionCode(getId() + ".setDisabledIconAt(" + tabIndex + ", " + disabledIcon + ");"); + } + + tabInfo = USED; + } + } + + @Override + public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException { + return new CompiledTabbedPane(id, getBeanClass(), compiler); + } + + @Override + protected void configureProxyEventInfo() { + super.configureProxyEventInfo(); + addProxyEventInfo("getSelectedIndex", ChangeListener.class); + addProxyEventInfo("getSelectedComponent", ChangeListener.class); + addProxyEventInfo("getTabCount", ContainerListener.class); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTextComponentHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTextComponentHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTextComponentHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,86 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.swing; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.CompiledObject; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.tags.DefaultComponentHandler; -import jaxx.runtime.SwingUtil; -import org.w3c.dom.Attr; -import org.w3c.dom.Element; - -import javax.swing.JTextArea; -import javax.swing.event.DocumentListener; -import javax.swing.text.JTextComponent; - -public class JTextComponentHandler extends DefaultComponentHandler { - - private static final int DEFAULT_COLUMNS = 15; - - public JTextComponentHandler(ClassDescriptor beanClass) { - super(beanClass); - ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JTextComponent.class); - } - - @Override - protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException { - super.setDefaults(object, tag, compiler); - try { - object.getObjectClass().getMethodDescriptor("setColumns", ClassDescriptorLoader.getClassDescriptor(int.class)); - setAttribute(object, "columns", String.valueOf(DEFAULT_COLUMNS), false, compiler); - } catch (NoSuchMethodException e) { - // ignore ? - } - - if (ClassDescriptorLoader.getClassDescriptor(JTextArea.class).isAssignableFrom(object.getObjectClass())) { - setAttribute(object, "lineWrap", "true", false, compiler); - setAttribute(object, "wrapStyleWord", "true", false, compiler); - } - } - - @Override - public String getSetPropertyCode(String id, String name, String valueCode, JAXXCompiler compiler) throws CompilerException { - if (name.equals("text")) { - return SwingUtil.class.getName() + ".setText(" + id + ", " + valueCode + ");\n"; - //return "jaxx.runtime.swing.Utils.setText(" + id + ", " + valueCode + ");\n"; - } - return super.getSetPropertyCode(id, name, valueCode, compiler); - } - - @Override - protected int getAttributeOrdering(Attr attr) { - // delay text in case other attributes affect how it's processed, as is the case - // with JEditorPane's contentType - if (attr.getName().equals("text")) { - return 1; - } - return super.getAttributeOrdering(attr); - } - - @Override - protected void configureProxyEventInfo() { - super.configureProxyEventInfo(); - addProxyEventInfo("getText", DocumentListener.class, "document"); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTextComponentHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTextComponentHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTextComponentHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTextComponentHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,86 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.swing; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.CompiledObject; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.tags.DefaultComponentHandler; +import jaxx.runtime.SwingUtil; +import org.w3c.dom.Attr; +import org.w3c.dom.Element; + +import javax.swing.JTextArea; +import javax.swing.event.DocumentListener; +import javax.swing.text.JTextComponent; + +public class JTextComponentHandler extends DefaultComponentHandler { + + private static final int DEFAULT_COLUMNS = 15; + + public JTextComponentHandler(ClassDescriptor beanClass) { + super(beanClass); + ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JTextComponent.class); + } + + @Override + protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException { + super.setDefaults(object, tag, compiler); + try { + object.getObjectClass().getMethodDescriptor("setColumns", ClassDescriptorLoader.getClassDescriptor(int.class)); + setAttribute(object, "columns", String.valueOf(DEFAULT_COLUMNS), false, compiler); + } catch (NoSuchMethodException e) { + // ignore ? + } + + if (ClassDescriptorLoader.getClassDescriptor(JTextArea.class).isAssignableFrom(object.getObjectClass())) { + setAttribute(object, "lineWrap", "true", false, compiler); + setAttribute(object, "wrapStyleWord", "true", false, compiler); + } + } + + @Override + public String getSetPropertyCode(String id, String name, String valueCode, JAXXCompiler compiler) throws CompilerException { + if (name.equals("text")) { + return SwingUtil.class.getName() + ".setText(" + id + ", " + valueCode + ");\n"; + //return "jaxx.runtime.swing.Utils.setText(" + id + ", " + valueCode + ");\n"; + } + return super.getSetPropertyCode(id, name, valueCode, compiler); + } + + @Override + protected int getAttributeOrdering(Attr attr) { + // delay text in case other attributes affect how it's processed, as is the case + // with JEditorPane's contentType + if (attr.getName().equals("text")) { + return 1; + } + return super.getAttributeOrdering(attr); + } + + @Override + protected void configureProxyEventInfo() { + super.configureProxyEventInfo(); + addProxyEventInfo("getText", DocumentListener.class, "document"); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JToolBarHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JToolBarHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JToolBarHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,55 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.swing; - -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.tags.DefaultComponentHandler; - -import javax.swing.JToolBar; - -public class JToolBarHandler extends DefaultComponentHandler { - - public JToolBarHandler(ClassDescriptor beanClass) { - super(beanClass); - ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JToolBar.class); - } - - /** - * Add support for <code>orientation="vertical"</code> and <code>orientation="horizontal"</code>. These values should - * have been supported without any special effort on my part, but JToolBar's BeanInfo doesn't contain the enum attribute - * for the orientation property. - */ - @Override - protected int constantValue(String key, String value) { - if (key.equals("orientation")) { - value = value.trim().toLowerCase(); - if (value.equals("horizontal")) { - return JToolBar.HORIZONTAL; - } - if (value.equals("vertical")) { - return JToolBar.VERTICAL; - } - throw new IllegalArgumentException("orientation must be 'horizontal' or 'vertical', found '" + value + "'"); - } - return super.constantValue(key, value); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JToolBarHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JToolBarHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JToolBarHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JToolBarHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,55 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.swing; + +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.tags.DefaultComponentHandler; + +import javax.swing.JToolBar; + +public class JToolBarHandler extends DefaultComponentHandler { + + public JToolBarHandler(ClassDescriptor beanClass) { + super(beanClass); + ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JToolBar.class); + } + + /** + * Add support for <code>orientation="vertical"</code> and <code>orientation="horizontal"</code>. These values should + * have been supported without any special effort on my part, but JToolBar's BeanInfo doesn't contain the enum attribute + * for the orientation property. + */ + @Override + protected int constantValue(String key, String value) { + if (key.equals("orientation")) { + value = value.trim().toLowerCase(); + if (value.equals("horizontal")) { + return JToolBar.HORIZONTAL; + } + if (value.equals("vertical")) { + return JToolBar.VERTICAL; + } + throw new IllegalArgumentException("orientation must be 'horizontal' or 'vertical', found '" + value + "'"); + } + return super.constantValue(key, value); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTreeHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTreeHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTreeHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,63 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.swing; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.tags.DefaultComponentHandler; -import org.w3c.dom.Element; - -import javax.swing.event.TreeSelectionListener; -import java.io.IOException; -import javax.swing.JTree; -import org.w3c.dom.NodeList; - -public class JTreeHandler extends DefaultComponentHandler { - - public JTreeHandler(ClassDescriptor beanClass) { - super(beanClass); - ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JTree.class); - } - - @Override - protected void configureProxyEventInfo() { - super.configureProxyEventInfo(); - addProxyEventInfo("getSelectionCount", TreeSelectionListener.class, "selectionModel"); - addProxyEventInfo("getSelectionPath", TreeSelectionListener.class, "selectionModel"); - addProxyEventInfo("getSelectionPaths", TreeSelectionListener.class, "selectionModel"); - addProxyEventInfo("getSelectionRows", TreeSelectionListener.class, "selectionModel"); - addProxyEventInfo("getSelectionValue", TreeSelectionListener.class, "selectionModel"); - } - - @Override - public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - NodeList children = tag.getChildNodes(); - if (children.getLength() > 0) { - compiler.reportError("JTree does not accept childs"); - throw new CompilerException("JTree does not accept childs"); - } - } -} - - - Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTreeHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTreeHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTreeHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTreeHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,63 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.swing; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.tags.DefaultComponentHandler; +import org.w3c.dom.Element; + +import javax.swing.event.TreeSelectionListener; +import java.io.IOException; +import javax.swing.JTree; +import org.w3c.dom.NodeList; + +public class JTreeHandler extends DefaultComponentHandler { + + public JTreeHandler(ClassDescriptor beanClass) { + super(beanClass); + ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JTree.class); + } + + @Override + protected void configureProxyEventInfo() { + super.configureProxyEventInfo(); + addProxyEventInfo("getSelectionCount", TreeSelectionListener.class, "selectionModel"); + addProxyEventInfo("getSelectionPath", TreeSelectionListener.class, "selectionModel"); + addProxyEventInfo("getSelectionPaths", TreeSelectionListener.class, "selectionModel"); + addProxyEventInfo("getSelectionRows", TreeSelectionListener.class, "selectionModel"); + addProxyEventInfo("getSelectionValue", TreeSelectionListener.class, "selectionModel"); + } + + @Override + public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + NodeList children = tag.getChildNodes(); + if (children.getLength() > 0) { + compiler.reportError("JTree does not accept childs"); + throw new CompilerException("JTree does not accept childs"); + } + } +} + + + Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JWindowHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JWindowHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JWindowHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,78 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.swing; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.CompiledObject; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.tags.DefaultComponentHandler; -import org.w3c.dom.Element; - -import javax.swing.JDialog; -import javax.swing.JFrame; -import javax.swing.JMenuBar; -import javax.swing.JWindow; -import java.io.IOException; -import java.util.Map; - -public class JWindowHandler extends DefaultComponentHandler { - - public JWindowHandler(ClassDescriptor beanClass) { - super(beanClass); - ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JWindow.class, JFrame.class, JDialog.class); - } - - @Override - public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException { - return new CompiledObject(id, getBeanClass(), compiler) { - - @Override - public void addChild(CompiledObject child, String constraints, JAXXCompiler compiler) throws CompilerException { - if (ClassDescriptorLoader.getClassDescriptor(JMenuBar.class).isAssignableFrom(child.getObjectClass())) { - appendAdditionCode(getId() + ".setJMenuBar(" + child.getId() + ");"); - } else { - super.addChild(child, constraints, compiler); - } - } - }; - } - - @Override - protected void openComponent(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException { - if (compiler.getOpenComponent() != null) { - compiler.openInvisibleComponent(object); - } else { - super.openComponent(object, tag, compiler); - } - } - - @Override - public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - super.compileSecondPass(tag, compiler); - CompiledObject object = objectMap.get(tag); - Map<?, ?> properties = object.getProperties(); - if (!properties.containsKey("width") && !properties.containsKey("height")) { - compiler.appendLateInitializer(object.getId() + ".pack();\n"); - } - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JWindowHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JWindowHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JWindowHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JWindowHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,78 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.swing; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.CompiledObject; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.tags.DefaultComponentHandler; +import org.w3c.dom.Element; + +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JMenuBar; +import javax.swing.JWindow; +import java.io.IOException; +import java.util.Map; + +public class JWindowHandler extends DefaultComponentHandler { + + public JWindowHandler(ClassDescriptor beanClass) { + super(beanClass); + ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JWindow.class, JFrame.class, JDialog.class); + } + + @Override + public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException { + return new CompiledObject(id, getBeanClass(), compiler) { + + @Override + public void addChild(CompiledObject child, String constraints, JAXXCompiler compiler) throws CompilerException { + if (ClassDescriptorLoader.getClassDescriptor(JMenuBar.class).isAssignableFrom(child.getObjectClass())) { + appendAdditionCode(getId() + ".setJMenuBar(" + child.getId() + ");"); + } else { + super.addChild(child, constraints, compiler); + } + } + }; + } + + @Override + protected void openComponent(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException { + if (compiler.getOpenComponent() != null) { + compiler.openInvisibleComponent(object); + } else { + super.openComponent(object, tag, compiler); + } + } + + @Override + public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + super.compileSecondPass(tag, compiler); + CompiledObject object = objectMap.get(tag); + Map<?, ?> properties = object.getProperties(); + if (!properties.containsKey("width") && !properties.containsKey("height")) { + compiler.appendLateInitializer(object.getId() + ".pack();\n"); + } + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/RowHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/RowHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/RowHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,104 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.swing; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.tags.TagHandler; -import jaxx.runtime.swing.Table; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.Text; - -import java.awt.GridBagConstraints; -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"); - return; - } - - TableHandler.CompiledTable table = (TableHandler.CompiledTable) compiler.getOpenComponent(); - table.newRow(); - GridBagConstraints c = table.getRowConstraints(); - CellHandler.setAttributes(c, tag); - compileChildrenSecondPass(tag, compiler); - } - - public void compileChildrenFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - NodeList children = tag.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { - Node node = children.item(i); - int nodeType = node.getNodeType(); - if (nodeType == Node.ELEMENT_NODE) { - Element child = (Element) node; - if (!child.getLocalName().equals("cell")) { - compiler.reportError("tag '" + tag.getLocalName() + "' may only contain cell tags as children"); - } - compileChildTagFirstPass(child, compiler); - } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) { - String text = ((Text) node).getData().trim(); - if (text.length() > 0) { - compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')"); - } - } - } - } - - public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - NodeList children = tag.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { - Node node = children.item(i); - int nodeType = node.getNodeType(); - if (nodeType == Node.ELEMENT_NODE) { - Element child = (Element) node; - if (!child.getLocalName().equals("cell")) { - compiler.reportError("tag '" + tag.getLocalName() + "' may only contain cell tags as children"); - } - compileChildTagSecondPass(child, compiler); - } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) { - String text = ((Text) node).getData().trim(); - if (text.length() > 0) { - compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')"); - } - } - } - } - - protected void compileChildTagFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - compiler.compileFirstPass(tag); - } - - protected void compileChildTagSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - compiler.compileSecondPass(tag); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/RowHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/RowHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/RowHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/RowHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,104 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.swing; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.tags.TagHandler; +import jaxx.runtime.swing.Table; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.Text; + +import java.awt.GridBagConstraints; +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"); + return; + } + + TableHandler.CompiledTable table = (TableHandler.CompiledTable) compiler.getOpenComponent(); + table.newRow(); + GridBagConstraints c = table.getRowConstraints(); + CellHandler.setAttributes(c, tag); + compileChildrenSecondPass(tag, compiler); + } + + public void compileChildrenFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + NodeList children = tag.getChildNodes(); + for (int i = 0; i < children.getLength(); i++) { + Node node = children.item(i); + int nodeType = node.getNodeType(); + if (nodeType == Node.ELEMENT_NODE) { + Element child = (Element) node; + if (!child.getLocalName().equals("cell")) { + compiler.reportError("tag '" + tag.getLocalName() + "' may only contain cell tags as children"); + } + compileChildTagFirstPass(child, compiler); + } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) { + String text = ((Text) node).getData().trim(); + if (text.length() > 0) { + compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')"); + } + } + } + } + + public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + NodeList children = tag.getChildNodes(); + for (int i = 0; i < children.getLength(); i++) { + Node node = children.item(i); + int nodeType = node.getNodeType(); + if (nodeType == Node.ELEMENT_NODE) { + Element child = (Element) node; + if (!child.getLocalName().equals("cell")) { + compiler.reportError("tag '" + tag.getLocalName() + "' may only contain cell tags as children"); + } + compileChildTagSecondPass(child, compiler); + } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) { + String text = ((Text) node).getData().trim(); + if (text.length() > 0) { + compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')"); + } + } + } + } + + protected void compileChildTagFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + compiler.compileFirstPass(tag); + } + + protected void compileChildTagSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + compiler.compileSecondPass(tag); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,189 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.swing; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.CompiledObject; -import jaxx.compiler.I18nHelper; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.binding.DataBindingHelper; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.tags.TagHandler; -import jaxx.compiler.types.TypeManager; -import jaxx.runtime.swing.TabInfo; -import org.apache.commons.lang.StringUtils; -import org.w3c.dom.Attr; -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.Text; - -import javax.swing.Icon; -import javax.swing.JTabbedPane; -import java.awt.Color; -import java.io.IOException; - -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"); - return; - } - - JTabbedPaneHandler.CompiledTabbedPane tabs = (JTabbedPaneHandler.CompiledTabbedPane) compiler.getOpenComponent(); - - String id = tag.getAttribute("id"); - if (id == null || id.length() == 0) { - id = compiler.getAutoId(TabInfo.class.getSimpleName()); -// id = compiler.getAutoId(ClassDescriptorLoader.getClassDescriptor(TabInfo.class)); - } - TabInfo tabInfo = new TabInfo(id); - CompiledObject compiledTabInfo = new CompiledObject(id, ClassDescriptorLoader.getClassDescriptor(TabInfo.class), compiler); - compiler.registerCompiledObject(compiledTabInfo); - //id = tabInfo.getId(); - tabs.tabInfo = tabInfo; - setAttributes(compiledTabInfo, tabs, tag, compiler); - compileChildrenSecondPass(tag, compiler); - tabs.tabInfo = null; - } - - public static void setAttribute(CompiledObject compiledTabInfo, JTabbedPaneHandler.CompiledTabbedPane tabs, String name, String value, JAXXCompiler compiler) throws CompilerException { - value = value.trim(); - TabInfo tabInfo = tabs.tabInfo; - String id = tabInfo.getId(); - String binding = DataBindingHelper.processDataBindings(value); - if (binding != null) { - compiler.getBindingHelper().registerDataBinding(id + "." + name, binding, id + ".set" + StringUtils.capitalize(name) + "(" + binding + ");"); -// compiler.getBindingHelper().registerDataBinding(binding, id + "." + name, id + ".set" + StringUtils.capitalize(name) + "(" + binding + ");"); - return; - } - - String valueCode = TypeManager.getJavaCode(value); - - // add i18n support - if (I18nHelper.isI18nableAttribute(name, compiler)) { - value = valueCode = I18nHelper.addI18nInvocation(id, name, valueCode, compiler); - } - if (name.equals("id")) { - // ignore, already handled - } else if (name.equals("title")) { - tabInfo.setTitle(value); - compiledTabInfo.appendInitializationCode(id + ".setTitle(" + valueCode + ");"); - //compiledTabInfo.appendInitializationCode(id + ".setTitle(" + TypeManager.getJavaCode(value) + ");"); - } else if (name.equals("toolTipText")) { - tabInfo.setToolTipText(value); - compiledTabInfo.appendInitializationCode(id + ".setToolTipText(" + valueCode + ");"); - //compiledTabInfo.appendInitializationCode(id + ".setToolTipText(" + TypeManager.getJavaCode(value) + ");"); - } else if (name.equals("icon")) { - Icon icon = (Icon) TypeManager.convertFromString(value, Icon.class); - tabInfo.setIcon(icon); - compiledTabInfo.appendInitializationCode(id + ".setIcon(" + TypeManager.getJavaCode(icon) + ");"); - } else if (name.equals("enabled")) { - boolean enabled = (Boolean) TypeManager.convertFromString(value, Boolean.class); - tabInfo.setEnabled(enabled); - compiledTabInfo.appendInitializationCode(id + ".setEnabled(" + enabled + ");"); - } else if (name.equals("disabledIcon")) { - Icon disabledIcon = (Icon) TypeManager.convertFromString(value, Icon.class); - tabInfo.setDisabledIcon(disabledIcon); - compiledTabInfo.appendInitializationCode(id + ".setDisabledIcon(" + TypeManager.getJavaCode(disabledIcon) + ");"); - } else if (name.equals("mnemonic")) { - int mnemonic = (Character) TypeManager.convertFromString(value, char.class); - tabInfo.setMnemonic(mnemonic); - compiledTabInfo.appendInitializationCode(id + ".setMnemonic(" + mnemonic + ");"); - } else if (name.equals("displayedMnemonicIndex")) { - int displayedMnemonicIndex = (Integer) TypeManager.convertFromString(value, int.class); - tabInfo.setDisplayedMnemonicIndex(displayedMnemonicIndex); - compiledTabInfo.appendInitializationCode(id + ".setDisplayedMnemonicIndex(" + displayedMnemonicIndex + ");"); - } else if (name.equals("foreground")) { - Color foreground = (Color) TypeManager.convertFromString(value, Color.class); - tabInfo.setForeground(foreground); - compiledTabInfo.appendInitializationCode(id + ".setForeground(" + TypeManager.getJavaCode(foreground) + ");"); - } else if (name.equals("background")) { - Color background = (Color) TypeManager.convertFromString(value, Color.class); - tabInfo.setBackground(background); - compiledTabInfo.appendInitializationCode(id + ".setBackground(" + TypeManager.getJavaCode(background) + ");"); - } else { - compiler.reportError("The <tab> tag does not support the attribute '" + name + "'"); - } - } - - public void setAttributes(CompiledObject compiledTabInfo, JTabbedPaneHandler.CompiledTabbedPane tabs, Element tag, JAXXCompiler compiler) throws CompilerException { - NamedNodeMap children = tag.getAttributes(); - for (int i = 0; i < children.getLength(); i++) { - Attr attribute = (Attr) children.item(i); - String name = attribute.getName(); - String value = attribute.getValue(); - if (!name.startsWith("xmlns") && !JAXXCompiler.JAXX_INTERNAL_NAMESPACE.equals(attribute.getNamespaceURI())) { - setAttribute(compiledTabInfo, tabs, name, value, compiler); - } - } - } - - protected void compileChildrenFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - NodeList children = tag.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { - Node node = children.item(i); - int nodeType = node.getNodeType(); - if (nodeType == Node.ELEMENT_NODE) { - Element child = (Element) node; - compileChildTagFirstPass(child, compiler); - } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) { - String text = ((Text) node).getData().trim(); - if (text.length() > 0) { - compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')"); - } - } - } - } - - protected void compileChildTagFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - compiler.compileFirstPass(tag); - } - - protected void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - NodeList children = tag.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { - Node node = children.item(i); - int nodeType = node.getNodeType(); - if (nodeType == Node.ELEMENT_NODE) { - Element child = (Element) node; - compileChildTagSecondPass(child, compiler); - } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) { - String text = ((Text) node).getData().trim(); - if (text.length() > 0) { - compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')"); - } - } - } - } - - protected void compileChildTagSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - compiler.compileSecondPass(tag); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,189 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.swing; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.CompiledObject; +import jaxx.compiler.I18nHelper; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.binding.DataBindingHelper; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.tags.TagHandler; +import jaxx.compiler.types.TypeManager; +import jaxx.runtime.swing.TabInfo; +import org.apache.commons.lang.StringUtils; +import org.w3c.dom.Attr; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.Text; + +import javax.swing.Icon; +import javax.swing.JTabbedPane; +import java.awt.Color; +import java.io.IOException; + +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"); + return; + } + + JTabbedPaneHandler.CompiledTabbedPane tabs = (JTabbedPaneHandler.CompiledTabbedPane) compiler.getOpenComponent(); + + String id = tag.getAttribute("id"); + if (id == null || id.length() == 0) { + id = compiler.getAutoId(TabInfo.class.getSimpleName()); +// id = compiler.getAutoId(ClassDescriptorLoader.getClassDescriptor(TabInfo.class)); + } + TabInfo tabInfo = new TabInfo(id); + CompiledObject compiledTabInfo = new CompiledObject(id, ClassDescriptorLoader.getClassDescriptor(TabInfo.class), compiler); + compiler.registerCompiledObject(compiledTabInfo); + //id = tabInfo.getId(); + tabs.tabInfo = tabInfo; + setAttributes(compiledTabInfo, tabs, tag, compiler); + compileChildrenSecondPass(tag, compiler); + tabs.tabInfo = null; + } + + public static void setAttribute(CompiledObject compiledTabInfo, JTabbedPaneHandler.CompiledTabbedPane tabs, String name, String value, JAXXCompiler compiler) throws CompilerException { + value = value.trim(); + TabInfo tabInfo = tabs.tabInfo; + String id = tabInfo.getId(); + String binding = DataBindingHelper.processDataBindings(value); + if (binding != null) { + compiler.getBindingHelper().registerDataBinding(id + "." + name, binding, id + ".set" + StringUtils.capitalize(name) + "(" + binding + ");"); +// compiler.getBindingHelper().registerDataBinding(binding, id + "." + name, id + ".set" + StringUtils.capitalize(name) + "(" + binding + ");"); + return; + } + + String valueCode = TypeManager.getJavaCode(value); + + // add i18n support + if (I18nHelper.isI18nableAttribute(name, compiler)) { + value = valueCode = I18nHelper.addI18nInvocation(id, name, valueCode, compiler); + } + if (name.equals("id")) { + // ignore, already handled + } else if (name.equals("title")) { + tabInfo.setTitle(value); + compiledTabInfo.appendInitializationCode(id + ".setTitle(" + valueCode + ");"); + //compiledTabInfo.appendInitializationCode(id + ".setTitle(" + TypeManager.getJavaCode(value) + ");"); + } else if (name.equals("toolTipText")) { + tabInfo.setToolTipText(value); + compiledTabInfo.appendInitializationCode(id + ".setToolTipText(" + valueCode + ");"); + //compiledTabInfo.appendInitializationCode(id + ".setToolTipText(" + TypeManager.getJavaCode(value) + ");"); + } else if (name.equals("icon")) { + Icon icon = (Icon) TypeManager.convertFromString(value, Icon.class); + tabInfo.setIcon(icon); + compiledTabInfo.appendInitializationCode(id + ".setIcon(" + TypeManager.getJavaCode(icon) + ");"); + } else if (name.equals("enabled")) { + boolean enabled = (Boolean) TypeManager.convertFromString(value, Boolean.class); + tabInfo.setEnabled(enabled); + compiledTabInfo.appendInitializationCode(id + ".setEnabled(" + enabled + ");"); + } else if (name.equals("disabledIcon")) { + Icon disabledIcon = (Icon) TypeManager.convertFromString(value, Icon.class); + tabInfo.setDisabledIcon(disabledIcon); + compiledTabInfo.appendInitializationCode(id + ".setDisabledIcon(" + TypeManager.getJavaCode(disabledIcon) + ");"); + } else if (name.equals("mnemonic")) { + int mnemonic = (Character) TypeManager.convertFromString(value, char.class); + tabInfo.setMnemonic(mnemonic); + compiledTabInfo.appendInitializationCode(id + ".setMnemonic(" + mnemonic + ");"); + } else if (name.equals("displayedMnemonicIndex")) { + int displayedMnemonicIndex = (Integer) TypeManager.convertFromString(value, int.class); + tabInfo.setDisplayedMnemonicIndex(displayedMnemonicIndex); + compiledTabInfo.appendInitializationCode(id + ".setDisplayedMnemonicIndex(" + displayedMnemonicIndex + ");"); + } else if (name.equals("foreground")) { + Color foreground = (Color) TypeManager.convertFromString(value, Color.class); + tabInfo.setForeground(foreground); + compiledTabInfo.appendInitializationCode(id + ".setForeground(" + TypeManager.getJavaCode(foreground) + ");"); + } else if (name.equals("background")) { + Color background = (Color) TypeManager.convertFromString(value, Color.class); + tabInfo.setBackground(background); + compiledTabInfo.appendInitializationCode(id + ".setBackground(" + TypeManager.getJavaCode(background) + ");"); + } else { + compiler.reportError("The <tab> tag does not support the attribute '" + name + "'"); + } + } + + public void setAttributes(CompiledObject compiledTabInfo, JTabbedPaneHandler.CompiledTabbedPane tabs, Element tag, JAXXCompiler compiler) throws CompilerException { + NamedNodeMap children = tag.getAttributes(); + for (int i = 0; i < children.getLength(); i++) { + Attr attribute = (Attr) children.item(i); + String name = attribute.getName(); + String value = attribute.getValue(); + if (!name.startsWith("xmlns") && !JAXXCompiler.JAXX_INTERNAL_NAMESPACE.equals(attribute.getNamespaceURI())) { + setAttribute(compiledTabInfo, tabs, name, value, compiler); + } + } + } + + protected void compileChildrenFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + NodeList children = tag.getChildNodes(); + for (int i = 0; i < children.getLength(); i++) { + Node node = children.item(i); + int nodeType = node.getNodeType(); + if (nodeType == Node.ELEMENT_NODE) { + Element child = (Element) node; + compileChildTagFirstPass(child, compiler); + } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) { + String text = ((Text) node).getData().trim(); + if (text.length() > 0) { + compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')"); + } + } + } + } + + protected void compileChildTagFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + compiler.compileFirstPass(tag); + } + + protected void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + NodeList children = tag.getChildNodes(); + for (int i = 0; i < children.getLength(); i++) { + Node node = children.item(i); + int nodeType = node.getNodeType(); + if (nodeType == Node.ELEMENT_NODE) { + Element child = (Element) node; + compileChildTagSecondPass(child, compiler); + } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) { + String text = ((Text) node).getData().trim(); + if (text.length() > 0) { + compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')"); + } + } + } + } + + protected void compileChildTagSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + compiler.compileSecondPass(tag); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TableHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TableHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TableHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,140 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.swing; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.UnsupportedAttributeException; -import jaxx.compiler.CompiledObject; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.tags.DefaultComponentHandler; -import jaxx.compiler.types.TypeManager; -import jaxx.runtime.swing.Table; - -import java.awt.GridBagConstraints; -import java.awt.Insets; -import java.util.ArrayList; -import java.util.List; - -public class TableHandler extends DefaultComponentHandler { - - public static final Insets DEFAULT_INSETS = new Insets(3, 3, 3, 3); - - public TableHandler(ClassDescriptor beanClass) { - super(beanClass); - ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, Table.class); - } - - @Override - public void setAttribute(CompiledObject object, String propertyName, String stringValue, boolean inline, JAXXCompiler compiler) throws CompilerException { - try { - if (object instanceof CompiledTable) { - CellHandler.setAttribute(((CompiledTable) object).getTableConstraints(), propertyName, stringValue); - } else { - super.setAttribute(object, propertyName, stringValue, inline, compiler); - } - } catch (UnsupportedAttributeException e) { - super.setAttribute(object, propertyName, stringValue, inline, compiler); - } - } - - class CompiledTable extends CompiledObject { - - private List<Integer> rowSpans = new ArrayList<Integer>(); - private GridBagConstraints tableConstraints; - private GridBagConstraints rowConstraints = null; - private GridBagConstraints cellConstraints = null; - private boolean emptyCell; - - public CompiledTable(String id, ClassDescriptor objectClass, JAXXCompiler compiler) throws CompilerException { - super(id, objectClass, compiler); - tableConstraints = new GridBagConstraints(); - tableConstraints.gridx = -1; - tableConstraints.gridy = -1; - tableConstraints.insets = DEFAULT_INSETS; - } - - @Override - public void addChild(CompiledObject child, String constraints, JAXXCompiler compiler) throws CompilerException { - if (constraints != null) { - compiler.reportError("Table does not accept constraints"); - } - GridBagConstraints c = getCellConstraints(); - if (c == null) { - compiler.reportError("Table tag may only contain row tags"); - return; - } - if (!emptyCell) { - compiler.reportError("Table cells may only have one child component"); - } - while (rowSpans.size() < c.gridx + c.gridwidth) { - rowSpans.add(null); - } - for (int x = c.gridx; x < c.gridx + c.gridwidth; x++) { - rowSpans.set(x, c.gridheight); - } - - super.addChild(child, TypeManager.getJavaCode(c), compiler); - - emptyCell = false; - } - - public GridBagConstraints getTableConstraints() { - return tableConstraints; - } - - public GridBagConstraints getRowConstraints() { - return rowConstraints; - } - - public GridBagConstraints getCellConstraints() { - return cellConstraints; - } - - public void newRow() { - tableConstraints.gridy++; - tableConstraints.gridx = -1; - rowConstraints = (GridBagConstraints) tableConstraints.clone(); - - for (int x = 0; x < rowSpans.size(); x++) { - int rowSpan = rowSpans.get(x); - if (rowSpan > 0) { - rowSpans.set(x, rowSpan - 1); - } - } - } - - public void newCell() { - emptyCell = true; - rowConstraints.gridx++; - while (rowConstraints.gridx < rowSpans.size() && rowSpans.get(rowConstraints.gridx) > 0) { - rowConstraints.gridx++; - } - cellConstraints = (GridBagConstraints) rowConstraints.clone(); - } - } - - @Override - public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException { - return new CompiledTable(id, getBeanClass(), compiler); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TableHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TableHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TableHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TableHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,140 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.swing; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.UnsupportedAttributeException; +import jaxx.compiler.CompiledObject; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.tags.DefaultComponentHandler; +import jaxx.compiler.types.TypeManager; +import jaxx.runtime.swing.Table; + +import java.awt.GridBagConstraints; +import java.awt.Insets; +import java.util.ArrayList; +import java.util.List; + +public class TableHandler extends DefaultComponentHandler { + + public static final Insets DEFAULT_INSETS = new Insets(3, 3, 3, 3); + + public TableHandler(ClassDescriptor beanClass) { + super(beanClass); + ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, Table.class); + } + + @Override + public void setAttribute(CompiledObject object, String propertyName, String stringValue, boolean inline, JAXXCompiler compiler) throws CompilerException { + try { + if (object instanceof CompiledTable) { + CellHandler.setAttribute(((CompiledTable) object).getTableConstraints(), propertyName, stringValue); + } else { + super.setAttribute(object, propertyName, stringValue, inline, compiler); + } + } catch (UnsupportedAttributeException e) { + super.setAttribute(object, propertyName, stringValue, inline, compiler); + } + } + + class CompiledTable extends CompiledObject { + + private List<Integer> rowSpans = new ArrayList<Integer>(); + private GridBagConstraints tableConstraints; + private GridBagConstraints rowConstraints = null; + private GridBagConstraints cellConstraints = null; + private boolean emptyCell; + + public CompiledTable(String id, ClassDescriptor objectClass, JAXXCompiler compiler) throws CompilerException { + super(id, objectClass, compiler); + tableConstraints = new GridBagConstraints(); + tableConstraints.gridx = -1; + tableConstraints.gridy = -1; + tableConstraints.insets = DEFAULT_INSETS; + } + + @Override + public void addChild(CompiledObject child, String constraints, JAXXCompiler compiler) throws CompilerException { + if (constraints != null) { + compiler.reportError("Table does not accept constraints"); + } + GridBagConstraints c = getCellConstraints(); + if (c == null) { + compiler.reportError("Table tag may only contain row tags"); + return; + } + if (!emptyCell) { + compiler.reportError("Table cells may only have one child component"); + } + while (rowSpans.size() < c.gridx + c.gridwidth) { + rowSpans.add(null); + } + for (int x = c.gridx; x < c.gridx + c.gridwidth; x++) { + rowSpans.set(x, c.gridheight); + } + + super.addChild(child, TypeManager.getJavaCode(c), compiler); + + emptyCell = false; + } + + public GridBagConstraints getTableConstraints() { + return tableConstraints; + } + + public GridBagConstraints getRowConstraints() { + return rowConstraints; + } + + public GridBagConstraints getCellConstraints() { + return cellConstraints; + } + + public void newRow() { + tableConstraints.gridy++; + tableConstraints.gridx = -1; + rowConstraints = (GridBagConstraints) tableConstraints.clone(); + + for (int x = 0; x < rowSpans.size(); x++) { + int rowSpan = rowSpans.get(x); + if (rowSpan > 0) { + rowSpans.set(x, rowSpan - 1); + } + } + } + + public void newCell() { + emptyCell = true; + rowConstraints.gridx++; + while (rowConstraints.gridx < rowSpans.size() && rowSpans.get(rowConstraints.gridx) > 0) { + rowConstraints.gridx++; + } + cellConstraints = (GridBagConstraints) rowConstraints.clone(); + } + } + + @Override + public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException { + return new CompiledTable(id, getBeanClass(), compiler); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/BeanValidatorHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/BeanValidatorHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/BeanValidatorHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,738 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.validator; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.CompiledObject; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.beans.JAXXBeanInfo; -import jaxx.compiler.beans.JAXXPropertyDescriptor; -import jaxx.compiler.binding.DataBindingHelper; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.tags.DefaultObjectHandler; -import jaxx.compiler.types.TypeManager; -import jaxx.runtime.validator.swing.SwingValidatorUtil; -import jaxx.runtime.validator.swing.SwingValidator; -import jaxx.runtime.validator.swing.ui.AbstractBeanValidatorUI; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.w3c.dom.Element; - -import java.beans.IntrospectionException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.TreeMap; - -public class BeanValidatorHandler extends DefaultObjectHandler { - - public static final String TAG = "BeanValidator"; - public static final String BEAN_ATTRIBUTE = "bean"; - public static final String BEAN_CLASS_ATTRIBUTE = "beanClass"; - public static final String BEAN_INITIALIZER_ATTRIBUTE = "beanInitializer"; - public static final String ERROR_LIST_MODEL_ATTRIBUTE = "errorListModel"; - public static final String ERROR_TABLE_MODEL_ATTRIBUTE = "errorTableModel"; - public static final String ERROR_LIST_ATTRIBUTE = "errorList"; - public static final String ERROR_TABLE_ATTRIBUTE = "errorTable"; - //TODO-TC20091024 should change this default value to errorListModel - public static final String ERROR_LIST_MODEL_DEFAULT = "errors"; - //TODO-TC20091024 should change this default value to errorTableModel - public static final String ERROR_TABLE_MODEL_DEFAULT = "errors2"; - public static final String ERROR_LIST_DEFAULT = "errorList"; - public static final String ERROR_TABLE_DEFAULT = "errorTable"; - public static final String AUTOFIELD_ATTRIBUTE = "autoField"; - public static final String UI_CLASS_ATTRIBUTE = "uiClass"; - public static final String STRICT_MODE_ATTRIBUTE = "strictMode"; - public static final String CONTEXT_NAME_ATTRIBUTE = "contextName"; - //public static final String SCOPE_ATTRIBUTE = "scope"; - public static final String PARENT_VALIDATOR_ATTRIBUTE = "parentValidator"; - /** - * to use log facility, just put in your code: log.info(\"...\"); - */ - static Log log = LogFactory.getLog(BeanValidatorHandler.class); - protected static Map<JAXXCompiler, List<CompiledBeanValidator>> validators = new HashMap<JAXXCompiler, List<CompiledBeanValidator>>(); - protected static Map<JAXXCompiler, List<String>> validatedComponents = new HashMap<JAXXCompiler, List<String>>(); - - public BeanValidatorHandler(ClassDescriptor beanClass) { - super(beanClass); - ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, SwingValidator.class); - } - - @Override - protected CompiledObject createCompiledObject(String id, JAXXCompiler compiler) { - return new CompiledBeanValidator(id, getBeanClass(), compiler); - } - - @Override - protected void compileChildTagFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - if (log.isDebugEnabled()) { - log.debug(tag); - } - if (!tag.getLocalName().equals(FieldValidatorHandler.TAG)) { - compiler.reportError("tag '" + tag.getParentNode().getLocalName() + "' may only contain " + FieldValidatorHandler.TAG + " as children, but found : " + tag.getLocalName()); - } else { - compiler.compileFirstPass(tag); - } - } - - @Override - public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - - super.compileSecondPass(tag, compiler); - - CompiledBeanValidator info = (CompiledBeanValidator) objectMap.get(tag); - - boolean error = info.addErrorListModel(tag, this, compiler); - - if (!error) { - error = info.addErrorList(tag, compiler); - } - - if (!error) { - error = info.addErrorTableModel(tag, this, compiler); - } - - if (!error) { - error = info.addErrorTable(tag, compiler); - } - - if (!error) { - error = info.addUiClass(this, compiler); - } - - if (!error) { - error = info.addBean(tag, this, compiler); - } - - /*if (!error) { - error = info.addContextName(this, compiler); - }*/ - - /*if (!error) { - error = info.addScope(this, compiler); - }*/ - - if (!error) { - error = info.addParentValidator(tag, this, compiler); - } - - if (error) { - log.warn("error were detected in second compile pass of CompiledObject [" + info + "]"); - } - - // close the compiled object - compiler.closeComponent(info); - } - - @Override - protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) { - // open the compiled object - compiler.openInvisibleComponent(object); - } - - @Override - public void setAttribute(CompiledObject object, String propertyName, String stringValue, boolean inline, JAXXCompiler compiler) { - if (log.isDebugEnabled()) { - log.debug(propertyName + " : " + stringValue + " for " + object); - } - // delegate to the compiled object with is statefull (but not the tag handler) - object.addProperty(propertyName, stringValue); - } - - /** - * The compiled objet representing a BeanValidator to be generated in JAXXObject - * - * @author chemit - */ - public static class CompiledBeanValidator extends CompiledObject { - - protected Map<String, String> fields; - protected Map<String, String> excludeFields; - protected String bean; - protected String beanClass; - protected String contextName; - protected String uiClass; - protected String errorListModel; - protected String errorList; - protected Boolean autoField; - protected Boolean strictMode; - protected JAXXBeanInfo beanDescriptor; - protected String errorTableModel; - protected String errorTable; - protected String parentValidator; - - public CompiledBeanValidator(String id, ClassDescriptor objectClass, JAXXCompiler compiler) { - //TC-20090524 Use the real class descriptor, not the one by default, - //TC-20090524 otherwise can not override the validator class while generation - //super(id, objectClass, compiler); - super(id, getDescriptor(objectClass, compiler), compiler); - fields = new TreeMap<String, String>(); - excludeFields = new TreeMap<String, String>(); - if (log.isDebugEnabled()) { - log.debug("validator objectClass " + super.getObjectClass()); - } - } - - protected static ClassDescriptor getDescriptor(ClassDescriptor objectClass, JAXXCompiler compiler) { - ClassDescriptor result = objectClass; - Class<?> validatorClass = compiler.getConfiguration().getValidatorClass(); - result = ClassDescriptorLoader.getClassDescriptor(validatorClass); - return result; - } - - public Map<String, String> getFields() { - return fields; - } - - public Map<String, String> getExcludeFields() { - return excludeFields; - } - - public void setFields(Map<String, String> fields) { - this.fields = fields; - } - - public void setExcludeFields(Map<String, String> excludeFields) { - this.excludeFields = excludeFields; - } - - @Override - public void addProperty(String property, String value) { - - if (BEAN_ATTRIBUTE.equals(property)) { - if (value != null && !value.trim().isEmpty()) { - bean = value.trim(); - } - return; - } - - if (CONTEXT_NAME_ATTRIBUTE.equals(property)) { - if (value != null && !value.trim().isEmpty()) { - contextName = value.trim(); - } - return; - } - - if (BEAN_CLASS_ATTRIBUTE.equals(property)) { - if (value != null && !value.trim().isEmpty()) { - beanClass = value.trim(); - } - return; - } - - if (ERROR_LIST_MODEL_ATTRIBUTE.equals(property)) { - if (value != null && !value.trim().isEmpty()) { - errorListModel = value.trim(); - } - return; - } - - if (ERROR_LIST_ATTRIBUTE.equals(property)) { - if (value != null && !value.trim().isEmpty()) { - errorList = value.trim(); - } - return; - } - - if (ERROR_TABLE_MODEL_ATTRIBUTE.equals(property)) { - if (value != null && !value.trim().isEmpty()) { - errorTableModel = value.trim(); - } - return; - } - - if (ERROR_TABLE_ATTRIBUTE.equals(property)) { - if (value != null && !value.trim().isEmpty()) { - errorTable = value.trim(); - } - return; - } - - if (UI_CLASS_ATTRIBUTE.equals(property)) { - if (value != null && !value.trim().isEmpty()) { - uiClass = value.trim(); - } - return; - } - - if (AUTOFIELD_ATTRIBUTE.equals(property)) { - if (value != null && !value.trim().isEmpty()) { - autoField = (Boolean) TypeManager.convertFromString(value.trim(), Boolean.class); - } - return; - } - - if (STRICT_MODE_ATTRIBUTE.equals(property)) { - if (value != null && !value.trim().isEmpty()) { - strictMode = (Boolean) TypeManager.convertFromString(value.trim(), Boolean.class); - } - return; - } - - if (PARENT_VALIDATOR_ATTRIBUTE.equals(property)) { - if (value != null && !value.trim().isEmpty()) { - parentValidator = value.trim(); - } - return; - } - - throw new CompilerException("property " + property + " is not allowed on object " + this); - } - - public String getBean() { - return bean; - } - - public String getErrorListModel() { - return errorListModel; - } - - public boolean getAutoField() { - return autoField != null && autoField; - } - - public boolean getStrictMode() { - return strictMode != null && strictMode; - } - - public String getUiClass() { - return uiClass; - } - - public String getBeanClass() { - return beanClass; - } - - public String getContextName() { - return contextName; - } - - public String getParentValidator() { - return parentValidator; - } - - public JAXXBeanInfo getBeanDescriptor(JAXXCompiler compiler) { - if (beanDescriptor == null && foundBean()) { - - String beanClassName = null; - try { - //TC-20090111 beanClass is mandatory - // get the real bean class name (from bean or beanClass) - /*if (beanClass != null) { - beanClassName = beanClass; - } else { - beanClassName = compiler.getSymbolTable().getClassTagIds().get(bean); - if (beanClassName == null) { - compiler.reportError("could not find class of the bean '" + bean + "'"); - return null; - } - }*/ - ClassDescriptor beanClassDescriptor = ClassDescriptorLoader.getClassDescriptor(beanClass); - beanDescriptor = DefaultObjectHandler.getJAXXBeanInfo(beanClassDescriptor); - } catch (ClassNotFoundException e) { - compiler.reportError("could not load class " + beanClassName); - } catch (IntrospectionException e) { - compiler.reportError("could not load class " + beanClassName); - } - } - return beanDescriptor; - } - - @Override - public void addChild(CompiledObject child, String constraints, JAXXCompiler compiler) throws CompilerException { - // do nothing - compiler.reportError("can not add CompiledObject in the tag '" + TAG + " (only field tags)"); - } - - public boolean foundBean() { - return !(beanClass == null || beanClass.isEmpty()); - } - - protected boolean addUiClass(BeanValidatorHandler handler, JAXXCompiler compiler) { - boolean withError = false; - if (uiClass == null && compiler.getConfiguration().getDefaultErrorUI() != null) { - uiClass = compiler.getConfiguration().getDefaultErrorUI().getName(); - } - if (uiClass != null) { - try { - ClassDescriptor uiClazz = ClassDescriptorLoader.getClassDescriptor(uiClass); - if (!ClassDescriptorLoader.getClassDescriptor(AbstractBeanValidatorUI.class).isAssignableFrom(uiClazz)) { - compiler.reportError("attribute 'ui' :'" + uiClass + "' is not assignable from class " + AbstractBeanValidatorUI.class); - withError = true; - } else { - String code = handler.getSetPropertyCode(getJavaCode(), UI_CLASS_ATTRIBUTE, uiClazz.getName() + ".class", compiler); - appendAdditionCode(code); - } - } catch (ClassNotFoundException e) { - compiler.reportError("class not found '" + uiClass + "'"); - withError = true; - } - } - - return withError; - } - - protected boolean addErrorListModel(Element tag, BeanValidatorHandler handler, JAXXCompiler compiler) { - if (errorListModel == null) { - // try with the default "errors" - if (!compiler.checkReference(tag, ERROR_LIST_MODEL_DEFAULT, false, ERROR_LIST_MODEL_ATTRIBUTE)) { - return false; - } - errorListModel = ERROR_LIST_MODEL_DEFAULT; - } else { - if (errorListModel.startsWith("{") && errorListModel.endsWith("}")) { - // this is a script, no check here - errorListModel = errorListModel.substring(1, errorListModel.length() - 1).trim(); - } else if (!compiler.checkReference(tag, errorListModel, true, ERROR_LIST_MODEL_ATTRIBUTE)) { - // errorListModel is not defined - return true; - } - } - - String code = handler.getSetPropertyCode(getJavaCode(), ERROR_LIST_MODEL_ATTRIBUTE, errorListModel, compiler); - appendAdditionCode(code); - - return false; - } - - protected boolean addErrorTableModel(Element tag, BeanValidatorHandler handler, JAXXCompiler compiler) { - if (errorTableModel == null) { - // try with the default "errors" - if (!compiler.checkReference(tag, ERROR_TABLE_MODEL_DEFAULT, false, ERROR_LIST_MODEL_ATTRIBUTE)) { - return false; - } - errorTableModel = ERROR_TABLE_MODEL_DEFAULT; - } else { - if (errorTableModel.startsWith("{") && errorTableModel.endsWith("}")) { - // this is a script, no check here - errorTableModel = errorTableModel.substring(1, errorTableModel.length() - 1).trim(); - } else if (!compiler.checkReference(tag, errorTableModel, true, ERROR_TABLE_MODEL_ATTRIBUTE)) { - // errorListModel is not defined - return true; - } - } - - String code = handler.getSetPropertyCode(getJavaCode(), ERROR_TABLE_MODEL_ATTRIBUTE, errorTableModel, compiler); - appendAdditionCode(code); - - return false; - - } - - protected boolean addParentValidator(Element tag, BeanValidatorHandler handler, JAXXCompiler compiler) { - if (parentValidator != null) { - String initializer; - if (parentValidator.startsWith("{") && parentValidator.endsWith("}")) { - - // todo : should be able to bind - initializer = parentValidator.substring(1, parentValidator.length() - 1); - - } else { - // the attribute referes an existing widget - if (!compiler.checkReference(tag, parentValidator, true, PARENT_VALIDATOR_ATTRIBUTE)) { - // parentValidator is not defined - return true; - } - initializer = parentValidator; - } - String code = handler.getSetPropertyCode(getJavaCode(), PARENT_VALIDATOR_ATTRIBUTE, initializer, compiler); - appendAdditionCode(code); - } - return false; - } - - protected boolean addErrorList(Element tag, JAXXCompiler compiler) { - - if (errorList == null) { - // try with the default "errorList" - if (!compiler.checkReference(tag, ERROR_LIST_DEFAULT, false, ERROR_LIST_ATTRIBUTE)) { - return false; - } - errorList = ERROR_LIST_DEFAULT; - } else { - if (!compiler.checkReference(tag, errorList, true, ERROR_LIST_ATTRIBUTE)) { - return true; - } - } - - String code = SwingValidatorUtil.class.getName() + ".registerErrorListMouseListener(" + errorList + ");"; - appendAdditionCode(code); - - return false; - } - - protected boolean addErrorTable(Element tag, JAXXCompiler compiler) { - - if (errorTable == null) { - // try with the default "errorList" - if (!compiler.checkReference(tag, ERROR_TABLE_DEFAULT, false, ERROR_TABLE_ATTRIBUTE)) { - return false; - } - errorTable = ERROR_TABLE_DEFAULT; - } else { - if (!compiler.checkReference(tag, errorTable, true, ERROR_TABLE_ATTRIBUTE)) { - return true; - } - } - - String code = SwingValidatorUtil.class.getName() + ".registerErrorTableMouseListener(" + errorTable + ");"; - appendAdditionCode(code); - - return false; - } - - protected boolean addBean(Element tag, BeanValidatorHandler handler, JAXXCompiler compiler) { - - if (beanClass == null || beanClass.isEmpty()) { - // try to guest beanClass from bean attribute - if (bean != null && !bean.isEmpty()) { - beanClass = compiler.getSymbolTable().getClassTagIds().get(bean); - if (beanClass == null) { - compiler.reportError("could not find class of the bean '" + bean + "', and no beanClass was setted"); - return true; - } - } - } - if (beanClass == null) { - compiler.reportError("tag '" + tag + "' requires a 'beanClass' attribute, and could not guest it from 'bean' attribute (no bean attribute setted...)"); - return true; - } - - JAXXBeanInfo beanInfo = getBeanDescriptor(compiler); - if (beanInfo == null) { - compiler.reportError(tag, "could not find descriptor of class " + beanClass); - return true; - } - - String beanInitializer = null; - if (bean != null) { - - if (bean.startsWith("{") && bean.endsWith("}")) { - - String labelBinding = DataBindingHelper.processDataBindings(bean); - if (labelBinding != null) { - compiler.getBindingHelper().registerDataBinding(getId() + ".bean", labelBinding, getId() + ".setBean(" + labelBinding + ");"); - } -// // just has an intializer -// beanInitializer = bean.substring(1, bean.length() - 1); -// // this is not a real bean, so delete it - bean = null; - } else { - - if (!compiler.checkReference(tag, bean, true, BEAN_ATTRIBUTE)) { - // could not find bean in compiled object - return true; - } - - if (isBeanUsedByValidator(compiler, bean)) { - compiler.reportError("the bean '" + bean + "' is already used in another the validator, can not used it in '" + tag + "'"); - return true; - } - - /*if (beanInitializer != null) { - compiler.reportWarning("tag '" + tag + "' found a 'bean' and a 'beanInitializer' attributes, 'beanInitializer' is skipped"); - }*/ - beanInitializer = bean; - } - } - - if (beanInitializer != null) { - String code = handler.getSetPropertyCode(getJavaCode(), BEAN_ATTRIBUTE, compiler.checkJavaCode(beanInitializer), compiler); - appendAdditionCode(code); - } - - String beanClassName = beanInfo.getJAXXBeanDescriptor().getClassDescriptor().getName(); - // contextName must be in constructor to able to init validator with his correct contextName - setConstructorParams(beanClassName + ".class, " + TypeManager.getJavaCode(contextName)); - // add generic type to validator - setGenericTypes(new String[]{beanClassName}); - - if (getAutoField()) { - registerAutoFieldBean(tag, compiler, beanInfo); - } - - if (getBeanDescriptor(compiler) != null) { - - // add fieldrepresentation invocations - addFieldRepresentations(tag, compiler); - - // register the validator in compiler - registerValidator(compiler, this); - - } - - return false; - } - - private void registerValidator(JAXXCompiler compiler, CompiledBeanValidator compiledBeanValidator) { - List<CompiledBeanValidator> vals = validators.get(compiler); - if (vals == null) { - vals = new ArrayList<CompiledBeanValidator>(); - validators.put(compiler, vals); - } - vals.add(compiledBeanValidator); - List<String> ids = validatedComponents.get(compiler); - if (ids == null) { - ids = new ArrayList<String>(); - validatedComponents.put(compiler, ids); - } - ids.addAll(compiledBeanValidator.getFields().values()); - } - - protected void addFieldRepresentations(Element tag, JAXXCompiler compiler) { - for (Entry<String, String> entry : fields.entrySet()) { - String propertyName = entry.getKey(); - String component = entry.getValue(); - if (!checkBeanProperty(compiler, propertyName)) { - // property not find on bean - continue; - } - if (!compiler.checkReference(tag, component, true, null)) { - // editor component not find on ui - continue; - } - String keyCode = TypeManager.getJavaCode(propertyName); - appendAdditionCode(getJavaCode() + ".setFieldRepresentation(" + keyCode + ", " + component + ");"); - } - } - - protected void registerAutoFieldBean(Element tag, JAXXCompiler compiler, JAXXBeanInfo beanInfo) { - for (JAXXPropertyDescriptor beanProperty : beanInfo.getJAXXPropertyDescriptors()) { - String descriptionName = beanProperty.getName(); - if (log.isDebugEnabled()) { - log.debug("try to bind on bean " + beanInfo.getJAXXBeanDescriptor().getName() + " property " + descriptionName); - } - if (beanProperty.getWriteMethodDescriptor() == null) { - // read-only property - continue; - } - if (fields.containsKey(descriptionName)) { - // already defined in field - continue; - } - if (excludeFields.containsKey(descriptionName)) { - // exclude field - continue; - } - if (!compiler.checkReference(tag, descriptionName, getStrictMode(), null)) { - // no editor component found - continue; - } - // ok add the field mapping - registerField(descriptionName, descriptionName, compiler); - } - - for (Entry<String, String> entry : excludeFields.entrySet()) { - String key = entry.getKey(); - if (fields.containsKey(key)) { - compiler.reportWarning("field '" + key + "' can not be used and excluded at same time ! (field is skipped) for validator " + this); - fields.remove(key); - } - } - } - - public void registerField(String id, String component, JAXXCompiler compiler) { - if (fields.containsKey(id)) { - compiler.reportError("duplicate field '" + id + "' for validator " + this); - } else { - if (log.isDebugEnabled()) { - log.debug("add field <" + id + ":" + component + ">"); - } - fields.put(id, component); - } - } - - public void registerExcludeField(String id, String component, JAXXCompiler compiler) { - if (excludeFields.containsKey(id)) { - compiler.reportError("duplicate field '" + id + "' for validator " + this); - } else { - if (log.isDebugEnabled()) { - log.debug("add excludeField <" + id + ":" + component + ">"); - } - excludeFields.put(id, component); - } - } - - protected boolean checkBeanProperty(JAXXCompiler compiler, String propertyName) { - - for (JAXXPropertyDescriptor beanProperty : getBeanDescriptor(compiler).getJAXXPropertyDescriptors()) { - if (beanProperty.getName().equals(propertyName)) { - if (beanProperty.getWriteMethodDescriptor() == null) { - // read-onlyproperty - compiler.reportError("could not bind the readonly property '" + propertyName + "' on bean [" + getBean() + "] "); - return false; - } - return true; - } - } - compiler.reportError("could not find the property '" + propertyName + "' on bean [" + getBean() + "] "); - return false; - } - } - - /** - * Test if a given bean is attached to a validator. - * - * @param compiler current compiler to use - * @param beanId the bean to test - * @return <code>true</code> if the given bean is attached to a validator, <code>false</code> otherwise - */ - public static boolean isBeanUsedByValidator(JAXXCompiler compiler, String beanId) { - List<CompiledBeanValidator> beanValidatorList = validators.get(compiler); - if (beanValidatorList != null) { - for (CompiledBeanValidator validator : beanValidatorList) { - if (beanId.equals(validator.getBean())) { - return true; - } - } - } - return false; - } - - /** - * @param compiler compiler to use - * @return <code>true</code> if some validators were detected, <code>false</code> otherwise - */ - public static boolean hasValidator(JAXXCompiler compiler) { - List<CompiledBeanValidator> beanValidatorList = validators.get(compiler); - return beanValidatorList != null && !beanValidatorList.isEmpty(); - } - - /** - * Test if a given CompiledObject is attached to a validator. - * - * @param compiler compiler to use - * @param componentId the compiled object to test - * @return <code>true</code> if the given compiled object is attached to a validator, <code>false</code> otherwise - */ - public static boolean isComponentUsedByValidator(JAXXCompiler compiler, String componentId) { - List<String> ids = validatedComponents.get(compiler); - return ids != null && ids.contains(componentId); - } - - public static List<CompiledBeanValidator> getValidators(JAXXCompiler compiler) { - return validators.get(compiler); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/BeanValidatorHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/BeanValidatorHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/BeanValidatorHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/BeanValidatorHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,738 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.validator; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.CompiledObject; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.beans.JAXXBeanInfo; +import jaxx.compiler.beans.JAXXPropertyDescriptor; +import jaxx.compiler.binding.DataBindingHelper; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.tags.DefaultObjectHandler; +import jaxx.compiler.types.TypeManager; +import jaxx.runtime.validator.swing.SwingValidatorUtil; +import jaxx.runtime.validator.swing.SwingValidator; +import jaxx.runtime.validator.swing.ui.AbstractBeanValidatorUI; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.w3c.dom.Element; + +import java.beans.IntrospectionException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.TreeMap; + +public class BeanValidatorHandler extends DefaultObjectHandler { + + public static final String TAG = "BeanValidator"; + public static final String BEAN_ATTRIBUTE = "bean"; + public static final String BEAN_CLASS_ATTRIBUTE = "beanClass"; + public static final String BEAN_INITIALIZER_ATTRIBUTE = "beanInitializer"; + public static final String ERROR_LIST_MODEL_ATTRIBUTE = "errorListModel"; + public static final String ERROR_TABLE_MODEL_ATTRIBUTE = "errorTableModel"; + public static final String ERROR_LIST_ATTRIBUTE = "errorList"; + public static final String ERROR_TABLE_ATTRIBUTE = "errorTable"; + //TODO-TC20091024 should change this default value to errorListModel + public static final String ERROR_LIST_MODEL_DEFAULT = "errors"; + //TODO-TC20091024 should change this default value to errorTableModel + public static final String ERROR_TABLE_MODEL_DEFAULT = "errors2"; + public static final String ERROR_LIST_DEFAULT = "errorList"; + public static final String ERROR_TABLE_DEFAULT = "errorTable"; + public static final String AUTOFIELD_ATTRIBUTE = "autoField"; + public static final String UI_CLASS_ATTRIBUTE = "uiClass"; + public static final String STRICT_MODE_ATTRIBUTE = "strictMode"; + public static final String CONTEXT_NAME_ATTRIBUTE = "contextName"; + //public static final String SCOPE_ATTRIBUTE = "scope"; + public static final String PARENT_VALIDATOR_ATTRIBUTE = "parentValidator"; + /** + * to use log facility, just put in your code: log.info(\"...\"); + */ + static Log log = LogFactory.getLog(BeanValidatorHandler.class); + protected static Map<JAXXCompiler, List<CompiledBeanValidator>> validators = new HashMap<JAXXCompiler, List<CompiledBeanValidator>>(); + protected static Map<JAXXCompiler, List<String>> validatedComponents = new HashMap<JAXXCompiler, List<String>>(); + + public BeanValidatorHandler(ClassDescriptor beanClass) { + super(beanClass); + ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, SwingValidator.class); + } + + @Override + protected CompiledObject createCompiledObject(String id, JAXXCompiler compiler) { + return new CompiledBeanValidator(id, getBeanClass(), compiler); + } + + @Override + protected void compileChildTagFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + if (log.isDebugEnabled()) { + log.debug(tag); + } + if (!tag.getLocalName().equals(FieldValidatorHandler.TAG)) { + compiler.reportError("tag '" + tag.getParentNode().getLocalName() + "' may only contain " + FieldValidatorHandler.TAG + " as children, but found : " + tag.getLocalName()); + } else { + compiler.compileFirstPass(tag); + } + } + + @Override + public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + + super.compileSecondPass(tag, compiler); + + CompiledBeanValidator info = (CompiledBeanValidator) objectMap.get(tag); + + boolean error = info.addErrorListModel(tag, this, compiler); + + if (!error) { + error = info.addErrorList(tag, compiler); + } + + if (!error) { + error = info.addErrorTableModel(tag, this, compiler); + } + + if (!error) { + error = info.addErrorTable(tag, compiler); + } + + if (!error) { + error = info.addUiClass(this, compiler); + } + + if (!error) { + error = info.addBean(tag, this, compiler); + } + + /*if (!error) { + error = info.addContextName(this, compiler); + }*/ + + /*if (!error) { + error = info.addScope(this, compiler); + }*/ + + if (!error) { + error = info.addParentValidator(tag, this, compiler); + } + + if (error) { + log.warn("error were detected in second compile pass of CompiledObject [" + info + "]"); + } + + // close the compiled object + compiler.closeComponent(info); + } + + @Override + protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) { + // open the compiled object + compiler.openInvisibleComponent(object); + } + + @Override + public void setAttribute(CompiledObject object, String propertyName, String stringValue, boolean inline, JAXXCompiler compiler) { + if (log.isDebugEnabled()) { + log.debug(propertyName + " : " + stringValue + " for " + object); + } + // delegate to the compiled object with is statefull (but not the tag handler) + object.addProperty(propertyName, stringValue); + } + + /** + * The compiled objet representing a BeanValidator to be generated in JAXXObject + * + * @author chemit + */ + public static class CompiledBeanValidator extends CompiledObject { + + protected Map<String, String> fields; + protected Map<String, String> excludeFields; + protected String bean; + protected String beanClass; + protected String contextName; + protected String uiClass; + protected String errorListModel; + protected String errorList; + protected Boolean autoField; + protected Boolean strictMode; + protected JAXXBeanInfo beanDescriptor; + protected String errorTableModel; + protected String errorTable; + protected String parentValidator; + + public CompiledBeanValidator(String id, ClassDescriptor objectClass, JAXXCompiler compiler) { + //TC-20090524 Use the real class descriptor, not the one by default, + //TC-20090524 otherwise can not override the validator class while generation + //super(id, objectClass, compiler); + super(id, getDescriptor(objectClass, compiler), compiler); + fields = new TreeMap<String, String>(); + excludeFields = new TreeMap<String, String>(); + if (log.isDebugEnabled()) { + log.debug("validator objectClass " + super.getObjectClass()); + } + } + + protected static ClassDescriptor getDescriptor(ClassDescriptor objectClass, JAXXCompiler compiler) { + ClassDescriptor result = objectClass; + Class<?> validatorClass = compiler.getConfiguration().getValidatorClass(); + result = ClassDescriptorLoader.getClassDescriptor(validatorClass); + return result; + } + + public Map<String, String> getFields() { + return fields; + } + + public Map<String, String> getExcludeFields() { + return excludeFields; + } + + public void setFields(Map<String, String> fields) { + this.fields = fields; + } + + public void setExcludeFields(Map<String, String> excludeFields) { + this.excludeFields = excludeFields; + } + + @Override + public void addProperty(String property, String value) { + + if (BEAN_ATTRIBUTE.equals(property)) { + if (value != null && !value.trim().isEmpty()) { + bean = value.trim(); + } + return; + } + + if (CONTEXT_NAME_ATTRIBUTE.equals(property)) { + if (value != null && !value.trim().isEmpty()) { + contextName = value.trim(); + } + return; + } + + if (BEAN_CLASS_ATTRIBUTE.equals(property)) { + if (value != null && !value.trim().isEmpty()) { + beanClass = value.trim(); + } + return; + } + + if (ERROR_LIST_MODEL_ATTRIBUTE.equals(property)) { + if (value != null && !value.trim().isEmpty()) { + errorListModel = value.trim(); + } + return; + } + + if (ERROR_LIST_ATTRIBUTE.equals(property)) { + if (value != null && !value.trim().isEmpty()) { + errorList = value.trim(); + } + return; + } + + if (ERROR_TABLE_MODEL_ATTRIBUTE.equals(property)) { + if (value != null && !value.trim().isEmpty()) { + errorTableModel = value.trim(); + } + return; + } + + if (ERROR_TABLE_ATTRIBUTE.equals(property)) { + if (value != null && !value.trim().isEmpty()) { + errorTable = value.trim(); + } + return; + } + + if (UI_CLASS_ATTRIBUTE.equals(property)) { + if (value != null && !value.trim().isEmpty()) { + uiClass = value.trim(); + } + return; + } + + if (AUTOFIELD_ATTRIBUTE.equals(property)) { + if (value != null && !value.trim().isEmpty()) { + autoField = (Boolean) TypeManager.convertFromString(value.trim(), Boolean.class); + } + return; + } + + if (STRICT_MODE_ATTRIBUTE.equals(property)) { + if (value != null && !value.trim().isEmpty()) { + strictMode = (Boolean) TypeManager.convertFromString(value.trim(), Boolean.class); + } + return; + } + + if (PARENT_VALIDATOR_ATTRIBUTE.equals(property)) { + if (value != null && !value.trim().isEmpty()) { + parentValidator = value.trim(); + } + return; + } + + throw new CompilerException("property " + property + " is not allowed on object " + this); + } + + public String getBean() { + return bean; + } + + public String getErrorListModel() { + return errorListModel; + } + + public boolean getAutoField() { + return autoField != null && autoField; + } + + public boolean getStrictMode() { + return strictMode != null && strictMode; + } + + public String getUiClass() { + return uiClass; + } + + public String getBeanClass() { + return beanClass; + } + + public String getContextName() { + return contextName; + } + + public String getParentValidator() { + return parentValidator; + } + + public JAXXBeanInfo getBeanDescriptor(JAXXCompiler compiler) { + if (beanDescriptor == null && foundBean()) { + + String beanClassName = null; + try { + //TC-20090111 beanClass is mandatory + // get the real bean class name (from bean or beanClass) + /*if (beanClass != null) { + beanClassName = beanClass; + } else { + beanClassName = compiler.getSymbolTable().getClassTagIds().get(bean); + if (beanClassName == null) { + compiler.reportError("could not find class of the bean '" + bean + "'"); + return null; + } + }*/ + ClassDescriptor beanClassDescriptor = ClassDescriptorLoader.getClassDescriptor(beanClass); + beanDescriptor = DefaultObjectHandler.getJAXXBeanInfo(beanClassDescriptor); + } catch (ClassNotFoundException e) { + compiler.reportError("could not load class " + beanClassName); + } catch (IntrospectionException e) { + compiler.reportError("could not load class " + beanClassName); + } + } + return beanDescriptor; + } + + @Override + public void addChild(CompiledObject child, String constraints, JAXXCompiler compiler) throws CompilerException { + // do nothing + compiler.reportError("can not add CompiledObject in the tag '" + TAG + " (only field tags)"); + } + + public boolean foundBean() { + return !(beanClass == null || beanClass.isEmpty()); + } + + protected boolean addUiClass(BeanValidatorHandler handler, JAXXCompiler compiler) { + boolean withError = false; + if (uiClass == null && compiler.getConfiguration().getDefaultErrorUI() != null) { + uiClass = compiler.getConfiguration().getDefaultErrorUI().getName(); + } + if (uiClass != null) { + try { + ClassDescriptor uiClazz = ClassDescriptorLoader.getClassDescriptor(uiClass); + if (!ClassDescriptorLoader.getClassDescriptor(AbstractBeanValidatorUI.class).isAssignableFrom(uiClazz)) { + compiler.reportError("attribute 'ui' :'" + uiClass + "' is not assignable from class " + AbstractBeanValidatorUI.class); + withError = true; + } else { + String code = handler.getSetPropertyCode(getJavaCode(), UI_CLASS_ATTRIBUTE, uiClazz.getName() + ".class", compiler); + appendAdditionCode(code); + } + } catch (ClassNotFoundException e) { + compiler.reportError("class not found '" + uiClass + "'"); + withError = true; + } + } + + return withError; + } + + protected boolean addErrorListModel(Element tag, BeanValidatorHandler handler, JAXXCompiler compiler) { + if (errorListModel == null) { + // try with the default "errors" + if (!compiler.checkReference(tag, ERROR_LIST_MODEL_DEFAULT, false, ERROR_LIST_MODEL_ATTRIBUTE)) { + return false; + } + errorListModel = ERROR_LIST_MODEL_DEFAULT; + } else { + if (errorListModel.startsWith("{") && errorListModel.endsWith("}")) { + // this is a script, no check here + errorListModel = errorListModel.substring(1, errorListModel.length() - 1).trim(); + } else if (!compiler.checkReference(tag, errorListModel, true, ERROR_LIST_MODEL_ATTRIBUTE)) { + // errorListModel is not defined + return true; + } + } + + String code = handler.getSetPropertyCode(getJavaCode(), ERROR_LIST_MODEL_ATTRIBUTE, errorListModel, compiler); + appendAdditionCode(code); + + return false; + } + + protected boolean addErrorTableModel(Element tag, BeanValidatorHandler handler, JAXXCompiler compiler) { + if (errorTableModel == null) { + // try with the default "errors" + if (!compiler.checkReference(tag, ERROR_TABLE_MODEL_DEFAULT, false, ERROR_LIST_MODEL_ATTRIBUTE)) { + return false; + } + errorTableModel = ERROR_TABLE_MODEL_DEFAULT; + } else { + if (errorTableModel.startsWith("{") && errorTableModel.endsWith("}")) { + // this is a script, no check here + errorTableModel = errorTableModel.substring(1, errorTableModel.length() - 1).trim(); + } else if (!compiler.checkReference(tag, errorTableModel, true, ERROR_TABLE_MODEL_ATTRIBUTE)) { + // errorListModel is not defined + return true; + } + } + + String code = handler.getSetPropertyCode(getJavaCode(), ERROR_TABLE_MODEL_ATTRIBUTE, errorTableModel, compiler); + appendAdditionCode(code); + + return false; + + } + + protected boolean addParentValidator(Element tag, BeanValidatorHandler handler, JAXXCompiler compiler) { + if (parentValidator != null) { + String initializer; + if (parentValidator.startsWith("{") && parentValidator.endsWith("}")) { + + // todo : should be able to bind + initializer = parentValidator.substring(1, parentValidator.length() - 1); + + } else { + // the attribute referes an existing widget + if (!compiler.checkReference(tag, parentValidator, true, PARENT_VALIDATOR_ATTRIBUTE)) { + // parentValidator is not defined + return true; + } + initializer = parentValidator; + } + String code = handler.getSetPropertyCode(getJavaCode(), PARENT_VALIDATOR_ATTRIBUTE, initializer, compiler); + appendAdditionCode(code); + } + return false; + } + + protected boolean addErrorList(Element tag, JAXXCompiler compiler) { + + if (errorList == null) { + // try with the default "errorList" + if (!compiler.checkReference(tag, ERROR_LIST_DEFAULT, false, ERROR_LIST_ATTRIBUTE)) { + return false; + } + errorList = ERROR_LIST_DEFAULT; + } else { + if (!compiler.checkReference(tag, errorList, true, ERROR_LIST_ATTRIBUTE)) { + return true; + } + } + + String code = SwingValidatorUtil.class.getName() + ".registerErrorListMouseListener(" + errorList + ");"; + appendAdditionCode(code); + + return false; + } + + protected boolean addErrorTable(Element tag, JAXXCompiler compiler) { + + if (errorTable == null) { + // try with the default "errorList" + if (!compiler.checkReference(tag, ERROR_TABLE_DEFAULT, false, ERROR_TABLE_ATTRIBUTE)) { + return false; + } + errorTable = ERROR_TABLE_DEFAULT; + } else { + if (!compiler.checkReference(tag, errorTable, true, ERROR_TABLE_ATTRIBUTE)) { + return true; + } + } + + String code = SwingValidatorUtil.class.getName() + ".registerErrorTableMouseListener(" + errorTable + ");"; + appendAdditionCode(code); + + return false; + } + + protected boolean addBean(Element tag, BeanValidatorHandler handler, JAXXCompiler compiler) { + + if (beanClass == null || beanClass.isEmpty()) { + // try to guest beanClass from bean attribute + if (bean != null && !bean.isEmpty()) { + beanClass = compiler.getSymbolTable().getClassTagIds().get(bean); + if (beanClass == null) { + compiler.reportError("could not find class of the bean '" + bean + "', and no beanClass was setted"); + return true; + } + } + } + if (beanClass == null) { + compiler.reportError("tag '" + tag + "' requires a 'beanClass' attribute, and could not guest it from 'bean' attribute (no bean attribute setted...)"); + return true; + } + + JAXXBeanInfo beanInfo = getBeanDescriptor(compiler); + if (beanInfo == null) { + compiler.reportError(tag, "could not find descriptor of class " + beanClass); + return true; + } + + String beanInitializer = null; + if (bean != null) { + + if (bean.startsWith("{") && bean.endsWith("}")) { + + String labelBinding = DataBindingHelper.processDataBindings(bean); + if (labelBinding != null) { + compiler.getBindingHelper().registerDataBinding(getId() + ".bean", labelBinding, getId() + ".setBean(" + labelBinding + ");"); + } +// // just has an intializer +// beanInitializer = bean.substring(1, bean.length() - 1); +// // this is not a real bean, so delete it + bean = null; + } else { + + if (!compiler.checkReference(tag, bean, true, BEAN_ATTRIBUTE)) { + // could not find bean in compiled object + return true; + } + + if (isBeanUsedByValidator(compiler, bean)) { + compiler.reportError("the bean '" + bean + "' is already used in another the validator, can not used it in '" + tag + "'"); + return true; + } + + /*if (beanInitializer != null) { + compiler.reportWarning("tag '" + tag + "' found a 'bean' and a 'beanInitializer' attributes, 'beanInitializer' is skipped"); + }*/ + beanInitializer = bean; + } + } + + if (beanInitializer != null) { + String code = handler.getSetPropertyCode(getJavaCode(), BEAN_ATTRIBUTE, compiler.checkJavaCode(beanInitializer), compiler); + appendAdditionCode(code); + } + + String beanClassName = beanInfo.getJAXXBeanDescriptor().getClassDescriptor().getName(); + // contextName must be in constructor to able to init validator with his correct contextName + setConstructorParams(beanClassName + ".class, " + TypeManager.getJavaCode(contextName)); + // add generic type to validator + setGenericTypes(new String[]{beanClassName}); + + if (getAutoField()) { + registerAutoFieldBean(tag, compiler, beanInfo); + } + + if (getBeanDescriptor(compiler) != null) { + + // add fieldrepresentation invocations + addFieldRepresentations(tag, compiler); + + // register the validator in compiler + registerValidator(compiler, this); + + } + + return false; + } + + private void registerValidator(JAXXCompiler compiler, CompiledBeanValidator compiledBeanValidator) { + List<CompiledBeanValidator> vals = validators.get(compiler); + if (vals == null) { + vals = new ArrayList<CompiledBeanValidator>(); + validators.put(compiler, vals); + } + vals.add(compiledBeanValidator); + List<String> ids = validatedComponents.get(compiler); + if (ids == null) { + ids = new ArrayList<String>(); + validatedComponents.put(compiler, ids); + } + ids.addAll(compiledBeanValidator.getFields().values()); + } + + protected void addFieldRepresentations(Element tag, JAXXCompiler compiler) { + for (Entry<String, String> entry : fields.entrySet()) { + String propertyName = entry.getKey(); + String component = entry.getValue(); + if (!checkBeanProperty(compiler, propertyName)) { + // property not find on bean + continue; + } + if (!compiler.checkReference(tag, component, true, null)) { + // editor component not find on ui + continue; + } + String keyCode = TypeManager.getJavaCode(propertyName); + appendAdditionCode(getJavaCode() + ".setFieldRepresentation(" + keyCode + ", " + component + ");"); + } + } + + protected void registerAutoFieldBean(Element tag, JAXXCompiler compiler, JAXXBeanInfo beanInfo) { + for (JAXXPropertyDescriptor beanProperty : beanInfo.getJAXXPropertyDescriptors()) { + String descriptionName = beanProperty.getName(); + if (log.isDebugEnabled()) { + log.debug("try to bind on bean " + beanInfo.getJAXXBeanDescriptor().getName() + " property " + descriptionName); + } + if (beanProperty.getWriteMethodDescriptor() == null) { + // read-only property + continue; + } + if (fields.containsKey(descriptionName)) { + // already defined in field + continue; + } + if (excludeFields.containsKey(descriptionName)) { + // exclude field + continue; + } + if (!compiler.checkReference(tag, descriptionName, getStrictMode(), null)) { + // no editor component found + continue; + } + // ok add the field mapping + registerField(descriptionName, descriptionName, compiler); + } + + for (Entry<String, String> entry : excludeFields.entrySet()) { + String key = entry.getKey(); + if (fields.containsKey(key)) { + compiler.reportWarning("field '" + key + "' can not be used and excluded at same time ! (field is skipped) for validator " + this); + fields.remove(key); + } + } + } + + public void registerField(String id, String component, JAXXCompiler compiler) { + if (fields.containsKey(id)) { + compiler.reportError("duplicate field '" + id + "' for validator " + this); + } else { + if (log.isDebugEnabled()) { + log.debug("add field <" + id + ":" + component + ">"); + } + fields.put(id, component); + } + } + + public void registerExcludeField(String id, String component, JAXXCompiler compiler) { + if (excludeFields.containsKey(id)) { + compiler.reportError("duplicate field '" + id + "' for validator " + this); + } else { + if (log.isDebugEnabled()) { + log.debug("add excludeField <" + id + ":" + component + ">"); + } + excludeFields.put(id, component); + } + } + + protected boolean checkBeanProperty(JAXXCompiler compiler, String propertyName) { + + for (JAXXPropertyDescriptor beanProperty : getBeanDescriptor(compiler).getJAXXPropertyDescriptors()) { + if (beanProperty.getName().equals(propertyName)) { + if (beanProperty.getWriteMethodDescriptor() == null) { + // read-onlyproperty + compiler.reportError("could not bind the readonly property '" + propertyName + "' on bean [" + getBean() + "] "); + return false; + } + return true; + } + } + compiler.reportError("could not find the property '" + propertyName + "' on bean [" + getBean() + "] "); + return false; + } + } + + /** + * Test if a given bean is attached to a validator. + * + * @param compiler current compiler to use + * @param beanId the bean to test + * @return <code>true</code> if the given bean is attached to a validator, <code>false</code> otherwise + */ + public static boolean isBeanUsedByValidator(JAXXCompiler compiler, String beanId) { + List<CompiledBeanValidator> beanValidatorList = validators.get(compiler); + if (beanValidatorList != null) { + for (CompiledBeanValidator validator : beanValidatorList) { + if (beanId.equals(validator.getBean())) { + return true; + } + } + } + return false; + } + + /** + * @param compiler compiler to use + * @return <code>true</code> if some validators were detected, <code>false</code> otherwise + */ + public static boolean hasValidator(JAXXCompiler compiler) { + List<CompiledBeanValidator> beanValidatorList = validators.get(compiler); + return beanValidatorList != null && !beanValidatorList.isEmpty(); + } + + /** + * Test if a given CompiledObject is attached to a validator. + * + * @param compiler compiler to use + * @param componentId the compiled object to test + * @return <code>true</code> if the given compiled object is attached to a validator, <code>false</code> otherwise + */ + public static boolean isComponentUsedByValidator(JAXXCompiler compiler, String componentId) { + List<String> ids = validatedComponents.get(compiler); + return ids != null && ids.contains(componentId); + } + + public static List<CompiledBeanValidator> getValidators(JAXXCompiler compiler) { + return validators.get(compiler); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/ExcludeFieldValidatorHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/ExcludeFieldValidatorHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/ExcludeFieldValidatorHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,101 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.validator; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.tags.TagHandler; -import jaxx.compiler.tags.validator.BeanValidatorHandler.CompiledBeanValidator; -import jaxx.runtime.validator.swing.SwingValidator; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.w3c.dom.Element; - -import java.io.IOException; - -public class ExcludeFieldValidatorHandler implements TagHandler { - - public static final String TAG = "excludeField"; - public static final String NAME_ATTRIBUTE = "name"; - public static final String COMPONENT_ATTRIBUTE = "component"; - /** 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.getConfiguration().isVerbose()) { - log.info(tag); - } - //todo check there is no child - } - - @Override - public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - if (compiler.getConfiguration().isVerbose()) { - log.debug(tag); - } - - if (!ClassDescriptorLoader.getClassDescriptor(SwingValidator.class).isAssignableFrom(compiler.getOpenComponent().getObjectClass())) { - compiler.reportError(TAG + " tag may only appear within " + BeanValidatorHandler.TAG + " tag but was " + tag); - return; - } - - CompiledBeanValidator info = (CompiledBeanValidator) compiler.getOpenComponent(); - if (!info.getAutoField()) { - compiler.reportError(TAG + " tag can not be used without an 'autoField' validator : " + tag); - return; - } - String name = tag.getAttribute(NAME_ATTRIBUTE); - String component = tag.getAttribute(COMPONENT_ATTRIBUTE); - if (name == null || name.trim().isEmpty()) { - compiler.reportError(TAG + " tag requires a " + NAME_ATTRIBUTE + " attribute"); - return; - } - name = name.trim(); - if (component == null || component.trim().isEmpty()) { - // try to use the name as component - if (!compiler.checkReference(tag, name, false, name)) { - compiler.reportError(TAG + " tag requires a " + COMPONENT_ATTRIBUTE + " attribute, try to use the name attribute [" + name + "] for the component, but no such component found"); - return; - } - component = name; - } - component = component.trim(); - - // check component is not already used by this compiled object - if (info.getFields().containsValue(component)) { - compiler.reportError(TAG + " tag found a attribute " + COMPONENT_ATTRIBUTE + " [" + component + "] already used in this validator"); - return; - } - if (info.getExcludeFields().containsValue(component)) { - compiler.reportError(TAG + " tag found a attribute " + COMPONENT_ATTRIBUTE + " [" + component + "] already used in this validator"); - return; - } - // check component exist (again perharps, but let the error knows exactly which tag failed...) - if (compiler.checkReference(tag, component, true, COMPONENT_ATTRIBUTE)) { - // add a field - info.registerField(name, component, compiler); - } - - - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/ExcludeFieldValidatorHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/ExcludeFieldValidatorHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/ExcludeFieldValidatorHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/ExcludeFieldValidatorHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,101 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.validator; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.tags.TagHandler; +import jaxx.compiler.tags.validator.BeanValidatorHandler.CompiledBeanValidator; +import jaxx.runtime.validator.swing.SwingValidator; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.w3c.dom.Element; + +import java.io.IOException; + +public class ExcludeFieldValidatorHandler implements TagHandler { + + public static final String TAG = "excludeField"; + public static final String NAME_ATTRIBUTE = "name"; + public static final String COMPONENT_ATTRIBUTE = "component"; + /** 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.getConfiguration().isVerbose()) { + log.info(tag); + } + //todo check there is no child + } + + @Override + public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + if (compiler.getConfiguration().isVerbose()) { + log.debug(tag); + } + + if (!ClassDescriptorLoader.getClassDescriptor(SwingValidator.class).isAssignableFrom(compiler.getOpenComponent().getObjectClass())) { + compiler.reportError(TAG + " tag may only appear within " + BeanValidatorHandler.TAG + " tag but was " + tag); + return; + } + + CompiledBeanValidator info = (CompiledBeanValidator) compiler.getOpenComponent(); + if (!info.getAutoField()) { + compiler.reportError(TAG + " tag can not be used without an 'autoField' validator : " + tag); + return; + } + String name = tag.getAttribute(NAME_ATTRIBUTE); + String component = tag.getAttribute(COMPONENT_ATTRIBUTE); + if (name == null || name.trim().isEmpty()) { + compiler.reportError(TAG + " tag requires a " + NAME_ATTRIBUTE + " attribute"); + return; + } + name = name.trim(); + if (component == null || component.trim().isEmpty()) { + // try to use the name as component + if (!compiler.checkReference(tag, name, false, name)) { + compiler.reportError(TAG + " tag requires a " + COMPONENT_ATTRIBUTE + " attribute, try to use the name attribute [" + name + "] for the component, but no such component found"); + return; + } + component = name; + } + component = component.trim(); + + // check component is not already used by this compiled object + if (info.getFields().containsValue(component)) { + compiler.reportError(TAG + " tag found a attribute " + COMPONENT_ATTRIBUTE + " [" + component + "] already used in this validator"); + return; + } + if (info.getExcludeFields().containsValue(component)) { + compiler.reportError(TAG + " tag found a attribute " + COMPONENT_ATTRIBUTE + " [" + component + "] already used in this validator"); + return; + } + // check component exist (again perharps, but let the error knows exactly which tag failed...) + if (compiler.checkReference(tag, component, true, COMPONENT_ATTRIBUTE)) { + // add a field + info.registerField(name, component, compiler); + } + + + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/FieldValidatorHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/FieldValidatorHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/FieldValidatorHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,94 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags.validator; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.tags.TagHandler; -import jaxx.compiler.tags.validator.BeanValidatorHandler.CompiledBeanValidator; -import jaxx.runtime.validator.swing.SwingValidator; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.w3c.dom.Element; - -import java.io.IOException; - -public class FieldValidatorHandler implements TagHandler { - - public static final String TAG = "field"; - public static final String NAME_ATTRIBUTE = "name"; - public static final String COMPONENT_ATTRIBUTE = "component"; - /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(FieldValidatorHandler.class); - - - public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - if (compiler.getConfiguration().isVerbose()) { - log.debug(tag); - } - //todo check there is no child - } - - @Override - public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - if (compiler.getConfiguration().isVerbose()) { - log.debug(tag); - } - - if (!ClassDescriptorLoader.getClassDescriptor(SwingValidator.class).isAssignableFrom(compiler.getOpenComponent().getObjectClass())) { - compiler.reportError(TAG + " tag may only appear within " + BeanValidatorHandler.TAG + " tag but was " + tag); - return; - } - - CompiledBeanValidator info = (CompiledBeanValidator) compiler.getOpenComponent(); - - String name = tag.getAttribute(NAME_ATTRIBUTE); - String component = tag.getAttribute(COMPONENT_ATTRIBUTE); - if (name == null || name.trim().isEmpty()) { - compiler.reportError(TAG + " tag requires a " + NAME_ATTRIBUTE + " attribute"); - return; - } - name = name.trim(); - if (component == null || component.trim().isEmpty()) { - // try to use the name as component - if (!compiler.checkReference(tag, name, false, name)) { - compiler.reportError(TAG + " tag requires a " + COMPONENT_ATTRIBUTE + " attribute, try to use the name attribute [" + name + "] for the component, but no such component found"); - return; - } - component = name; - } - component = component.trim(); - - // check component is not already used by this compiled object - if (info.getFields().containsValue(component)) { - compiler.reportError(TAG + " tag found a attribute " + COMPONENT_ATTRIBUTE + " [" + component + "] already used in this validator"); - return; - } - // check component exist (again perharps, but let the error knows exactly which tag failed...) - if (compiler.checkReference(tag, component, true, COMPONENT_ATTRIBUTE)) { - // add a field - info.registerField(name, component, compiler); - } - - - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/FieldValidatorHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/FieldValidatorHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/FieldValidatorHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/FieldValidatorHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,94 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags.validator; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.tags.TagHandler; +import jaxx.compiler.tags.validator.BeanValidatorHandler.CompiledBeanValidator; +import jaxx.runtime.validator.swing.SwingValidator; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.w3c.dom.Element; + +import java.io.IOException; + +public class FieldValidatorHandler implements TagHandler { + + public static final String TAG = "field"; + public static final String NAME_ATTRIBUTE = "name"; + public static final String COMPONENT_ATTRIBUTE = "component"; + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private Log log = LogFactory.getLog(FieldValidatorHandler.class); + + + public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + if (compiler.getConfiguration().isVerbose()) { + log.debug(tag); + } + //todo check there is no child + } + + @Override + public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + if (compiler.getConfiguration().isVerbose()) { + log.debug(tag); + } + + if (!ClassDescriptorLoader.getClassDescriptor(SwingValidator.class).isAssignableFrom(compiler.getOpenComponent().getObjectClass())) { + compiler.reportError(TAG + " tag may only appear within " + BeanValidatorHandler.TAG + " tag but was " + tag); + return; + } + + CompiledBeanValidator info = (CompiledBeanValidator) compiler.getOpenComponent(); + + String name = tag.getAttribute(NAME_ATTRIBUTE); + String component = tag.getAttribute(COMPONENT_ATTRIBUTE); + if (name == null || name.trim().isEmpty()) { + compiler.reportError(TAG + " tag requires a " + NAME_ATTRIBUTE + " attribute"); + return; + } + name = name.trim(); + if (component == null || component.trim().isEmpty()) { + // try to use the name as component + if (!compiler.checkReference(tag, name, false, name)) { + compiler.reportError(TAG + " tag requires a " + COMPONENT_ATTRIBUTE + " attribute, try to use the name attribute [" + name + "] for the component, but no such component found"); + return; + } + component = name; + } + component = component.trim(); + + // check component is not already used by this compiled object + if (info.getFields().containsValue(component)) { + compiler.reportError(TAG + " tag found a attribute " + COMPONENT_ATTRIBUTE + " [" + component + "] already used in this validator"); + return; + } + // check component exist (again perharps, but let the error knows exactly which tag failed...) + if (compiler.checkReference(tag, component, true, COMPONENT_ATTRIBUTE)) { + // add a field + info.registerField(name, component, compiler); + } + + + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/PrintTagInfo.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/PrintTagInfo.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/PrintTagInfo.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,137 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tools; - -import jaxx.compiler.tags.*; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.JAXXEngine; -import jaxx.compiler.beans.JAXXPropertyDescriptor; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.reflect.MethodDescriptor; - -import java.io.BufferedWriter; -import java.io.FileWriter; -import java.io.IOException; -import java.io.OutputStreamWriter; - -/** Generates information about a tag for use on the jaxxframework.org web site. */ -public class PrintTagInfo { - /** - * Displays information about the class name in arg[0]. - * - * @param arg command-line arguments - * @throws Exception if an error occurs - */ - public static void main(String[] arg) throws Exception { - if (arg.length < 1) { - throw new IllegalArgumentException("programm needs at least two parameters : the file where to put the result, and at least one fqn class to treate"); - } - String firstarg = arg[0]; - boolean toFile = false; - BufferedWriter w; - if (firstarg.startsWith("file:")) { - w = new BufferedWriter(new FileWriter(firstarg.substring(5))); - toFile = true; - } else { - w = new BufferedWriter(new OutputStreamWriter(System.out)); - } - - try { - JAXXEngine.loadLibraries(false); - for (int i = toFile ? 1 : 0; i < arg.length; i++) { - String className = arg[i]; - treateClass(w, className); - } - } finally { - w.flush(); - w.close(); - } - - } - - protected static void treateClass(BufferedWriter w, String className) throws ClassNotFoundException, IOException { - - ClassDescriptor beanClass = ClassDescriptorLoader.getClassDescriptor(className); - DefaultObjectHandler handler = TagManager.getTagHandler(beanClass); - - DefaultObjectHandler superHandler = TagManager.getTagHandler(beanClass.getSuperclass()); - - // dump all bean properties - w.append("Properties in ").append(String.valueOf(beanClass)); - w.newLine(); - JAXXPropertyDescriptor[] properties = handler.getJAXXBeanInfo().getJAXXPropertyDescriptors(); - JAXXPropertyDescriptor[] superProperties = superHandler.getJAXXBeanInfo().getJAXXPropertyDescriptors(); - for (JAXXPropertyDescriptor property : properties) { - if (property.getWriteMethodDescriptor() == null) { - continue; - } - - boolean found = false; - String name = property.getName(); - for (JAXXPropertyDescriptor superProperty : superProperties) { - if (superProperty.getName().equals(name)) { - found = true; - break; - } - } - if (!found) { - if (property.getPropertyType() == null) { - System.err.println(name + " has null type"); - } else { - w.append("{{EquivalentAttribute|"); - w.append(name); - w.append("|"); - w.append(className.replace('.', '/')); - w.append("|set"); - w.append(org.apache.commons.lang.StringUtils.capitalize(name)); - w.append("|"); - w.append(JAXXCompiler.getCanonicalName(property.getPropertyType())); - w.append("}}"); - w.append("|-"); - w.newLine(); - } - } - } - - w.newLine(); - w.newLine(); - - // dump all bound methods - dumpMethods(w, beanClass, handler); - } - - protected static void dumpMethods(BufferedWriter w, ClassDescriptor beanClass, DefaultObjectHandler handler) throws IOException { - MethodDescriptor[] methods = beanClass.getMethodDescriptors(); - w.append("Bound methods in ").append(String.valueOf(beanClass)); - w.newLine(); - for (MethodDescriptor method : methods) { - try { - if (handler.isMemberBound(method.getName())) { - w.append("* <tt>").append(method.getName()).append("()</tt>"); - w.newLine(); - } - } catch (Throwable e) { - // ignore ? - } - } - } -} \ No newline at end of file Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/PrintTagInfo.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/PrintTagInfo.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/PrintTagInfo.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/PrintTagInfo.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,137 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tools; + +import jaxx.compiler.tags.*; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.JAXXEngine; +import jaxx.compiler.beans.JAXXPropertyDescriptor; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.reflect.MethodDescriptor; + +import java.io.BufferedWriter; +import java.io.FileWriter; +import java.io.IOException; +import java.io.OutputStreamWriter; + +/** Generates information about a tag for use on the jaxxframework.org web site. */ +public class PrintTagInfo { + /** + * Displays information about the class name in arg[0]. + * + * @param arg command-line arguments + * @throws Exception if an error occurs + */ + public static void main(String[] arg) throws Exception { + if (arg.length < 1) { + throw new IllegalArgumentException("programm needs at least two parameters : the file where to put the result, and at least one fqn class to treate"); + } + String firstarg = arg[0]; + boolean toFile = false; + BufferedWriter w; + if (firstarg.startsWith("file:")) { + w = new BufferedWriter(new FileWriter(firstarg.substring(5))); + toFile = true; + } else { + w = new BufferedWriter(new OutputStreamWriter(System.out)); + } + + try { + JAXXEngine.loadLibraries(false); + for (int i = toFile ? 1 : 0; i < arg.length; i++) { + String className = arg[i]; + treateClass(w, className); + } + } finally { + w.flush(); + w.close(); + } + + } + + protected static void treateClass(BufferedWriter w, String className) throws ClassNotFoundException, IOException { + + ClassDescriptor beanClass = ClassDescriptorLoader.getClassDescriptor(className); + DefaultObjectHandler handler = TagManager.getTagHandler(beanClass); + + DefaultObjectHandler superHandler = TagManager.getTagHandler(beanClass.getSuperclass()); + + // dump all bean properties + w.append("Properties in ").append(String.valueOf(beanClass)); + w.newLine(); + JAXXPropertyDescriptor[] properties = handler.getJAXXBeanInfo().getJAXXPropertyDescriptors(); + JAXXPropertyDescriptor[] superProperties = superHandler.getJAXXBeanInfo().getJAXXPropertyDescriptors(); + for (JAXXPropertyDescriptor property : properties) { + if (property.getWriteMethodDescriptor() == null) { + continue; + } + + boolean found = false; + String name = property.getName(); + for (JAXXPropertyDescriptor superProperty : superProperties) { + if (superProperty.getName().equals(name)) { + found = true; + break; + } + } + if (!found) { + if (property.getPropertyType() == null) { + System.err.println(name + " has null type"); + } else { + w.append("{{EquivalentAttribute|"); + w.append(name); + w.append("|"); + w.append(className.replace('.', '/')); + w.append("|set"); + w.append(org.apache.commons.lang.StringUtils.capitalize(name)); + w.append("|"); + w.append(JAXXCompiler.getCanonicalName(property.getPropertyType())); + w.append("}}"); + w.append("|-"); + w.newLine(); + } + } + } + + w.newLine(); + w.newLine(); + + // dump all bound methods + dumpMethods(w, beanClass, handler); + } + + protected static void dumpMethods(BufferedWriter w, ClassDescriptor beanClass, DefaultObjectHandler handler) throws IOException { + MethodDescriptor[] methods = beanClass.getMethodDescriptors(); + w.append("Bound methods in ").append(String.valueOf(beanClass)); + w.newLine(); + for (MethodDescriptor method : methods) { + try { + if (handler.isMemberBound(method.getName())) { + w.append("* <tt>").append(method.getName()).append("()</tt>"); + w.newLine(); + } + } catch (Throwable e) { + // ignore ? + } + } + } +} \ No newline at end of file Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/AbstractContextNode.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/AbstractContextNode.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/AbstractContextNode.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,39 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tools.jaxxcapture; - -import java.util.ArrayList; -import java.util.List; - -public abstract class AbstractContextNode implements ContextNode { - private List<ContextNode> arguments = new ArrayList<ContextNode>(); - - - @Override - public void addArgument(ContextNode node) { - arguments.add(node); - } - - @Override - public ContextNode[] getArguments() { - return arguments.toArray(new ContextNode[arguments.size()]); - } -} \ No newline at end of file Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/AbstractContextNode.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/AbstractContextNode.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/AbstractContextNode.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/AbstractContextNode.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,39 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tools.jaxxcapture; + +import java.util.ArrayList; +import java.util.List; + +public abstract class AbstractContextNode implements ContextNode { + private List<ContextNode> arguments = new ArrayList<ContextNode>(); + + + @Override + public void addArgument(ContextNode node) { + arguments.add(node); + } + + @Override + public ContextNode[] getArguments() { + return arguments.toArray(new ContextNode[arguments.size()]); + } +} \ No newline at end of file Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/CapturedObject.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/CapturedObject.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/CapturedObject.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,166 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tools.jaxxcapture; - -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.tools.jaxxcapture.handlers.ObjectHandler; - -import java.awt.Component; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; - -public class CapturedObject extends AbstractContextNode { - private String className; - private ObjectHandler handler; - /** Maps children to their constraints. */ - private Map<CapturedObject, ContextNode> children = new LinkedHashMap<CapturedObject, ContextNode>(); - private CapturedObject parent; - private Map<String, String> properties = new LinkedHashMap<String, String>(); - private Map<String, Object> additionalData = new HashMap<String, Object>(); - private StringBuffer innerXML = new StringBuffer(); - private StringBuffer script = new StringBuffer(); - private boolean inlineable = true; - private JAXXCapture capture; - - public CapturedObject(ObjectHandler handler, String className, JAXXCapture capture) { - this.handler = handler; - this.className = className; - this.capture = capture; - } - - - public ObjectHandler getObjectHandler() { - return handler; - } - - - public void addChild(CapturedObject child, ContextNode constraints) { - children.put(child, constraints); - child.setParent(this); - } - - - public CapturedObject[] getChildren() { - return children.keySet().toArray(new CapturedObject[children.size()]); - } - - - public CapturedObject getParent() { - return parent; - } - - - public void setParent(CapturedObject parent) { - this.parent = parent; - } - - - public ContextNode getConstraints(CapturedObject child) { - return children.get(child); - } - - - public String getClassName() { - return className; - } - - - public String getProperty(String key) { - return properties.get(key); - } - - - public void setProperty(String key, String value) { - properties.put(key, value); - } - - - public Map<String, String> getProperties() { - return properties; - } - - - public Object getAdditionalData(String key) { - return additionalData.get(key); - } - - - public void setAdditionalData(String key, Object value) { - additionalData.put(key, value); - } - - - public Map<String, Object> getAdditionalData() { - return additionalData; - } - - - public void setInlineable(boolean inlineable) { - this.inlineable = inlineable; - } - - - public boolean isInlineable() { - try { - return script.length() == 0 && !Component.class.isAssignableFrom(Class.forName(className, true, capture.getClassLoader())) && inlineable; - } - catch (ClassNotFoundException e) { - throw new RuntimeException(e); - } - } - - - public void appendInnerXML(String xml) { - if (this.innerXML.length() > 0) { - this.innerXML.append(JAXXCompiler.getLineSeparator()); - } - this.innerXML.append(xml); - } - - - public String getInnerXML() { - return innerXML.toString(); - } - - - public void appendScriptCode(String script) { - if (this.script.length() > 0) { - this.script.append(JAXXCompiler.getLineSeparator()); - } - this.script.append(script); - } - - - public String getScriptCode() { - return script.toString(); - } - - - public String getXML(JAXXCapture capture) { - return getObjectHandler().getXML(this, capture); - } - - @Override - public String toString() { - return "CapturedObject[" + getProperty("id") + ", " + className + "]"; - } -} \ No newline at end of file Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/CapturedObject.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/CapturedObject.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/CapturedObject.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/CapturedObject.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,166 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tools.jaxxcapture; + +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.tools.jaxxcapture.handlers.ObjectHandler; + +import java.awt.Component; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; + +public class CapturedObject extends AbstractContextNode { + private String className; + private ObjectHandler handler; + /** Maps children to their constraints. */ + private Map<CapturedObject, ContextNode> children = new LinkedHashMap<CapturedObject, ContextNode>(); + private CapturedObject parent; + private Map<String, String> properties = new LinkedHashMap<String, String>(); + private Map<String, Object> additionalData = new HashMap<String, Object>(); + private StringBuffer innerXML = new StringBuffer(); + private StringBuffer script = new StringBuffer(); + private boolean inlineable = true; + private JAXXCapture capture; + + public CapturedObject(ObjectHandler handler, String className, JAXXCapture capture) { + this.handler = handler; + this.className = className; + this.capture = capture; + } + + + public ObjectHandler getObjectHandler() { + return handler; + } + + + public void addChild(CapturedObject child, ContextNode constraints) { + children.put(child, constraints); + child.setParent(this); + } + + + public CapturedObject[] getChildren() { + return children.keySet().toArray(new CapturedObject[children.size()]); + } + + + public CapturedObject getParent() { + return parent; + } + + + public void setParent(CapturedObject parent) { + this.parent = parent; + } + + + public ContextNode getConstraints(CapturedObject child) { + return children.get(child); + } + + + public String getClassName() { + return className; + } + + + public String getProperty(String key) { + return properties.get(key); + } + + + public void setProperty(String key, String value) { + properties.put(key, value); + } + + + public Map<String, String> getProperties() { + return properties; + } + + + public Object getAdditionalData(String key) { + return additionalData.get(key); + } + + + public void setAdditionalData(String key, Object value) { + additionalData.put(key, value); + } + + + public Map<String, Object> getAdditionalData() { + return additionalData; + } + + + public void setInlineable(boolean inlineable) { + this.inlineable = inlineable; + } + + + public boolean isInlineable() { + try { + return script.length() == 0 && !Component.class.isAssignableFrom(Class.forName(className, true, capture.getClassLoader())) && inlineable; + } + catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } + } + + + public void appendInnerXML(String xml) { + if (this.innerXML.length() > 0) { + this.innerXML.append(JAXXCompiler.getLineSeparator()); + } + this.innerXML.append(xml); + } + + + public String getInnerXML() { + return innerXML.toString(); + } + + + public void appendScriptCode(String script) { + if (this.script.length() > 0) { + this.script.append(JAXXCompiler.getLineSeparator()); + } + this.script.append(script); + } + + + public String getScriptCode() { + return script.toString(); + } + + + public String getXML(JAXXCapture capture) { + return getObjectHandler().getXML(this, capture); + } + + @Override + public String toString() { + return "CapturedObject[" + getProperty("id") + ", " + className + "]"; + } +} \ No newline at end of file Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ContextNode.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ContextNode.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ContextNode.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,28 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tools.jaxxcapture; - -public interface ContextNode { - - void addArgument(ContextNode node); - - ContextNode[] getArguments(); -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ContextNode.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ContextNode.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ContextNode.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ContextNode.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,28 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tools.jaxxcapture; + +public interface ContextNode { + + void addArgument(ContextNode node); + + ContextNode[] getArguments(); +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/JAXXCapture.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/JAXXCapture.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/JAXXCapture.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,398 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tools.jaxxcapture; - -import jaxx.compiler.ClassMap; -import jaxx.compiler.CompiledObject; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import jaxx.compiler.tools.jaxxcapture.handlers.JTabbedPaneHandler; -import jaxx.compiler.tools.jaxxcapture.handlers.ObjectHandler; -import jaxx.compiler.tools.jaxxcapture.handlers.TableHandler; -import jaxx.compiler.types.TypeManager; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.Text; -import org.xml.sax.SAXException; - -import javax.swing.JDialog; -import javax.swing.JFrame; -import javax.swing.JTabbedPane; -import javax.swing.JWindow; -import javax.swing.SwingUtilities; -import java.awt.AWTEvent; -import java.awt.Component; -import java.awt.Container; -import java.awt.EventQueue; -import java.awt.Toolkit; -import java.awt.Window; -import java.awt.event.MouseEvent; -import java.beans.XMLEncoder; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import java.util.Stack; -import java.util.jar.Attributes; -import java.util.jar.JarFile; -import java.util.jar.Manifest; - -public class JAXXCapture { - - private static ClassMap<Object> objectHandlers = new ClassMap<Object>(); - - static { - //TODO make a serviceLoader mecanism to allow inter-module loading - objectHandlers.put(ClassDescriptorLoader.getClassDescriptor(Object.class), new ObjectHandler()); - objectHandlers.put(ClassDescriptorLoader.getClassDescriptor(JTabbedPane.class), new JTabbedPaneHandler()); - try { - objectHandlers.put(ClassDescriptorLoader.getClassDescriptor("jaxx.runtime.swing.Table"), new TableHandler()); - } catch (ClassNotFoundException e) { - System.err.println(e); - } - } - private Map<String, Object> sourceObjects = new HashMap<String, Object>(); - private Map<String, CapturedObject> capturedObjects = new HashMap<String, CapturedObject>(); - private ClassLoader classLoader; - private int count; - - private static class CaptureEventQueue extends EventQueue { - - private ClassLoader classLoader; - - private CaptureEventQueue(ClassLoader classLoader) { - this.classLoader = classLoader; - } - - @Override - public void dispatchEvent(AWTEvent event) { - if (event.getID() == MouseEvent.MOUSE_PRESSED && ((MouseEvent) event).isControlDown()) { - Component target = ((MouseEvent) event).getComponent(); - if (!(target instanceof Window)) { - target = SwingUtilities.getWindowAncestor(target); - } - if (target instanceof JFrame) { - target = ((JFrame) target).getContentPane(); - } else if (target instanceof JDialog) { - target = ((JDialog) target).getContentPane(); - } - if (target instanceof JWindow) { - target = ((JWindow) target).getContentPane(); - } - if (target != null) { - Thread.currentThread().setContextClassLoader(classLoader); - JAXXCapture capture = new JAXXCapture(classLoader); - capture.applyNames(target); - ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - XMLEncoder encoder = new XMLEncoder(buffer); - encoder.writeObject(target); - encoder.close(); - try { - System.err.println(new String(buffer.toByteArray())); - System.out.println(capture.convertToJAXX(new ByteArrayInputStream(buffer.toByteArray()))); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - } - super.dispatchEvent(event); - } - } - - private JAXXCapture(ClassLoader classLoader) { - this.classLoader = classLoader; - } - - public ClassLoader getClassLoader() { - return classLoader; - } - - public Map<String, CapturedObject> getCapturedObjects() { - return capturedObjects; - } - - private void applyNames(Component target) { - String name = target.getName(); - if (name == null || sourceObjects.containsKey(name) || !CompiledObject.isValidID(name)) { - do { - name = "Object" + ++count; - } while (sourceObjects.containsKey(name)); - } - target.setName(name); - assert !sourceObjects.containsKey(name) : "ID " + name + " is already registered"; - sourceObjects.put(name, target); - - if (target instanceof Container) { - Container container = (Container) target; - for (int i = 0; i < container.getComponentCount(); i++) { - applyNames(container.getComponent(i)); - } - } - } - - public static String getText(Element tag) { // NOT a safe general-purpose implementation! - return ((Text) tag.getChildNodes().item(0)).getData(); - } - - private String getArgumentsCode(ContextNode[] arguments) { - StringBuffer result = new StringBuffer(); - result.append('('); - for (int i = 0; i < arguments.length; i++) { - if (i != 0) { - result.append(", "); - } - result.append(getJavaCode(arguments[i])); - } - result.append(')'); - return result.toString(); - } - - public String getJavaCode(ContextNode node) { - StringBuffer result = new StringBuffer(); - if (node instanceof PropertyNode) { - ContextNode[] arguments = node.getArguments(); - result.append(arguments.length == 0 ? "get" : "set"); - result.append(org.apache.commons.lang.StringUtils.capitalize(((PropertyNode) node).getProperty())); - result.append(getArgumentsCode(arguments)); - } else if (node instanceof MethodNode) { - result.append((((MethodNode) node).getMethodName())); - result.append(getArgumentsCode(node.getArguments())); - } else if (node instanceof CapturedObject) { - CapturedObject object = (CapturedObject) node; - if (object.isInlineable()) { - result.append("new "); - result.append(object.getClassName()); - result.append(getArgumentsCode(node.getArguments())); - } else { - String id = object.getProperty("id"); - assert id != null; - result.append(id); - } - } else if (node instanceof ValueNode) { - result.append(TypeManager.getJavaCode(((ValueNode) node).getValue())); - } else if (node instanceof LiteralNode) { - result.append(((LiteralNode) node).getJavaCode()); - } else { - throw new IllegalArgumentException("unrecognized node type: " + node); - } - return result.toString(); - } - - // returns the best matching method for the specified argument types - private static Method getMethod(Class<?> target, String methodName, Class<?>[] arguments) { - try { - // use the package-private class java.beans.ReflectionUtils to resolve the method. This isn't 100% safe, but it's better than - // having to rewrite the resolution myself. - Class<?> reflectionUtils = Class.forName("java.beans.ReflectionUtils"); - Method getMethod = reflectionUtils.getDeclaredMethod("getMethod", new Class<?>[]{Class.class, String.class, Class[].class}); - getMethod.setAccessible(true); - return (Method) getMethod.invoke(null, target, methodName, arguments); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - // returns the best matching constructor for the specified argument types - private static Constructor<?> getConstructor(Class<?> target, Class<?>[] arguments) { - try { - // use the package-private class java.beans.ReflectionUtils to resolve the constructor. This isn't 100% safe, but it's better than - // having to rewrite the resolution myself. - Class<?> reflectionUtils = Class.forName("java.beans.ReflectionUtils"); - Method getConstructor = reflectionUtils.getDeclaredMethod("getConstructor", new Class<?>[]{Class.class, Class[].class}); - getConstructor.setAccessible(true); - return (Constructor<?>) getConstructor.invoke(null, target, arguments); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - private Object createInstance(CapturedObject object) { - try { - ContextNode[] argumentNodes = object.getArguments(); - Object[] arguments = new Object[argumentNodes.length]; - Class<?>[] argumentTypes = new Class<?>[argumentNodes.length]; - for (int j = 0; j < argumentNodes.length; j++) { - if (argumentNodes[j] instanceof ValueNode) { - arguments[j] = ((ValueNode) argumentNodes[j]).getValue(); - argumentTypes[j] = arguments[j] != null ? arguments[j].getClass() : null; - } else if (argumentNodes[j] instanceof CapturedObject) { - arguments[j] = createInstance((CapturedObject) argumentNodes[j]); - argumentTypes[j] = arguments[j] != null ? arguments[j].getClass() : null; - } - } - Constructor<?> constructor = getConstructor(Class.forName(object.getClassName(), true, classLoader), argumentTypes); - return constructor.newInstance(arguments); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - public String getJavaCode(Stack/*<ContextNode>*/ context) { - CapturedObject contextCapturedObject = (CapturedObject) context.get(0); - StringBuffer result = new StringBuffer(); - int start = 1; - for (int i = context.size() - 1; i > 1; i--) { - if (context.get(i) instanceof CapturedObject) { - start = i; - contextCapturedObject = (CapturedObject) context.get(i); - break; - } - } - Object contextObject = sourceObjects.get(contextCapturedObject.getProperty("id")); - Class<?> contextClass = contextObject != null ? contextObject.getClass() : null; - - for (int i = start; i < context.size(); i++) { - ContextNode node = (ContextNode) context.get(i); - if (contextObject != null && (node instanceof MethodNode || node instanceof PropertyNode)) { - // need to follow the call chain so we can insert typecasts as necessary - try { - String methodName; - ContextNode[] argumentNodes = node.getArguments(); - if (node instanceof MethodNode) { - methodName = ((MethodNode) node).getMethodName(); - } else { - methodName = (argumentNodes.length == 0 ? "get" : "set") + org.apache.commons.lang.StringUtils.capitalize(((PropertyNode) node).getProperty()); - } - Object[] arguments = new Object[argumentNodes.length]; - Class<?>[] argumentTypes = new Class<?>[argumentNodes.length]; - for (int j = 0; j < argumentNodes.length; j++) { - if (argumentNodes[j] instanceof ValueNode) { - arguments[j] = ((ValueNode) argumentNodes[j]).getValue(); - argumentTypes[j] = arguments[j] != null ? arguments[j].getClass() : null; - } else if (argumentNodes[j] instanceof CapturedObject) { - arguments[j] = createInstance((CapturedObject) argumentNodes[j]); - argumentTypes[j] = arguments[j].getClass(); - } else if (argumentNodes[j] instanceof LiteralNode) { - arguments[j] = ((LiteralNode) argumentNodes[j]).getValue(); - argumentTypes[j] = arguments[j].getClass(); - } else { - throw new IllegalArgumentException("unsupported argument type: " + argumentNodes[j]); - } - } - - Method method = getMethod(contextClass, methodName, argumentTypes); - if (method == null) { - // could not find method in contextClass, must be defined in a subclass -- insert a typecast - result.insert(0, "((" + getOutputName(contextObject.getClass()) + ") "); - result.append(')'); - method = getMethod(contextObject.getClass(), methodName, argumentTypes); - } - if (method == null) { - throw new RuntimeException("could not find method " + methodName + Arrays.asList(argumentTypes) + " in " + contextObject.getClass() + " (context: " + context + ")"); - } - contextObject = method.invoke(contextObject, arguments); - contextClass = method.getReturnType(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - if (i > start) { - result.append('.'); - } - - result.append(getJavaCode(node)); - } - return result + ";"; - } - - private String getOutputName(Class<?> c) { - return c.getName(); - } - - public CapturedObject processObject(Element objectTag, Stack<ContextNode> context) { - String className = objectTag.getAttribute("class"); - ObjectHandler handler; - if (className.length() > 0) { - try { - ClassDescriptor descriptor = ClassDescriptorLoader.getClassDescriptor(className, classLoader); - handler = (ObjectHandler) objectHandlers.get(descriptor); - } catch (ClassNotFoundException e) { - throw new RuntimeException(e); - } - } else { - handler = (ObjectHandler) objectHandlers.get(ClassDescriptorLoader.getClassDescriptor(Object.class)); - } - - return handler.processObject(objectTag, context, this); - } - - private synchronized String convertToJAXX(InputStream beansXML) throws IOException { - try { - Document document = JAXXCompiler.parseDocument(beansXML); - Element rootElement = document.getDocumentElement(); - NodeList nodes = rootElement.getChildNodes(); - Stack<ContextNode> context = new Stack<ContextNode>(); - for (int i = 0; i < nodes.getLength(); i++) { - Node child = nodes.item(i); - if (child.getNodeType() == Node.ELEMENT_NODE) { - Element element = (Element) child; - if (!element.getTagName().equals("object")) { - throw new Error("expected tag 'object', found '" + element.getTagName() + "'"); - } - CapturedObject root = processObject(element, context); - for (CapturedObject object : capturedObjects.values()) { // add all orphan objects to the root, so any non-inlineable ones have their XML created - if (object.getParent() == null && object != root) { - root.addChild(object, null); - } - } - return root.getXML(this); - } - } - return null; - } catch (SAXException e) { - throw new RuntimeException(e); - } finally { - reset(); - } - } - - private void reset() { - sourceObjects.clear(); - capturedObjects.clear(); - count = 0; - } - - public static void main(String[] arg) throws Exception { - File file = new File(arg[0]); - JarFile jarFile = new JarFile(file); - ClassLoader classLoader = new URLClassLoader(new URL[]{file.toURI().toURL()}); - Thread.currentThread().setContextClassLoader(classLoader); - EventQueue systemQueue = Toolkit.getDefaultToolkit().getSystemEventQueue(); - systemQueue.push(new CaptureEventQueue(classLoader)); - Manifest mf = jarFile.getManifest(); - String mainClassName = mf.getMainAttributes().getValue(Attributes.Name.MAIN_CLASS); - Class<?> mainClass = Class.forName(mainClassName, true, classLoader); - Method main = mainClass.getMethod("main", String[].class); - main.invoke(null, new Object[]{new String[0]}); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/JAXXCapture.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/JAXXCapture.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/JAXXCapture.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/JAXXCapture.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,398 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tools.jaxxcapture; + +import jaxx.compiler.ClassMap; +import jaxx.compiler.CompiledObject; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import jaxx.compiler.tools.jaxxcapture.handlers.JTabbedPaneHandler; +import jaxx.compiler.tools.jaxxcapture.handlers.ObjectHandler; +import jaxx.compiler.tools.jaxxcapture.handlers.TableHandler; +import jaxx.compiler.types.TypeManager; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.Text; +import org.xml.sax.SAXException; + +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JTabbedPane; +import javax.swing.JWindow; +import javax.swing.SwingUtilities; +import java.awt.AWTEvent; +import java.awt.Component; +import java.awt.Container; +import java.awt.EventQueue; +import java.awt.Toolkit; +import java.awt.Window; +import java.awt.event.MouseEvent; +import java.beans.XMLEncoder; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Stack; +import java.util.jar.Attributes; +import java.util.jar.JarFile; +import java.util.jar.Manifest; + +public class JAXXCapture { + + private static ClassMap<Object> objectHandlers = new ClassMap<Object>(); + + static { + //TODO make a serviceLoader mecanism to allow inter-module loading + objectHandlers.put(ClassDescriptorLoader.getClassDescriptor(Object.class), new ObjectHandler()); + objectHandlers.put(ClassDescriptorLoader.getClassDescriptor(JTabbedPane.class), new JTabbedPaneHandler()); + try { + objectHandlers.put(ClassDescriptorLoader.getClassDescriptor("jaxx.runtime.swing.Table"), new TableHandler()); + } catch (ClassNotFoundException e) { + System.err.println(e); + } + } + private Map<String, Object> sourceObjects = new HashMap<String, Object>(); + private Map<String, CapturedObject> capturedObjects = new HashMap<String, CapturedObject>(); + private ClassLoader classLoader; + private int count; + + private static class CaptureEventQueue extends EventQueue { + + private ClassLoader classLoader; + + private CaptureEventQueue(ClassLoader classLoader) { + this.classLoader = classLoader; + } + + @Override + public void dispatchEvent(AWTEvent event) { + if (event.getID() == MouseEvent.MOUSE_PRESSED && ((MouseEvent) event).isControlDown()) { + Component target = ((MouseEvent) event).getComponent(); + if (!(target instanceof Window)) { + target = SwingUtilities.getWindowAncestor(target); + } + if (target instanceof JFrame) { + target = ((JFrame) target).getContentPane(); + } else if (target instanceof JDialog) { + target = ((JDialog) target).getContentPane(); + } + if (target instanceof JWindow) { + target = ((JWindow) target).getContentPane(); + } + if (target != null) { + Thread.currentThread().setContextClassLoader(classLoader); + JAXXCapture capture = new JAXXCapture(classLoader); + capture.applyNames(target); + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + XMLEncoder encoder = new XMLEncoder(buffer); + encoder.writeObject(target); + encoder.close(); + try { + System.err.println(new String(buffer.toByteArray())); + System.out.println(capture.convertToJAXX(new ByteArrayInputStream(buffer.toByteArray()))); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + super.dispatchEvent(event); + } + } + + private JAXXCapture(ClassLoader classLoader) { + this.classLoader = classLoader; + } + + public ClassLoader getClassLoader() { + return classLoader; + } + + public Map<String, CapturedObject> getCapturedObjects() { + return capturedObjects; + } + + private void applyNames(Component target) { + String name = target.getName(); + if (name == null || sourceObjects.containsKey(name) || !CompiledObject.isValidID(name)) { + do { + name = "Object" + ++count; + } while (sourceObjects.containsKey(name)); + } + target.setName(name); + assert !sourceObjects.containsKey(name) : "ID " + name + " is already registered"; + sourceObjects.put(name, target); + + if (target instanceof Container) { + Container container = (Container) target; + for (int i = 0; i < container.getComponentCount(); i++) { + applyNames(container.getComponent(i)); + } + } + } + + public static String getText(Element tag) { // NOT a safe general-purpose implementation! + return ((Text) tag.getChildNodes().item(0)).getData(); + } + + private String getArgumentsCode(ContextNode[] arguments) { + StringBuffer result = new StringBuffer(); + result.append('('); + for (int i = 0; i < arguments.length; i++) { + if (i != 0) { + result.append(", "); + } + result.append(getJavaCode(arguments[i])); + } + result.append(')'); + return result.toString(); + } + + public String getJavaCode(ContextNode node) { + StringBuffer result = new StringBuffer(); + if (node instanceof PropertyNode) { + ContextNode[] arguments = node.getArguments(); + result.append(arguments.length == 0 ? "get" : "set"); + result.append(org.apache.commons.lang.StringUtils.capitalize(((PropertyNode) node).getProperty())); + result.append(getArgumentsCode(arguments)); + } else if (node instanceof MethodNode) { + result.append((((MethodNode) node).getMethodName())); + result.append(getArgumentsCode(node.getArguments())); + } else if (node instanceof CapturedObject) { + CapturedObject object = (CapturedObject) node; + if (object.isInlineable()) { + result.append("new "); + result.append(object.getClassName()); + result.append(getArgumentsCode(node.getArguments())); + } else { + String id = object.getProperty("id"); + assert id != null; + result.append(id); + } + } else if (node instanceof ValueNode) { + result.append(TypeManager.getJavaCode(((ValueNode) node).getValue())); + } else if (node instanceof LiteralNode) { + result.append(((LiteralNode) node).getJavaCode()); + } else { + throw new IllegalArgumentException("unrecognized node type: " + node); + } + return result.toString(); + } + + // returns the best matching method for the specified argument types + private static Method getMethod(Class<?> target, String methodName, Class<?>[] arguments) { + try { + // use the package-private class java.beans.ReflectionUtils to resolve the method. This isn't 100% safe, but it's better than + // having to rewrite the resolution myself. + Class<?> reflectionUtils = Class.forName("java.beans.ReflectionUtils"); + Method getMethod = reflectionUtils.getDeclaredMethod("getMethod", new Class<?>[]{Class.class, String.class, Class[].class}); + getMethod.setAccessible(true); + return (Method) getMethod.invoke(null, target, methodName, arguments); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + // returns the best matching constructor for the specified argument types + private static Constructor<?> getConstructor(Class<?> target, Class<?>[] arguments) { + try { + // use the package-private class java.beans.ReflectionUtils to resolve the constructor. This isn't 100% safe, but it's better than + // having to rewrite the resolution myself. + Class<?> reflectionUtils = Class.forName("java.beans.ReflectionUtils"); + Method getConstructor = reflectionUtils.getDeclaredMethod("getConstructor", new Class<?>[]{Class.class, Class[].class}); + getConstructor.setAccessible(true); + return (Constructor<?>) getConstructor.invoke(null, target, arguments); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + private Object createInstance(CapturedObject object) { + try { + ContextNode[] argumentNodes = object.getArguments(); + Object[] arguments = new Object[argumentNodes.length]; + Class<?>[] argumentTypes = new Class<?>[argumentNodes.length]; + for (int j = 0; j < argumentNodes.length; j++) { + if (argumentNodes[j] instanceof ValueNode) { + arguments[j] = ((ValueNode) argumentNodes[j]).getValue(); + argumentTypes[j] = arguments[j] != null ? arguments[j].getClass() : null; + } else if (argumentNodes[j] instanceof CapturedObject) { + arguments[j] = createInstance((CapturedObject) argumentNodes[j]); + argumentTypes[j] = arguments[j] != null ? arguments[j].getClass() : null; + } + } + Constructor<?> constructor = getConstructor(Class.forName(object.getClassName(), true, classLoader), argumentTypes); + return constructor.newInstance(arguments); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + public String getJavaCode(Stack/*<ContextNode>*/ context) { + CapturedObject contextCapturedObject = (CapturedObject) context.get(0); + StringBuffer result = new StringBuffer(); + int start = 1; + for (int i = context.size() - 1; i > 1; i--) { + if (context.get(i) instanceof CapturedObject) { + start = i; + contextCapturedObject = (CapturedObject) context.get(i); + break; + } + } + Object contextObject = sourceObjects.get(contextCapturedObject.getProperty("id")); + Class<?> contextClass = contextObject != null ? contextObject.getClass() : null; + + for (int i = start; i < context.size(); i++) { + ContextNode node = (ContextNode) context.get(i); + if (contextObject != null && (node instanceof MethodNode || node instanceof PropertyNode)) { + // need to follow the call chain so we can insert typecasts as necessary + try { + String methodName; + ContextNode[] argumentNodes = node.getArguments(); + if (node instanceof MethodNode) { + methodName = ((MethodNode) node).getMethodName(); + } else { + methodName = (argumentNodes.length == 0 ? "get" : "set") + org.apache.commons.lang.StringUtils.capitalize(((PropertyNode) node).getProperty()); + } + Object[] arguments = new Object[argumentNodes.length]; + Class<?>[] argumentTypes = new Class<?>[argumentNodes.length]; + for (int j = 0; j < argumentNodes.length; j++) { + if (argumentNodes[j] instanceof ValueNode) { + arguments[j] = ((ValueNode) argumentNodes[j]).getValue(); + argumentTypes[j] = arguments[j] != null ? arguments[j].getClass() : null; + } else if (argumentNodes[j] instanceof CapturedObject) { + arguments[j] = createInstance((CapturedObject) argumentNodes[j]); + argumentTypes[j] = arguments[j].getClass(); + } else if (argumentNodes[j] instanceof LiteralNode) { + arguments[j] = ((LiteralNode) argumentNodes[j]).getValue(); + argumentTypes[j] = arguments[j].getClass(); + } else { + throw new IllegalArgumentException("unsupported argument type: " + argumentNodes[j]); + } + } + + Method method = getMethod(contextClass, methodName, argumentTypes); + if (method == null) { + // could not find method in contextClass, must be defined in a subclass -- insert a typecast + result.insert(0, "((" + getOutputName(contextObject.getClass()) + ") "); + result.append(')'); + method = getMethod(contextObject.getClass(), methodName, argumentTypes); + } + if (method == null) { + throw new RuntimeException("could not find method " + methodName + Arrays.asList(argumentTypes) + " in " + contextObject.getClass() + " (context: " + context + ")"); + } + contextObject = method.invoke(contextObject, arguments); + contextClass = method.getReturnType(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + if (i > start) { + result.append('.'); + } + + result.append(getJavaCode(node)); + } + return result + ";"; + } + + private String getOutputName(Class<?> c) { + return c.getName(); + } + + public CapturedObject processObject(Element objectTag, Stack<ContextNode> context) { + String className = objectTag.getAttribute("class"); + ObjectHandler handler; + if (className.length() > 0) { + try { + ClassDescriptor descriptor = ClassDescriptorLoader.getClassDescriptor(className, classLoader); + handler = (ObjectHandler) objectHandlers.get(descriptor); + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } + } else { + handler = (ObjectHandler) objectHandlers.get(ClassDescriptorLoader.getClassDescriptor(Object.class)); + } + + return handler.processObject(objectTag, context, this); + } + + private synchronized String convertToJAXX(InputStream beansXML) throws IOException { + try { + Document document = JAXXCompiler.parseDocument(beansXML); + Element rootElement = document.getDocumentElement(); + NodeList nodes = rootElement.getChildNodes(); + Stack<ContextNode> context = new Stack<ContextNode>(); + for (int i = 0; i < nodes.getLength(); i++) { + Node child = nodes.item(i); + if (child.getNodeType() == Node.ELEMENT_NODE) { + Element element = (Element) child; + if (!element.getTagName().equals("object")) { + throw new Error("expected tag 'object', found '" + element.getTagName() + "'"); + } + CapturedObject root = processObject(element, context); + for (CapturedObject object : capturedObjects.values()) { // add all orphan objects to the root, so any non-inlineable ones have their XML created + if (object.getParent() == null && object != root) { + root.addChild(object, null); + } + } + return root.getXML(this); + } + } + return null; + } catch (SAXException e) { + throw new RuntimeException(e); + } finally { + reset(); + } + } + + private void reset() { + sourceObjects.clear(); + capturedObjects.clear(); + count = 0; + } + + public static void main(String[] arg) throws Exception { + File file = new File(arg[0]); + JarFile jarFile = new JarFile(file); + ClassLoader classLoader = new URLClassLoader(new URL[]{file.toURI().toURL()}); + Thread.currentThread().setContextClassLoader(classLoader); + EventQueue systemQueue = Toolkit.getDefaultToolkit().getSystemEventQueue(); + systemQueue.push(new CaptureEventQueue(classLoader)); + Manifest mf = jarFile.getManifest(); + String mainClassName = mf.getMainAttributes().getValue(Attributes.Name.MAIN_CLASS); + Class<?> mainClass = Class.forName(mainClassName, true, classLoader); + Method main = mainClass.getMethod("main", String[].class); + main.invoke(null, new Object[]{new String[0]}); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/LiteralNode.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/LiteralNode.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/LiteralNode.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,40 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tools.jaxxcapture; - -public class LiteralNode extends AbstractContextNode { - private String javaCode; - private Object value; - - public LiteralNode(String javaCode, Object value) { - this.javaCode = javaCode; - this.value = value; - } - - - public String getJavaCode() { - return javaCode; - } - - public Object getValue() { - return value; - } -} \ No newline at end of file Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/LiteralNode.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/LiteralNode.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/LiteralNode.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/LiteralNode.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,40 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tools.jaxxcapture; + +public class LiteralNode extends AbstractContextNode { + private String javaCode; + private Object value; + + public LiteralNode(String javaCode, Object value) { + this.javaCode = javaCode; + this.value = value; + } + + + public String getJavaCode() { + return javaCode; + } + + public Object getValue() { + return value; + } +} \ No newline at end of file Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/MethodNode.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/MethodNode.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/MethodNode.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,39 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tools.jaxxcapture; - -public class MethodNode extends AbstractContextNode { - private String methodName; - - public MethodNode(String methodName) { - this.methodName = methodName; - } - - - public String getMethodName() { - return methodName; - } - - @Override - public String toString() { - return "Method[" + methodName + ", " + java.util.Arrays.asList(getArguments()) + "]"; - } -} \ No newline at end of file Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/MethodNode.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/MethodNode.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/MethodNode.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/MethodNode.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,39 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tools.jaxxcapture; + +public class MethodNode extends AbstractContextNode { + private String methodName; + + public MethodNode(String methodName) { + this.methodName = methodName; + } + + + public String getMethodName() { + return methodName; + } + + @Override + public String toString() { + return "Method[" + methodName + ", " + java.util.Arrays.asList(getArguments()) + "]"; + } +} \ No newline at end of file Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/PropertyNode.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/PropertyNode.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/PropertyNode.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,39 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tools.jaxxcapture; - -public class PropertyNode extends AbstractContextNode { - private String property; - - public PropertyNode(String property) { - this.property = property; - } - - - public String getProperty() { - return property; - } - - - public String toString() { - return "Property[" + property + ", " + java.util.Arrays.asList(getArguments()) + "]"; - } -} \ No newline at end of file Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/PropertyNode.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/PropertyNode.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/PropertyNode.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/PropertyNode.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,39 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tools.jaxxcapture; + +public class PropertyNode extends AbstractContextNode { + private String property; + + public PropertyNode(String property) { + this.property = property; + } + + + public String getProperty() { + return property; + } + + + public String toString() { + return "Property[" + property + ", " + java.util.Arrays.asList(getArguments()) + "]"; + } +} \ No newline at end of file Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ValueNode.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ValueNode.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ValueNode.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,34 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tools.jaxxcapture; - -public class ValueNode extends AbstractContextNode { - private Object value; - - public ValueNode(Object value) { - this.value = value; - } - - - public Object getValue() { - return value; - } -} \ No newline at end of file Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ValueNode.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ValueNode.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ValueNode.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ValueNode.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,34 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tools.jaxxcapture; + +public class ValueNode extends AbstractContextNode { + private Object value; + + public ValueNode(Object value) { + this.value = value; + } + + + public Object getValue() { + return value; + } +} \ No newline at end of file Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/JTabbedPaneHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/JTabbedPaneHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/JTabbedPaneHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,46 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tools.jaxxcapture.handlers; - -import jaxx.compiler.tools.jaxxcapture.ContextNode; -import jaxx.compiler.tools.jaxxcapture.JAXXCapture; -import jaxx.compiler.tools.jaxxcapture.MethodNode; -import org.w3c.dom.Element; - -import java.util.Arrays; -import java.util.Stack; - -public class JTabbedPaneHandler extends ObjectHandler { - - @Override - protected void evaluateMethod(Element tag, Stack<ContextNode> context, JAXXCapture capture) { - String methodName = tag.getAttribute("method"); - if (methodName.equals("addTab")) { - MethodNode addTab = new MethodNode(methodName); - context.push(addTab); - processChildren(tag, context, capture); - context.pop(); - System.err.println(Arrays.asList(addTab.getArguments())); - } else { - super.evaluateMethod(tag, context, capture); - } - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/JTabbedPaneHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/JTabbedPaneHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/JTabbedPaneHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/JTabbedPaneHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,46 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tools.jaxxcapture.handlers; + +import jaxx.compiler.tools.jaxxcapture.ContextNode; +import jaxx.compiler.tools.jaxxcapture.JAXXCapture; +import jaxx.compiler.tools.jaxxcapture.MethodNode; +import org.w3c.dom.Element; + +import java.util.Arrays; +import java.util.Stack; + +public class JTabbedPaneHandler extends ObjectHandler { + + @Override + protected void evaluateMethod(Element tag, Stack<ContextNode> context, JAXXCapture capture) { + String methodName = tag.getAttribute("method"); + if (methodName.equals("addTab")) { + MethodNode addTab = new MethodNode(methodName); + context.push(addTab); + processChildren(tag, context, capture); + context.pop(); + System.err.println(Arrays.asList(addTab.getArguments())); + } else { + super.evaluateMethod(tag, context, capture); + } + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/ObjectHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/ObjectHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/ObjectHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,343 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tools.jaxxcapture.handlers; - -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.java.JavaFileGenerator; -import jaxx.compiler.tools.jaxxcapture.CapturedObject; -import jaxx.compiler.tools.jaxxcapture.ContextNode; -import jaxx.compiler.tools.jaxxcapture.JAXXCapture; -import jaxx.compiler.tools.jaxxcapture.LiteralNode; -import jaxx.compiler.tools.jaxxcapture.MethodNode; -import jaxx.compiler.tools.jaxxcapture.PropertyNode; -import jaxx.compiler.tools.jaxxcapture.ValueNode; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import java.awt.Container; -import java.lang.reflect.Field; -import java.util.Map; -import java.util.Stack; - -public class ObjectHandler { - private static int count; - - protected CapturedObject createCapturedObject(String className, JAXXCapture capture) { - return new CapturedObject(this, className, capture); - } - - - // returns true if the tag has any "void" children - protected boolean processChildren(Element tag, Stack<ContextNode> context, JAXXCapture capture) { - boolean result = false; - NodeList children = tag.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { - Node child = children.item(i); - if (child.getNodeType() == Node.ELEMENT_NODE) { - Element innerTag = (Element) child; - if (innerTag.getTagName().equals("void")) { - result = true; - } - evaluate(innerTag, context, capture); - } - } - return result; - } - - - protected void evaluateProperty(Element tag, Stack<ContextNode> context, JAXXCapture capture) { - // determine containing object - CapturedObject contextObject = null; - for (int i = context.size() - 1; i >= 0; i--) { - if (context.get(i) instanceof CapturedObject) { - contextObject = (CapturedObject) context.get(i); - break; - } - } - assert contextObject != null; - - String property = tag.getAttribute("property"); - if (!property.equals("actionCommand")) { // filter out actionCommand due to screwiness in XMLEncoder's handling of it - Object current = context.peek(); - PropertyNode newContext = new PropertyNode(property); - context.push(newContext); - boolean voidChildren = processChildren(tag, context, capture); - - ContextNode[] arguments = newContext.getArguments(); - if (arguments.length == 1) { - if (current instanceof CapturedObject && arguments[0] instanceof ValueNode) // simple property assignment - { - ((CapturedObject) current).setProperty(property, dataBindingEncode(String.valueOf(((ValueNode) arguments[0]).getValue()))); - } else if (current instanceof CapturedObject && arguments[0] instanceof CapturedObject && ((CapturedObject) arguments[0]).isInlineable()) // simple data binding - { - ((CapturedObject) current).setProperty(property, "{" + capture.getJavaCode(arguments[0]) + "}"); - } else { - contextObject.setInlineable(false); - contextObject.appendScriptCode(capture.getJavaCode(context)); - } - } else if (!voidChildren) { - contextObject.setInlineable(false); - contextObject.appendScriptCode(capture.getJavaCode(context)); - } - - assert context.peek() == newContext; - context.pop(); - } - } - - - protected void evaluateAdd(CapturedObject contextObject, CapturedObject child, ContextNode constraints) { - contextObject.addChild(child, constraints); - } - - - protected void evaluateMethod(Element tag, Stack<ContextNode> context, JAXXCapture capture) { - // determine containing object - CapturedObject contextObject = null; - for (int i = context.size() - 1; i >= 0; i--) { - if (context.get(i) instanceof CapturedObject) { - contextObject = (CapturedObject) context.get(i); - break; - } - } - assert contextObject != null; - - try { - String methodName = tag.getAttribute("method"); - MethodNode newContext = new MethodNode(methodName); - context.push(newContext); - boolean voidChildren = processChildren(tag, context, capture); - boolean add = false; - - ContextNode[] arguments = newContext.getArguments(); - if (methodName.equals("add") && arguments.length >= 1 && arguments[0] instanceof CapturedObject) { - Class<?> contextClass = Class.forName(contextObject.getClassName(), true, capture.getClassLoader()); - if (Container.class.isAssignableFrom(contextClass)) { - add = true; - evaluateAdd(contextObject, (CapturedObject) arguments[0], null); - } - } - - if (!voidChildren && !add) { - contextObject.appendScriptCode(capture.getJavaCode(context)); - } - - assert context.peek() == newContext; - context.pop(); - } - catch (ClassNotFoundException e) { - throw new RuntimeException(e); - } - } - - - protected void evaluate(Element tag, Stack<ContextNode> context, JAXXCapture capture) { - String tagName = tag.getTagName(); - if (tagName.equals("object")) { - String fieldName = tag.getAttribute("field"); - ContextNode currentNode = context.peek(); - if (fieldName.length() > 0) { - try { - String className = tag.getAttribute("class"); - Field field = Class.forName(className, true, capture.getClassLoader()).getField(fieldName); - Object value = field.get(null); - currentNode.addArgument(new LiteralNode(className + "." + fieldName, value)); - } - catch (Exception e) { - throw new RuntimeException(e); - } - } else { - currentNode.addArgument(capture.processObject(tag, context)); - } - } else if (tagName.equals("void")) { - String property = tag.getAttribute("property"); - if (property.length() > 0) { - evaluateProperty(tag, context, capture); - } else { - evaluateMethod(tag, context, capture); - } - } else if (tagName.equals("string")) { - context.peek().addArgument(new ValueNode(JAXXCapture.getText(tag))); - } else if (tagName.equals("boolean")) { - context.peek().addArgument(new ValueNode(Boolean.valueOf(JAXXCapture.getText(tag)))); - } else if (tagName.equals("char")) { - context.peek().addArgument(new ValueNode(JAXXCapture.getText(tag).charAt(0))); - } else if (tagName.equals("short")) { - context.peek().addArgument(new ValueNode(Short.valueOf(JAXXCapture.getText(tag)))); - } else if (tagName.equals("int")) { - context.peek().addArgument(new ValueNode(Integer.valueOf(JAXXCapture.getText(tag)))); - } else if (tagName.equals("long")) { - context.peek().addArgument(new ValueNode(Long.valueOf(JAXXCapture.getText(tag)))); - } else if (tagName.equals("float")) { - context.peek().addArgument(new ValueNode(Float.valueOf(JAXXCapture.getText(tag)))); - } else if (tagName.equals("double")) { - context.peek().addArgument(new ValueNode(Double.valueOf(JAXXCapture.getText(tag)))); - } else if (tagName.equals("null")) { - context.peek().addArgument(new ValueNode(null)); - } else { - System.err.println("unsupported tag: " + tag.getTagName()); - } - } - - - private static String dataBindingEncode(String value) { - return value.replaceAll("\\{", "\\\\{").replaceAll("\\}", "\\\\}"); - } - - - public CapturedObject processObject(Element objectTag, Stack<ContextNode> context, JAXXCapture capture) { - String className = objectTag.getAttribute("class"); - if (className.length() > 0) { - CapturedObject capturedObject = createCapturedObject(className, capture); - context.push(capturedObject); - NodeList children = objectTag.getChildNodes(); - String id = objectTag.getAttribute("id"); - if (id.length() == 0 || capture.getCapturedObjects().containsKey(id)) { - id = "Auto" + ++count; - } - assert !capture.getCapturedObjects().containsKey(id); - capture.getCapturedObjects().put(id, capturedObject); - capturedObject.setProperty("id", id); - // process object's name before anything else - for (int i = 0; i < children.getLength(); i++) { - Node child = children.item(i); - if (child.getNodeType() == Node.ELEMENT_NODE) { - Element element = (Element) child; - if (element.getTagName().equals("void") && element.getAttribute("property").equals("name")) { - evaluate(element, context, capture); - String name = capturedObject.getProperty("name"); - if (name != null && !capture.getCapturedObjects().containsKey(name)) { - capture.getCapturedObjects().put(name, capturedObject); - capturedObject.setProperty("id", name); - capturedObject.getProperties().remove("name"); - } - } - } - } - // process remaining children - for (int i = 0; i < children.getLength(); i++) { - Node child = children.item(i); - if (child.getNodeType() == Node.ELEMENT_NODE) { - Element element = (Element) child; - if (!element.getTagName().equals("void") || !element.getAttribute("property").equals("name")) { - evaluate(element, context, capture); - } - } - } - assert context.peek() == capturedObject; - context.pop(); - - return capturedObject; - } else { - CapturedObject result = capture.getCapturedObjects().get(objectTag.getAttribute("idref")); - if (result == null) { - throw new RuntimeException("Internal error: could not find tag with id " + objectTag.getAttribute("idref")); - } - result.setInlineable(false); // we have at least two references to it, and so can't inline it - return result; - } - } - - - private static String xmlEncode(String src) { - return src.replaceAll("'", "&").replaceAll("<", "<"); - } - - - public String getXML(CapturedObject object, JAXXCapture capture) { - StringBuffer result = new StringBuffer(); - result.append('<'); - String className = object.getClassName(); - if (className.startsWith("javax.swing.")) { - className = className.substring("javax.swing.".length()); - } - result.append(className); - Map<String, String> properties = object.getProperties(); - for (Map.Entry<String, String> e : properties.entrySet()) { - result.append(' '); - result.append(e.getKey()); - result.append("='"); - result.append(xmlEncode(e.getValue())); - result.append('\''); - } - ContextNode[] arguments = object.getArguments(); - if (arguments != null && arguments.length > 0) { - result.append(" constructorParams='"); - for (int j = 0; j < arguments.length; j++) { - if (j != 0) { - result.append(", "); - } - result.append(capture.getJavaCode(arguments[j])); - } - result.append('\''); - } - boolean tagClosed = false; - - String children = getChildXML(object, capture); - String lineSeparator = JAXXCompiler.getLineSeparator(); - if (children != null && children.length() > 0) { - if (!tagClosed) { - tagClosed = true; - result.append('>'); - result.append(lineSeparator); - } - result.append(children); - } - - String script = object.getScriptCode(); - if (script != null && script.length() > 0) { - if (!tagClosed) { - tagClosed = true; - result.append('>'); - result.append(lineSeparator); - } - result.append(" <script>"); - result.append(lineSeparator); - result.append(JavaFileGenerator.indent(script, 4, false, lineSeparator)); - result.append(lineSeparator); - result.append(" </script>"); - result.append(lineSeparator); - } - if (tagClosed) { - result.append("</"); - result.append(className); - result.append('>'); - } else { - result.append("/>"); - } - return result.toString(); - } - - - protected String getChildXML(CapturedObject object, JAXXCapture capture) { - StringBuffer result = new StringBuffer(); - CapturedObject[] children = object.getChildren(); - String lineSeparator = JAXXCompiler.getLineSeparator(); - for (CapturedObject aChildren : children) { - if (!aChildren.isInlineable()) { - result.append(JavaFileGenerator.indent(aChildren.getXML(capture), 2, false, lineSeparator)); - result.append(lineSeparator); - } - } - return result.toString(); - } -} \ No newline at end of file Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/ObjectHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/ObjectHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/ObjectHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/ObjectHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,343 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tools.jaxxcapture.handlers; + +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.java.JavaFileGenerator; +import jaxx.compiler.tools.jaxxcapture.CapturedObject; +import jaxx.compiler.tools.jaxxcapture.ContextNode; +import jaxx.compiler.tools.jaxxcapture.JAXXCapture; +import jaxx.compiler.tools.jaxxcapture.LiteralNode; +import jaxx.compiler.tools.jaxxcapture.MethodNode; +import jaxx.compiler.tools.jaxxcapture.PropertyNode; +import jaxx.compiler.tools.jaxxcapture.ValueNode; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import java.awt.Container; +import java.lang.reflect.Field; +import java.util.Map; +import java.util.Stack; + +public class ObjectHandler { + private static int count; + + protected CapturedObject createCapturedObject(String className, JAXXCapture capture) { + return new CapturedObject(this, className, capture); + } + + + // returns true if the tag has any "void" children + protected boolean processChildren(Element tag, Stack<ContextNode> context, JAXXCapture capture) { + boolean result = false; + NodeList children = tag.getChildNodes(); + for (int i = 0; i < children.getLength(); i++) { + Node child = children.item(i); + if (child.getNodeType() == Node.ELEMENT_NODE) { + Element innerTag = (Element) child; + if (innerTag.getTagName().equals("void")) { + result = true; + } + evaluate(innerTag, context, capture); + } + } + return result; + } + + + protected void evaluateProperty(Element tag, Stack<ContextNode> context, JAXXCapture capture) { + // determine containing object + CapturedObject contextObject = null; + for (int i = context.size() - 1; i >= 0; i--) { + if (context.get(i) instanceof CapturedObject) { + contextObject = (CapturedObject) context.get(i); + break; + } + } + assert contextObject != null; + + String property = tag.getAttribute("property"); + if (!property.equals("actionCommand")) { // filter out actionCommand due to screwiness in XMLEncoder's handling of it + Object current = context.peek(); + PropertyNode newContext = new PropertyNode(property); + context.push(newContext); + boolean voidChildren = processChildren(tag, context, capture); + + ContextNode[] arguments = newContext.getArguments(); + if (arguments.length == 1) { + if (current instanceof CapturedObject && arguments[0] instanceof ValueNode) // simple property assignment + { + ((CapturedObject) current).setProperty(property, dataBindingEncode(String.valueOf(((ValueNode) arguments[0]).getValue()))); + } else if (current instanceof CapturedObject && arguments[0] instanceof CapturedObject && ((CapturedObject) arguments[0]).isInlineable()) // simple data binding + { + ((CapturedObject) current).setProperty(property, "{" + capture.getJavaCode(arguments[0]) + "}"); + } else { + contextObject.setInlineable(false); + contextObject.appendScriptCode(capture.getJavaCode(context)); + } + } else if (!voidChildren) { + contextObject.setInlineable(false); + contextObject.appendScriptCode(capture.getJavaCode(context)); + } + + assert context.peek() == newContext; + context.pop(); + } + } + + + protected void evaluateAdd(CapturedObject contextObject, CapturedObject child, ContextNode constraints) { + contextObject.addChild(child, constraints); + } + + + protected void evaluateMethod(Element tag, Stack<ContextNode> context, JAXXCapture capture) { + // determine containing object + CapturedObject contextObject = null; + for (int i = context.size() - 1; i >= 0; i--) { + if (context.get(i) instanceof CapturedObject) { + contextObject = (CapturedObject) context.get(i); + break; + } + } + assert contextObject != null; + + try { + String methodName = tag.getAttribute("method"); + MethodNode newContext = new MethodNode(methodName); + context.push(newContext); + boolean voidChildren = processChildren(tag, context, capture); + boolean add = false; + + ContextNode[] arguments = newContext.getArguments(); + if (methodName.equals("add") && arguments.length >= 1 && arguments[0] instanceof CapturedObject) { + Class<?> contextClass = Class.forName(contextObject.getClassName(), true, capture.getClassLoader()); + if (Container.class.isAssignableFrom(contextClass)) { + add = true; + evaluateAdd(contextObject, (CapturedObject) arguments[0], null); + } + } + + if (!voidChildren && !add) { + contextObject.appendScriptCode(capture.getJavaCode(context)); + } + + assert context.peek() == newContext; + context.pop(); + } + catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } + } + + + protected void evaluate(Element tag, Stack<ContextNode> context, JAXXCapture capture) { + String tagName = tag.getTagName(); + if (tagName.equals("object")) { + String fieldName = tag.getAttribute("field"); + ContextNode currentNode = context.peek(); + if (fieldName.length() > 0) { + try { + String className = tag.getAttribute("class"); + Field field = Class.forName(className, true, capture.getClassLoader()).getField(fieldName); + Object value = field.get(null); + currentNode.addArgument(new LiteralNode(className + "." + fieldName, value)); + } + catch (Exception e) { + throw new RuntimeException(e); + } + } else { + currentNode.addArgument(capture.processObject(tag, context)); + } + } else if (tagName.equals("void")) { + String property = tag.getAttribute("property"); + if (property.length() > 0) { + evaluateProperty(tag, context, capture); + } else { + evaluateMethod(tag, context, capture); + } + } else if (tagName.equals("string")) { + context.peek().addArgument(new ValueNode(JAXXCapture.getText(tag))); + } else if (tagName.equals("boolean")) { + context.peek().addArgument(new ValueNode(Boolean.valueOf(JAXXCapture.getText(tag)))); + } else if (tagName.equals("char")) { + context.peek().addArgument(new ValueNode(JAXXCapture.getText(tag).charAt(0))); + } else if (tagName.equals("short")) { + context.peek().addArgument(new ValueNode(Short.valueOf(JAXXCapture.getText(tag)))); + } else if (tagName.equals("int")) { + context.peek().addArgument(new ValueNode(Integer.valueOf(JAXXCapture.getText(tag)))); + } else if (tagName.equals("long")) { + context.peek().addArgument(new ValueNode(Long.valueOf(JAXXCapture.getText(tag)))); + } else if (tagName.equals("float")) { + context.peek().addArgument(new ValueNode(Float.valueOf(JAXXCapture.getText(tag)))); + } else if (tagName.equals("double")) { + context.peek().addArgument(new ValueNode(Double.valueOf(JAXXCapture.getText(tag)))); + } else if (tagName.equals("null")) { + context.peek().addArgument(new ValueNode(null)); + } else { + System.err.println("unsupported tag: " + tag.getTagName()); + } + } + + + private static String dataBindingEncode(String value) { + return value.replaceAll("\\{", "\\\\{").replaceAll("\\}", "\\\\}"); + } + + + public CapturedObject processObject(Element objectTag, Stack<ContextNode> context, JAXXCapture capture) { + String className = objectTag.getAttribute("class"); + if (className.length() > 0) { + CapturedObject capturedObject = createCapturedObject(className, capture); + context.push(capturedObject); + NodeList children = objectTag.getChildNodes(); + String id = objectTag.getAttribute("id"); + if (id.length() == 0 || capture.getCapturedObjects().containsKey(id)) { + id = "Auto" + ++count; + } + assert !capture.getCapturedObjects().containsKey(id); + capture.getCapturedObjects().put(id, capturedObject); + capturedObject.setProperty("id", id); + // process object's name before anything else + for (int i = 0; i < children.getLength(); i++) { + Node child = children.item(i); + if (child.getNodeType() == Node.ELEMENT_NODE) { + Element element = (Element) child; + if (element.getTagName().equals("void") && element.getAttribute("property").equals("name")) { + evaluate(element, context, capture); + String name = capturedObject.getProperty("name"); + if (name != null && !capture.getCapturedObjects().containsKey(name)) { + capture.getCapturedObjects().put(name, capturedObject); + capturedObject.setProperty("id", name); + capturedObject.getProperties().remove("name"); + } + } + } + } + // process remaining children + for (int i = 0; i < children.getLength(); i++) { + Node child = children.item(i); + if (child.getNodeType() == Node.ELEMENT_NODE) { + Element element = (Element) child; + if (!element.getTagName().equals("void") || !element.getAttribute("property").equals("name")) { + evaluate(element, context, capture); + } + } + } + assert context.peek() == capturedObject; + context.pop(); + + return capturedObject; + } else { + CapturedObject result = capture.getCapturedObjects().get(objectTag.getAttribute("idref")); + if (result == null) { + throw new RuntimeException("Internal error: could not find tag with id " + objectTag.getAttribute("idref")); + } + result.setInlineable(false); // we have at least two references to it, and so can't inline it + return result; + } + } + + + private static String xmlEncode(String src) { + return src.replaceAll("'", "&").replaceAll("<", "<"); + } + + + public String getXML(CapturedObject object, JAXXCapture capture) { + StringBuffer result = new StringBuffer(); + result.append('<'); + String className = object.getClassName(); + if (className.startsWith("javax.swing.")) { + className = className.substring("javax.swing.".length()); + } + result.append(className); + Map<String, String> properties = object.getProperties(); + for (Map.Entry<String, String> e : properties.entrySet()) { + result.append(' '); + result.append(e.getKey()); + result.append("='"); + result.append(xmlEncode(e.getValue())); + result.append('\''); + } + ContextNode[] arguments = object.getArguments(); + if (arguments != null && arguments.length > 0) { + result.append(" constructorParams='"); + for (int j = 0; j < arguments.length; j++) { + if (j != 0) { + result.append(", "); + } + result.append(capture.getJavaCode(arguments[j])); + } + result.append('\''); + } + boolean tagClosed = false; + + String children = getChildXML(object, capture); + String lineSeparator = JAXXCompiler.getLineSeparator(); + if (children != null && children.length() > 0) { + if (!tagClosed) { + tagClosed = true; + result.append('>'); + result.append(lineSeparator); + } + result.append(children); + } + + String script = object.getScriptCode(); + if (script != null && script.length() > 0) { + if (!tagClosed) { + tagClosed = true; + result.append('>'); + result.append(lineSeparator); + } + result.append(" <script>"); + result.append(lineSeparator); + result.append(JavaFileGenerator.indent(script, 4, false, lineSeparator)); + result.append(lineSeparator); + result.append(" </script>"); + result.append(lineSeparator); + } + if (tagClosed) { + result.append("</"); + result.append(className); + result.append('>'); + } else { + result.append("/>"); + } + return result.toString(); + } + + + protected String getChildXML(CapturedObject object, JAXXCapture capture) { + StringBuffer result = new StringBuffer(); + CapturedObject[] children = object.getChildren(); + String lineSeparator = JAXXCompiler.getLineSeparator(); + for (CapturedObject aChildren : children) { + if (!aChildren.isInlineable()) { + result.append(JavaFileGenerator.indent(aChildren.getXML(capture), 2, false, lineSeparator)); + result.append(lineSeparator); + } + } + return result.toString(); + } +} \ No newline at end of file Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/TableHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/TableHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/TableHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,34 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tools.jaxxcapture.handlers; - -import jaxx.compiler.tools.jaxxcapture.CapturedObject; -import jaxx.compiler.tools.jaxxcapture.JAXXCapture; - -public class TableHandler extends ObjectHandler { - - @Override - protected CapturedObject createCapturedObject(String className, JAXXCapture capture) { - CapturedObject result = new CapturedObject(this, "javax.swing.JPanel", capture); - result.setProperty("layout", "{new GridBagLayout()}"); - return result; - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/TableHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/TableHandler.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/TableHandler.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/TableHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,34 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tools.jaxxcapture.handlers; + +import jaxx.compiler.tools.jaxxcapture.CapturedObject; +import jaxx.compiler.tools.jaxxcapture.JAXXCapture; + +public class TableHandler extends ObjectHandler { + + @Override + protected CapturedObject createCapturedObject(String className, JAXXCapture capture) { + CapturedObject result = new CapturedObject(this, "javax.swing.JPanel", capture); + result.setProperty("layout", "{new GridBagLayout()}"); + return result; + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/ColorConverter.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/ColorConverter.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/ColorConverter.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,58 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.types; - -import java.awt.Color; -import java.lang.reflect.Field; - -public class ColorConverter implements TypeConverter { - - @Override - public Class<?>[] getSupportedTypes() { - return new Class<?>[]{ - Color.class - }; - } - - @Override - public String getJavaCode(Object object) { - Color color = (Color) object; - return "new Color(" + color.getRed() + ", " + color.getGreen() + ", " + color.getBlue() + ")"; - } - - @Override - public Object convertFromString(String string, Class<?> type) { - if (type != Color.class) { - throw new IllegalArgumentException("unsupported type: " + type); - } - if (string.length() == 7 && string.charAt(0) == '#') { - return new Color(Integer.parseInt(string.substring(1), 16)); - } - try { - Field color = Color.class.getField(string); - return color.get(null); - } catch (NoSuchFieldException e) { - throw new IllegalArgumentException("colors must be of the form #xxxxxx ('#' followed by six hexadecimal digits), or the name of a constant field in java.awt.Color (found: '" + string + "')"); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/ColorConverter.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/ColorConverter.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/ColorConverter.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/ColorConverter.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,58 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.types; + +import java.awt.Color; +import java.lang.reflect.Field; + +public class ColorConverter implements TypeConverter { + + @Override + public Class<?>[] getSupportedTypes() { + return new Class<?>[]{ + Color.class + }; + } + + @Override + public String getJavaCode(Object object) { + Color color = (Color) object; + return "new Color(" + color.getRed() + ", " + color.getGreen() + ", " + color.getBlue() + ")"; + } + + @Override + public Object convertFromString(String string, Class<?> type) { + if (type != Color.class) { + throw new IllegalArgumentException("unsupported type: " + type); + } + if (string.length() == 7 && string.charAt(0) == '#') { + return new Color(Integer.parseInt(string.substring(1), 16)); + } + try { + Field color = Color.class.getField(string); + return color.get(null); + } catch (NoSuchFieldException e) { + throw new IllegalArgumentException("colors must be of the form #xxxxxx ('#' followed by six hexadecimal digits), or the name of a constant field in java.awt.Color (found: '" + string + "')"); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/GridBagConstraintsConverter.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/GridBagConstraintsConverter.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/GridBagConstraintsConverter.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,46 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.types; - -import java.awt.GridBagConstraints; - -public class GridBagConstraintsConverter implements TypeConverter { - - @Override - public Class<?>[] getSupportedTypes() { - return new Class<?>[] { - GridBagConstraints.class - }; - } - - @Override - public String getJavaCode(Object object) { - GridBagConstraints g = (GridBagConstraints) object; - return "new GridBagConstraints(" + g.gridx + ", " + g.gridy + ", " + g.gridwidth + ", " + g.gridheight + ", " + - g.weightx + ", " + g.weighty + ", " + g.anchor + ", " + g.fill + ", " + - TypeManager.getJavaCode(g.insets) + ", " + g.ipadx + ", " + g.ipady + ")"; - } - - @Override - public Object convertFromString(String string, Class<?> type) { - throw new UnsupportedOperationException("GridBagConstraints must be represented using Java code"); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/GridBagConstraintsConverter.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/GridBagConstraintsConverter.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/GridBagConstraintsConverter.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/GridBagConstraintsConverter.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,46 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.types; + +import java.awt.GridBagConstraints; + +public class GridBagConstraintsConverter implements TypeConverter { + + @Override + public Class<?>[] getSupportedTypes() { + return new Class<?>[] { + GridBagConstraints.class + }; + } + + @Override + public String getJavaCode(Object object) { + GridBagConstraints g = (GridBagConstraints) object; + return "new GridBagConstraints(" + g.gridx + ", " + g.gridy + ", " + g.gridwidth + ", " + g.gridheight + ", " + + g.weightx + ", " + g.weighty + ", " + g.anchor + ", " + g.fill + ", " + + TypeManager.getJavaCode(g.insets) + ", " + g.ipadx + ", " + g.ipady + ")"; + } + + @Override + public Object convertFromString(String string, Class<?> type) { + throw new UnsupportedOperationException("GridBagConstraints must be represented using Java code"); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/InsetsConverter.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/InsetsConverter.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/InsetsConverter.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,59 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.types; - -import java.awt.Insets; -import java.util.StringTokenizer; - -public class InsetsConverter implements TypeConverter { - - @Override - public Class<?>[] getSupportedTypes() { - return new Class<?>[]{Insets.class}; - } - - @Override - public String getJavaCode(Object object) { - Insets insets = (Insets) object; - return "new Insets(" + insets.top + ", " + insets.left + ", " + insets.bottom + ", " + insets.right + ")"; - } - - @Override - public Object convertFromString(String string, Class<?> type) { - if (type != Insets.class) { - throw new IllegalArgumentException("unsupported type: " + type); - } - StringTokenizer tokenizer = new StringTokenizer(string, ","); - int count = tokenizer.countTokens(); - if (count == 1) { - int i = Integer.parseInt(tokenizer.nextToken().trim()); - return new Insets(i, i, i, i); - } - if (count == 4) { - int[] insets = new int[count]; - for (int i = 0; tokenizer.hasMoreTokens(); i++) { - insets[i] = Integer.parseInt(tokenizer.nextToken().trim()); - } - return new Insets(insets[0], insets[1], insets[2], insets[3]); - } - throw new IllegalArgumentException("unable to convert string '" + string + "' to Insets"); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/InsetsConverter.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/InsetsConverter.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/InsetsConverter.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/InsetsConverter.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,59 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.types; + +import java.awt.Insets; +import java.util.StringTokenizer; + +public class InsetsConverter implements TypeConverter { + + @Override + public Class<?>[] getSupportedTypes() { + return new Class<?>[]{Insets.class}; + } + + @Override + public String getJavaCode(Object object) { + Insets insets = (Insets) object; + return "new Insets(" + insets.top + ", " + insets.left + ", " + insets.bottom + ", " + insets.right + ")"; + } + + @Override + public Object convertFromString(String string, Class<?> type) { + if (type != Insets.class) { + throw new IllegalArgumentException("unsupported type: " + type); + } + StringTokenizer tokenizer = new StringTokenizer(string, ","); + int count = tokenizer.countTokens(); + if (count == 1) { + int i = Integer.parseInt(tokenizer.nextToken().trim()); + return new Insets(i, i, i, i); + } + if (count == 4) { + int[] insets = new int[count]; + for (int i = 0; tokenizer.hasMoreTokens(); i++) { + insets[i] = Integer.parseInt(tokenizer.nextToken().trim()); + } + return new Insets(insets[0], insets[1], insets[2], insets[3]); + } + throw new IllegalArgumentException("unable to convert string '" + string + "' to Insets"); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/KeyStrokeConverter.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/KeyStrokeConverter.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/KeyStrokeConverter.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,44 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.types; - -import javax.swing.KeyStroke; - -public class KeyStrokeConverter implements TypeConverter { - - @Override - public Class<?>[] getSupportedTypes() { - return new Class<?>[]{KeyStroke.class}; - } - - @Override - public String getJavaCode(Object object) { - return "KeyStroke.getKeyStroke(\"" + object.toString() + "\")"; - } - - @Override - public Object convertFromString(String string, Class<?> type) { - if (type != KeyStroke.class) { - throw new IllegalArgumentException("unsupported type: " + type); - } - return KeyStroke.getKeyStroke(string); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/KeyStrokeConverter.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/KeyStrokeConverter.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/KeyStrokeConverter.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/KeyStrokeConverter.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,44 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.types; + +import javax.swing.KeyStroke; + +public class KeyStrokeConverter implements TypeConverter { + + @Override + public Class<?>[] getSupportedTypes() { + return new Class<?>[]{KeyStroke.class}; + } + + @Override + public String getJavaCode(Object object) { + return "KeyStroke.getKeyStroke(\"" + object.toString() + "\")"; + } + + @Override + public Object convertFromString(String string, Class<?> type) { + if (type != KeyStroke.class) { + throw new IllegalArgumentException("unsupported type: " + type); + } + return KeyStroke.getKeyStroke(string); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/PrimitiveConverter.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/PrimitiveConverter.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/PrimitiveConverter.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,120 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.types; - -import jaxx.compiler.JAXXCompiler; - -public class PrimitiveConverter implements TypeConverter { - - @Override - public Class<?>[] getSupportedTypes() { - - return new Class<?>[]{ - boolean.class, - Boolean.class, - byte.class, - Byte.class, - short.class, - Short.class, - int.class, - Integer.class, - long.class, - Long.class, - float.class, - Float.class, - double.class, - Double.class, - char.class, - Character.class, - String.class - }; - } - - @Override - public String getJavaCode(Object object) { - if (object instanceof Boolean) { - return String.valueOf(((Boolean) object).booleanValue()); - } - if (object instanceof Byte) { - return String.valueOf(((Byte) object).byteValue()); - } - if (object instanceof Short) { - return String.valueOf(((Short) object).shortValue()); - } - if (object instanceof Integer) { - return String.valueOf(((Integer) object).intValue()); - } - if (object instanceof Long) { - return String.valueOf(((Long) object).longValue()) + "L"; - } - if (object instanceof Float) { - return String.valueOf(((Float) object).floatValue()) + "F"; - } - if (object instanceof Double) { - return String.valueOf(((Double) object).doubleValue()); - } - if (object instanceof String) { - return '"' + JAXXCompiler.escapeJavaString((String) object) + '"'; - } - throw new IllegalArgumentException("unsupported object: " + object); - } - - @Override - public Object convertFromString(String string, Class<?> type) { - if (type == String.class || type == Object.class || type == null) { - return string; - } - if (type == int.class || type == Integer.class) { - return Integer.valueOf(string); - } - if (type == boolean.class || type == Boolean.class) { - if (string.toLowerCase().equals("true")) { - return Boolean.TRUE; - } - if (string.toLowerCase().equals("false")) { - return Boolean.FALSE; - } - throw new IllegalArgumentException("expected 'true' or 'false', found '" + string + "'"); - } - if (type == byte.class || type == Byte.class) { - return Byte.valueOf(string); - } - if (type == short.class || type == Short.class) { - return Short.valueOf(string); - } - if (type == long.class || type == Long.class) { - return Long.valueOf(string); - } - if (type == float.class || type == Float.class) { - return Float.valueOf(string); - } - if (type == double.class || type == Double.class) { - return Double.valueOf(string); - } - if (type == char.class || type == Character.class) { - if (string.length() == 1) { - return string.charAt(0); - } - throw new IllegalArgumentException("expected a single character, found '" + string + "'"); - } - throw new IllegalArgumentException("unsupported type: " + type); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/PrimitiveConverter.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/PrimitiveConverter.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/PrimitiveConverter.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/PrimitiveConverter.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,120 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.types; + +import jaxx.compiler.JAXXCompiler; + +public class PrimitiveConverter implements TypeConverter { + + @Override + public Class<?>[] getSupportedTypes() { + + return new Class<?>[]{ + boolean.class, + Boolean.class, + byte.class, + Byte.class, + short.class, + Short.class, + int.class, + Integer.class, + long.class, + Long.class, + float.class, + Float.class, + double.class, + Double.class, + char.class, + Character.class, + String.class + }; + } + + @Override + public String getJavaCode(Object object) { + if (object instanceof Boolean) { + return String.valueOf(((Boolean) object).booleanValue()); + } + if (object instanceof Byte) { + return String.valueOf(((Byte) object).byteValue()); + } + if (object instanceof Short) { + return String.valueOf(((Short) object).shortValue()); + } + if (object instanceof Integer) { + return String.valueOf(((Integer) object).intValue()); + } + if (object instanceof Long) { + return String.valueOf(((Long) object).longValue()) + "L"; + } + if (object instanceof Float) { + return String.valueOf(((Float) object).floatValue()) + "F"; + } + if (object instanceof Double) { + return String.valueOf(((Double) object).doubleValue()); + } + if (object instanceof String) { + return '"' + JAXXCompiler.escapeJavaString((String) object) + '"'; + } + throw new IllegalArgumentException("unsupported object: " + object); + } + + @Override + public Object convertFromString(String string, Class<?> type) { + if (type == String.class || type == Object.class || type == null) { + return string; + } + if (type == int.class || type == Integer.class) { + return Integer.valueOf(string); + } + if (type == boolean.class || type == Boolean.class) { + if (string.toLowerCase().equals("true")) { + return Boolean.TRUE; + } + if (string.toLowerCase().equals("false")) { + return Boolean.FALSE; + } + throw new IllegalArgumentException("expected 'true' or 'false', found '" + string + "'"); + } + if (type == byte.class || type == Byte.class) { + return Byte.valueOf(string); + } + if (type == short.class || type == Short.class) { + return Short.valueOf(string); + } + if (type == long.class || type == Long.class) { + return Long.valueOf(string); + } + if (type == float.class || type == Float.class) { + return Float.valueOf(string); + } + if (type == double.class || type == Double.class) { + return Double.valueOf(string); + } + if (type == char.class || type == Character.class) { + if (string.length() == 1) { + return string.charAt(0); + } + throw new IllegalArgumentException("expected a single character, found '" + string + "'"); + } + throw new IllegalArgumentException("unsupported type: " + type); + } +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeConverter.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeConverter.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeConverter.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,30 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.types; - -public interface TypeConverter { - - Class<?>[] getSupportedTypes(); - - String getJavaCode(Object object); - - Object convertFromString(String string, Class<?> type); -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeConverter.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeConverter.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeConverter.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeConverter.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,30 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.types; + +public interface TypeConverter { + + Class<?>[] getSupportedTypes(); + + String getJavaCode(Object object); + + Object convertFromString(String string, Class<?> type); +} Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeManager.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeManager.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeManager.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,123 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.types; - -import java.util.HashMap; -import java.util.Map; -import java.util.ServiceLoader; - -public class TypeManager { - - /** - * Dictionnary of converters loaded by the {@link java.util.ServiceLoader} mecanism - */ - private static Map<Class<?>, TypeConverter> converters; - - /** - * @return dictionnary of known converters - */ - public static Map<Class<?>, TypeConverter> getConverters() { - if (converters == null) { - converters = new HashMap<Class<?>, TypeConverter>(); - // load converters - ServiceLoader<TypeConverter> loader = ServiceLoader.load(TypeConverter.class); - for (TypeConverter c : loader) { - // for each supported type, register the converter - for (Class<?> type : c.getSupportedTypes()) { - converters.put(type, c); - } - } - } - return converters; - } - - private TypeManager() { /* not instantiable */ } - - public static TypeConverter getTypeConverter(Class<?> type) { - return getConverters().get(type); - } - - public static String getJavaCode(Object object) { - if (object == null) { - return "null"; - } - TypeConverter converter = getTypeConverter(object.getClass()); - if (converter == null) { - throw new IllegalArgumentException("unsupported type: " + object.getClass()); - } - return converter.getJavaCode(object); - } - - public static Object convertFromString(String string, Class<?> type) { - TypeConverter converter = getTypeConverter(type); - if (converter == null) { - throw new IllegalArgumentException("unsupported type: " + type); - } - return converter.convertFromString(string, type); - } - - /** - * Convertit un nom de variable en nom de constante. - * - * @param variableName le nom de variable a convertir - * @return le nom de la constante à partir du nom de la variable - */ - public static String convertVariableNameToConstantName(String variableName) { - StringBuilder buffer = new StringBuilder(); - boolean lastCarIsUp = false; - char lastChar = '$'; - for (int i = 0, j = variableName.length(); i < j; i++) { - char c = variableName.charAt(i); - boolean carIsUp; - if (c == '!') { - buffer.append("NOT_"); - lastChar = '_'; - lastCarIsUp = true; - continue; - } - if (Character.isLetterOrDigit(c)) { - carIsUp = Character.isUpperCase(c); - } else { - carIsUp = false; - if (c != '$') { - // on remplace tous les caractères non standard par un _ - if (lastChar == '_' && c != '_') { - continue; - } - c = '_'; - } - } - - if (i > 0 && !lastCarIsUp && carIsUp) { - // ajout d'un _ - buffer.append('_'); - } - if (carIsUp) { - buffer.append(c); - } else { - buffer.append(Character.toUpperCase(c)); - } - lastCarIsUp = carIsUp || c == '$' || c == '_'; - lastChar = c; - } - return buffer.toString(); - } -} Copied: trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeManager.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeManager.java) =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeManager.java (rev 0) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeManager.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,123 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.types; + +import java.util.HashMap; +import java.util.Map; +import java.util.ServiceLoader; + +public class TypeManager { + + /** + * Dictionnary of converters loaded by the {@link java.util.ServiceLoader} mecanism + */ + private static Map<Class<?>, TypeConverter> converters; + + /** + * @return dictionnary of known converters + */ + public static Map<Class<?>, TypeConverter> getConverters() { + if (converters == null) { + converters = new HashMap<Class<?>, TypeConverter>(); + // load converters + ServiceLoader<TypeConverter> loader = ServiceLoader.load(TypeConverter.class); + for (TypeConverter c : loader) { + // for each supported type, register the converter + for (Class<?> type : c.getSupportedTypes()) { + converters.put(type, c); + } + } + } + return converters; + } + + private TypeManager() { /* not instantiable */ } + + public static TypeConverter getTypeConverter(Class<?> type) { + return getConverters().get(type); + } + + public static String getJavaCode(Object object) { + if (object == null) { + return "null"; + } + TypeConverter converter = getTypeConverter(object.getClass()); + if (converter == null) { + throw new IllegalArgumentException("unsupported type: " + object.getClass()); + } + return converter.getJavaCode(object); + } + + public static Object convertFromString(String string, Class<?> type) { + TypeConverter converter = getTypeConverter(type); + if (converter == null) { + throw new IllegalArgumentException("unsupported type: " + type); + } + return converter.convertFromString(string, type); + } + + /** + * Convertit un nom de variable en nom de constante. + * + * @param variableName le nom de variable a convertir + * @return le nom de la constante à partir du nom de la variable + */ + public static String convertVariableNameToConstantName(String variableName) { + StringBuilder buffer = new StringBuilder(); + boolean lastCarIsUp = false; + char lastChar = '$'; + for (int i = 0, j = variableName.length(); i < j; i++) { + char c = variableName.charAt(i); + boolean carIsUp; + if (c == '!') { + buffer.append("NOT_"); + lastChar = '_'; + lastCarIsUp = true; + continue; + } + if (Character.isLetterOrDigit(c)) { + carIsUp = Character.isUpperCase(c); + } else { + carIsUp = false; + if (c != '$') { + // on remplace tous les caractères non standard par un _ + if (lastChar == '_' && c != '_') { + continue; + } + c = '_'; + } + } + + if (i > 0 && !lastCarIsUp && carIsUp) { + // ajout d'un _ + buffer.append('_'); + } + if (carIsUp) { + buffer.append(c); + } else { + buffer.append(Character.toUpperCase(c)); + } + lastCarIsUp = carIsUp || c == '$' || c == '_'; + lastChar = c; + } + return buffer.toString(); + } +} Copied: trunk/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.CompiledObjectDecorator (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.CompiledObjectDecorator) =================================================================== --- trunk/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.CompiledObjectDecorator (rev 0) +++ trunk/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.CompiledObjectDecorator 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,3 @@ +jaxx.compiler.decorators.DefaultCompiledObjectDecorator +jaxx.compiler.decorators.BoxedCompiledObjectDecorator +jaxx.compiler.decorators.HelpRootCompiledObjectDecorator Deleted: trunk/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.Generator =================================================================== --- trunk/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.Generator 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.Generator 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +0,0 @@ -jaxx.compiler.JAXXObjectGenerator -jaxx.compiler.SwingGenerator -jaxx.compiler.ValidatorGenerator Copied: trunk/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.JAXXCompilerFinalizer (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.JAXXCompilerFinalizer) =================================================================== --- trunk/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.JAXXCompilerFinalizer (rev 0) +++ trunk/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.JAXXCompilerFinalizer 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,3 @@ +jaxx.compiler.finalizers.DefaultFinalizer +jaxx.compiler.finalizers.SwingFinalizer +jaxx.compiler.finalizers.ValidatorFinalizer Copied: trunk/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.spi.Initializer (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.spi.Initializer) =================================================================== --- trunk/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.spi.Initializer (rev 0) +++ trunk/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.spi.Initializer 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1 @@ +jaxx.compiler.spi.DefaultInitializer \ No newline at end of file Copied: trunk/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.types.TypeConverter (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.types.TypeConverter) =================================================================== --- trunk/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.types.TypeConverter (rev 0) +++ trunk/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.types.TypeConverter 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,5 @@ +jaxx.compiler.types.ColorConverter +jaxx.compiler.types.GridBagConstraintsConverter +jaxx.compiler.types.InsetsConverter +jaxx.compiler.types.KeyStrokeConverter +jaxx.compiler.types.PrimitiveConverter Deleted: trunk/jaxx-compiler/src/main/resources/META-INF/services/jaxx.spi.Initializer =================================================================== --- trunk/jaxx-compiler/src/main/resources/META-INF/services/jaxx.spi.Initializer 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/main/resources/META-INF/services/jaxx.spi.Initializer 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +0,0 @@ -jaxx.DefaultInitializer -jaxx.SwingInitializer -jaxx.tags.validator.ValidatorInitializer Modified: trunk/jaxx-compiler/src/site/rst/JAXXContext.rst =================================================================== --- trunk/jaxx-compiler/src/site/rst/JAXXContext.rst 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/site/rst/JAXXContext.rst 2009-12-02 13:59:28 UTC (rev 1673) @@ -32,7 +32,7 @@ Le nom qui est facultatif permet de pouvoir distinguer plusieurs données d'un même type dans le context. Si le nom n'est pas utilisé pour caractériser une données on fixera alors sa valeur à *null*. -Afin de pouvoir caractériser les entrées dans le context, une classe a été définie *jaxx.runtime.JAXXContextEntryDef*. +Afin de pouvoir caractériser les entrées dans le context, une classe a été définie *jaxx.runtime.context.JAXXContextEntryDef*. Les méthodes de lecture *********************** @@ -87,7 +87,7 @@ Cette entrée spéciale ne sera pas stockée avec les autres entrées afin d'optimiser les algorithmes d'injection et de restitution. -jaxx.runtime.JAXXInitialContext +jaxx.runtime.context.JAXXInitialContext ******************************* On a implanté un second type de context qui lui peut servir à l'initialisation des JAXXObject. Deleted: trunk/jaxx-compiler/src/test/java/jaxx/compiler/JavaFileParserTest.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/JavaFileParserTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/test/java/jaxx/compiler/JavaFileParserTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,77 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler; - -import jaxx.compiler.CompilerException; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.JavaFileParser; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.File; -import java.io.FileReader; -import java.io.Reader; - -public class JavaFileParserTest { - - - /** log */ - protected static final Log log = LogFactory.getLog(JavaFileParserTest.class); - - static File basedir; - - @BeforeClass - public static void initBaseDir() { - // get maven env basedir - String basedir = System.getenv("basedir"); - if (basedir == null) { - basedir = new File("").getAbsolutePath(); - } - JavaFileParserTest.basedir = new File(basedir); - } - - @Test - public void testParseJavaSourceFile() throws Exception { - - File testSourceRoot = new File(basedir, "src" + File.separator + "test" + File.separator + "java"); - Assert.assertTrue(testSourceRoot.exists()); - - File src = new File(testSourceRoot, getClass().getName().replaceAll("\\.", File.separator) + ".java"); - Assert.assertTrue(src.exists()); - log.info("trying parsing file " + src); - Reader reader = new FileReader(src); - try { - ClassDescriptor result = JavaFileParser.parseJavaFile("TestParserJava", reader, getClass().getClassLoader()); - Assert.assertNotNull(result); - - } catch (CompilerException e) { - log.error("could not parse file " + src + " for reason " + e.getMessage(), e); - Assert.fail(e.getMessage()); - } - finally { - reader.close(); - } - } - -} Copied: trunk/jaxx-compiler/src/test/java/jaxx/compiler/JavaFileParserTest.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/JavaFileParserTest.java) =================================================================== --- trunk/jaxx-compiler/src/test/java/jaxx/compiler/JavaFileParserTest.java (rev 0) +++ trunk/jaxx-compiler/src/test/java/jaxx/compiler/JavaFileParserTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,77 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler; + +import jaxx.compiler.CompilerException; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.JavaFileParser; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.io.File; +import java.io.FileReader; +import java.io.Reader; + +public class JavaFileParserTest { + + + /** log */ + protected static final Log log = LogFactory.getLog(JavaFileParserTest.class); + + static File basedir; + + @BeforeClass + public static void initBaseDir() { + // get maven env basedir + String basedir = System.getenv("basedir"); + if (basedir == null) { + basedir = new File("").getAbsolutePath(); + } + JavaFileParserTest.basedir = new File(basedir); + } + + @Test + public void testParseJavaSourceFile() throws Exception { + + File testSourceRoot = new File(basedir, "src" + File.separator + "test" + File.separator + "java"); + Assert.assertTrue(testSourceRoot.exists()); + + File src = new File(testSourceRoot, getClass().getName().replaceAll("\\.", File.separator) + ".java"); + Assert.assertTrue(src.exists()); + log.info("trying parsing file " + src); + Reader reader = new FileReader(src); + try { + ClassDescriptor result = JavaFileParser.parseJavaFile("TestParserJava", reader, getClass().getClassLoader()); + Assert.assertNotNull(result); + + } catch (CompilerException e) { + log.error("could not parse file " + src + " for reason " + e.getMessage(), e); + Assert.fail(e.getMessage()); + } + finally { + reader.close(); + } + } + +} Deleted: trunk/jaxx-compiler/src/test/java/jaxx/compiler/JavaMethodTest.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/JavaMethodTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/test/java/jaxx/compiler/JavaMethodTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,72 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler; - -import jaxx.compiler.java.JavaMethod; -import jaxx.compiler.java.JavaMethod.MethodOrder; -import org.junit.Assert; -import org.junit.Test; - -import java.lang.reflect.Modifier; -import java.util.EnumSet; - -/** @author chemit */ -public class JavaMethodTest { - - @Test - public void testGetMethodOrderScope() { - EnumSet<MethodOrder> allConstants = EnumSet.allOf(MethodOrder.class); - - EnumSet<MethodOrder> constants; - - constants = JavaMethod.getMethodOrderScope(allConstants, Modifier.STATIC); - - Assert.assertEquals(1, constants.size()); - Assert.assertTrue(constants.contains(MethodOrder.statics)); - - constants = JavaMethod.getMethodOrderScope(allConstants, Modifier.PUBLIC); - - Assert.assertEquals(8, constants.size()); - Assert.assertTrue(constants.contains(MethodOrder.constructors)); - Assert.assertTrue(constants.contains(MethodOrder.JAXXObject)); - Assert.assertTrue(constants.contains(MethodOrder.JAXXContext)); - Assert.assertTrue(constants.contains(MethodOrder.JAXXValidation)); - Assert.assertTrue(constants.contains(MethodOrder.events)); - Assert.assertTrue(constants.contains(MethodOrder.publicGetters)); - Assert.assertTrue(constants.contains(MethodOrder.publicSetters)); - Assert.assertTrue(constants.contains(MethodOrder.otherPublic)); - - constants = JavaMethod.getMethodOrderScope(allConstants, Modifier.PROTECTED); - - Assert.assertEquals(3, constants.size()); - Assert.assertTrue(constants.contains(MethodOrder.protectedGetters)); - Assert.assertTrue(constants.contains(MethodOrder.protecteds)); - Assert.assertTrue(constants.contains(MethodOrder.createMethod)); - - - constants = JavaMethod.getMethodOrderScope(allConstants, Modifier.PRIVATE); - Assert.assertEquals(3, constants.size()); - Assert.assertTrue(constants.contains(MethodOrder.createMethod)); - Assert.assertTrue(constants.contains(MethodOrder.packageLocal)); - Assert.assertTrue(constants.contains(MethodOrder.privates)); - - } -} Copied: trunk/jaxx-compiler/src/test/java/jaxx/compiler/JavaMethodTest.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/JavaMethodTest.java) =================================================================== --- trunk/jaxx-compiler/src/test/java/jaxx/compiler/JavaMethodTest.java (rev 0) +++ trunk/jaxx-compiler/src/test/java/jaxx/compiler/JavaMethodTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,72 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler; + +import jaxx.compiler.java.JavaMethod; +import jaxx.compiler.java.JavaMethod.MethodOrder; +import org.junit.Assert; +import org.junit.Test; + +import java.lang.reflect.Modifier; +import java.util.EnumSet; + +/** @author chemit */ +public class JavaMethodTest { + + @Test + public void testGetMethodOrderScope() { + EnumSet<MethodOrder> allConstants = EnumSet.allOf(MethodOrder.class); + + EnumSet<MethodOrder> constants; + + constants = JavaMethod.getMethodOrderScope(allConstants, Modifier.STATIC); + + Assert.assertEquals(1, constants.size()); + Assert.assertTrue(constants.contains(MethodOrder.statics)); + + constants = JavaMethod.getMethodOrderScope(allConstants, Modifier.PUBLIC); + + Assert.assertEquals(8, constants.size()); + Assert.assertTrue(constants.contains(MethodOrder.constructors)); + Assert.assertTrue(constants.contains(MethodOrder.JAXXObject)); + Assert.assertTrue(constants.contains(MethodOrder.JAXXContext)); + Assert.assertTrue(constants.contains(MethodOrder.JAXXValidation)); + Assert.assertTrue(constants.contains(MethodOrder.events)); + Assert.assertTrue(constants.contains(MethodOrder.publicGetters)); + Assert.assertTrue(constants.contains(MethodOrder.publicSetters)); + Assert.assertTrue(constants.contains(MethodOrder.otherPublic)); + + constants = JavaMethod.getMethodOrderScope(allConstants, Modifier.PROTECTED); + + Assert.assertEquals(3, constants.size()); + Assert.assertTrue(constants.contains(MethodOrder.protectedGetters)); + Assert.assertTrue(constants.contains(MethodOrder.protecteds)); + Assert.assertTrue(constants.contains(MethodOrder.createMethod)); + + + constants = JavaMethod.getMethodOrderScope(allConstants, Modifier.PRIVATE); + Assert.assertEquals(3, constants.size()); + Assert.assertTrue(constants.contains(MethodOrder.createMethod)); + Assert.assertTrue(constants.contains(MethodOrder.packageLocal)); + Assert.assertTrue(constants.contains(MethodOrder.privates)); + + } +} Deleted: trunk/jaxx-compiler/src/test/java/jaxx/compiler/beans/BeanIntoUtilTest.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/beans/BeanIntoUtilTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/test/java/jaxx/compiler/beans/BeanIntoUtilTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,54 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.beans; - -import org.junit.Assert; -import org.junit.Test; - -import java.beans.Introspector; - -/** @author chemit */ -public class BeanIntoUtilTest { - - @Test - public void testExtraBeanInfoPath() { - BeanInfoUtil.reset(); - String[] searchPath0 = Introspector.getBeanInfoSearchPath(); - - BeanInfoUtil.addJaxxBeanInfoPath("jaxx.runtime.swing"); - - String[] searchPath = Introspector.getBeanInfoSearchPath(); - Assert.assertEquals(searchPath0.length + 1, searchPath.length); - - BeanInfoUtil.reset(); - Assert.assertEquals(searchPath0.length, Introspector.getBeanInfoSearchPath().length); - - String packageName = getClass().getPackage().getName() + ".dummy"; - BeanInfoUtil.addJaxxBeanInfoPath("jaxx.beaninfos", packageName); - - searchPath = Introspector.getBeanInfoSearchPath(); - Assert.assertEquals(searchPath0.length + 2, searchPath.length); - Assert.assertEquals(packageName, searchPath[searchPath.length - 1]); - - BeanInfoUtil.reset(); - Assert.assertEquals(searchPath0.length, Introspector.getBeanInfoSearchPath().length); - } -} Copied: trunk/jaxx-compiler/src/test/java/jaxx/compiler/beans/BeanIntoUtilTest.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/beans/BeanIntoUtilTest.java) =================================================================== --- trunk/jaxx-compiler/src/test/java/jaxx/compiler/beans/BeanIntoUtilTest.java (rev 0) +++ trunk/jaxx-compiler/src/test/java/jaxx/compiler/beans/BeanIntoUtilTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,54 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.beans; + +import org.junit.Assert; +import org.junit.Test; + +import java.beans.Introspector; + +/** @author chemit */ +public class BeanIntoUtilTest { + + @Test + public void testExtraBeanInfoPath() { + BeanInfoUtil.reset(); + String[] searchPath0 = Introspector.getBeanInfoSearchPath(); + + BeanInfoUtil.addJaxxBeanInfoPath("jaxx.runtime.swing"); + + String[] searchPath = Introspector.getBeanInfoSearchPath(); + Assert.assertEquals(searchPath0.length + 1, searchPath.length); + + BeanInfoUtil.reset(); + Assert.assertEquals(searchPath0.length, Introspector.getBeanInfoSearchPath().length); + + String packageName = getClass().getPackage().getName() + ".dummy"; + BeanInfoUtil.addJaxxBeanInfoPath("jaxx.beaninfos", packageName); + + searchPath = Introspector.getBeanInfoSearchPath(); + Assert.assertEquals(searchPath0.length + 2, searchPath.length); + Assert.assertEquals(packageName, searchPath[searchPath.length - 1]); + + BeanInfoUtil.reset(); + Assert.assertEquals(searchPath0.length, Introspector.getBeanInfoSearchPath().length); + } +} Deleted: trunk/jaxx-compiler/src/test/java/jaxx/compiler/reflect/ClassDescriptorTest.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/reflect/ClassDescriptorTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/test/java/jaxx/compiler/reflect/ClassDescriptorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,79 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.reflect; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import org.junit.Test; - -public class ClassDescriptorTest { - - /*@Test - public void testGetClassDescriptor() throws Exception { - ClassDescriptorLoader.getClassDescriptor("jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode"); - }*/ - @Test - public void testBuiltInClassName() throws ClassNotFoundException, NoSuchMethodException { - ClassDescriptor object = ClassDescriptorLoader.getClassDescriptor("java.lang.Object"); - MethodDescriptor toString = object.getMethodDescriptor("toString"); - assertEquals(toString.getName(), "toString"); - assertEquals(toString.getParameterTypes().length, 0); - - MethodDescriptor equals = object.getMethodDescriptor("equals", object); - assertEquals(equals.getName(), "equals"); - assertEquals(equals.getParameterTypes().length, 1); - assertEquals(equals.getParameterTypes()[0], object); - } - - @Test - public void testBuiltInClass() throws ClassNotFoundException, NoSuchMethodException { - ClassDescriptor object1 = ClassDescriptorLoader.getClassDescriptor("java.lang.Object"); - ClassDescriptor object2 = ClassDescriptorLoader.getClassDescriptor(Object.class); - assertEquals(object1, object2); - } - - @Test - public void testUserClassName() throws ClassNotFoundException, NoSuchMethodException { - ClassDescriptor me = ClassDescriptorLoader.getClassDescriptor(ClassDescriptorTest.class.getName(), getClass().getClassLoader()); - MethodDescriptor testUserClassName = me.getMethodDescriptor("testUserClassName"); - assertEquals(testUserClassName.getName(), "testUserClassName"); - assertEquals(testUserClassName.getParameterTypes().length, 0); - } - - @Test(expected = ClassNotFoundException.class) - public void testWrongCase() throws ClassNotFoundException { - //try { - //ClassDescriptor object = - ClassDescriptorLoader.getClassDescriptor("jaxx.junit.classdescriptortest", getClass().getClassLoader()); - // fail("Found descriptor using wrong case: " + object); - //} - //catch (ClassNotFoundException e) { - //} - } - - @Test - public void testArrays() throws ClassNotFoundException { - ClassDescriptor intArray = ClassDescriptorLoader.getClassDescriptor(int[].class); - assertNotNull(intArray); - ClassDescriptor objectArray = ClassDescriptorLoader.getClassDescriptor(Object[].class); - assertNotNull(objectArray); - } -} Copied: trunk/jaxx-compiler/src/test/java/jaxx/compiler/reflect/ClassDescriptorTest.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/reflect/ClassDescriptorTest.java) =================================================================== --- trunk/jaxx-compiler/src/test/java/jaxx/compiler/reflect/ClassDescriptorTest.java (rev 0) +++ trunk/jaxx-compiler/src/test/java/jaxx/compiler/reflect/ClassDescriptorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,79 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.reflect; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import org.junit.Test; + +public class ClassDescriptorTest { + + /*@Test + public void testGetClassDescriptor() throws Exception { + ClassDescriptorLoader.getClassDescriptor("jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode"); + }*/ + @Test + public void testBuiltInClassName() throws ClassNotFoundException, NoSuchMethodException { + ClassDescriptor object = ClassDescriptorLoader.getClassDescriptor("java.lang.Object"); + MethodDescriptor toString = object.getMethodDescriptor("toString"); + assertEquals(toString.getName(), "toString"); + assertEquals(toString.getParameterTypes().length, 0); + + MethodDescriptor equals = object.getMethodDescriptor("equals", object); + assertEquals(equals.getName(), "equals"); + assertEquals(equals.getParameterTypes().length, 1); + assertEquals(equals.getParameterTypes()[0], object); + } + + @Test + public void testBuiltInClass() throws ClassNotFoundException, NoSuchMethodException { + ClassDescriptor object1 = ClassDescriptorLoader.getClassDescriptor("java.lang.Object"); + ClassDescriptor object2 = ClassDescriptorLoader.getClassDescriptor(Object.class); + assertEquals(object1, object2); + } + + @Test + public void testUserClassName() throws ClassNotFoundException, NoSuchMethodException { + ClassDescriptor me = ClassDescriptorLoader.getClassDescriptor(ClassDescriptorTest.class.getName(), getClass().getClassLoader()); + MethodDescriptor testUserClassName = me.getMethodDescriptor("testUserClassName"); + assertEquals(testUserClassName.getName(), "testUserClassName"); + assertEquals(testUserClassName.getParameterTypes().length, 0); + } + + @Test(expected = ClassNotFoundException.class) + public void testWrongCase() throws ClassNotFoundException { + //try { + //ClassDescriptor object = + ClassDescriptorLoader.getClassDescriptor("jaxx.junit.classdescriptortest", getClass().getClassLoader()); + // fail("Found descriptor using wrong case: " + object); + //} + //catch (ClassNotFoundException e) { + //} + } + + @Test + public void testArrays() throws ClassNotFoundException { + ClassDescriptor intArray = ClassDescriptorLoader.getClassDescriptor(int[].class); + assertNotNull(intArray); + ClassDescriptor objectArray = ClassDescriptorLoader.getClassDescriptor(Object[].class); + assertNotNull(objectArray); + } +} Deleted: trunk/jaxx-compiler/src/test/java/jaxx/compiler/tags/TagManagerTest.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/tags/TagManagerTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/test/java/jaxx/compiler/tags/TagManagerTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,158 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.tags; - -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.JAXXEngine; -import jaxx.compiler.reflect.ClassDescriptor; -import jaxx.compiler.reflect.ClassDescriptorLoader; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import javax.swing.JPopupMenu; -import java.io.ByteArrayOutputStream; -import java.io.FileInputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.PrintStream; - -public class TagManagerTest { - - protected JAXXCompiler compiler; - - public static class TestHandler extends DefaultObjectHandler { - - public TestHandler(ClassDescriptor beanClass) { - super(beanClass); - } - } - - @BeforeClass - public static void initTagManaer() throws Exception { - - TagManager.reset(true); - - } - - @Before - public void setUp() { - JAXXEngine.newLaunchor(); - compiler = JAXXEngine.createDummyCompiler(JAXXCompiler.class.getClassLoader()); -// compiler = new JAXXCompiler(JAXXCompiler.class.getClassLoader()); - compiler.addImport("javax.swing.*"); - - } - - @Test - public void testRegisterBean() { - TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(InputStream.class), TestHandler.class); - - Assert.assertTrue(TagManager.getTagHandler(ClassDescriptorLoader.getClassDescriptor(InputStream.class)) instanceof TestHandler); - Assert.assertTrue(TagManager.getTagHandler(ClassDescriptorLoader.getClassDescriptor(FileInputStream.class)) instanceof TestHandler); - } - - @Test - public void testRegisterDefaultNamespace() { - - TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(OutputStream.class), TestHandler.class); - - TagManager.registerDefaultNamespace("OutputStream", "java.io.*"); - Assert.assertTrue("Could not find handler for OutputStream despite default namespace", TagManager.getTagHandler(null, "OutputStream", compiler) instanceof TestHandler); - - PrintStream oldErr = System.err; - ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - System.setErr(new PrintStream(buffer)); - TagManager.registerDefaultNamespace("OutputStream", "java.dummy.*"); - Assert.assertNull("Found handler for OutputStream despite ambiguous default namespace", TagManager.getTagHandler(null, "OutputStream", compiler)); - System.setErr(oldErr); - Assert.assertTrue("No errors were produced with an ambiguous default namespace", buffer.size() > 0); - Assert.assertTrue(buffer.size() > 0); - } - - @Test - public void testResolveClassName() { - Assert.assertEquals("Could not resolve class name 'Object'", TagManager.resolveClassName("Object", compiler), "java.lang.Object"); - Assert.assertEquals("Could not resolve class name 'java.lang.Object'", TagManager.resolveClassName("java.lang.Object", compiler), "java.lang.Object"); - Assert.assertNull("Unexpectedly resolved class name 'java.awt.Object'", TagManager.resolveClassName("java.awt.Object", compiler)); - } - - @Test - public void testPackages() { - Assert.assertNull("Unexpectedly found handler for java.awt.JButton", TagManager.getTagHandler(null, "java.awt.JButton", compiler)); - Assert.assertNotNull("Did not find handler for JButton with default namespace of java.awt.*", TagManager.getTagHandler("java.awt.*", "JButton", compiler)); - Assert.assertNull("Unexpectedly found handler for java.awt.*:JButton", TagManager.getTagHandler("java.awt.*", "JButton", true, compiler)); - Assert.assertNotNull("Did not find handler for javax.swing.JButton", TagManager.getTagHandler(null, "javax.swing.JButton", compiler)); - Assert.assertNotNull("Did not find handler for JButton with default namespace of java.swing.*", TagManager.getTagHandler("java.swing.*", "JButton", compiler)); - Assert.assertNotNull("Did not find handler for javax.swing.*:JButton", TagManager.getTagHandler("javax.swing.*", "JButton", true, compiler)); - } - - @Test - public void testImport() throws Exception { - Assert.assertNull("Found handler for ActionListener despite no java.awt.event.* import", TagManager.getTagHandler(null, "ActionListener", compiler)); - - compiler.addImport("java.awt.event.*"); - - Assert.assertNotNull("Did not find ActionListener with java.awt.event.* import", TagManager.getTagHandler(null, "ActionListener", compiler)); - } - - @Test - public void testAmbiguousImport() throws Exception { - compiler.addImport("java.sql.*"); - Assert.assertNotNull("Did not find java.sql.Date with only java.sql.* imported", TagManager.getTagHandler(null, "Date", compiler)); - - PrintStream oldErr = System.err; - ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - System.setErr(new PrintStream(buffer)); - compiler.addImport("java.util.*"); - TagManager.reset(true); - Assert.assertNull("Still found a handler for Date with an ambiguous import", TagManager.getTagHandler(null, "Date", compiler)); - System.setErr(oldErr); - Assert.assertTrue("No errors were produced with an ambiguous import", buffer.size() > 0); - - compiler.addImport("java.util.Date"); - Assert.assertNotNull("Did not find java.util.Date with a disambiguating import", TagManager.getTagHandler(null, "Date", compiler)); - } - - @Test - public void testInnerClass() { - TagHandler handler = TagManager.getTagHandler(null, "JPopupMenu.Separator", compiler); - Assert.assertTrue("Unable to resolve tag <JPopupMenu.Separator>", handler instanceof DefaultComponentHandler); - Assert.assertTrue(((DefaultComponentHandler) handler).getBeanClass().getName().equals(JPopupMenu.Separator.class.getName())); - - handler = TagManager.getTagHandler(null, "javax.swing.JPopupMenu.Separator", compiler); - Assert.assertTrue("Unable to resolve tag <javax.swing.JPopupMenu.Separator>", handler instanceof DefaultComponentHandler); - Assert.assertTrue(((DefaultComponentHandler) handler).getBeanClass().getName().equals(JPopupMenu.Separator.class.getName())); - } - - @Test - public void testWrongCase() { - Assert.assertNull("Unexpectedly found handler for 'object'", TagManager.getTagHandler(null, "object", compiler)); - Assert.assertNull("Unexpectedly found handler for 'tagmanagertest'", TagManager.getTagHandler(null, "tagmanagertest", compiler)); - } - - @Test - public void testAliasing() { - 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)); - } -} Copied: trunk/jaxx-compiler/src/test/java/jaxx/compiler/tags/TagManagerTest.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/tags/TagManagerTest.java) =================================================================== --- trunk/jaxx-compiler/src/test/java/jaxx/compiler/tags/TagManagerTest.java (rev 0) +++ trunk/jaxx-compiler/src/test/java/jaxx/compiler/tags/TagManagerTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,158 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.tags; + +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.JAXXEngine; +import jaxx.compiler.reflect.ClassDescriptor; +import jaxx.compiler.reflect.ClassDescriptorLoader; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import javax.swing.JPopupMenu; +import java.io.ByteArrayOutputStream; +import java.io.FileInputStream; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.PrintStream; + +public class TagManagerTest { + + protected JAXXCompiler compiler; + + public static class TestHandler extends DefaultObjectHandler { + + public TestHandler(ClassDescriptor beanClass) { + super(beanClass); + } + } + + @BeforeClass + public static void initTagManaer() throws Exception { + + TagManager.reset(true); + + } + + @Before + public void setUp() { + JAXXEngine.newLaunchor(); + compiler = JAXXEngine.createDummyCompiler(JAXXCompiler.class.getClassLoader()); +// compiler = new JAXXCompiler(JAXXCompiler.class.getClassLoader()); + compiler.addImport("javax.swing.*"); + + } + + @Test + public void testRegisterBean() { + TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(InputStream.class), TestHandler.class); + + Assert.assertTrue(TagManager.getTagHandler(ClassDescriptorLoader.getClassDescriptor(InputStream.class)) instanceof TestHandler); + Assert.assertTrue(TagManager.getTagHandler(ClassDescriptorLoader.getClassDescriptor(FileInputStream.class)) instanceof TestHandler); + } + + @Test + public void testRegisterDefaultNamespace() { + + TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(OutputStream.class), TestHandler.class); + + TagManager.registerDefaultNamespace("OutputStream", "java.io.*"); + Assert.assertTrue("Could not find handler for OutputStream despite default namespace", TagManager.getTagHandler(null, "OutputStream", compiler) instanceof TestHandler); + + PrintStream oldErr = System.err; + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + System.setErr(new PrintStream(buffer)); + TagManager.registerDefaultNamespace("OutputStream", "java.dummy.*"); + Assert.assertNull("Found handler for OutputStream despite ambiguous default namespace", TagManager.getTagHandler(null, "OutputStream", compiler)); + System.setErr(oldErr); + Assert.assertTrue("No errors were produced with an ambiguous default namespace", buffer.size() > 0); + Assert.assertTrue(buffer.size() > 0); + } + + @Test + public void testResolveClassName() { + Assert.assertEquals("Could not resolve class name 'Object'", TagManager.resolveClassName("Object", compiler), "java.lang.Object"); + Assert.assertEquals("Could not resolve class name 'java.lang.Object'", TagManager.resolveClassName("java.lang.Object", compiler), "java.lang.Object"); + Assert.assertNull("Unexpectedly resolved class name 'java.awt.Object'", TagManager.resolveClassName("java.awt.Object", compiler)); + } + + @Test + public void testPackages() { + Assert.assertNull("Unexpectedly found handler for java.awt.JButton", TagManager.getTagHandler(null, "java.awt.JButton", compiler)); + Assert.assertNotNull("Did not find handler for JButton with default namespace of java.awt.*", TagManager.getTagHandler("java.awt.*", "JButton", compiler)); + Assert.assertNull("Unexpectedly found handler for java.awt.*:JButton", TagManager.getTagHandler("java.awt.*", "JButton", true, compiler)); + Assert.assertNotNull("Did not find handler for javax.swing.JButton", TagManager.getTagHandler(null, "javax.swing.JButton", compiler)); + Assert.assertNotNull("Did not find handler for JButton with default namespace of java.swing.*", TagManager.getTagHandler("java.swing.*", "JButton", compiler)); + Assert.assertNotNull("Did not find handler for javax.swing.*:JButton", TagManager.getTagHandler("javax.swing.*", "JButton", true, compiler)); + } + + @Test + public void testImport() throws Exception { + Assert.assertNull("Found handler for ActionListener despite no java.awt.event.* import", TagManager.getTagHandler(null, "ActionListener", compiler)); + + compiler.addImport("java.awt.event.*"); + + Assert.assertNotNull("Did not find ActionListener with java.awt.event.* import", TagManager.getTagHandler(null, "ActionListener", compiler)); + } + + @Test + public void testAmbiguousImport() throws Exception { + compiler.addImport("java.sql.*"); + Assert.assertNotNull("Did not find java.sql.Date with only java.sql.* imported", TagManager.getTagHandler(null, "Date", compiler)); + + PrintStream oldErr = System.err; + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + System.setErr(new PrintStream(buffer)); + compiler.addImport("java.util.*"); + TagManager.reset(true); + Assert.assertNull("Still found a handler for Date with an ambiguous import", TagManager.getTagHandler(null, "Date", compiler)); + System.setErr(oldErr); + Assert.assertTrue("No errors were produced with an ambiguous import", buffer.size() > 0); + + compiler.addImport("java.util.Date"); + Assert.assertNotNull("Did not find java.util.Date with a disambiguating import", TagManager.getTagHandler(null, "Date", compiler)); + } + + @Test + public void testInnerClass() { + TagHandler handler = TagManager.getTagHandler(null, "JPopupMenu.Separator", compiler); + Assert.assertTrue("Unable to resolve tag <JPopupMenu.Separator>", handler instanceof DefaultComponentHandler); + Assert.assertTrue(((DefaultComponentHandler) handler).getBeanClass().getName().equals(JPopupMenu.Separator.class.getName())); + + handler = TagManager.getTagHandler(null, "javax.swing.JPopupMenu.Separator", compiler); + Assert.assertTrue("Unable to resolve tag <javax.swing.JPopupMenu.Separator>", handler instanceof DefaultComponentHandler); + Assert.assertTrue(((DefaultComponentHandler) handler).getBeanClass().getName().equals(JPopupMenu.Separator.class.getName())); + } + + @Test + public void testWrongCase() { + Assert.assertNull("Unexpectedly found handler for 'object'", TagManager.getTagHandler(null, "object", compiler)); + Assert.assertNull("Unexpectedly found handler for 'tagmanagertest'", TagManager.getTagHandler(null, "tagmanagertest", compiler)); + } + + @Test + public void testAliasing() { + 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)); + } +} Deleted: trunk/jaxx-compiler/src/test/java/jaxx/compiler/types/ColorConverterTest.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/ColorConverterTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/test/java/jaxx/compiler/types/ColorConverterTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,70 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.types; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import java.awt.*; - -public class ColorConverterTest { - - ColorConverter converter; - - @Before - public void setUp() { - converter = new ColorConverter(); - } - - @Test - public void testHexValue() { - Color value = (Color) converter.convertFromString("#3000FF", Color.class); - Assert.assertEquals(value, new Color(48, 0, 255)); - } - - @Test - public void testUpperCaseConstant() { - Color value = (Color) converter.convertFromString("RED", Color.class); - Assert.assertEquals(value, Color.RED); - } - - @Test - public void testLowerCaseConstant() { - Color value = (Color) converter.convertFromString("blue", Color.class); - Assert.assertEquals(value, Color.blue); - } - - @Test(expected = IllegalArgumentException.class) - public void testMissingHash() { - converter.convertFromString("ABCDEF", Color.class); - } - - @Test(expected = IllegalArgumentException.class) - public void testInvalidNumber() { - converter.convertFromString("#ABCDEG", Color.class); - } - - @Test(expected = IllegalArgumentException.class) - public void testInvalidConstant() { - converter.convertFromString("rEd", Color.class); - } -} \ No newline at end of file Copied: trunk/jaxx-compiler/src/test/java/jaxx/compiler/types/ColorConverterTest.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/ColorConverterTest.java) =================================================================== --- trunk/jaxx-compiler/src/test/java/jaxx/compiler/types/ColorConverterTest.java (rev 0) +++ trunk/jaxx-compiler/src/test/java/jaxx/compiler/types/ColorConverterTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,70 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.types; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.awt.*; + +public class ColorConverterTest { + + ColorConverter converter; + + @Before + public void setUp() { + converter = new ColorConverter(); + } + + @Test + public void testHexValue() { + Color value = (Color) converter.convertFromString("#3000FF", Color.class); + Assert.assertEquals(value, new Color(48, 0, 255)); + } + + @Test + public void testUpperCaseConstant() { + Color value = (Color) converter.convertFromString("RED", Color.class); + Assert.assertEquals(value, Color.RED); + } + + @Test + public void testLowerCaseConstant() { + Color value = (Color) converter.convertFromString("blue", Color.class); + Assert.assertEquals(value, Color.blue); + } + + @Test(expected = IllegalArgumentException.class) + public void testMissingHash() { + converter.convertFromString("ABCDEF", Color.class); + } + + @Test(expected = IllegalArgumentException.class) + public void testInvalidNumber() { + converter.convertFromString("#ABCDEG", Color.class); + } + + @Test(expected = IllegalArgumentException.class) + public void testInvalidConstant() { + converter.convertFromString("rEd", Color.class); + } +} \ No newline at end of file Deleted: trunk/jaxx-compiler/src/test/java/jaxx/compiler/types/InsetsConverterTest.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/InsetsConverterTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/test/java/jaxx/compiler/types/InsetsConverterTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,70 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.types; - -import jaxx.compiler.types.InsetsConverter; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import java.awt.Insets; - -public class InsetsConverterTest { - - InsetsConverter converter; - - @Before - public void setUp() { - converter = new InsetsConverter(); - } - - @Test - public void testSingleValue() { - Insets value = (Insets) converter.convertFromString("3", Insets.class); - Assert.assertEquals(value, new Insets(3, 3, 3, 3)); - } - - @Test - public void testFourValues() { - Insets value = (Insets) converter.convertFromString("3, 0, 12, 1000000", Insets.class); - Assert.assertEquals(value, new Insets(3, 0, 12, 1000000)); - } - - @Test(expected = IllegalArgumentException.class) - public void testTwoValues() { - converter.convertFromString("0, 4", Insets.class); - } - - @Test(expected = IllegalArgumentException.class) - public void testThreeValues() { - converter.convertFromString("0, 4, 9", Insets.class); - } - - @Test(expected = IllegalArgumentException.class) - public void testInvalidNumber() { - converter.convertFromString("0, 4, 9, A", Insets.class); - } - - @Test(expected = IllegalArgumentException.class) - public void testBadFormatting() { - converter.convertFromString("0 - 1 - 2 - 3", Insets.class); - } -} \ No newline at end of file Copied: trunk/jaxx-compiler/src/test/java/jaxx/compiler/types/InsetsConverterTest.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/InsetsConverterTest.java) =================================================================== --- trunk/jaxx-compiler/src/test/java/jaxx/compiler/types/InsetsConverterTest.java (rev 0) +++ trunk/jaxx-compiler/src/test/java/jaxx/compiler/types/InsetsConverterTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,70 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.types; + +import jaxx.compiler.types.InsetsConverter; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.awt.Insets; + +public class InsetsConverterTest { + + InsetsConverter converter; + + @Before + public void setUp() { + converter = new InsetsConverter(); + } + + @Test + public void testSingleValue() { + Insets value = (Insets) converter.convertFromString("3", Insets.class); + Assert.assertEquals(value, new Insets(3, 3, 3, 3)); + } + + @Test + public void testFourValues() { + Insets value = (Insets) converter.convertFromString("3, 0, 12, 1000000", Insets.class); + Assert.assertEquals(value, new Insets(3, 0, 12, 1000000)); + } + + @Test(expected = IllegalArgumentException.class) + public void testTwoValues() { + converter.convertFromString("0, 4", Insets.class); + } + + @Test(expected = IllegalArgumentException.class) + public void testThreeValues() { + converter.convertFromString("0, 4, 9", Insets.class); + } + + @Test(expected = IllegalArgumentException.class) + public void testInvalidNumber() { + converter.convertFromString("0, 4, 9, A", Insets.class); + } + + @Test(expected = IllegalArgumentException.class) + public void testBadFormatting() { + converter.convertFromString("0 - 1 - 2 - 3", Insets.class); + } +} \ No newline at end of file Deleted: trunk/jaxx-compiler/src/test/java/jaxx/compiler/types/PrimitiveConverterTest.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/PrimitiveConverterTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/test/java/jaxx/compiler/types/PrimitiveConverterTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,133 +0,0 @@ -/* - * *##% - * JAXX Compiler - * 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>. - * ##%* - */ -package jaxx.compiler.types; - -import jaxx.compiler.types.PrimitiveConverter; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -public class PrimitiveConverterTest { - - PrimitiveConverter converter; - - - @Before - public void setUp() { - converter = new PrimitiveConverter(); - } - - @Test - public void testBoolean() { - Boolean value = (Boolean) converter.convertFromString("true", Boolean.class); - Assert.assertTrue(value); - - value = (Boolean) converter.convertFromString("false", Boolean.class); - Assert.assertFalse(value); - - } - - @Test(expected = IllegalArgumentException.class) - public void testBoolean2() { - converter.convertFromString("yes", Boolean.class); - } - - @Test - public void testByte() { - Byte value = (Byte) converter.convertFromString(String.valueOf(Byte.MAX_VALUE), Byte.class); - Assert.assertEquals(value.byteValue(), Byte.MAX_VALUE); - - } - - @Test(expected = IllegalArgumentException.class) - public void testByte2() { - - converter.convertFromString(String.valueOf(1 + Byte.MAX_VALUE), Byte.class); - } - - @Test - public void testShort() { - Short value = (Short) converter.convertFromString(String.valueOf(Short.MAX_VALUE), Short.class); - Assert.assertEquals(value.shortValue(), Short.MAX_VALUE); - - - } - - @Test(expected = IllegalArgumentException.class) - public void testShort2() { - - converter.convertFromString(String.valueOf(1 + Short.MAX_VALUE), Short.class); - } - - @Test - public void testInteger() { - Integer value = (Integer) converter.convertFromString(String.valueOf(Integer.MAX_VALUE), Integer.class); - Assert.assertEquals(value.intValue(), Integer.MAX_VALUE); - } - - @Test(expected = IllegalArgumentException.class) - public void testInteger2() { - - converter.convertFromString(String.valueOf(1L + Integer.MAX_VALUE), Integer.class); - } - - @Test - public void testLong() { - Long value = (Long) converter.convertFromString(String.valueOf(Long.MAX_VALUE), Long.class); - Assert.assertEquals(value.longValue(), Long.MAX_VALUE); - } - - @Test - public void testFloat() { - Float value = (Float) converter.convertFromString("3.1415", Float.class); - Assert.assertTrue(value == 3.1415f); - } - - @Test - public void testDouble() { - Double value = (Double) converter.convertFromString("3.1415", Double.class); - Assert.assertTrue(value == 3.1415); - } - - @Test - public void testCharacter() { - Character value = (Character) converter.convertFromString("A", Character.class); - Assert.assertEquals(value.charValue(), 'A'); - } - - @Test(expected = IllegalArgumentException.class) - public void testCharacter2() { - - converter.convertFromString("12", Character.class); - - } - - @Test(expected = IllegalArgumentException.class) - public void testCharacter3() { - converter.convertFromString("", Character.class); - } - - @Test - public void testString() { - String value = (String) converter.convertFromString("Test", String.class); - Assert.assertEquals(value, "Test"); - } -} \ No newline at end of file Copied: trunk/jaxx-compiler/src/test/java/jaxx/compiler/types/PrimitiveConverterTest.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/PrimitiveConverterTest.java) =================================================================== --- trunk/jaxx-compiler/src/test/java/jaxx/compiler/types/PrimitiveConverterTest.java (rev 0) +++ trunk/jaxx-compiler/src/test/java/jaxx/compiler/types/PrimitiveConverterTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,133 @@ +/* + * *##% + * JAXX Compiler + * 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>. + * ##%* + */ +package jaxx.compiler.types; + +import jaxx.compiler.types.PrimitiveConverter; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class PrimitiveConverterTest { + + PrimitiveConverter converter; + + + @Before + public void setUp() { + converter = new PrimitiveConverter(); + } + + @Test + public void testBoolean() { + Boolean value = (Boolean) converter.convertFromString("true", Boolean.class); + Assert.assertTrue(value); + + value = (Boolean) converter.convertFromString("false", Boolean.class); + Assert.assertFalse(value); + + } + + @Test(expected = IllegalArgumentException.class) + public void testBoolean2() { + converter.convertFromString("yes", Boolean.class); + } + + @Test + public void testByte() { + Byte value = (Byte) converter.convertFromString(String.valueOf(Byte.MAX_VALUE), Byte.class); + Assert.assertEquals(value.byteValue(), Byte.MAX_VALUE); + + } + + @Test(expected = IllegalArgumentException.class) + public void testByte2() { + + converter.convertFromString(String.valueOf(1 + Byte.MAX_VALUE), Byte.class); + } + + @Test + public void testShort() { + Short value = (Short) converter.convertFromString(String.valueOf(Short.MAX_VALUE), Short.class); + Assert.assertEquals(value.shortValue(), Short.MAX_VALUE); + + + } + + @Test(expected = IllegalArgumentException.class) + public void testShort2() { + + converter.convertFromString(String.valueOf(1 + Short.MAX_VALUE), Short.class); + } + + @Test + public void testInteger() { + Integer value = (Integer) converter.convertFromString(String.valueOf(Integer.MAX_VALUE), Integer.class); + Assert.assertEquals(value.intValue(), Integer.MAX_VALUE); + } + + @Test(expected = IllegalArgumentException.class) + public void testInteger2() { + + converter.convertFromString(String.valueOf(1L + Integer.MAX_VALUE), Integer.class); + } + + @Test + public void testLong() { + Long value = (Long) converter.convertFromString(String.valueOf(Long.MAX_VALUE), Long.class); + Assert.assertEquals(value.longValue(), Long.MAX_VALUE); + } + + @Test + public void testFloat() { + Float value = (Float) converter.convertFromString("3.1415", Float.class); + Assert.assertTrue(value == 3.1415f); + } + + @Test + public void testDouble() { + Double value = (Double) converter.convertFromString("3.1415", Double.class); + Assert.assertTrue(value == 3.1415); + } + + @Test + public void testCharacter() { + Character value = (Character) converter.convertFromString("A", Character.class); + Assert.assertEquals(value.charValue(), 'A'); + } + + @Test(expected = IllegalArgumentException.class) + public void testCharacter2() { + + converter.convertFromString("12", Character.class); + + } + + @Test(expected = IllegalArgumentException.class) + public void testCharacter3() { + converter.convertFromString("", Character.class); + } + + @Test + public void testString() { + String value = (String) converter.convertFromString("Test", String.class); + Assert.assertEquals(value, "Test"); + } +} \ No newline at end of file Deleted: trunk/jaxx-compiler/src/test/java/jaxx/compiler/types/TypeManagerTest.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/TypeManagerTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/test/java/jaxx/compiler/types/TypeManagerTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,56 +0,0 @@ -package jaxx.compiler.types; - -import org.junit.Assert; -import org.junit.Test; - -/** - * Created: 29 nov. 2009 - * - * @author Tony Chemit <chemit@codelutin.com> Copyright Code Lutin - * @version $Revision$ - * <p/> - * Mise a jour: $Date$ par : - * $Author: tchemit $ - */ -public class TypeManagerTest { - - @Test - public void testHexValue() { - - String actual; - String expected; - - actual = TypeManager.convertVariableNameToConstantName("azerty"); - expected = "AZERTY"; - Assert.assertEquals(expected, actual); - - actual = TypeManager.convertVariableNameToConstantName("azertyQwerty"); - expected = "AZERTY_QWERTY"; - Assert.assertEquals(expected, actual); - - actual = TypeManager.convertVariableNameToConstantName("1azertyQwerty"); - expected = "1AZERTY_QWERTY"; - Assert.assertEquals(expected, actual); - - actual = TypeManager.convertVariableNameToConstantName("$1azertyQwerty"); - expected = "$1AZERTY_QWERTY"; - Assert.assertEquals(expected, actual); - - actual = TypeManager.convertVariableNameToConstantName("binding_$hum"); - expected = "BINDING_$HUM"; - Assert.assertEquals(expected, actual); - - actual = TypeManager.convertVariableNameToConstantName("BINding_$hum"); - expected = "BINDING_$HUM"; - Assert.assertEquals(expected, actual); - - actual = TypeManager.convertVariableNameToConstantName("BINding_$Hum"); - expected = "BINDING_$HUM"; - Assert.assertEquals(expected, actual); - - actual = TypeManager.convertVariableNameToConstantName("!BINding_$Hum"); - expected = "NOT_BINDING_$HUM"; - Assert.assertEquals(expected, actual); - } - -} Copied: trunk/jaxx-compiler/src/test/java/jaxx/compiler/types/TypeManagerTest.java (from rev 1672, branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/TypeManagerTest.java) =================================================================== --- trunk/jaxx-compiler/src/test/java/jaxx/compiler/types/TypeManagerTest.java (rev 0) +++ trunk/jaxx-compiler/src/test/java/jaxx/compiler/types/TypeManagerTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,56 @@ +package jaxx.compiler.types; + +import org.junit.Assert; +import org.junit.Test; + +/** + * Created: 29 nov. 2009 + * + * @author Tony Chemit <chemit@codelutin.com> Copyright Code Lutin + * @version $Revision$ + * <p/> + * Mise a jour: $Date$ par : + * $Author: tchemit $ + */ +public class TypeManagerTest { + + @Test + public void testHexValue() { + + String actual; + String expected; + + actual = TypeManager.convertVariableNameToConstantName("azerty"); + expected = "AZERTY"; + Assert.assertEquals(expected, actual); + + actual = TypeManager.convertVariableNameToConstantName("azertyQwerty"); + expected = "AZERTY_QWERTY"; + Assert.assertEquals(expected, actual); + + actual = TypeManager.convertVariableNameToConstantName("1azertyQwerty"); + expected = "1AZERTY_QWERTY"; + Assert.assertEquals(expected, actual); + + actual = TypeManager.convertVariableNameToConstantName("$1azertyQwerty"); + expected = "$1AZERTY_QWERTY"; + Assert.assertEquals(expected, actual); + + actual = TypeManager.convertVariableNameToConstantName("binding_$hum"); + expected = "BINDING_$HUM"; + Assert.assertEquals(expected, actual); + + actual = TypeManager.convertVariableNameToConstantName("BINding_$hum"); + expected = "BINDING_$HUM"; + Assert.assertEquals(expected, actual); + + actual = TypeManager.convertVariableNameToConstantName("BINding_$Hum"); + expected = "BINDING_$HUM"; + Assert.assertEquals(expected, actual); + + actual = TypeManager.convertVariableNameToConstantName("!BINding_$Hum"); + expected = "NOT_BINDING_$HUM"; + Assert.assertEquals(expected, actual); + } + +} Modified: trunk/jaxx-compiler/src/test/resources/log4j.properties =================================================================== --- trunk/jaxx-compiler/src/test/resources/log4j.properties 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-compiler/src/test/resources/log4j.properties 2009-12-02 13:59:28 UTC (rev 1673) @@ -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 Property changes on: trunk/jaxx-demo ___________________________________________________________________ Modified: svn:ignore - target + target *.iml *.ipr *.iws Modified: trunk/jaxx-demo/pom.xml =================================================================== --- trunk/jaxx-demo/pom.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/pom.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -10,7 +10,7 @@ <parent> <groupId>org.nuiton</groupId> <artifactId>jaxx</artifactId> - <version>1.7.2-SNAPSHOT</version> + <version>2.0.0-beta-3-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> @@ -46,14 +46,19 @@ <artifactId>junit</artifactId> </dependency> + <dependency> + <groupId>org.nuiton.thirdparty</groupId> + <artifactId>rsyntaxtextarea</artifactId> + </dependency> + </dependencies> <!-- ************************************************************* --> <!-- *** Project Information ************************************* --> <!-- ************************************************************* --> - <name>${project.artifactId}</name> - <description>Jaxx Demo module</description> + <name>JAXX :: Demo</name> + <description>JAXX Demo</description> <!-- ************************************************************* --> <!-- *** Build Settings ****************************************** --> @@ -135,19 +140,10 @@ <plugin> <groupId>org.nuiton</groupId> - <artifactId>maven-helper-plugin</artifactId> + <artifactId>maven-license-plugin</artifactId> <configuration> <copyToMETA_INF>true</copyToMETA_INF> </configuration> - <executions> - <execution> - <id>attach-licenses</id> - <goals> - <goal>add-license</goal> - <goal>add-third-party</goal> - </goals> - </execution> - </executions> </plugin> </plugins> @@ -210,10 +206,14 @@ <plugin> <groupId>org.nuiton</groupId> - <artifactId>maven-helper-plugin</artifactId> + <artifactId>maven-license-plugin</artifactId> <executions> <execution> <id>attach-licenses</id> + <goals> + <goal>add-license</goal> + <goal>add-third-party</goal> + </goals> </execution> </executions> </plugin> @@ -287,6 +287,19 @@ </build> </profile> + <profile> + <id>staging-site-profile</id> + <activation> + <property> + <name>stagingSite</name> + <value>true</value> + </property> + </activation> + <properties> + <jnlp.codebase>http://maven-site.liosalfar/jaxx/jaxx-demo/jnlp</jnlp.codebase> + </properties> + </profile> + </profiles> </project> Modified: trunk/jaxx-demo/src/main/filters/jaxx-demo.properties =================================================================== --- trunk/jaxx-demo/src/main/filters/jaxx-demo.properties 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/filters/jaxx-demo.properties 2009-12-02 13:59:28 UTC (rev 1673) @@ -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: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,6 +1,6 @@ /* * *##% - * jaxx-demo + * JAXX Demo * Copyright (C) 2008 - 2009 CodeLutin * * This program is free software: you can redistribute it and/or modify @@ -26,6 +26,7 @@ import java.util.Locale; import java.util.Properties; +import jaxx.demo.component.jaxx.navigation.FullNavigationTreeDemo; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -110,6 +111,11 @@ return result; } + public String getDemoPath() { + String result = getOption(Option.DEMO_PATH.key); + return result; + } + public void setFullscreen(boolean fullscreen) { Object oldValue = null; setOption(Option.FULL_SCREEN.key, fullscreen + ""); @@ -159,7 +165,8 @@ CONFIG_FILE(CONFIG_FILE_NAME, _("jaxxdemo.config.configFileName.description"), "jaxxdemo", String.class, true, true), FULL_SCREEN("ui.fullscreen", _("jaxxdemo.config.ui.fullscreen"), "false", Boolean.class, false, false), - LOCALE("ui.locale", _("jaxxdemo.config.ui.locale"), Locale.FRANCE.toString(), Locale.class, false, false); + LOCALE("ui.locale", _("jaxxdemo.config.ui.locale"), Locale.FRANCE.toString(), Locale.class, false, false), + DEMO_PATH("ui.demo.path", _("jaxxdemo.config.ui.demo.path"), "$root/jaxxdemo.tree.component.jaxx/jaxxdemo.tree.component.jaxx.tree.navigation/" + FullNavigationTreeDemo.class.getSimpleName(), String.class, false, false); public final String key; public final String description; public final String defaultValue; Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,87 +1,118 @@ - -<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> -</JTabbedPane> \ No newline at end of file +<!-- + *##% + 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; +import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; + +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 + RSyntaxTextArea content = new RSyntaxTextArea(); + if (extra.matches(".*\\.jaxx") || extra.matches(".*\\.xml")){ + content.setSyntaxEditingStyle(RSyntaxTextArea.SYNTAX_STYLE_XML); + } else if (extra.matches(".*\\.java")){ + content.setSyntaxEditingStyle(RSyntaxTextArea.SYNTAX_STYLE_JAVA); + } else if (extra.matches(".*\\.css")){ + content.setSyntaxEditingStyle(RSyntaxTextArea.SYNTAX_STYLE_CSS); + } + 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> Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,6 +1,6 @@ /* * *##% - * jaxx-demo + * JAXX Demo * Copyright (C) 2008 - 2009 CodeLutin * * This program is free software: you can redistribute it and/or modify @@ -20,34 +20,36 @@ */ package jaxx.demo; -import java.util.Stack; -import javax.swing.JPanel; +import jaxx.runtime.JAXXContext; +import jaxx.runtime.context.JAXXContextEntryDef; +import jaxx.runtime.JAXXObject; +import jaxx.runtime.swing.CardLayout2; +import jaxx.runtime.swing.ErrorDialogUI; + +import jaxx.runtime.swing.navigation.NavigationTreeHelper; +import jaxx.runtime.swing.navigation.NavigationTreeHandlerWithCardLayout; +import jaxx.runtime.swing.navigation.NavigationTreeModelBuilder; +import jaxx.runtime.swing.navigation.NavigationTreeModel; +import jaxx.runtime.swing.navigation.NavigationTreeNode; +import jaxx.runtime.swing.navigation.NavigationTreeHandler; +import jaxx.runtime.swing.navigation.NavigationTreeHandler.Strategy; + 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.navigation.FullNavigationTreeDemo; import jaxx.demo.feature.databinding.BeanDataBindingDemo; import jaxx.demo.feature.validation.*; import jaxx.demo.fun.*; import static org.nuiton.i18n.I18n.n_; - -import jaxx.runtime.JAXXContext; -import jaxx.runtime.JAXXContextEntryDef; -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 org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import java.util.Stack; +import javax.swing.JPanel; + /** * * @author chemit @@ -67,7 +69,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 +123,7 @@ addDemo(ValidationListDemo.class). addDemo(ValidationTableDemo.class). goUp(). + goUp(). addText(n_("jaxxdemo.tree.fun")). addDemo(LabelStyleDemo.class). addDemo(CounterDemo.class). @@ -129,7 +132,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 +142,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 +171,8 @@ ErrorDialogUI.showError(e); } - protected DemoUI getContext() { + @Override + public DemoUI getContext() { return (DemoUI) context; } }; @@ -185,38 +189,38 @@ /** * la definition de l'unqiue object a partage */ - static private final JAXXContextEntryDef<DemoConfig> def = JAXXContextEntryDef.newDef(DemoConfig.class); + static private final JAXXContextEntryDef<DemoConfig> def = jaxx.runtime.Util.newContextEntryDef(DemoConfig.class); /** * 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: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.css =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.css 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.css 2009-12-02 13:59:28 UTC (rev 1673) @@ -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: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,81 +1,109 @@ - -<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> -</JFrame> \ No newline at end of file +<!-- + *##% + 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.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); +} + +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(DemoUI.this)}' + selectionModel="{getTreeHelper().createTreeHandler(DemoUI.this)}"/> + </JScrollPane> + + <JPanel id='content'/> + + </JSplitPane> + + <jaxx.runtime.swing.StatusMessagePanel id='p' constraints='BorderLayout.SOUTH'/> + + </JPanel> +</JFrame> Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,6 +1,6 @@ /** * *##% - * jaxx-demo + * JAXX Demo * Copyright (C) 2008 - 2009 CodeLutin * * This program is free software: you can redistribute it and/or modify @@ -20,26 +20,28 @@ */ package jaxx.demo; +import jaxx.runtime.JAXXContext; +import jaxx.runtime.context.DefaultApplicationContext; +import jaxx.runtime.context.JAXXContextEntryDef; +import jaxx.runtime.context.JAXXInitialContext; +import jaxx.runtime.decorator.DecoratorProvider; +import jaxx.runtime.swing.AboutPanel; import jaxx.runtime.swing.ErrorDialogUI; -import jaxx.runtime.JAXXContext; -import jaxx.runtime.JAXXInitialContext; -import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode; +import jaxx.runtime.swing.editor.config.ConfigUI; +import jaxx.runtime.swing.editor.config.ConfigUIBuilder; +import jaxx.runtime.swing.editor.config.model.ConfigUIModel; +import jaxx.runtime.swing.navigation.NavigationTreeNode; +import jaxx.runtime.swing.renderer.DecoratorProviderListCellRenderer; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.nuiton.i18n.I18n; import static org.nuiton.i18n.I18n._; import static org.nuiton.i18n.I18n.n_; -import java.awt.Desktop; +import javax.swing.*; +import java.awt.*; import java.net.URL; import java.util.Locale; -import javax.swing.SwingUtilities; -import jaxx.runtime.DefaultApplicationContext; -import jaxx.runtime.JAXXContextEntryDef; -import jaxx.runtime.swing.AboutPanel; -import jaxx.runtime.swing.editor.config.ConfigUI; -import jaxx.runtime.swing.editor.config.ConfigUIBuilder; -import jaxx.runtime.swing.editor.config.model.ConfigUIModel; -import org.nuiton.i18n.I18n; /** * Le handler de l'ui principale. @@ -49,9 +51,11 @@ */ public class DemoUIHandler { //implements JAXXHelp { - /** to use log facility, just put in your code: log.info(\"...\"); */ + /** + * to use log facility, just put in your code: log.info(\"...\"); + */ static private Log log = LogFactory.getLog(DemoUIHandler.class); - static final JAXXContextEntryDef<DemoUI> MAIN_UI_ENTRY_DEF = JAXXContextEntryDef.newDef("mainui", DemoUI.class); + static final JAXXContextEntryDef<DemoUI> MAIN_UI_ENTRY_DEF = jaxx.runtime.Util.newContextEntryDef("mainui", DemoUI.class); /** * Methode pour initialiser l'ui principale sans l'afficher. @@ -78,6 +82,13 @@ // share config context.add(rootContext.getContextValue(DemoConfig.class)); + // share a unique DecoratorProviderListCellRenderer + DecoratorProvider decoratorProvider = rootContext.getContextValue(DecoratorProvider.class); + + context.add(decoratorProvider); + + context.add(new DecoratorProviderListCellRenderer(decoratorProvider)); + // instanciate ui DemoUI ui = new DemoUI(context); @@ -93,7 +104,7 @@ return ui; } - public void displayUI(final DemoUI ui, final NavigationTreeNode node) { + public void displayUI(final DemoUI ui, final String nodePath) { // expend all nodes of the demo tree jaxx.runtime.SwingUtil.expandTree(ui.getNavigation()); @@ -102,32 +113,32 @@ @Override public void run() { -// // use best dimensions -// ui.getSplitPane().resetToPreferredSizes(); String path; - if (node == null) { + if (nodePath == null) { // take first node path = "$root/jaxxdemo.tree.component.swing"; } else { // take selected node - path = node.getContextPath(); + path = nodePath; } + 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); } @@ -145,7 +156,8 @@ // scan main ui DemoUI ui = getUI(rootContext); - NavigationTreeNode node = null; + NavigationTreeNode node; + String nodePath = null; if (ui != null) { @@ -154,7 +166,8 @@ node = ui.getTreeHelper().getSelectedNode(ui); if (node != null) { - log.info("selected node " + node.getContextPath()); + nodePath = node.getFullPath(); + log.info("selected node " + nodePath); } ErrorDialogUI.init(null); @@ -169,7 +182,7 @@ ui = initUI(rootContext, fullscreen); - displayUI(ui, node); + displayUI(ui, nodePath); } /** @@ -179,7 +192,7 @@ * mode console (c'est à dire en mode plein écran exclusif), sinon on * passe en mode fenetré normal. * - * @param context l'ui principale de l'application + * @param context l'ui principale de l'application * @param fullscreen le nouvel état requis. */ public void changeScreen(JAXXContext context, final boolean fullscreen) { @@ -248,7 +261,7 @@ ConfigUIBuilder.showConfigUI(configUI, ui, false); } -// @Override + // @Override public void showHelp(JAXXContext context, String helpId) { // DemoUI mainUI = getUI(context); // ObserveHelpBroker helpBroker = context.getContextValue(ObserveHelpBroker.class); @@ -284,14 +297,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: trunk/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,6 +1,6 @@ /* * *##% - * jaxx-demo + * JAXX Demo * Copyright (C) 2008 - 2009 CodeLutin * * This program is free software: you can redistribute it and/or modify @@ -20,7 +20,11 @@ */ package jaxx.demo; -import jaxx.runtime.DefaultApplicationContext; +import jaxx.demo.component.jaxx.navigation.Movie; +import jaxx.demo.component.jaxx.navigation.People; +import jaxx.runtime.SwingUtil; +import jaxx.runtime.context.DefaultApplicationContext; +import jaxx.runtime.decorator.DecoratorProvider; import jaxx.runtime.swing.ErrorDialogUI; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -28,10 +32,7 @@ import static org.nuiton.i18n.I18n._; import org.nuiton.util.StringUtil; -import jaxx.runtime.SwingUtil; - /** - * * @author chemit */ public class RunDemo { @@ -41,18 +42,14 @@ */ private static Log log = LogFactory.getLog(RunDemo.class); /** - * When application was started - */ - private static long startingTime = System.nanoTime(); - /** * The singleton instance of the main context */ protected static DefaultApplicationContext context; public static void main(String[] args) { - startingTime = System.nanoTime(); - log.info("Observe start at " + new java.util.Date() + " args: " + java.util.Arrays.toString(args)); + long startingTime = System.nanoTime(); + log.info("JAXX Demo start at " + new java.util.Date() + " args: " + java.util.Arrays.toString(args)); try { @@ -81,6 +78,20 @@ // share the config rootContext.setContextValue(config); + // init decorator provider + DecoratorProvider p = new DecoratorProvider() { + + @Override + protected void loadDecorators() { + + registerMultiJXPathDecorator(Movie.class, "${title}$s##${year}$s", "##", " - "); + registerMultiJXPathDecorator(People.class, "${firstName}$s##${lastName}$s", "##", " "); + } + }; + + // share the decorator provider + rootContext.setContextValue(p); + long t00 = System.nanoTime(); // init i18n @@ -119,7 +130,7 @@ log.info(_("jaxxdemo.init.ui.done")); - handler.displayUI(ui, null); + handler.displayUI(ui, config.getDemoPath()); } catch (Exception e) { ErrorDialogUI.showError(e); @@ -141,6 +152,7 @@ * l'context partagée. * <p/> * Note : Cette méthode ne peut être appelée qu'une seule fois. + * * @return l'context partagée * @throws IllegalStateException si un contexte applicatif a déja été positionné. */ @@ -177,7 +189,6 @@ try { super.run(); - //JAXXContext.get().close(); // force to kill main thread log.info(_("jaxxdemo.init.closed", new java.util.Date())); Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/BoxedDecoratorDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/BoxedDecoratorDemo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/BoxedDecoratorDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,91 +1,110 @@ - -<jaxx.demo.DemoPanel> - <jaxx.runtime.swing.BlockingLayerUI id='layerUI' - blockIcon='{SwingUtil.createImageIcon("action-block.png")}' - acceptIcon='{SwingUtil.createImageIcon("action-accept.png")}' - useIcon='true' - blockingColor='{new Color(50,50,50)}' - acceptAction='{new AbstractAction() { private static final long serialVersionUID = 1L; - @Override - public void actionPerformed(ActionEvent e) { - accept(e, "from icon of layer"); - } - }}' /> - <jaxx.runtime.swing.BlockingLayerUI2 id='layerUI2' - blockIcon='{SwingUtil.createImageIcon("action-block.png")}' - acceptIcon='{SwingUtil.createImageIcon("action-accept.png")}' - acceptAction='{new AbstractAction() { private static final long serialVersionUID = 1L; - @Override - public void actionPerformed(ActionEvent e) { - accept(e, "from icon of layer"); - } - }}' /> - <script><![CDATA[ -import jaxx.runtime.SwingUtil; - -void $afterCompleteSetup() { - for (JComponent boxed : SwingUtil.getLayeredComponents(this)) { - if (boxed == d) { - SwingUtil.getLayer(boxed).setUI(layerUI2); - continue; - } - - jaxx.runtime.swing.BlockingLayerUI ui = layerUI.clone(); - if ( boxed == c) { - ui.setBlock(true); - } - SwingUtil.getLayer(boxed).setUI(ui); - } -} - -public void setLayer(boolean active) { - for (JComponent boxed : SwingUtil.getLayeredComponents(this)) { - if (boxed == d) { - continue; - } - jaxx.runtime.swing.BlockingLayerUI ui = (jaxx.runtime.swing.BlockingLayerUI)SwingUtil.getLayer(boxed).getUI(); - if ( boxed == c) { - ui.setBlock(active); - } - ui.setUseIcon(active); - } -} - -protected void accept(ActionEvent e, String suffix) { - JButton source = (JButton) e.getSource(); - String clickedMessage = (String) source.getClientProperty("clickedText"); - String msg = "'" + source.getText() + "' clicked - " + suffix + " : " + clickedMessage; - ((DefaultListModel)messages.getModel()).addElement(msg); -}]]> - </script> - <Table id='demoPanel' fill='both' weightx='1'> - <row> - <cell> - <JCheckBox id='toggle' selected='true' - text='{toggle.isSelected() ? "Active layer" : "No layer"}' - onActionPerformed='setLayer(toggle.isSelected());'/> - </cell> - </row> - <row> - <cell weighty='0.5'> - <JPanel layout='{new GridLayout(1,3,3,3)}'> - <JButton text='button A' decorator='boxed' _clickedText='"button A was clicked"' - onActionPerformed='accept(event, "from button (no layer)")'/> - <JButton text='button B' decorator='boxed' _clickedText='"button B was clicked"' - onActionPerformed='accept(event, "from button (no layer)")'/> - <JButton id='c' text='button C (full block)' decorator='boxed' _clickedText='"button C was clicked"' - onActionPerformed='accept(event, "from button (no layer)");'/> - <JButton id='d' text='button D (full block 2)' decorator='boxed' _clickedText='"button D was clicked"' - onActionPerformed='accept(event, "from button (no layer)");'/> - </JPanel> - </cell> - </row> - <row> - <cell weighty='0.5'> - <JScrollPane> - <JList id='messages' model='{new DefaultListModel()}'/> - </JScrollPane> - </cell> - </row> - </Table> -</jaxx.demo.DemoPanel> \ No newline at end of file +<!-- + *##% + 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' + blockIcon='{SwingUtil.createImageIcon("action-block.png")}' + acceptIcon='{SwingUtil.createImageIcon("action-accept.png")}' + useIcon='true' + blockingColor='{new Color(50,50,50)}' + acceptAction='{new AbstractAction() { private static final long serialVersionUID = 1L; + @Override + public void actionPerformed(ActionEvent e) { + accept(e, "from icon of layer"); + } + }}' /> + <jaxx.runtime.swing.BlockingLayerUI2 id='layerUI2' + blockIcon='{SwingUtil.createImageIcon("action-block.png")}' + acceptIcon='{SwingUtil.createImageIcon("action-accept.png")}' + acceptAction='{new AbstractAction() { private static final long serialVersionUID = 1L; + @Override + public void actionPerformed(ActionEvent e) { + accept(e, "from icon of layer"); + } + }}' /> + <script><![CDATA[ + +void $afterCompleteSetup() { + for (JComponent boxed : SwingUtil.getLayeredComponents(this)) { + if (boxed == d) { + SwingUtil.getLayer(boxed).setUI(layerUI2); + continue; + } + + jaxx.runtime.swing.BlockingLayerUI ui = layerUI.clone(); + if ( boxed == c) { + ui.setBlock(true); + } + SwingUtil.getLayer(boxed).setUI(ui); + } +} + +public void setLayer(boolean active) { + for (JComponent boxed : SwingUtil.getLayeredComponents(this)) { + if (boxed == d) { + continue; + } + jaxx.runtime.swing.BlockingLayerUI ui = (jaxx.runtime.swing.BlockingLayerUI)SwingUtil.getLayer(boxed).getUI(); + if ( boxed == c) { + ui.setBlock(active); + } + ui.setUseIcon(active); + } +} + +protected void accept(ActionEvent e, String suffix) { + JButton source = (JButton) e.getSource(); + String clickedMessage = (String) source.getClientProperty("clickedText"); + String msg = "'" + source.getText() + "' clicked - " + suffix + " : " + clickedMessage; + ((DefaultListModel)messages.getModel()).addElement(msg); +}]]> + </script> + <Table id='demoPanel' fill='both' weightx='1'> + <row> + <cell> + <JCheckBox id='toggle' selected='true' + text='{toggle.isSelected() ? "Active layer" : "No layer"}' + onActionPerformed='setLayer(toggle.isSelected());'/> + </cell> + </row> + <row> + <cell weighty='0.5'> + <JPanel layout='{new GridLayout(1,3,3,3)}'> + <JButton text='button A' decorator='boxed' _clickedText='"button A was clicked"' + onActionPerformed='accept(event, "from button (no layer)")'/> + <JButton text='button B' decorator='boxed' _clickedText='"button B was clicked"' + onActionPerformed='accept(event, "from button (no layer)")'/> + <JButton id='c' text='button C (full block)' decorator='boxed' _clickedText='"button C was clicked"' + onActionPerformed='accept(event, "from button (no layer)");'/> + <JButton id='d' text='button D (full block 2)' decorator='boxed' _clickedText='"button D was clicked"' + onActionPerformed='accept(event, "from button (no layer)");'/> + </JPanel> + </cell> + </row> + <row> + <cell weighty='0.5'> + <JScrollPane> + <JList id='messages' model='{new DefaultListModel()}'/> + </JScrollPane> + </cell> + </row> + </Table> +</jaxx.demo.DemoPanel> Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/StatusMessagePanelDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/StatusMessagePanelDemo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/StatusMessagePanelDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,11 +1,31 @@ -<jaxx.demo.DemoPanel> - <JPanel id='demoPanel' layout='{new BorderLayout()}'> - <JPanel layout='{new GridLayout(0,1)}' constraints='BorderLayout.CENTER'> - <JButton text='Fool me once' - onActionPerformed='p.setStatus(((JButton)event.getSource()).getText() + " ? shame on you!")'/> - <JButton text='Fool me twice' - onActionPerformed='p.setStatus(((JButton)event.getSource()).getText() + " ? shame on ...")'/> - </JPanel> - <jaxx.runtime.swing.StatusMessagePanel id='p' constraints='BorderLayout.SOUTH'/> - </JPanel> -</jaxx.demo.DemoPanel> \ No newline at end of file +<!-- + *##% + 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'> + <JButton text='Fool me once' + onActionPerformed='p.setStatus(((JButton)event.getSource()).getText() + " ? shame on you!")'/> + <JButton text='Fool me twice' + onActionPerformed='p.setStatus(((JButton)event.getSource()).getText() + " ? shame on ...")'/> + </JPanel> + <jaxx.runtime.swing.StatusMessagePanel id='p' constraints='BorderLayout.SOUTH'/> + </JPanel> +</jaxx.demo.DemoPanel> Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/ComboEditorDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/ComboEditorDemo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/ComboEditorDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,35 +1,55 @@ - -<jaxx.demo.DemoPanel> - <Table id='demoPanel' fill='both'> - <row> - <cell> - <JLabel text='Locale editor:' labelFor='{localeEditor}'/> - </cell> - - <cell> - <LocaleEditor id='localeEditor'/> - </cell> - </row> - <row> - <cell> - <JLabel text='EnumEditor (language) :' labelFor='{languageEditor}'/> - </cell> - <cell> - <EnumEditor id='languageEditor' constructorParams='org.nuiton.i18n.LanguageEnum.class'/> - </cell> - </row> - <row> - <cell> - <JLabel text='EnumEditor (country) :' labelFor='{countryEditor}'/> - </cell> - <cell> - <EnumEditor id='countryEditor' constructorParams='org.nuiton.i18n.CountryEnum.class'/> - </cell> - </row> - <row> - <cell columns="2"> - <JTextArea text='{"locale : "+ localeEditor.getSelectedItem() + "\nlanguage : "+ languageEditor.getSelectedItem() + "\ncountry : " + countryEditor.getSelectedItem()}'/> - </cell> - </row> - </Table> -</jaxx.demo.DemoPanel> \ No newline at end of file +<!-- + *##% + 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'> + <row> + <cell> + <JLabel text='Locale editor:' labelFor='{localeEditor}'/> + </cell> + + <cell> + <LocaleEditor id='localeEditor'/> + </cell> + </row> + <row> + <cell> + <JLabel text='EnumEditor (language) :' labelFor='{languageEditor}'/> + </cell> + <cell> + <EnumEditor id='languageEditor' constructorParams='org.nuiton.i18n.LanguageEnum.class'/> + </cell> + </row> + <row> + <cell> + <JLabel text='EnumEditor (country) :' labelFor='{countryEditor}'/> + </cell> + <cell> + <EnumEditor id='countryEditor' constructorParams='org.nuiton.i18n.CountryEnum.class'/> + </cell> + </row> + <row> + <cell columns="2"> + <JTextArea text='{"locale : "+ localeEditor.getSelectedItem() + "\nlanguage : "+ languageEditor.getSelectedItem() + "\ncountry : " + countryEditor.getSelectedItem()}'/> + </cell> + </row> + </Table> +</jaxx.demo.DemoPanel> Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/I18nEditorDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/I18nEditorDemo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/I18nEditorDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,46 +1,86 @@ - -<jaxx.demo.DemoPanel> - <script><![CDATA[ -//localeEditor.loadI18nBundles(); -]]> - </script> - <Table id='demoPanel' fill='both'> - <row> - <cell> - <JLabel text='Empty I18n editor:' labelFor='{localeEmptyEditor}'/> - </cell> - <cell> - <jaxx.runtime.swing.editor.I18nEditor id='localeEmptyEditor' /> - </cell> - </row> - <row> - <cell> - <JLabel text='I18n editor:' labelFor='{localeEditor}'/> - </cell> - <cell> - <jaxx.runtime.swing.editor.I18nEditor id='localeEditor' - locales='{java.util.Arrays.asList(org.nuiton.i18n.I18n.getLoader().getLocales())}'/> - </cell> - </row> - <row> - <cell> - <JLabel text='I18n editor with no text :' labelFor='{localeWithNoTextEditor}'/> - </cell> - <cell> - <jaxx.runtime.swing.editor.I18nEditor id='localeWithNoTextEditor' - locales='{java.util.Arrays.asList(org.nuiton.i18n.I18n.getLoader().getLocales())}' - showText='false'/> - </cell> - </row> - <row> - <cell> - <JLabel text='I18n editor with no icon :' labelFor='{localeWithNoIconEditor}'/> - </cell> - <cell> - <jaxx.runtime.swing.editor.I18nEditor id='localeWithNoIconEditor' - locales='{java.util.Arrays.asList(org.nuiton.i18n.I18n.getLoader().getLocales())}' - showIcon='false'/> - </cell> - </row> - </Table> -</jaxx.demo.DemoPanel> \ No newline at end of file +<!-- + *##% + 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 jaxx.runtime.swing.editor.I18nEditor; +import org.nuiton.i18n.I18n; +import java.util.Arrays; + +protected Border getPopupBorder(String text) { + if (text==null || text.trim().isEmpty()) { + return null; + } + return new TitledBorder(_(text)); +} +]]> + </script> + <Table id='demoPanel' fill='both'> + <row> + <cell> + <JPanel border='{new TitledBorder(_("jaxxdemo.i18neditor.configuration"))}' + layout='{new GridLayout(0,1)}'> + + <JCheckBox id='showText' + text='jaxxdemo.i18neditor.showText' + selected='true'/> + + <JCheckBox id='showIcon' + text='jaxxdemo.i18neditor.showIcon' + selected='true'/> + + <JCheckBox id='showPopupText' + text='jaxxdemo.i18neditor.showPopupText' + selected='true'/> + + <JCheckBox id='showPopupIcon' + text='jaxxdemo.i18neditor.showPopupIcon' + selected='true'/> + + <JPanel> + <JLabel text='jaxxdemo.i18neditor.popupBorderText' + labelFor='{popupBorderText}'/> + <JTextField id='popupBorderText' + text='{_("i18neditor.popup.title")}'/> + </JPanel> + + </JPanel> + </cell> + </row> + <row> + <cell> + <I18nEditor id='editor' + showText='{showText.isSelected()}' + showIcon='{showIcon.isSelected()}' + showPopupText='{showPopupText.isSelected()}' + showPopupIcon='{showPopupIcon.isSelected()}' + popupBorder='{getPopupBorder(popupBorderText.getText())}' + locales='{Arrays.asList(I18n.getLoader().getLocales())}'/> + </cell> + </row> + <row> + <cell> + <JLabel border='{new TitledBorder(_("jaxxdemo.i18neditor.selected.locale"))}' + text='{editor.getSelectedLocale().toString()}'/> + </cell> + </row> + </Table> +</jaxx.demo.DemoPanel> Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,132 +1,182 @@ - -<jaxx.demo.DemoPanel> - <script><![CDATA[ -import jaxx.runtime.swing.editor.NumberEditor; - -void $afterCompleteSetup() { - positifIntegerEditor.init(); - positifIntegerEditor2.init(); - normalIntegerEditor.init(); - normalIntegerEditor2.init(); - positifFloatEditor.init(); - positifFloatEditor2.init(); - normalFloatEditor.init(); - normalFloatEditor2.init(); -} -]]> - </script> - - <!-- model --> - <NumberEditorDemoModel id='demoModel'/> - - <Table id='demoPanel' insets='0' fill='both'> - <row> - <cell weightx='0.5'> - <JLabel horizontalAlignment='center' text='numbereditor.type'/> - </cell> - <cell weightx='0.25'> - <JLabel horizontalAlignment='center' text='numbereditor.without.auto.popup'/> - </cell> - <cell weightx='0.25'> - <JLabel horizontalAlignment='center' text='numbereditor.with.auto.popup'/> - </cell> - </row> - <row> - <cell> - <JLabel text='{_("numbereditor.positive.int", demoModel.getPositifInteger())}'/> - </cell> - <cell> - <NumberEditor id='positifIntegerEditor' - property='positifInteger' - constructorParams='this' - bean='{demoModel}' - autoPopup='false' - showPopupButton='true' - showReset='true'/> - </cell> - <cell> - <NumberEditor id='positifIntegerEditor2' - property='positifInteger' - constructorParams='this' - bean='{demoModel}' - autoPopup='true' - showPopupButton='true' - showReset='true'/> - </cell> - </row> - <row> - <cell> - <JLabel text='{_("numbereditor.normal.int", demoModel.getNormalInteger())}'/> - </cell> - <cell> - <NumberEditor id='normalIntegerEditor' - property='normalInteger' - constructorParams='this' - bean='{demoModel}' - autoPopup='false' - showPopupButton='true' - showReset='true' - useSign='true'/> - </cell> - <cell> - <NumberEditor id='normalIntegerEditor2' - property='normalInteger' - constructorParams='this' - bean='{demoModel}' - autoPopup='true' - showPopupButton='true' - showReset='true' - useSign='true'/> - </cell> - </row> - <row> - <cell> - <JLabel text='{_("numbereditor.positive.float", demoModel.getPositifFloat())}'/> - </cell> - <cell> - <NumberEditor id='positifFloatEditor' - property='positifFloat' - constructorParams='this' - bean='{demoModel}' - autoPopup='false' - showPopupButton='true' - showReset='true'/> - </cell> - <cell> - <NumberEditor id='positifFloatEditor2' - property='positifFloat' - constructorParams='this' - bean='{demoModel}' - autoPopup='true' - showPopupButton='true' - showReset='true'/> - </cell> - </row> - <row> - <cell> - <JLabel text='{_("numbereditor.normal.float", demoModel.getNormalFloat())}'/> - </cell> - <cell> - <NumberEditor id='normalFloatEditor' - property='normalFloat' - constructorParams='this' - bean='{demoModel}' - autoPopup='false' - showPopupButton='true' - showReset='true' - useSign='true'/> - </cell> - <cell> - <NumberEditor id='normalFloatEditor2' - property='normalFloat' - constructorParams='this' - bean='{demoModel}' - autoPopup='true' - showPopupButton='true' - showReset='true' - useSign='true'/> - </cell> - </row> - </Table> - -</jaxx.demo.DemoPanel> +<!-- + *##% + 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 jaxx.runtime.swing.editor.NumberEditor; + +void $afterCompleteSetup() { + editor.init(); +} +]]> + </script> + + <!-- model --> + <NumberEditorDemoModel id='demoModel'/> + + <Table id='demoPanel' insets='0' fill='both'> + <row> + <cell> + <JPanel border='{new TitledBorder(_("jaxxdemo.numbereditor.configuration"))}' + layout='{new GridLayout(0,1)}'> + + <JCheckBox id='useFloat' + text='jaxxdemo.numbereditor.useFloat' + selected='true'/> + + <JCheckBox id='useSign' + text='jaxxdemo.numbereditor.useSign' + selected='true'/> + + <JCheckBox id='showPopupButton' + text='jaxxdemo.numbereditor.showPopupButton' + selected='true'/> + + <JCheckBox id='showResetButton' + text='jaxxdemo.numbereditor.showReset' + selected='true'/> + + <JCheckBox id='autoPopup' + text='jaxxdemo.numbereditor.autoPopup' + selected='false'/> + + </JPanel> + </cell> + </row> + <row> + <cell> + <NumberEditor id='editor' + constructorParams='this' + bean='{demoModel}' + property='{useFloat.isSelected() ? "floatProperty" : "integerProperty"}' + useFloat='{useFloat.isSelected()}' + useSign='{useSign.isSelected()}' + autoPopup='{autoPopup.isSelected()}' + showPopupButton='{showPopupButton.isSelected()}' + showReset='{showResetButton.isSelected()}' /> + </cell> + </row> + <row> + <cell> + <JPanel border='{new TitledBorder(_("jaxxdemo.numbereditor.model"))}' + layout='{new GridLayout(0,1)}'> + <JLabel text='{_("jaxxdemo.numbereditor.model.int", demoModel.getIntegerProperty())}'/> + <JLabel text='{_("jaxxdemo.numbereditor.model.float", demoModel.getFloatProperty())}'/> + + </JPanel> + </cell> + </row> + </Table> +</jaxx.demo.DemoPanel> + <!--row> + <cell> + <NumberEditor id='positifIntegerEditor' + property='positifInteger' + constructorParams='this' + bean='{demoModel}' + autoPopup='false' + showPopupButton='true' + showReset='true'/> + </cell> + <cell> + <NumberEditor id='positifIntegerEditor2' + property='positifInteger' + constructorParams='this' + bean='{demoModel}' + autoPopup='true' + showPopupButton='true' + showReset='true'/> + </cell> + </row> + <row> + <cell> + <JLabel text='{_("numbereditor.normal.int", demoModel.getNormalInteger())}'/> + </cell> + <cell> + <NumberEditor id='normalIntegerEditor' + property='normalInteger' + constructorParams='this' + bean='{demoModel}' + autoPopup='false' + showPopupButton='true' + showReset='true' + useSign='true'/> + </cell> + <cell> + <NumberEditor id='normalIntegerEditor2' + property='normalInteger' + constructorParams='this' + bean='{demoModel}' + autoPopup='true' + showPopupButton='true' + showReset='true' + useSign='true'/> + </cell> + </row> + <row> + <cell> + <JLabel text='{_("numbereditor.positive.float", demoModel.getPositifFloat())}'/> + </cell> + <cell> + <NumberEditor id='positifFloatEditor' + property='positifFloat' + constructorParams='this' + bean='{demoModel}' + autoPopup='false' + showPopupButton='true' + showReset='true'/> + </cell> + <cell> + <NumberEditor id='positifFloatEditor2' + property='positifFloat' + constructorParams='this' + bean='{demoModel}' + autoPopup='true' + showPopupButton='true' + showReset='true'/> + </cell> + </row> + <row> + <cell> + <JLabel text='{_("numbereditor.normal.float", demoModel.getNormalFloat())}'/> + </cell> + <cell> + <NumberEditor id='normalFloatEditor' + property='normalFloat' + constructorParams='this' + bean='{demoModel}' + autoPopup='false' + showPopupButton='true' + showReset='true' + useSign='true'/> + </cell> + <cell> + <NumberEditor id='normalFloatEditor2' + property='normalFloat' + constructorParams='this' + bean='{demoModel}' + autoPopup='true' + showPopupButton='true' + showReset='true' + useSign='true'/> + </cell> + </row--> + Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemoModel.java =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemoModel.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemoModel.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,6 +1,6 @@ /* * *##% - * jaxx-demo + * JAXX Demo * Copyright (C) 2008 - 2009 CodeLutin * * This program is free software: you can redistribute it and/or modify @@ -30,56 +30,80 @@ */ public class NumberEditorDemoModel { + public static final String INTEGER_PROPERTY = "integerProperty"; + public static final String FLOAT_PROPERTY = "floatProperty"; protected PropertyChangeSupport p; - protected int positifInteger; - protected int normalInteger; - protected float positifFloat; - protected float normalFloat; + protected int integerProperty; + protected float floatProperty; +// protected int positifInteger; +// protected int normalInteger; +// protected float positifFloat; +// protected float normalFloat; public NumberEditorDemoModel() { p = new PropertyChangeSupport(this); } - public float getNormalFloat() { - return normalFloat; + public float getFloatProperty() { + return floatProperty; } - public int getNormalInteger() { - return normalInteger; + public int getIntegerProperty() { + return integerProperty; } - public float getPositifFloat() { - return positifFloat; + public void setFloatProperty(float floatProperty) { + float old = this.floatProperty; + this.floatProperty = floatProperty; + p.firePropertyChange(FLOAT_PROPERTY, old, floatProperty); } - public int getPositifInteger() { - return positifInteger; + public void setIntegerProperty(int integerProperty) { + int old = this.integerProperty; + this.integerProperty = integerProperty; + p.firePropertyChange(INTEGER_PROPERTY, old, integerProperty); } - public void setNormalFloat(float normalFloat) { - float old = this.normalFloat; - this.normalFloat = normalFloat; - p.firePropertyChange("normalFloat", old, normalFloat); - } - - public void setNormalInteger(int normalInteger) { - int old = this.normalInteger; - this.normalInteger = normalInteger; - p.firePropertyChange("normalInteger", old, normalInteger); - } - - public void setPositifFloat(float positifFloat) { - float old = this.positifFloat; - this.positifFloat = positifFloat; - p.firePropertyChange("positifFloat", old, positifFloat); - } - - public void setPositifInteger(int positifInteger) { - int old = this.positifInteger; - this.positifInteger = positifInteger; - p.firePropertyChange("positifInteger", old, positifInteger); - } - +// +// public float getNormalFloat() { +// return normalFloat; +// } +// +// public int getNormalInteger() { +// return normalInteger; +// } +// +// public float getPositifFloat() { +// return positifFloat; +// } +// +// public int getPositifInteger() { +// return positifInteger; +// } +// +// public void setNormalFloat(float normalFloat) { +// float old = this.normalFloat; +// this.normalFloat = normalFloat; +// p.firePropertyChange("normalFloat", old, normalFloat); +// } +// +// public void setNormalInteger(int normalInteger) { +// int old = this.normalInteger; +// this.normalInteger = normalInteger; +// p.firePropertyChange("normalInteger", old, normalInteger); +// } +// +// public void setPositifFloat(float positifFloat) { +// float old = this.positifFloat; +// this.positifFloat = positifFloat; +// p.firePropertyChange("positifFloat", old, positifFloat); +// } +// +// public void setPositifInteger(int positifInteger) { +// int old = this.positifInteger; +// this.positifInteger = positifInteger; +// p.firePropertyChange("positifInteger", old, positifInteger); +// } public void addPropertyChangeListener(PropertyChangeListener listener) { p.addPropertyChangeListener(listener); } Copied: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeDemo.jaxx (from rev 1672, branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeDemo.jaxx) =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeDemo.jaxx (rev 0) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,86 @@ +<!-- + *##% + 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.CardLayout2 id='contentLayout' + useOnlyVisibleComponentDimension='true'/> + + <script><![CDATA[ +import jaxx.demo.component.jaxx.navigation.content.*; + +import jaxx.runtime.decorator.DecoratorProvider; + +private final FullNavigationTreeHelper helper = new FullNavigationTreeHelper(); +private final ContentUIHandler contentUIHandler = new ContentUIHandler(); +setContextValue(helper); +setContextValue(contentUIHandler); +helper.setTree(this, navigation); +log.info("decorator provider = "+getContextValue(DecoratorProvider.class)); +helper.createModel(this); + +@Override +protected String[] getSources() { + return new String[]{ getDefaultSource(), "FullNavigationTreeHelper.java", "Movie.java", "People.java" }; +} + +private void $afterCompleteSetup() { + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + navigation.setSelectionInterval(0, 0); + splitPane.resetToPreferredSizes(); + } + }); + // expand the tree + SwingUtil.expandTree(navigation); + // auto-expand node when selected + SwingUtil.addExpandOnClickListener(navigation); +} + ]]> + </script> + + <JPanel id='demoPanel' layout='{new BorderLayout()}'> + + <JSplitPane id='splitPane' + constraints='BorderLayout.CENTER' + oneTouchExpandable='true'> + + <JScrollPane border='{null}' + horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_NEVER}' + verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_NEVER}'> + + <JTree id="navigation" + font-size='11' + rootVisible='false' + showsRootHandles='false' + model='{helper.createTreeModel(this)}' + selectionModel="{helper.createTreeHandler(this)}"/> + </JScrollPane> + + <JPanel id="content" layout="{contentLayout}" /> + + </JSplitPane> + + </JPanel> + +</jaxx.demo.DemoPanel> Copied: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeHelper.java (from rev 1672, branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeHelper.java) =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeHelper.java (rev 0) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeHelper.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,165 @@ +/* + * *##% + * 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>. + * ##%* + */ +package jaxx.demo.component.jaxx.navigation; + +import jaxx.runtime.JAXXContext; +import jaxx.runtime.JAXXObject; +import jaxx.runtime.Util; +import jaxx.runtime.context.JAXXContextEntryDef; +import jaxx.runtime.swing.CardLayout2; +import jaxx.runtime.swing.ErrorDialogUI; +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.navigation.NavigationTreeModel; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.swing.*; +import java.util.Arrays; +import java.util.List; + +/** + * + * @author chemit + * @since 1.7.2 + */ +public class FullNavigationTreeHelper extends NavigationTreeHelper { + +// static { +// // register decorator one for all +// +// DecoratorUtils.register( +// Movie.class.getSimpleName(), +// DecoratorUtils.newMultiJXPathDecorator(Movie.class, "${title}$s##${year}$s", "##", " - ")); +// +// DecoratorUtils.register( +// People.class.getSimpleName(), +// DecoratorUtils.newMultiJXPathDecorator(People.class, "${firstName}$s##${lastName}$s", "##", " ")); +// } + /** + * Logger + */ + static private final Log log = LogFactory.getLog(FullNavigationTreeHelper.class); + /** + * where the movies are hold in context + */ + static public final JAXXContextEntryDef<List<Movie>> MOVIES = Util.newListContextEntryDef("movies"); + /** + * where the actors are hold in context + */ + static public final JAXXContextEntryDef<List<People>> ACTORS = Util.newListContextEntryDef("actors"); + protected FullNavigationTreeModelBuilder builder; + + public FullNavigationTreeHelper() { + super("full"); + } + + /** + * Create the model and store it in the given context. + * + * @param context the context where to hold the model + */ + public void createModel(JAXXContext context) { + log.info("for " + this); + People a = new People("0", "Jack", "Black", 0, "/jaxx/demo/images/jack.jpg"); + People a2 = new People("1", "Héctor", "Jiménez", 0, "/jaxx/demo/images/hector.jpg"); + People a3 = new People("2", "Ana", "de la Reguera", 0, "/jaxx/demo/images/ana.jpg"); + + Movie m = new Movie("0", "Nacho libre", 1996, "/jaxx/demo/images/nacho.jpg"); + m.addActor(a); + m.addActor(a2); + m.addActor(a3); + + Movie m2 = new Movie("1", "Nacho 2", 2009, "/jaxx/demo/images/nacho2.png"); + m2.addActor(a); + m2.addActor(a2); + + MOVIES.setContextValue(context, Arrays.asList(m, m2)); + ACTORS.setContextValue(context, Arrays.asList(a, a2, a3)); + } + + @Override + public NavigationTreeModel createTreeModel(JAXXContext context) { + + if (builder == null) { + builder = new FullNavigationTreeModelBuilder(context); + } + + builder.createInitialModel(); + + NavigationTreeModel model = builder.getModel(); + + // save tree model in context + setTreeModel(context, model); + return model; + } + + @Override + public NavigationTreeHandler createTreeHandler(JAXXObject context) { + + if (log.isDebugEnabled()) { + log.debug("create handler"); + } + + NavigationTreeHandler handler; + + handler = new NavigationTreeHandlerWithCardLayout( + getPrefix(), + context, + Strategy.PER_UI_TYPE) { + + private static final long serialVersionUID = 1L; + + @Override + protected NavigationTreeModel getNavigationTreeModel() { + return getSafeTreeModel(getContext()); + } + + @Override + protected JPanel getContentContainer() { + return getContext().getContent(); + } + + @Override + protected CardLayout2 getContentLayout() { + return getContext().getContentLayout(); + } + + @Override + protected void treateError(Exception e) { + ErrorDialogUI.showError(e); + } + + @Override + public FullNavigationTreeDemo getContext() { + return (FullNavigationTreeDemo) this.context; + } + }; + // on ne peut selectionner qu'un seul noeud a la fois + handler.setSelectionMode(NavigationTreeHandler.SINGLE_TREE_SELECTION); + + // save handler in ui context + setTreeHandler(context, handler); + return handler; + } +} Copied: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeModelBuilder.java (from rev 1672, branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeModelBuilder.java) =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeModelBuilder.java (rev 0) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeModelBuilder.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,143 @@ +/* + * *##% + * 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>. + * ##%* + */ +package jaxx.demo.component.jaxx.navigation; + +import jaxx.demo.component.jaxx.navigation.content.ActorContentUI; +import jaxx.demo.component.jaxx.navigation.content.ActorsContentUI; +import jaxx.demo.component.jaxx.navigation.content.MovieContentUI; +import jaxx.demo.component.jaxx.navigation.content.MoviesContentUI; +import jaxx.runtime.JAXXContext; +import jaxx.runtime.decorator.Decorator; +import jaxx.runtime.decorator.DecoratorProvider; +import jaxx.runtime.swing.navigation.NavigationTreeModelBuilder; +import jaxx.runtime.swing.navigation.NavigationTreeNode; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import static org.nuiton.i18n.I18n._; + +import java.util.List; + +/** + * + * @author chemit + * @since 2.0.0 + */ +public class FullNavigationTreeModelBuilder extends NavigationTreeModelBuilder { + + /** + * Logger + */ + static private final Log log = LogFactory.getLog(FullNavigationTreeModelBuilder.class); + + protected FullNavigationTreeModelBuilder(JAXXContext context) { + super("/", context, null, null); + } + + public void addMovie(Movie movie) { + //TODO + } + + public void addActor(People people,Movie... movies) { + //TODO + } + + public void createInitialModel() { + + List<Movie> movies = FullNavigationTreeHelper.MOVIES.getContextValue(getModel().getContext()); + List<People> actors = FullNavigationTreeHelper.ACTORS.getContextValue(getModel().getContext()); + + if (log.isDebugEnabled()) { + log.debug("for " + movies.size() + " movie(s)"); + } + + + DecoratorProvider decoratorProvider = getModel().getContext().getContextValue(DecoratorProvider.class); + Decorator<Movie> mDecorator = decoratorProvider.getDecorator(Movie.class); + Decorator<People> pDecorator = decoratorProvider.getDecorator(People.class); + + // construction du noeud root + // il ne contient pas de context et ne sera pas visible + NavigationTreeNode rootNode = this.buildEmptyRoot(null, "$root"); + + // construction du noeud avec les films recupere la liste des films + // dans le context avec la clef movies + // navigation path = $root/movies + NavigationTreeNode moviesNode = this.build( + rootNode, + _("movies"), + FullNavigationTreeHelper.MOVIES, + "movies", + MoviesContentUI.class, + null); + + for (Movie m : movies) { + + // navigation path = $root/movies/m.id + NavigationTreeNode movieNode = this.build( + moviesNode, + mDecorator, + "..[@id=\"" + m.getId() + "\"]", + m.getId(), + MovieContentUI.class, + null); + + // navigation path = $root/movies/m.id/actors + NavigationTreeNode actorsNode = this.build( + movieNode, + _("actors"), + "../actors", + "actors", + ActorsContentUI.class, + null); + + for (People p : m.getActors()) { + // navigation path = $root/movies/m.id/actors/p.id + this.build( + actorsNode, + pDecorator, + "..[@id=\"" + p.getId() + "\"]", + p.getId(), + ActorContentUI.class, + null); + } + } + + // construction du noeud avec les acteurs + NavigationTreeNode actorsNode = this.build(rootNode, _("actors"), + FullNavigationTreeHelper.ACTORS, + "actors", ActorsContentUI.class, null); + + for (People p : actors) { + // navigation path = $root/actors/p.id + this.build( + actorsNode, + pDecorator, + "..[@id=\"" + p.getId() + "\"]", + p.getId(), + ActorContentUI.class, + null); + } + + if (log.isDebugEnabled()) { + printModel(getModel().getRoot()); + } + } +} Copied: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/Movie.java (from rev 1672, branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/Movie.java) =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/Movie.java (rev 0) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/Movie.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,128 @@ +/* + * *##% + * 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>. + * ##%* + */ +package jaxx.demo.component.jaxx.navigation; + +import java.util.ArrayList; +import java.util.List; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + +/** + * + * @author chemit + * @since 1.7.2 + */ +public class Movie { + + protected String id; + protected String title; + protected String image; + protected int year; + protected List<People> actors; + + public Movie(String id, String title, int year,String image) { + this(); + this.id = id; + this.title = title; + this.year = year; + this.image=image; + } + + public Movie() { + actors = new ArrayList<People>(); + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public List<People> getActors() { + return actors; + } + + public void setActors(List<People> actors) { + this.actors = actors; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public int getYear() { + return year; + } + + public void setYear(int year) { + this.year = year; + } + + public String getImage() { + return image; + } + + public void setImage(String image) { + this.image = image; + } + + public void addActor(People actor) { + actors.add(actor); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Movie other = (Movie) obj; + if ((this.id == null) ? (other.id != null) : !this.id.equals(other.id)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 5; + hash = 41 * hash + (this.id != null ? this.id.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE); + b.append("id", id); + b.append("title", title); + b.append("year", year); + b.append("actors", actors); + return b.toString(); + } +} Copied: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/People.java (from rev 1672, branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/People.java) =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/People.java (rev 0) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/People.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,118 @@ +/* + * *##% + * 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>. + * ##%* + */ +package jaxx.demo.component.jaxx.navigation; + +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + +/** + * + * @author chemit + * @since 1.7.2 + */ +public class People { + + protected String id; + protected String image; + protected String firstName; + protected String lastName; + protected int age; + + public People(String id, String firstName, String lastName, int age, String image) { + this.id = id; + this.firstName = firstName; + this.lastName = lastName; + this.age = age; + this.image = image; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getImage() { + return image; + } + + public void setImage(String image) { + this.image = image; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final People other = (People) obj; + if ((this.id == null) ? (other.id != null) : !this.id.equals(other.id)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 97 * hash + (this.id != null ? this.id.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE); + b.append("id", id); + b.append("firstName", firstName); + b.append("lastName", lastName); + b.append("age", age); + return b.toString(); + } +} Deleted: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorContentUI.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorContentUI.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorContentUI.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,76 +0,0 @@ -<!-- - *##% - 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>. - ##%* ---> -<ContentUI superGenericType='People'> - - <script><![CDATA[ -import jaxx.runtime.swing.navigation.NavigationTreeNode; -import jaxx.demo.component.jaxx.navigation.*; - -@Override -public void openUI(NavigationTreeNode node) throws Exception { - People p = (People) getHelper().getSelectedBean(this); - log.info("selected people = "+p); - setData(p); -} - -String getContent(People data) { - if (data == null) { - return "no content"; - } - StringBuilder buffer = new StringBuilder(); - buffer.append(data); - return buffer.toString(); -} - -ImageIcon getImage(People data) { - return data == null? null :SwingUtil.createIcon(data.getImage()); -} -]]> - </script> - - <People id='data' javaBean='null'/> - - <JSplitPane id='splitPane' - orientation='{JSplitPane.VERTICAL_SPLIT}' - resizeWeight='0.5' - constraints='BorderLayout.CENTER' - oneTouchExpandable='true'> - - <JScrollPane border='{null}' - horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_NEVER}' - verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED}'> - <JTextPane border='{new TitledBorder(_("jaxxdemo.navigation.actor.title"))}' - editable='false' - font-size='11' - text='{getContent(getData())}'/> - </JScrollPane> - - <JScrollPane border='{new TitledBorder("Picture")}' - horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED}' - verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED}' - minimumSize='{SwingUtil.newMinDimension()}'> - - <JLabel horizontalAlignment='center' icon='{getImage(getData())}'/> - - </JScrollPane> - - </JSplitPane> -</ContentUI> Copied: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorContentUI.jaxx (from rev 1672, branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorContentUI.jaxx) =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorContentUI.jaxx (rev 0) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorContentUI.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,76 @@ +<!-- + *##% + 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>. + ##%* +--> +<ContentUI superGenericType='People'> + + <script><![CDATA[ +import jaxx.runtime.swing.navigation.NavigationTreeNode; +import jaxx.demo.component.jaxx.navigation.*; + +@Override +public void openUI(NavigationTreeNode node) throws Exception { + People p = (People) getHelper().getSelectedBean(this); + log.info("selected people = "+p); + setData(p); +} + +String getContent(People data) { + if (data == null) { + return "no content"; + } + StringBuilder buffer = new StringBuilder(); + buffer.append(data); + return buffer.toString(); +} + +ImageIcon getImage(People data) { + return data == null? null :SwingUtil.createIcon(data.getImage()); +} +]]> + </script> + + <People id='data' javaBean='null'/> + + <JSplitPane id='splitPane' + orientation='{JSplitPane.VERTICAL_SPLIT}' + resizeWeight='0.5' + constraints='BorderLayout.CENTER' + oneTouchExpandable='true'> + + <JScrollPane border='{null}' + horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_NEVER}' + verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED}'> + <JTextPane border='{new TitledBorder(_("jaxxdemo.navigation.actor.title"))}' + editable='false' + font-size='11' + text='{getContent(getData())}'/> + </JScrollPane> + + <JScrollPane border='{new TitledBorder("Picture")}' + horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED}' + verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED}' + minimumSize='{SwingUtil.newMinDimension()}'> + + <JLabel horizontalAlignment='center' icon='{getImage(getData())}'/> + + </JScrollPane> + + </JSplitPane> +</ContentUI> Deleted: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorsContentUI.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorsContentUI.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorsContentUI.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,68 +0,0 @@ -<!-- - *##% - 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>. - ##%* ---> -<ContentUI superGenericType='java.util.List<People>'> - - <script><![CDATA[ -import jaxx.demo.component.jaxx.navigation.*; -import jaxx.runtime.swing.renderer.DecoratorProviderListCellRenderer; -import jaxx.runtime.swing.navigation.NavigationTreeNode; - -@Override -public void openUI(NavigationTreeNode node) throws Exception { - java.util.List<People> ps = (java.util.List<People>)getHelper().getSelectedBean(this); - log.info("selected peoples = "+ps.size()); - setData(ps); - if (ps!=null) { - DefaultListModel model = (DefaultListModel) list.getModel(); - for (People p : ps) { - model.addElement(p); - } - } -} - -@Override -public void closeUI(NavigationTreeNode node) throws Exception { - // clean list model - DefaultListModel model = (DefaultListModel) list.getModel(); - model.removeAllElements(); -} - ]]> - </script> - - <java.util.List id='data' genericType='People' javaBean='null'/> - - <JScrollPane border='{new TitledBorder(_("jaxxdemo.navigation.actors.title"))}' - constraints='BorderLayout.CENTER' - columnHeaderView='{toolbar}' - horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_NEVER}' - verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED}'> - <JList id='list' model='{new DefaultListModel()}' cellRenderer='{getContextValue(DecoratorProviderListCellRenderer.class)}'/> - </JScrollPane> - <JToolBar id='toolbar' constraints='BorderLayout.SOUTH' - floatable='false'> - <JPanel layout='{new GridLayout(1,0)}'> - <JButton text='jaxxdemo.action.show' enabled='{list.getSelectedIndex()!=-1}' onActionPerformed='getHandler().selectChild(this, list.getSelectedIndex())'/> - <JButton text='jaxxdemo.action.add'/> - <JButton text='jaxxdemo.action.remove' enabled='{list.getSelectedIndex()!=-1}'/> - </JPanel> - </JToolBar> - -</ContentUI> Copied: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorsContentUI.jaxx (from rev 1672, branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorsContentUI.jaxx) =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorsContentUI.jaxx (rev 0) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorsContentUI.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,68 @@ +<!-- + *##% + 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>. + ##%* +--> +<ContentUI superGenericType='java.util.List<People>'> + + <script><![CDATA[ +import jaxx.demo.component.jaxx.navigation.*; +import jaxx.runtime.swing.renderer.DecoratorProviderListCellRenderer; +import jaxx.runtime.swing.navigation.NavigationTreeNode; + +@Override +public void openUI(NavigationTreeNode node) throws Exception { + java.util.List<People> ps = (java.util.List<People>)getHelper().getSelectedBean(this); + log.info("selected peoples = "+ps.size()); + setData(ps); + if (ps!=null) { + DefaultListModel model = (DefaultListModel) list.getModel(); + for (People p : ps) { + model.addElement(p); + } + } +} + +@Override +public void closeUI(NavigationTreeNode node) throws Exception { + // clean list model + DefaultListModel model = (DefaultListModel) list.getModel(); + model.removeAllElements(); +} + ]]> + </script> + + <java.util.List id='data' genericType='People' javaBean='null'/> + + <JScrollPane border='{new TitledBorder(_("jaxxdemo.navigation.actors.title"))}' + constraints='BorderLayout.CENTER' + columnHeaderView='{toolbar}' + horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_NEVER}' + verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED}'> + <JList id='list' model='{new DefaultListModel()}' cellRenderer='{getContextValue(DecoratorProviderListCellRenderer.class)}'/> + </JScrollPane> + <JToolBar id='toolbar' constraints='BorderLayout.SOUTH' + floatable='false'> + <JPanel layout='{new GridLayout(1,0)}'> + <JButton text='jaxxdemo.action.show' enabled='{list.getSelectedIndex()!=-1}' onActionPerformed='getHandler().selectChild(this, list.getSelectedIndex())'/> + <JButton text='jaxxdemo.action.add'/> + <JButton text='jaxxdemo.action.remove' enabled='{list.getSelectedIndex()!=-1}'/> + </JPanel> + </JToolBar> + +</ContentUI> Deleted: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ContentUI.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ContentUI.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ContentUI.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,49 +0,0 @@ -<!-- - *##% - 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>. - ##%* ---> -<JPanel abstract='true' - layout='{new BorderLayout()}' - genericType='B extends Object' - implements='NavigationContentUI'> - - <script><![CDATA[ -import jaxx.demo.component.jaxx.navigation.*; -import jaxx.runtime.swing.navigation.NavigationTreeNode; -import jaxx.runtime.swing.navigation.NavigationContentUI; - -ContentUIHandler getHandler() { - return getContextValue(ContentUIHandler.class); -} - -FullNavigationTreeHelper getHelper() { - return getContextValue(FullNavigationTreeHelper.class); -} - -public abstract B getData(); - -public abstract void setData(B data); - -@Override -public void closeUI(NavigationTreeNode node) throws Exception { - // nothing to do -} - ]]> - </script> -</JPanel> Copied: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ContentUI.jaxx (from rev 1672, branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ContentUI.jaxx) =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ContentUI.jaxx (rev 0) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ContentUI.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,49 @@ +<!-- + *##% + 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>. + ##%* +--> +<JPanel abstract='true' + layout='{new BorderLayout()}' + genericType='B extends Object' + implements='NavigationContentUI'> + + <script><![CDATA[ +import jaxx.demo.component.jaxx.navigation.*; +import jaxx.runtime.swing.navigation.NavigationTreeNode; +import jaxx.runtime.swing.navigation.NavigationContentUI; + +ContentUIHandler getHandler() { + return getContextValue(ContentUIHandler.class); +} + +FullNavigationTreeHelper getHelper() { + return getContextValue(FullNavigationTreeHelper.class); +} + +public abstract B getData(); + +public abstract void setData(B data); + +@Override +public void closeUI(NavigationTreeNode node) throws Exception { + // nothing to do +} + ]]> + </script> +</JPanel> Deleted: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ContentUIHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ContentUIHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ContentUIHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,48 +0,0 @@ -/* - * *##% - * 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>. - * ##%* - */ -package jaxx.demo.component.jaxx.navigation.content; - -import java.util.List; -import jaxx.demo.component.jaxx.navigation.FullNavigationTreeHelper; -import jaxx.demo.component.jaxx.navigation.Movie; -import jaxx.demo.component.jaxx.navigation.People; -import jaxx.runtime.JAXXContext; - -/** - * - * @author chemit - */ -public class ContentUIHandler { - - public void selectChild(JAXXContext context, int movieIndex) { - FullNavigationTreeHelper helper = context.getContextValue(FullNavigationTreeHelper.class); - helper.gotoChildNode(context, movieIndex); - } - - public void addMovie(JAXXContext context, Movie movie) { - List<Movie> movies = FullNavigationTreeHelper.MOVIES.getContextValue(context); - List<People> actors = FullNavigationTreeHelper.ACTORS.getContextValue(context); - } - - public void addActor(JAXXContext context, People a, Movie... movies) { - List<People> actors = FullNavigationTreeHelper.ACTORS.getContextValue(context); - } -} Copied: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ContentUIHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ContentUIHandler.java) =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ContentUIHandler.java (rev 0) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ContentUIHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,48 @@ +/* + * *##% + * 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>. + * ##%* + */ +package jaxx.demo.component.jaxx.navigation.content; + +import java.util.List; +import jaxx.demo.component.jaxx.navigation.FullNavigationTreeHelper; +import jaxx.demo.component.jaxx.navigation.Movie; +import jaxx.demo.component.jaxx.navigation.People; +import jaxx.runtime.JAXXContext; + +/** + * + * @author chemit + */ +public class ContentUIHandler { + + public void selectChild(JAXXContext context, int movieIndex) { + FullNavigationTreeHelper helper = context.getContextValue(FullNavigationTreeHelper.class); + helper.gotoChildNode(context, movieIndex); + } + + public void addMovie(JAXXContext context, Movie movie) { + List<Movie> movies = FullNavigationTreeHelper.MOVIES.getContextValue(context); + List<People> actors = FullNavigationTreeHelper.ACTORS.getContextValue(context); + } + + public void addActor(JAXXContext context, People a, Movie... movies) { + List<People> actors = FullNavigationTreeHelper.ACTORS.getContextValue(context); + } +} Deleted: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MovieContentUI.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MovieContentUI.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MovieContentUI.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,76 +0,0 @@ -<!-- - *##% - 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>. - ##%* ---> -<ContentUI superGenericType='Movie'> - - <script><![CDATA[ -import jaxx.runtime.swing.navigation.NavigationTreeNode; -import jaxx.demo.component.jaxx.navigation.*; - -@Override -public void openUI(NavigationTreeNode node) throws Exception { - Movie m = (Movie) getHelper().getSelectedBean(this); - log.info("selected movie = " + m); - setData(m); -} - -String getContent(Movie data) { - if (data == null) { - return "no content"; - } - StringBuilder buffer = new StringBuilder(); - buffer.append(data); - return buffer.toString(); -} - -ImageIcon getImage(Movie data) { - return data == null? null :SwingUtil.createIcon(data.getImage()); -} -]]> - </script> - - <Movie id='data' javaBean='null'/> - - <JSplitPane id='splitPane' - orientation='{JSplitPane.VERTICAL_SPLIT}' - resizeWeight='0.5' - constraints='BorderLayout.CENTER' - oneTouchExpandable='true'> - - <JScrollPane border='{null}' - horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_NEVER}' - verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED}'> - <JTextPane border='{new TitledBorder(_("jaxxdemo.navigation.movie.title"))}' - editable='false' - font-size='11' - text='{getContent(getData())}'/> - </JScrollPane> - - <JScrollPane border='{new TitledBorder("Picture")}' - horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED}' - verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED}' - minimumSize='{SwingUtil.newMinDimension()}'> - - <JLabel horizontalAlignment='center' icon='{getImage(getData())}'/> - - </JScrollPane> - - </JSplitPane> -</ContentUI> Copied: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MovieContentUI.jaxx (from rev 1672, branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MovieContentUI.jaxx) =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MovieContentUI.jaxx (rev 0) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MovieContentUI.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,76 @@ +<!-- + *##% + 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>. + ##%* +--> +<ContentUI superGenericType='Movie'> + + <script><![CDATA[ +import jaxx.runtime.swing.navigation.NavigationTreeNode; +import jaxx.demo.component.jaxx.navigation.*; + +@Override +public void openUI(NavigationTreeNode node) throws Exception { + Movie m = (Movie) getHelper().getSelectedBean(this); + log.info("selected movie = " + m); + setData(m); +} + +String getContent(Movie data) { + if (data == null) { + return "no content"; + } + StringBuilder buffer = new StringBuilder(); + buffer.append(data); + return buffer.toString(); +} + +ImageIcon getImage(Movie data) { + return data == null? null :SwingUtil.createIcon(data.getImage()); +} +]]> + </script> + + <Movie id='data' javaBean='null'/> + + <JSplitPane id='splitPane' + orientation='{JSplitPane.VERTICAL_SPLIT}' + resizeWeight='0.5' + constraints='BorderLayout.CENTER' + oneTouchExpandable='true'> + + <JScrollPane border='{null}' + horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_NEVER}' + verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED}'> + <JTextPane border='{new TitledBorder(_("jaxxdemo.navigation.movie.title"))}' + editable='false' + font-size='11' + text='{getContent(getData())}'/> + </JScrollPane> + + <JScrollPane border='{new TitledBorder("Picture")}' + horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED}' + verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED}' + minimumSize='{SwingUtil.newMinDimension()}'> + + <JLabel horizontalAlignment='center' icon='{getImage(getData())}'/> + + </JScrollPane> + + </JSplitPane> +</ContentUI> Deleted: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MoviesContentUI.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MoviesContentUI.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MoviesContentUI.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,68 +0,0 @@ -<!-- - *##% - 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>. - ##%* ---> -<ContentUI superGenericType='java.util.List<Movie>'> - - <script><![CDATA[ -import jaxx.demo.component.jaxx.navigation.*; -import jaxx.runtime.swing.renderer.DecoratorProviderListCellRenderer; -import jaxx.runtime.swing.navigation.NavigationTreeNode; - -@Override -public void openUI(NavigationTreeNode node) throws Exception { - java.util.List<Movie> ms = (java.util.List<Movie>)getHelper().getSelectedBean(this); - log.info("selected movies = "+ms.size()); - setData(ms); - if (ms != null) { - DefaultListModel model = (DefaultListModel) list.getModel(); - for (Movie m : ms) { - model.addElement(m); - } - } -} - -@Override -public void closeUI(NavigationTreeNode node) throws Exception { - // clean list model - DefaultListModel model = (DefaultListModel) list.getModel(); - model.removeAllElements(); -} - ]]> - </script> - - <java.util.List id='data' genericType='Movie' javaBean='null'/> - - <JScrollPane border='{new TitledBorder(_("jaxxdemo.navigation.movies.title"))}' - constraints='BorderLayout.CENTER' - columnHeaderView='{toolbar}' - horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_NEVER}' - verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED}'> - <JList id='list' model='{new DefaultListModel()}' cellRenderer='{getContextValue(DecoratorProviderListCellRenderer.class)}'/> - </JScrollPane> - <JToolBar id='toolbar' opaque='false' constraints='BorderLayout.SOUTH' - floatable='false'> - <JPanel layout='{new GridLayout(1,0)}'> - <JButton text='jaxxdemo.action.show' enabled='{list.getSelectedIndex()!=-1}' onActionPerformed='getHandler().selectChild(this, list.getSelectedIndex())'/> - <JButton text='jaxxdemo.action.add'/> - <JButton text='jaxxdemo.action.remove' enabled='{list.getSelectedIndex()!=-1}'/> - </JPanel> - </JToolBar> - -</ContentUI> Copied: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MoviesContentUI.jaxx (from rev 1672, branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MoviesContentUI.jaxx) =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MoviesContentUI.jaxx (rev 0) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MoviesContentUI.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,68 @@ +<!-- + *##% + 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>. + ##%* +--> +<ContentUI superGenericType='java.util.List<Movie>'> + + <script><![CDATA[ +import jaxx.demo.component.jaxx.navigation.*; +import jaxx.runtime.swing.renderer.DecoratorProviderListCellRenderer; +import jaxx.runtime.swing.navigation.NavigationTreeNode; + +@Override +public void openUI(NavigationTreeNode node) throws Exception { + java.util.List<Movie> ms = (java.util.List<Movie>)getHelper().getSelectedBean(this); + log.info("selected movies = "+ms.size()); + setData(ms); + if (ms != null) { + DefaultListModel model = (DefaultListModel) list.getModel(); + for (Movie m : ms) { + model.addElement(m); + } + } +} + +@Override +public void closeUI(NavigationTreeNode node) throws Exception { + // clean list model + DefaultListModel model = (DefaultListModel) list.getModel(); + model.removeAllElements(); +} + ]]> + </script> + + <java.util.List id='data' genericType='Movie' javaBean='null'/> + + <JScrollPane border='{new TitledBorder(_("jaxxdemo.navigation.movies.title"))}' + constraints='BorderLayout.CENTER' + columnHeaderView='{toolbar}' + horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_NEVER}' + verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED}'> + <JList id='list' model='{new DefaultListModel()}' cellRenderer='{getContextValue(DecoratorProviderListCellRenderer.class)}'/> + </JScrollPane> + <JToolBar id='toolbar' opaque='false' constraints='BorderLayout.SOUTH' + floatable='false'> + <JPanel layout='{new GridLayout(1,0)}'> + <JButton text='jaxxdemo.action.show' enabled='{list.getSelectedIndex()!=-1}' onActionPerformed='getHandler().selectChild(this, list.getSelectedIndex())'/> + <JButton text='jaxxdemo.action.add'/> + <JButton text='jaxxdemo.action.remove' enabled='{list.getSelectedIndex()!=-1}'/> + </JPanel> + </JToolBar> + +</ContentUI> Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ExempleItemTreeNavigationAdapter.java =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ExempleItemTreeNavigationAdapter.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ExempleItemTreeNavigationAdapter.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,6 +1,6 @@ /* * *##% - * jaxx-demo + * JAXX Demo * Copyright (C) 2008 - 2009 CodeLutin * * This program is free software: you can redistribute it and/or modify Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -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'/> @@ -20,7 +40,7 @@ <JPanel id='demoPanel' layout='{new BorderLayout()}'> <JSplitPane constraints='BorderLayout.CENTER'> <JScrollPane> - <JTree id='nav' rootVisible='{false}'> + <JAXXTree id='nav' rootVisible='{false}'> <!-- Allow to diplay associated pane without value --> <item id='stringItemParent' label='String' value='{String.class}'> <item id='string1Item' label='String1' value='{new String("Ceci est un String")}' selected='true'/> @@ -29,7 +49,7 @@ <item id='dateItemParent' label='Date' value='{Date.class}'> <item id='dateItem' label='CurrentDate' value='{new Date()}'/> </item> - </JTree> + </JAXXTree> </JScrollPane> <!-- Card panel, only ItemNavigationPanel children is allowed --> <ItemNavigationCardPanel id="content"> @@ -43,4 +63,4 @@ </ItemNavigationCardPanel> </JSplitPane> </JPanel> -</jaxx.demo.DemoPanel> \ No newline at end of file +</jaxx.demo.DemoPanel> Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JButtonDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JButtonDemo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JButtonDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,29 +1,49 @@ -<jaxx.demo.DemoPanel> - <style> - JButton.fancy { - foreground: blue; - font-face: Arial; - font-size: 18; - } - - JButton.fancy:mouseover { - foreground: red; - font-style: italic; - } - </style> - - <script> - public void buttonClicked(JButton button) { - JOptionPane.showMessageDialog(this, button.getText() + " clicked!", "onActionPerformed", - JOptionPane.INFORMATION_MESSAGE); - } - </script> - - <javax.swing.ImageIcon id='pencil' constructorParams='getClass().getResource("/jaxx/demo/images/pencil_black.gif")'/> - - <VBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'> - <JButton text='Simple Button' onActionPerformed='buttonClicked((JButton) event.getSource())'/> - <JButton text='Fancy Button' styleClass='fancy' icon='{pencil}' - onActionPerformed='buttonClicked((JButton) event.getSource())'/> - </VBox> -</jaxx.demo.DemoPanel> \ No newline at end of file +<!-- + *##% + 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 { + foreground: blue; + font-face: Arial; + font-size: 18; + } + + JButton.fancy:mouseover { + foreground: red; + font-style: italic; + } + </style> + + <script> + public void buttonClicked(JButton button) { + JOptionPane.showMessageDialog(this, button.getText() + " clicked!", "onActionPerformed", + JOptionPane.INFORMATION_MESSAGE); + } + </script> + + <javax.swing.ImageIcon id='pencil' constructorParams='getClass().getResource("/jaxx/demo/images/pencil_black.gif")'/> + + <VBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'> + <JButton text='Simple Button' onActionPerformed='buttonClicked((JButton) event.getSource())'/> + <JButton text='Fancy Button' styleClass='fancy' icon='{pencil}' + onActionPerformed='buttonClicked((JButton) event.getSource())'/> + </VBox> +</jaxx.demo.DemoPanel> Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxDemo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,38 +1,58 @@ -<jaxx.demo.DemoPanel> - <script><![CDATA[ - public String getText(boolean bold, boolean italic, boolean underline) { - String text ="Sample Text"; - if (bold) - text = "<b>" + text + "</b>"; - if (italic) - text = "<i>" + text + "</i>"; - if (underline) - text = "<u>" + text + "</u>"; - return "<html>" + text; - } - ]]></script> - - <VBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'> - <Table anchor='west'> - <row> - <cell> - <JCheckBox id='bold' text='Bold' mnemonic='B'/> - </cell> - <cell rows='3'> - <JLabel font='{new Font("Arial", 0, 18)}' - text='{getText(bold.isSelected(), italic.isSelected(), underline.isSelected())}'/> - </cell> - </row> - <row> - <cell> - <JCheckBox id='italic' text='Italic' mnemonic='I'/> - </cell> - </row> - <row> - <cell> - <JCheckBox id='underline' text='Underline' mnemonic='U'/> - </cell> - </row> - </Table> - </VBox> -</jaxx.demo.DemoPanel> \ No newline at end of file +<!-- + *##% + 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) { + String text ="Sample Text"; + if (bold) + text = "<b>" + text + "</b>"; + if (italic) + text = "<i>" + text + "</i>"; + if (underline) + text = "<u>" + text + "</u>"; + return "<html>" + text; + } + ]]></script> + + <VBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'> + <Table anchor='west'> + <row> + <cell> + <JCheckBox id='bold' text='Bold' mnemonic='B'/> + </cell> + <cell rows='3'> + <JLabel font='{new Font("Arial", 0, 18)}' + text='{getText(bold.isSelected(), italic.isSelected(), underline.isSelected())}'/> + </cell> + </row> + <row> + <cell> + <JCheckBox id='italic' text='Italic' mnemonic='I'/> + </cell> + </row> + <row> + <cell> + <JCheckBox id='underline' text='Underline' mnemonic='U'/> + </cell> + </row> + </Table> + </VBox> +</jaxx.demo.DemoPanel> Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxMenuItemDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxMenuItemDemo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxMenuItemDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,59 +1,79 @@ -<JMenuItemDemo> - <style> - .form { - enabled: { enabledCheckBox.isSelected() }; - editable: { editableCheckBox.isSelected() }; - } - </style> - - <JMenuBar id='menuBar'> - <JMenu text='View'> - <JCheckBoxMenuItem id='enabledCheckBox' text='Enabled' selected='true'/> - <JCheckBoxMenuItem id='editableCheckBox' text='Editable' selected='true'/> - </JMenu> - </JMenuBar> - - <Table id='framePanel' anchor='northwest'> - <row> - <cell> - <JLabel text='First Name:' displayedMnemonic='F' labelFor='{firstName}'/> - </cell> - - <cell weightx='1' fill='horizontal'> - <JTextField id='firstName' styleClass="form"/> - </cell> - </row> - - <row> - <cell> - <JLabel text='Last Name:' displayedMnemonic='L' labelFor='{lastName}'/> - </cell> - - <cell fill='horizontal'> - <JTextField id='lastName' styleClass="form"/> - </cell> - </row> - - <row> - <cell> - <JLabel text='Email Address:' displayedMnemonic='E' labelFor='{email}'/> - </cell> - - <cell fill='horizontal'> - <JTextField id='email' styleClass="form"/> - </cell> - </row> - - <row> - <cell> - <JLabel text='Comments:' displayedMnemonic='C' labelFor='{comments}'/> - </cell> - - <cell weightx='1' weighty='1' fill='both'> - <JScrollPane width='150' height='75'> - <JTextArea id='comments' styleClass="form"/> - </JScrollPane> - </cell> - </row> - </Table> -</JMenuItemDemo> \ No newline at end of file +<!-- + *##% + 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 { + enabled: { enabledCheckBox.isSelected() }; + editable: { editableCheckBox.isSelected() }; + } + </style> + + <JMenuBar id='menuBar'> + <JMenu text='View'> + <JCheckBoxMenuItem id='enabledCheckBox' text='Enabled' selected='true'/> + <JCheckBoxMenuItem id='editableCheckBox' text='Editable' selected='true'/> + </JMenu> + </JMenuBar> + + <Table id='framePanel' anchor='northwest'> + <row> + <cell> + <JLabel text='First Name:' displayedMnemonic='F' labelFor='{firstName}'/> + </cell> + + <cell weightx='1' fill='horizontal'> + <JTextField id='firstName' styleClass="form"/> + </cell> + </row> + + <row> + <cell> + <JLabel text='Last Name:' displayedMnemonic='L' labelFor='{lastName}'/> + </cell> + + <cell fill='horizontal'> + <JTextField id='lastName' styleClass="form"/> + </cell> + </row> + + <row> + <cell> + <JLabel text='Email Address:' displayedMnemonic='E' labelFor='{email}'/> + </cell> + + <cell fill='horizontal'> + <JTextField id='email' styleClass="form"/> + </cell> + </row> + + <row> + <cell> + <JLabel text='Comments:' displayedMnemonic='C' labelFor='{comments}'/> + </cell> + + <cell weightx='1' weighty='1' fill='both'> + <JScrollPane width='150' height='75'> + <JTextArea id='comments' styleClass="form"/> + </JScrollPane> + </cell> + </row> + </Table> +</JMenuItemDemo> Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JComboBoxDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JComboBoxDemo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JComboBoxDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -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.DemoPanel> \ No newline at end of file +<!-- + *##% + 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='{String.valueOf(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> Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JDialogDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JDialogDemo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JDialogDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,79 +1,99 @@ -<jaxx.demo.DemoPanel> - <script> - String username; - String password; - - private class OKAction extends javax.swing.AbstractAction { - public OKAction() { - putValue(NAME, "OK"); - } - - - public void actionPerformed(ActionEvent e) { - username = usernameField.getText(); - password = new String(passwordField.getPassword()); - dialog.dispose(); - } - } - - - private class CancelAction extends javax.swing.AbstractAction { - public CancelAction() { - putValue(NAME, "Cancel"); - } - - - public void actionPerformed(ActionEvent e) { - dialog.dispose(); - } - } - { - JRootPane rootPane = dialog.getRootPane(); - rootPane.setDefaultButton(ok); - rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "cancel"); - rootPane.getActionMap().put("cancel", new CancelAction()); - } - </script> - - <JDialog title='Sign on' id='dialog' modal='true' onWindowOpened='dialog.setLocationRelativeTo(demoPanel); - passwordField.setText("");'> - <Table> - <row> - <cell> - <JLabel text='Username:' displayedMnemonic='U' labelFor='{usernameField}'/> - </cell> - - <cell> - <JTextField id='usernameField'/> - </cell> - </row> - - <row> - <cell> - <JLabel text='Password:' displayedMnemonic='P' labelFor='{passwordField}'/> - </cell> - - <cell> - <JPasswordField id='passwordField'/> - </cell> - </row> - - <row> - <cell columns='2'> - <JPanel layout='{new GridLayout(1, 0, 6, 6)}'> - <JButton id='ok' text='OK' action='{new OKAction()}'/> - <JButton text='Cancel' action='{new CancelAction()}'/> - </JPanel> - </cell> - </row> - </Table> - </JDialog> - - <VBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'> - <JButton text='Show password dialog' onActionPerformed='dialog.setVisible(true)'/> - <VBox> - <JLabel text='{username != null ? "Username: " + username : ""}'/> - <JLabel text='{password != null ? "Password: " + password : ""}'/> - </VBox> - </VBox> -</jaxx.demo.DemoPanel> +<!-- + *##% + 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; + String password; + + private class OKAction extends javax.swing.AbstractAction { + public OKAction() { + putValue(NAME, "OK"); + } + + + public void actionPerformed(ActionEvent e) { + username = usernameField.getText(); + password = new String(passwordField.getPassword()); + dialog.dispose(); + } + } + + + private class CancelAction extends javax.swing.AbstractAction { + public CancelAction() { + putValue(NAME, "Cancel"); + } + + + public void actionPerformed(ActionEvent e) { + dialog.dispose(); + } + } + { + JRootPane rootPane = dialog.getRootPane(); + rootPane.setDefaultButton(ok); + rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "cancel"); + rootPane.getActionMap().put("cancel", new CancelAction()); + } + </script> + + <JDialog title='Sign on' id='dialog' modal='true' onWindowOpened='dialog.setLocationRelativeTo(demoPanel); + passwordField.setText("");'> + <Table> + <row> + <cell> + <JLabel text='Username:' displayedMnemonic='U' labelFor='{usernameField}'/> + </cell> + + <cell> + <JTextField id='usernameField'/> + </cell> + </row> + + <row> + <cell> + <JLabel text='Password:' displayedMnemonic='P' labelFor='{passwordField}'/> + </cell> + + <cell> + <JPasswordField id='passwordField'/> + </cell> + </row> + + <row> + <cell columns='2'> + <JPanel layout='{new GridLayout(1, 0, 6, 6)}'> + <JButton id='ok' text='OK' action='{new OKAction()}'/> + <JButton text='Cancel' action='{new CancelAction()}'/> + </JPanel> + </cell> + </row> + </Table> + </JDialog> + + <VBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'> + <JButton text='Show password dialog' onActionPerformed='dialog.setVisible(true)'/> + <VBox> + <JLabel text='{username != null ? "Username: " + username : ""}'/> + <JLabel text='{password != null ? "Password: " + password : ""}'/> + </VBox> + </VBox> +</jaxx.demo.DemoPanel> Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JListDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JListDemo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JListDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,59 +1,79 @@ -<jaxx.demo.DemoPanel> - <Table id='demoPanel'> - <row> - <cell> - <JLabel text='Supported Swing components:'/> - </cell> - </row> - - <row> - <cell> - <JScrollPane> - <JList> - <item value='JApplet'/> - <item value='JButton'/> - <item value='JCheckBox'/> - <item value='JCheckBoxMenuItem'/> - <item value='JColorChooser'/> - <item value='JComboBox'/> - <item value='JDesktopPane'/> - <item value='JDialog'/> - <item value='JEditorPane'/> - <item value='JFileChooser'/> - <item value='JFormattedTextField'/> - <item value='JFrame'/> - <item value='JInternalFrame'/> - <item value='JLabel'/> - <item value='JLayeredPane'/> - <item value='JList'/> - <item value='JMenu'/> - <item value='JMenuBar'/> - <item value='JMenuItem'/> - <item value='JOptionPane'/> - <item value='JPanel'/> - <item value='JPasswordField'/> - <item value='JPopupMenu'/> - <item value='JProgressBar'/> - <item value='JRadioButton'/> - <item value='JRadioButtonMenuItem'/> - <item value='JScrollBar'/> - <item value='JScrollPane'/> - <item value='JSeparator'/> - <item value='JSlider'/> - <item value='JSpinner'/> - <item value='JSplitPane'/> - <item value='JTabbedPane'/> - <item value='JTable'/> - <item value='JTextArea'/> - <item value='JTextField'/> - <item value='JTextPane'/> - <item value='JToggleButton'/> - <item value='JToolBar'/> - <item value='JTree'/> - <item value='JWindow'/> - </JList> - </JScrollPane> - </cell> - </row> - </Table> -</jaxx.demo.DemoPanel> \ No newline at end of file +<!-- + *##% + 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> + <cell> + <JLabel text='Supported Swing components:'/> + </cell> + </row> + + <row> + <cell> + <JScrollPane> + <JAXXList> + <item value='JApplet'/> + <item value='JButton'/> + <item value='JCheckBox'/> + <item value='JCheckBoxMenuItem'/> + <item value='JColorChooser'/> + <item value='JComboBox'/> + <item value='JDesktopPane'/> + <item value='JDialog'/> + <item value='JEditorPane'/> + <item value='JFileChooser'/> + <item value='JFormattedTextField'/> + <item value='JFrame'/> + <item value='JInternalFrame'/> + <item value='JLabel'/> + <item value='JLayeredPane'/> + <item value='JList'/> + <item value='JMenu'/> + <item value='JMenuBar'/> + <item value='JMenuItem'/> + <item value='JOptionPane'/> + <item value='JPanel'/> + <item value='JPasswordField'/> + <item value='JPopupMenu'/> + <item value='JProgressBar'/> + <item value='JRadioButton'/> + <item value='JRadioButtonMenuItem'/> + <item value='JScrollBar'/> + <item value='JScrollPane'/> + <item value='JSeparator'/> + <item value='JSlider'/> + <item value='JSpinner'/> + <item value='JSplitPane'/> + <item value='JTabbedPane'/> + <item value='JTable'/> + <item value='JTextArea'/> + <item value='JTextField'/> + <item value='JTextPane'/> + <item value='JToggleButton'/> + <item value='JToolBar'/> + <item value='JTree'/> + <item value='JWindow'/> + </JAXXList> + </JScrollPane> + </cell> + </row> + </Table> +</jaxx.demo.DemoPanel> Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JMenuItemDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JMenuItemDemo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JMenuItemDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -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(){} @@ -21,4 +41,4 @@ </JInternalFrame> </JDesktopPane> </JPanel> -</jaxx.demo.DemoPanel> \ No newline at end of file +</jaxx.demo.DemoPanel> Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JPasswordFieldDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JPasswordFieldDemo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JPasswordFieldDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,10 +1,30 @@ -<jaxx.demo.DemoPanel> - <VBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'> - <HBox> - <JLabel text='Password:' displayedMnemonic='P' labelFor='{password}'/> - <JPasswordField id='password'/> - </HBox> - - <JLabel text='You entered: {new String(password.getPassword())}'/> - </VBox> -</jaxx.demo.DemoPanel> \ No newline at end of file +<!-- + *##% + 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> + <JLabel text='Password:' displayedMnemonic='P' labelFor='{password}'/> + <JPasswordField id='password'/> + </HBox> + + <JLabel text='You entered: {new String(password.getPassword())}'/> + </VBox> +</jaxx.demo.DemoPanel> Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JProgressBarDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JProgressBarDemo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JProgressBarDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,77 +1,97 @@ -<jaxx.demo.DemoPanel> - <script><![CDATA[ - import javax.swing.Timer; - - int red = 0; - int green = 0; - int blue = 0; - int speed = 2; - int redDirection = 1; - int greenDirection = 1; - int blueDirection = 1; - - Timer redTimer = new Timer(5, new ActionListener() { - public void actionPerformed(ActionEvent e) { - red = Math.max(0, Math.min(255, red + speed * redDirection)); - if (red == 0 || red == 255) - redDirection = -redDirection; - } - }); - - Timer greenTimer = new Timer(50, new ActionListener() { - public void actionPerformed(ActionEvent e) { - green = Math.max(0, Math.min(255, green + speed * greenDirection)); - if (green == 0 || green == 255) - greenDirection = -greenDirection; - } - }); - - Timer blueTimer = new Timer(500, new ActionListener() { - public void actionPerformed(ActionEvent e) { - blue = Math.max(0, Math.min(255, blue + speed * blueDirection)); - if (blue == 0 || blue == 255) - blueDirection = -blueDirection; - } - }); - - redTimer.start(); - greenTimer.start(); - blueTimer.start(); - ]]></script> - - <Table insets='6' id='demoPanel'> - <row> - <cell columns='3'> - <JLabel text='Welcome to the JAXX framework!' font='{UIManager.getFont("Label.font").deriveFont(18f)}' - foreground='{new Color(red, green, blue)}'/> - </cell> - </row> - - <row> - <cell columns='3' fill='horizontal'> - <JProgressBar foreground='{new Color(red, 0, 0)}' value='{red}' maximum='255'/> - </cell> - </row> - - <row> - <cell columns='3' fill='horizontal'> - <JProgressBar foreground='{new Color(0, green, 0)}' value='{green}' maximum='255'/> - </cell> - </row> - - <row> - <cell columns='3' fill='horizontal'> - <JProgressBar foreground='{new Color(0, 0, blue)}' value='{blue}' maximum='255'/> - </cell> - </row> - - <row> - <cell weightx='1' anchor='east'> - <JButton text='Start' onActionPerformed='redTimer.start(); greenTimer.start(); blueTimer.start()'/> - </cell> - <cell> - <JButton text='Stop' onActionPerformed='redTimer.stop(); greenTimer.stop(); blueTimer.stop()'/> - </cell> - </row> - </Table> -</jaxx.demo.DemoPanel> \ No newline at end of file +<!-- + *##% + 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; + + int red = 0; + int green = 0; + int blue = 0; + int speed = 2; + int redDirection = 1; + int greenDirection = 1; + int blueDirection = 1; + + Timer redTimer = new Timer(5, new ActionListener() { + public void actionPerformed(ActionEvent e) { + red = Math.max(0, Math.min(255, red + speed * redDirection)); + if (red == 0 || red == 255) + redDirection = -redDirection; + } + }); + + Timer greenTimer = new Timer(50, new ActionListener() { + public void actionPerformed(ActionEvent e) { + green = Math.max(0, Math.min(255, green + speed * greenDirection)); + if (green == 0 || green == 255) + greenDirection = -greenDirection; + } + }); + + Timer blueTimer = new Timer(500, new ActionListener() { + public void actionPerformed(ActionEvent e) { + blue = Math.max(0, Math.min(255, blue + speed * blueDirection)); + if (blue == 0 || blue == 255) + blueDirection = -blueDirection; + } + }); + + redTimer.start(); + greenTimer.start(); + blueTimer.start(); + ]]></script> + + <Table insets='6' id='demoPanel'> + <row> + <cell columns='3'> + <JLabel text='Welcome to the JAXX framework!' font='{UIManager.getFont("Label.font").deriveFont(18f)}' + foreground='{new Color(red, green, blue)}'/> + </cell> + </row> + + <row> + <cell columns='3' fill='horizontal'> + <JProgressBar foreground='{new Color(red, 0, 0)}' value='{red}' maximum='255'/> + </cell> + </row> + + <row> + <cell columns='3' fill='horizontal'> + <JProgressBar foreground='{new Color(0, green, 0)}' value='{green}' maximum='255'/> + </cell> + </row> + + <row> + <cell columns='3' fill='horizontal'> + <JProgressBar foreground='{new Color(0, 0, blue)}' value='{blue}' maximum='255'/> + </cell> + </row> + + <row> + <cell weightx='1' anchor='east'> + <JButton text='Start' onActionPerformed='redTimer.start(); greenTimer.start(); blueTimer.start()'/> + </cell> + <cell> + <JButton text='Stop' onActionPerformed='redTimer.stop(); greenTimer.stop(); blueTimer.stop()'/> + </cell> + </row> + </Table> +</jaxx.demo.DemoPanel> Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonDemo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,11 +1,31 @@ -<jaxx.demo.DemoPanel> - <HBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'> - <VBox> - <JRadioButton text='Animal' value='Lynx.jpg' buttonGroup='radioButtons' selected='true'/> - <JRadioButton text='Vegetable' buttonGroup='radioButtons' value='Tomato.jpg'/> - <JRadioButton text='Mineral' buttonGroup='radioButtons' value='Amethyst.jpg'/> - </VBox> - - <JLabel icon='{new ImageIcon(getClass().getResource("/jaxx/demo/images/" + radioButtons.getSelectedValue()))}'/> - </HBox> -</jaxx.demo.DemoPanel> \ No newline at end of file +<!-- + *##% + 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> + <JRadioButton text='Animal' value='Lynx.jpg' buttonGroup='radioButtons' selected='true'/> + <JRadioButton text='Vegetable' buttonGroup='radioButtons' value='Tomato.jpg'/> + <JRadioButton text='Mineral' buttonGroup='radioButtons' value='Amethyst.jpg'/> + </VBox> + + <JLabel icon='{new ImageIcon(getClass().getResource("/jaxx/demo/images/" + radioButtons.getSelectedValue()))}'/> + </HBox> +</jaxx.demo.DemoPanel> Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonMenuItemDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonMenuItemDemo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonMenuItemDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,14 +1,34 @@ -<JMenuItemDemo> - <JMenuBar id='menuBar'> - <JMenu text='Font size'> - <JRadioButtonMenuItem text='10' value='{new Integer(10)}' buttonGroup='fontSize'/> - <JRadioButtonMenuItem text='12' value='{new Integer(12)}' buttonGroup='fontSize' selected='true'/> - <JRadioButtonMenuItem text='14' value='{new Integer(14)}' buttonGroup='fontSize'/> - <JRadioButtonMenuItem text='18' value='{new Integer(18)}' buttonGroup='fontSize'/> - <JRadioButtonMenuItem text='24' value='{new Integer(24)}' buttonGroup='fontSize'/> - </JMenu> - </JMenuBar> - - <JLabel id='demoMessage' text='Font size: {fontSize.getSelectedValue()}' horizontalAlignment='center' - font='{UIManager.getFont("Label.font").deriveFont(fontSize.getSelectedValue() != null ? (float) ((Integer) fontSize.getSelectedValue()).intValue() : 12)}'/> -</JMenuItemDemo> \ No newline at end of file +<!-- + *##% + 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'> + <JRadioButtonMenuItem text='10' value='{new Integer(10)}' buttonGroup='fontSize'/> + <JRadioButtonMenuItem text='12' value='{new Integer(12)}' buttonGroup='fontSize' selected='true'/> + <JRadioButtonMenuItem text='14' value='{new Integer(14)}' buttonGroup='fontSize'/> + <JRadioButtonMenuItem text='18' value='{new Integer(18)}' buttonGroup='fontSize'/> + <JRadioButtonMenuItem text='24' value='{new Integer(24)}' buttonGroup='fontSize'/> + </JMenu> + </JMenuBar> + + <JLabel id='demoMessage' text='Font size: {fontSize.getSelectedValue()}' horizontalAlignment='center' + font='{UIManager.getFont("Label.font").deriveFont(fontSize.getSelectedValue() != null ? (float) ((Integer) fontSize.getSelectedValue()).intValue() : 12)}'/> +</JMenuItemDemo> Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSliderDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSliderDemo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSliderDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,12 +1,32 @@ -<jaxx.demo.DemoPanel> - <HBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'> - <VBox> - <JSlider id='red' maximum='255' value='200'/> - <JSlider id='green' maximum='255' value='180'/> - <JSlider id='blue' maximum='255' value='240'/> - </VBox> - - <JPanel border='{BorderFactory.createEtchedBorder()}' width='64' height='64' - background='{new Color(red.getValue(), green.getValue(), blue.getValue())}'/> - </HBox> -</jaxx.demo.DemoPanel> \ No newline at end of file +<!-- + *##% + 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> + <JSlider id='red' maximum='255' value='200'/> + <JSlider id='green' maximum='255' value='180'/> + <JSlider id='blue' maximum='255' value='240'/> + </VBox> + + <JPanel border='{BorderFactory.createEtchedBorder()}' width='64' height='64' + background='{new Color(red.getValue(), green.getValue(), blue.getValue())}'/> + </HBox> +</jaxx.demo.DemoPanel> Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSpinnerDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSpinnerDemo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSpinnerDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,13 +1,33 @@ -<jaxx.demo.DemoPanel> - <HBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'> - <JLabel text='Spacing:' displayedMnemonic='S' labelFor='{spinner}'/> - - <JSpinner minimum='0' maximum='50' id='spinner'/> - - <VBox spacing='{((Integer) spinner.getValue()).intValue()}'> - <JLabel text='Use the spinner to'/> - <JLabel text='adjust the spacing'/> - <JLabel text='between these lines'/> - </VBox> - </HBox> -</jaxx.demo.DemoPanel> \ No newline at end of file +<!-- + *##% + 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}'/> + + <JSpinner minimum='0' maximum='50' id='spinner'/> + + <VBox spacing='{((Integer) spinner.getValue()).intValue()}'> + <JLabel text='Use the spinner to'/> + <JLabel text='adjust the spacing'/> + <JLabel text='between these lines'/> + </VBox> + </HBox> +</jaxx.demo.DemoPanel> Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSplitPaneDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSplitPaneDemo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSplitPaneDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,13 +1,33 @@ -<jaxx.demo.DemoPanel> - <JPanel id='demoPanel' layout='{new BorderLayout()}'> - <JSplitPane> - <JScrollPane> - <JLabel icon='{new ImageIcon(getClass().getResource("/jaxx/demo/images/Amethyst.jpg"))}'/> - </JScrollPane> - - <JScrollPane> - <JLabel icon='{new ImageIcon(getClass().getResource("/jaxx/demo/images/Lynx.jpg"))}'/> - </JScrollPane> - </JSplitPane> - </JPanel> -</jaxx.demo.DemoPanel> \ No newline at end of file +<!-- + *##% + 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> + <JScrollPane> + <JLabel icon='{new ImageIcon(getClass().getResource("/jaxx/demo/images/Amethyst.jpg"))}'/> + </JScrollPane> + + <JScrollPane> + <JLabel icon='{new ImageIcon(getClass().getResource("/jaxx/demo/images/Lynx.jpg"))}'/> + </JScrollPane> + </JSplitPane> + </JPanel> +</jaxx.demo.DemoPanel> Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextAreaDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextAreaDemo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextAreaDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,33 +1,53 @@ -<jaxx.demo.DemoPanel> - <Table id='demoPanel' anchor='northwest'> - <row> - <cell> - <JLabel text='Normal text:' displayedMnemonic='N' labelFor='{textArea}'/> - </cell> - - <cell weightx='1' fill='both'> - <JScrollPane height='120'> - <JTextArea id='textArea' text='Try typing some text here.'/> - </JScrollPane> - </cell> - </row> - - <row> - <cell> - <JLabel text='Upper case text:'/> - </cell> - - <cell weightx='1' fill='both'> - <JScrollPane height='120'> - <JTextArea editable='false' background='{null}' text='{textArea.getText().toUpperCase()}'/> - </JScrollPane> - </cell> - </row> - - <row> - <cell weighty='1'> - <JPanel/> - </cell> - </row> - </Table> -</jaxx.demo.DemoPanel> \ No newline at end of file +<!-- + *##% + 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> + <cell> + <JLabel text='Normal text:' displayedMnemonic='N' labelFor='{textArea}'/> + </cell> + + <cell weightx='1' fill='both'> + <JScrollPane height='120'> + <JTextArea id='textArea' text='Try typing some text here.'/> + </JScrollPane> + </cell> + </row> + + <row> + <cell> + <JLabel text='Upper case text:'/> + </cell> + + <cell weightx='1' fill='both'> + <JScrollPane height='120'> + <JTextArea editable='false' background='{null}' text='{textArea.getText().toUpperCase()}'/> + </JScrollPane> + </cell> + </row> + + <row> + <cell weighty='1'> + <JPanel/> + </cell> + </row> + </Table> +</jaxx.demo.DemoPanel> Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextFieldDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextFieldDemo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextFieldDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,22 +1,42 @@ -<jaxx.demo.DemoPanel> - <JPanel id='demoPanel'> - <Table> - <row> - <cell> - <JLabel text='Your name:' displayedMnemonic='n' labelFor='{textField}'/> - </cell> - - <cell> - <JTextField id='textField'/> - </cell> - </row> - - <row> - <cell columns='2'> - <JButton text='Greet' - onActionPerformed='JOptionPane.showMessageDialog(demoPanel, "Hello, " + textField.getText() + "!")'/> - </cell> - </row> - </Table> - </JPanel> -</jaxx.demo.DemoPanel> \ No newline at end of file +<!-- + *##% + 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> + <row> + <cell> + <JLabel text='Your name:' displayedMnemonic='n' labelFor='{textField}'/> + </cell> + + <cell> + <JTextField id='textField'/> + </cell> + </row> + + <row> + <cell columns='2'> + <JButton text='Greet' + onActionPerformed='JOptionPane.showMessageDialog(demoPanel, "Hello, " + textField.getText() + "!")'/> + </cell> + </row> + </Table> + </JPanel> +</jaxx.demo.DemoPanel> Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JToggleButtonDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JToggleButtonDemo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JToggleButtonDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,9 +1,29 @@ -<jaxx.demo.DemoPanel> - <HBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'> - <JToggleButton text='1' id='one'/> - <JToggleButton text='2' id='two'/> - <JToggleButton text='3' id='three'/> - - <JLabel text='Total: {(one.isSelected() ? 1 : 0) + (two.isSelected() ? 2 : 0) + (three.isSelected() ? 3 : 0)}'/> - </HBox> -</jaxx.demo.DemoPanel> \ No newline at end of file +<!-- + *##% + 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'/> + <JToggleButton text='2' id='two'/> + <JToggleButton text='3' id='three'/> + + <JLabel text='Total: {(one.isSelected() ? 1 : 0) + (two.isSelected() ? 2 : 0) + (three.isSelected() ? 3 : 0)}'/> + </HBox> +</jaxx.demo.DemoPanel> Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BaseBeanDataBinding.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BaseBeanDataBinding.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BaseBeanDataBinding.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -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: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BeanDataBindingDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BeanDataBindingDemo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BeanDataBindingDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -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: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Identity.java =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Identity.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Identity.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,6 +1,6 @@ /* * *##% - * jaxx-demo + * JAXX Demo * Copyright (C) 2008 - 2009 CodeLutin * * This program is free software: you can redistribute it and/or modify Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Model.java =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Model.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Model.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,6 +1,6 @@ /* * *##% - * jaxx-demo + * JAXX Demo * Copyright (C) 2008 - 2009 CodeLutin * * This program is free software: you can redistribute it and/or modify Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,8 +1,30 @@ +<!-- + *##% + 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"/> -<script><![CDATA[ + <script><![CDATA[ import static org.nuiton.i18n.I18n.n_; +import jaxx.runtime.validator.swing.SwingValidatorMessageListRenderer; + void $afterCompleteSetup() { } @Override @@ -10,7 +32,7 @@ return new String[]{ getDefaultSource(), "Validation.css", "Model.java", "Identity.java" }; } ]]> -</script> + </script> <!-- models --> <Model id='model1'/> <Model id='model2'/> @@ -70,7 +92,7 @@ <JLabel text='Ratio:'/> </cell> <cell> - <JSlider id='ratio' minimum='0' maximum='100' + <JSlider id='ratio' minimum='0' maximum='100' value='{model1.getRatio()}' _validatorLabel='{n_("form.ratio")}' onStateChanged='model1.setRatio(ratio.getValue())'/> @@ -105,7 +127,7 @@ <JLabel text='Ratio:'/> </cell> <cell> - <JLabel text='{model1.getRatio()}'/> + <JLabel text='{model1.getRatio()+""}'/> </cell> </row> </Table> @@ -143,7 +165,7 @@ <JLabel text='Ratio:'/> </cell> <cell> - <JSlider id='_ratio' minimum='0' maximum='100' + <JSlider id='_ratio' minimum='0' maximum='100' value='{model2.getRatio()}' _validatorLabel='{n_("form2.ratio")}' onStateChanged='model2.setRatio(_ratio.getValue())'/> @@ -178,7 +200,7 @@ <JLabel text='Ratio:'/> </cell> <cell> - <JLabel text='{model2.getRatio()}'/> + <JLabel text='{model2.getRatio()+""}'/> </cell> </row> </Table> @@ -232,7 +254,7 @@ <JLabel text='Config file :'/> </cell> <cell> - <JTextField id='config' text='{identity.getConfig()}' + <JTextField id='config' text='{identity.getConfig()+""}' onKeyReleased='identity.setConfig(new java.io.File(config.getText()))'/> </cell> </row> @@ -241,7 +263,7 @@ <JLabel text='Working directory:'/> </cell> <cell> - <JTextField id='dir' text='{identity.getDir()}' + <JTextField id='dir' text='{identity.getDir()+""}' onKeyReleased='identity.setDir(new java.io.File(dir.getText()))'/> </cell> </row> @@ -281,7 +303,7 @@ <JLabel text='Age:'/> </cell> <cell> - <JLabel text='{identity.getAge()}'/> + <JLabel text='{identity.getAge()+""}'/> </cell> </row> <row> @@ -289,7 +311,7 @@ <JLabel text='Config file:'/> </cell> <cell> - <JLabel text='{identity.getConfig()}'/> + <JLabel text='{identity.getConfig()+""}'/> </cell> </row> <row> @@ -297,7 +319,7 @@ <JLabel text='Directory file:'/> </cell> <cell> - <JLabel text='{identity.getDir()}'/> + <JLabel text='{identity.getDir()+""}'/> </cell> </row> </Table> @@ -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: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -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"/> @@ -30,10 +50,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 @@ -111,7 +132,7 @@ <JLabel text='Ratio:'/> </cell> <cell> - <JLabel text='{model1.getRatio()}'/> + <JLabel text='{model1.getRatio()+""}'/> </cell> </row> </Table> @@ -184,7 +205,7 @@ <JLabel text='Ratio:'/> </cell> <cell> - <JLabel text='{model2.getRatio()}'/> + <JLabel text='{model2.getRatio()+""}'/> </cell> </row> </Table> @@ -238,7 +259,7 @@ <JLabel text='Config file :'/> </cell> <cell> - <JTextField id='config' text='{identity.getConfig()}' + <JTextField id='config' text='{identity.getConfig()+""}' onKeyReleased='identity.setConfig(new java.io.File(config.getText()))'/> </cell> </row> @@ -247,7 +268,7 @@ <JLabel text='Working directory:'/> </cell> <cell> - <JTextField id='dir' text='{identity.getDir()}' + <JTextField id='dir' text='{identity.getDir()+""}' onKeyReleased='identity.setDir(new java.io.File(dir.getText()))'/> </cell> </row> @@ -287,7 +308,7 @@ <JLabel text='Age:'/> </cell> <cell> - <JLabel text='{identity.getAge()}'/> + <JLabel text='{identity.getAge()+""}'/> </cell> </row> <row> @@ -295,7 +316,7 @@ <JLabel text='Config file:'/> </cell> <cell> - <JLabel text='{identity.getConfig()}'/> + <JLabel text='{identity.getConfig()+""}'/> </cell> </row> <row> @@ -303,7 +324,7 @@ <JLabel text='Directory file:'/> </cell> <cell> - <JLabel text='{identity.getDir()}'/> + <JLabel text='{identity.getDir()+""}'/> </cell> </row> </Table> Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/fun/Calculator.css =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/fun/Calculator.css 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/fun/Calculator.css 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,41 +1,21 @@ #table { - border: { BorderFactory . createEmptyBorder( 4, 4, 4, 4 ) + border: {BorderFactory.createEmptyBorder(4, 4, 4, 4)}; + font-face:"Trebuchet MS"; } -; -font-face: - -"Trebuchet MS" -; -} - #display { background: #BCE5AD; opaque: true; horizontalAlignment: right; - border: { BorderFactory . createBevelBorder( BevelBorder . LOWERED ) + border: {BorderFactory.createBevelBorder(BevelBorder.LOWERED)}; + font-size:22; + font-weight: bold; } -; -font-size: - -22 -; -font-weight: bold - -; +#display:{object.getText().startsWith( "-" )} { +foreground: red; } -#display:{ - object . getText( ) . startsWith( "-" ) -} - -{ -foreground: red - -; -} - JButton { font-size: 18; width: 80; Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorDemo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -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[ @@ -92,4 +112,4 @@ </cell> </row> </Table> -</jaxx.demo.DemoPanel> \ No newline at end of file +</jaxx.demo.DemoPanel> Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorEngine.java =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorEngine.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorEngine.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,6 +1,6 @@ /* * *##% - * jaxx-demo + * JAXX Demo * Copyright (C) 2008 - 2009 CodeLutin * * This program is free software: you can redistribute it and/or modify Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CounterDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CounterDemo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CounterDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,12 +1,32 @@ -<jaxx.demo.DemoPanel> - <script>int count;</script> - <JPanel id='demoPanel'> - <JTextField text='{count}' constraints='BorderLayout.NORTH'/> - <HBox constraints='BorderLayout.SOUTH'> - <JButton text='Dec (-)' onActionPerformed='count--'/> - <JButton text='Reset' onActionPerformed='count = 0'/> - <JButton text='Inc (+)' onActionPerformed='count++'/> - </HBox> - </JPanel> - -</jaxx.demo.DemoPanel> \ No newline at end of file +<!-- + *##% + 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'> + <JTextField text='{count+""}' constraints='BorderLayout.NORTH'/> + <HBox constraints='BorderLayout.SOUTH'> + <JButton text='Dec (-)' onActionPerformed='count--'/> + <JButton text='Reset' onActionPerformed='count = 0'/> + <JButton text='Inc (+)' onActionPerformed='count++'/> + </HBox> + </JPanel> + +</jaxx.demo.DemoPanel> Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyle.css =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyle.css 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyle.css 2009-12-02 13:59:28 UTC (rev 1673) @@ -5,19 +5,13 @@ JSlider.color { minorTickSpacing: 10; majorTickSpacing: 50; - border: { BorderFactory . createEmptyBorder( 1, 1, 1, 1 ) + border: {BorderFactory.createEmptyBorder(1, 1, 1, 1)}; } -; -} - JSlider.color:focused { - border: { BorderFactory . createLineBorder( Color . BLACK, 1 ) + border: {BorderFactory.createLineBorder(Color.BLACK, 1)}; } -; -} - JSlider#red:focused { background: #E7ADAD; } @@ -36,8 +30,5 @@ } JRadioButton { - enabled: { backgroundCheckbox . isSelected( ) -} - -; + enabled: {backgroundCheckbox.isSelected()}; } \ No newline at end of file Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyleDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyleDemo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyleDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -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[ @@ -89,4 +109,4 @@ </cell> </row> </Table> -</jaxx.demo.DemoPanel> \ No newline at end of file +</jaxx.demo.DemoPanel> Modified: trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties =================================================================== --- trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties 2009-12-02 13:59:28 UTC (rev 1673) @@ -42,11 +42,13 @@ First\ Name\:= FirstName\:= Font\ size= +Font\ size\:\ = Fool\ me\ once= Fool\ me\ twice= Green= Green\:= Greet= +Help= I18n\ editor\ with\ no\ icon\ \:= I18n\ editor\ with\ no\ text\ \:= I18n\ editor\:= @@ -80,6 +82,7 @@ Supported\ Swing\ components\:= Text2\:= Text\:= +Total\:\ = Underline= Upper\ case\ text\:= Use\ the\ spinner\ to= @@ -89,6 +92,7 @@ Welcome\ to\ the\ JAXX\ framework\!= Working\ directory\:= Yellow= +You\ entered\:\ = Your\ name\:= \\u00f7= actors= @@ -105,22 +109,25 @@ edit=Edit edit2=Edit 2 edit3=Edit 3 +editor.getSelectedLocale()= form.ratio=Ratio form.text=Text form.text2=Text 2 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>. +i18neditor.popup.title= +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.add= jaxxdemo.action.configuration=Preferences jaxxdemo.action.configuration.tip=Change the preferences of the application jaxxdemo.action.exit=Quit 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 @@ -128,6 +135,8 @@ jaxxdemo.action.locale.uk.tip=Change to english language jaxxdemo.action.normalscreen=Normal screen jaxxdemo.action.normalscreen.tip=Change to normal screen mode +jaxxdemo.action.remove= +jaxxdemo.action.show= jaxxdemo.action.site=Web site jaxxdemo.action.site.tip=Go to the web site jaxxdemo.config.category.directories=Files @@ -135,16 +144,37 @@ jaxxdemo.config.category.other=Others jaxxdemo.config.category.other.description=Others preferences jaxxdemo.config.configFileName.description=Configuration file name +jaxxdemo.config.ui.demo.path= jaxxdemo.config.ui.fullscreen=To change the screen mode (true for full screen) jaxxdemo.config.ui.locale=Locale of the application +jaxxdemo.i18neditor.configuration=Configuration +jaxxdemo.i18neditor.popupBorderText=Popup title +jaxxdemo.i18neditor.selected.locale=Selected Language +jaxxdemo.i18neditor.showIcon=Show icons +jaxxdemo.i18neditor.showPopupIcon=Show icons in popup +jaxxdemo.i18neditor.showPopupText=Show texts in popup +jaxxdemo.i18neditor.showText=Show text jaxxdemo.init.closed=JAXXDemo was closed at %1$s jaxxdemo.init.context.done=Context initialized in %1$s 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.navigation.actor.title= +jaxxdemo.navigation.actors.title= +jaxxdemo.navigation.movie.title= +jaxxdemo.navigation.movies.title= +jaxxdemo.numbereditor.autoPopup= +jaxxdemo.numbereditor.configuration= +jaxxdemo.numbereditor.model= +jaxxdemo.numbereditor.model.float= +jaxxdemo.numbereditor.model.int= +jaxxdemo.numbereditor.showPopupButton= +jaxxdemo.numbereditor.showReset= +jaxxdemo.numbereditor.useFloat= +jaxxdemo.numbereditor.useSign= jaxxdemo.title.about=About JAXXDemo... jaxxdemo.tree.component.jaxx=JAXX Components jaxxdemo.tree.component.jaxx.editor=Editors @@ -170,5 +200,6 @@ numbereditor.type=Type numbereditor.with.auto.popup=With auto popup numbereditor.without.auto.popup=Without auto popup +test= valid= x= Modified: trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties =================================================================== --- trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties 2009-12-02 13:59:28 UTC (rev 1673) @@ -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 @@ -42,11 +42,13 @@ First\ Name\:=Pr\u00E9nom FirstName\:=Pr\u00E9nom \: Font\ size=Taille de la police +Font\ size\:\ = Fool\ me\ once= Fool\ me\ twice= 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 @@ -80,6 +82,7 @@ Supported\ Swing\ components\:=Composants Swing support\u00E9s Text2\:=Text 2 Text\:=Texte \: +Total\:\ = Underline=soulign\u00E9 Upper\ case\ text\:=Texte en majuscule Use\ the\ spinner\ to=Utiliser la jauge pour @@ -89,6 +92,7 @@ Welcome\ to\ the\ JAXX\ framework\!=Bienvenu dans le framework JAXX Working\ directory\:=R\u00E9pertoire de travail Yellow=Jaune +You\ entered\:\ = Your\ name\:=Votre nom \: \\u00f7= actors=Acteurs @@ -105,15 +109,18 @@ edit=Editer edit2=Editer 2 edit3=Editer 3 +editor.getSelectedLocale()= form.ratio=Form \: ratio form.text=Form \: text form.text2=Form \: text2 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>. +i18neditor.popup.title= +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.add= jaxxdemo.action.configuration=Configuration jaxxdemo.action.configuration.tip=Modifier la configuration jaxxdemo.action.exit=Quitter @@ -128,6 +135,8 @@ jaxxdemo.action.locale.uk.tip=Changer la langue en anglais jaxxdemo.action.normalscreen=Ecran normal jaxxdemo.action.normalscreen.tip=Revenir en mode normal +jaxxdemo.action.remove= +jaxxdemo.action.show= jaxxdemo.action.site=Site internet jaxxdemo.action.site.tip=Acc\u00E9der au site de l'application sur internet jaxxdemo.config.category.directories=R\u00E9pertoires @@ -135,8 +144,16 @@ jaxxdemo.config.category.other=Autre jaxxdemo.config.category.other.description=Autres options jaxxdemo.config.configFileName.description=Le nom du fichier de configuration +jaxxdemo.config.ui.demo.path= jaxxdemo.config.ui.fullscreen=Pour afficher l'aplication en mode pleine \u00E9cran jaxxdemo.config.ui.locale=Langue utilis\u00E9e par l'application (fr_FR, en_GB ou es_ES) +jaxxdemo.i18neditor.configuration=Configuration +jaxxdemo.i18neditor.popupBorderText=Titre de la popup +jaxxdemo.i18neditor.selected.locale=Langue s\u00E9lectionn\u00E9e +jaxxdemo.i18neditor.showIcon=Afficher les icones +jaxxdemo.i18neditor.showPopupIcon=Afficher les icones dans la popup +jaxxdemo.i18neditor.showPopupText=Afficher les textes dans la popup +jaxxdemo.i18neditor.showText=Afficher le text jaxxdemo.init.closed=JAXX Demo a \u00E9t\u00E9 ferm\u00E9 \u00E0 %1$s jaxxdemo.init.context.done=Initialisation du contexte termin\u00E9e en %1$s. jaxxdemo.init.ui.done=Initialisation de l'interface graphique termin\u00E9e. @@ -145,6 +162,19 @@ jaxxdemo.menu.help=Aide jaxxdemo.message.config.loaded=Configuration de JAXX Demo v. %1$s charg\u00E9e. jaxxdemo.message.goto.site=Acc\u00E9der au site de JAXX Demo (%1$s) +jaxxdemo.navigation.actor.title= +jaxxdemo.navigation.actors.title= +jaxxdemo.navigation.movie.title= +jaxxdemo.navigation.movies.title= +jaxxdemo.numbereditor.autoPopup=Affichage automatique popup +jaxxdemo.numbereditor.configuration=Configuration +jaxxdemo.numbereditor.model=R\u00E9sultat +jaxxdemo.numbereditor.model.float=Valeur d\u00E9cimale \: %1$s +jaxxdemo.numbereditor.model.int=Valeur enti\u00E8re \: %1$s +jaxxdemo.numbereditor.showPopupButton=Afficher le boutton de popup +jaxxdemo.numbereditor.showReset=Afficher le boutton de reset +jaxxdemo.numbereditor.useFloat=Utiliser les d\u00E9cimales +jaxxdemo.numbereditor.useSign=Utiliser le signe jaxxdemo.title.about=A propos de JAXX Demo... jaxxdemo.tree.component.jaxx=Composants JAXX jaxxdemo.tree.component.jaxx.editor=Editeurs @@ -159,7 +189,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 @@ -170,5 +200,6 @@ numbereditor.type=Type d'\u00E9diteur numbereditor.with.auto.popup=Avec popup auto numbereditor.without.auto.popup=Sans popup auto +test= valid=valide x=x Modified: trunk/jaxx-demo/src/main/resources/log4j.properties =================================================================== --- trunk/jaxx-demo/src/main/resources/log4j.properties 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/main/resources/log4j.properties 2009-12-02 13:59:28 UTC (rev 1673) @@ -6,5 +6,8 @@ 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.editor.I18nEditor=INFO +#log4j.logger.jaxx.runtime.swing.navigation.NavigationTreeCellRenderer=DEBUG +#log4j.logger.jaxx.runtime.swing.navigation.NavigationTreeNodeRenderer=DEBUG +#log4j.logger.jaxx.runtime.swing.navigation.NavigationTreeModel=DEBUG log4j.logger.org.nuiton=WARN Modified: trunk/jaxx-demo/src/site/rst/index.rst =================================================================== --- trunk/jaxx-demo/src/site/rst/index.rst 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/site/rst/index.rst 2009-12-02 13:59:28 UTC (rev 1673) @@ -38,6 +38,6 @@ .. |webstart| image:: images/webstart.gif -.. _following link: ./launch.jnlp +.. _following link: ./jnlp/launch.jnlp .. _Jaxx Demo webstart: jnlp-report.html Modified: trunk/jaxx-demo/src/test/java/jaxx/demo/BeanValidatorDetectorTest.java =================================================================== --- trunk/jaxx-demo/src/test/java/jaxx/demo/BeanValidatorDetectorTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-demo/src/test/java/jaxx/demo/BeanValidatorDetectorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -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>. + * ##%* + */ package jaxx.demo; import jaxx.demo.feature.validation.Model; Property changes on: trunk/jaxx-runtime ___________________________________________________________________ Added: svn:ignore + target *.log *.iml *.ipr *.iws Added: svn:mergeinfo + Deleted: trunk/jaxx-runtime/LICENSE.txt =================================================================== --- branches/jaxx-2.X/jaxx-runtime/LICENSE.txt 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/LICENSE.txt 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,166 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. - Copied: trunk/jaxx-runtime/LICENSE.txt (from rev 1672, branches/jaxx-2.X/jaxx-runtime/LICENSE.txt) =================================================================== --- trunk/jaxx-runtime/LICENSE.txt (rev 0) +++ trunk/jaxx-runtime/LICENSE.txt 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,166 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. + Deleted: trunk/jaxx-runtime/README.txt =================================================================== --- branches/jaxx-2.X/jaxx-runtime/README.txt 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/README.txt 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,2 +0,0 @@ -To deploy new version of pom: mvn deploy -To install localy: mvn install Copied: trunk/jaxx-runtime/README.txt (from rev 1672, branches/jaxx-2.X/jaxx-runtime/README.txt) =================================================================== --- trunk/jaxx-runtime/README.txt (rev 0) +++ trunk/jaxx-runtime/README.txt 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,2 @@ +To deploy new version of pom: mvn deploy +To install localy: mvn install Deleted: trunk/jaxx-runtime/changelog.txt =================================================================== --- branches/jaxx-2.X/jaxx-runtime/changelog.txt 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/changelog.txt 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,109 +0,0 @@ -1.5 - * 20090506 [chemit] - super-pom has no dependencies - -1.3 chemit 20090409 - * 20090404 [chemit] - introduce DataContext class - * 20090331 [chemit] - introduce DecoratorUtils class - * 20090302 [chemit] - add pcs in ApplicationContext - - add method in Util to filter JAXX property changed listeners - -1.2 letellier 2009022? - * 2009021 [chemit] - introduce DefaultApplicationContext iwth annotation system. - -1.1 chemit 20090220 - * 20090124 [chemit] - add methods to retreave icons from UIManager in Util class - * 20090123 [chemit] - add a simple createIcon method in Util classe (to create an icon with no path prefix) - - add a UIManager key "default.icon.path" to be able to change the path where to find icons - * 20090122 [chemit] - refactor poms (sibling dependencies, pluginsManagment,...) - -1.0 chemit 20090111 - * 20090111 [chemit] - integrate new architecture to allow to have runtime code with NO link with compiler :) - -0.8 ??? 200812?? - * 20081228 [chemit] - generify ClassDescriptor - - introduce StylesheetHelper helper class to detach Stylesheet, Rule and Selector classes from - JAXXCompiler and make possible to extract compiler engine from runtime - - * 20081227 [chemit] - add PCS on ValidatorErrorTable to be used by table validation - * 20081218 [chemit] - improve generation of methods - * 20081214 [chemit] - can now in validation, put error with args (all args must be separated by a ##) - - improve event naming : replace the $evXXX by doMEthodName__on__field (except with optimize option) - - add jaww.runtime.swing.Utils.fillComboBox to fill a combobox model from a collection - - add addSourcesToClassPath property to add sources directories in class-path - - improve classloader managment - - keep in DataSource objetCode - - fix bug when processDataBinding on a null objectCode - - always clean node cached values when selected it - - add usefull databinding method in Util - - * 20081213 [chemit] - improve navigation tree node rendering with some caches - - introduce a ChildBuilder to simplify building of child nodes from a collection or array - -0.7 chemit 20081210 - * 20081210 [chemit] - fix bug 1751 - * 20081210 [chemit] - improve JAXXButtonGroup (add ActionChangeListener and toolTipText mecanism) - * 20081208 [chemit] - javabBean attribute use to initialize bean - - introduce Base64Coder to fix bug 1750 and control serailVersionUI (put them to 1L for the moment) - - introduce MultiJXPathDecorator - - add a resetAfterCompile parameter toCompilerOption to keep in test used compilers - - * 20081207 [chemit] use lutinproject 3.1 - - can exclude field from validator - * 20081202 [chemit] - add strategy for loading ui in NavigationTreeSelectionAdapter - - fix bug when searching for a inner class - - * 20081201 [chemit] - implements jaxx.runtime.JXPathDecorator - - add setcontextValue and removeContextValue on JAXXContextEntryDef - - introduce scope in BeanValidator (ERROR or WARNING) and related swing stuff - - only enter once in $initialize method in generated code - - 0.6 chemit 20081117 - * 20081118 [chemit] introduce NavigationUtil, save in context selected node - * 20081107 [chemit] improve data binding and code generation : - - make possible inheritance in binding - - add an attribute javaBean to an object : will generate a full java bean support property - - make possible binding to the javaBean added properties - - clean generated code - - * 20081105 [chemit] - introduce a CardLayout2 to extends awt CardLayout - - introduce a NavigationTreeModel - - introduce a Decorator to render Object - - propagate constructor JAXXContext(JAXXContext) in JAXXObject generation - - begin of rst documentation - - * 20081104 [chemit] can add extra beanInfoSearchPath in SwingInitializer - * 20081104 [chemit] add jaxxContextImplementorClass in option to make possible use of other JAXXContext implementor. - * 20081102 [chemit] improve JAXXContext : - - introduce a JAXXContextEntryDef to qualify an entry of a JAXXContext - - do javadoc in JAXXContext - - add logic in DefaultJAXXContext : seek in parent context if entry not found - * 20081102 [chemit] improve tests : - - fix the last failed test from Jaxx original version :) - - dumps tests to JUnit4 :) - * 20081030 [chemit] improve BeanValidator : - - add full PropertyChangeEvent java-bean support and a property valid - - when remove bean from validator, must remove errors from model - - make possible to have a dynamic errorListModel in jaxx files - * 20081030 [chemit] improve JAXXContext : - - fix setContextValue bug when setting twice a same type for a same key - - implements a DefaultJAXXContext - - use this default implementation with delegate pattern in JAXXObject - * 20081030 [chemit] add JAXXAction contract to simplify init of ui with JAXXInitialContext - * 20081027 [chemit] fix bug 1722 - * 20081027 [chemit] add conversion support in validator - * 20081025 [chemit] improve BeanValidator tag : - - add a errorList attribute for set a ErrorListMouseListener on the errorList - - add a beanInitializer attribute for set the validator's bean at runtime - - add a default errorListModel value 'errors' - * 20081025 [chemit] introduce JAXXInitialContext to fill JAXXContext at runtime before $initialize() method - * 20081024 [chemit] fix validator context lost if UI is launched from another thread - 0.5 chemit 20081002 - * 20081017 [chemit] add validator support - * 20081013 [chemit] can generate logger on jaxx files - * 20081011 [chemit] improve site - * 20081011 [chemit] fix bug on JavaFileParser : works again - * 20081002 [chemit] Using lutinproject 3.0, changing groupId to org.codelutin - * 20081002 [chemit] use a single module jaxx-core (no more core, runtime and jaxx-swing modules) - * 20081002 [chemit] Introduce JAXXContext - * 20081002 [chemit] Fix bug on method creation via scripting - * 20081002 [chemit] Improve i18n integration (works now also for tabs) Copied: trunk/jaxx-runtime/changelog.txt (from rev 1672, branches/jaxx-2.X/jaxx-runtime/changelog.txt) =================================================================== --- trunk/jaxx-runtime/changelog.txt (rev 0) +++ trunk/jaxx-runtime/changelog.txt 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,109 @@ +1.5 + * 20090506 [chemit] - super-pom has no dependencies + +1.3 chemit 20090409 + * 20090404 [chemit] - introduce DataContext class + * 20090331 [chemit] - introduce DecoratorUtils class + * 20090302 [chemit] - add pcs in ApplicationContext + - add method in Util to filter JAXX property changed listeners + +1.2 letellier 2009022? + * 2009021 [chemit] - introduce DefaultApplicationContext iwth annotation system. + +1.1 chemit 20090220 + * 20090124 [chemit] - add methods to retreave icons from UIManager in Util class + * 20090123 [chemit] - add a simple createIcon method in Util classe (to create an icon with no path prefix) + - add a UIManager key "default.icon.path" to be able to change the path where to find icons + * 20090122 [chemit] - refactor poms (sibling dependencies, pluginsManagment,...) + +1.0 chemit 20090111 + * 20090111 [chemit] - integrate new architecture to allow to have runtime code with NO link with compiler :) + +0.8 ??? 200812?? + * 20081228 [chemit] - generify ClassDescriptor + - introduce StylesheetHelper helper class to detach Stylesheet, Rule and Selector classes from + JAXXCompiler and make possible to extract compiler engine from runtime + + * 20081227 [chemit] - add PCS on ValidatorErrorTable to be used by table validation + * 20081218 [chemit] - improve generation of methods + * 20081214 [chemit] - can now in validation, put error with args (all args must be separated by a ##) + - improve event naming : replace the $evXXX by doMEthodName__on__field (except with optimize option) + - add jaww.runtime.swing.Utils.fillComboBox to fill a combobox model from a collection + - add addSourcesToClassPath property to add sources directories in class-path + - improve classloader managment + - keep in DataSource objetCode + - fix bug when processDataBinding on a null objectCode + - always clean node cached values when selected it + - add usefull databinding method in Util + + * 20081213 [chemit] - improve navigation tree node rendering with some caches + - introduce a ChildBuilder to simplify building of child nodes from a collection or array + +0.7 chemit 20081210 + * 20081210 [chemit] - fix bug 1751 + * 20081210 [chemit] - improve JAXXButtonGroup (add ActionChangeListener and toolTipText mecanism) + * 20081208 [chemit] - javabBean attribute use to initialize bean + - introduce Base64Coder to fix bug 1750 and control serailVersionUI (put them to 1L for the moment) + - introduce MultiJXPathDecorator + - add a resetAfterCompile parameter toCompilerOption to keep in test used compilers + + * 20081207 [chemit] use lutinproject 3.1 + - can exclude field from validator + * 20081202 [chemit] - add strategy for loading ui in NavigationTreeSelectionAdapter + - fix bug when searching for a inner class + + * 20081201 [chemit] - implements jaxx.runtime.JXPathDecorator + - add setcontextValue and removeContextValue on JAXXContextEntryDef + - introduce scope in BeanValidator (ERROR or WARNING) and related swing stuff + - only enter once in $initialize method in generated code + + 0.6 chemit 20081117 + * 20081118 [chemit] introduce NavigationUtil, save in context selected node + * 20081107 [chemit] improve data binding and code generation : + - make possible inheritance in binding + - add an attribute javaBean to an object : will generate a full java bean support property + - make possible binding to the javaBean added properties + - clean generated code + + * 20081105 [chemit] - introduce a CardLayout2 to extends awt CardLayout + - introduce a NavigationTreeModel + - introduce a Decorator to render Object + - propagate constructor JAXXContext(JAXXContext) in JAXXObject generation + - begin of rst documentation + + * 20081104 [chemit] can add extra beanInfoSearchPath in SwingInitializer + * 20081104 [chemit] add jaxxContextImplementorClass in option to make possible use of other JAXXContext implementor. + * 20081102 [chemit] improve JAXXContext : + - introduce a JAXXContextEntryDef to qualify an entry of a JAXXContext + - do javadoc in JAXXContext + - add logic in DefaultJAXXContext : seek in parent context if entry not found + * 20081102 [chemit] improve tests : + - fix the last failed test from Jaxx original version :) + - dumps tests to JUnit4 :) + * 20081030 [chemit] improve BeanValidator : + - add full PropertyChangeEvent java-bean support and a property valid + - when remove bean from validator, must remove errors from model + - make possible to have a dynamic errorListModel in jaxx files + * 20081030 [chemit] improve JAXXContext : + - fix setContextValue bug when setting twice a same type for a same key + - implements a DefaultJAXXContext + - use this default implementation with delegate pattern in JAXXObject + * 20081030 [chemit] add JAXXAction contract to simplify init of ui with JAXXInitialContext + * 20081027 [chemit] fix bug 1722 + * 20081027 [chemit] add conversion support in validator + * 20081025 [chemit] improve BeanValidator tag : + - add a errorList attribute for set a ErrorListMouseListener on the errorList + - add a beanInitializer attribute for set the validator's bean at runtime + - add a default errorListModel value 'errors' + * 20081025 [chemit] introduce JAXXInitialContext to fill JAXXContext at runtime before $initialize() method + * 20081024 [chemit] fix validator context lost if UI is launched from another thread + 0.5 chemit 20081002 + * 20081017 [chemit] add validator support + * 20081013 [chemit] can generate logger on jaxx files + * 20081011 [chemit] improve site + * 20081011 [chemit] fix bug on JavaFileParser : works again + * 20081002 [chemit] Using lutinproject 3.0, changing groupId to org.codelutin + * 20081002 [chemit] use a single module jaxx-core (no more core, runtime and jaxx-swing modules) + * 20081002 [chemit] Introduce JAXXContext + * 20081002 [chemit] Fix bug on method creation via scripting + * 20081002 [chemit] Improve i18n integration (works now also for tabs) Deleted: trunk/jaxx-runtime/pom.xml =================================================================== --- branches/jaxx-2.X/jaxx-runtime/pom.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/pom.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,146 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - - <modelVersion>4.0.0</modelVersion> - - <!-- ************************************************************* --> - <!-- *** POM Relationships *************************************** --> - <!-- ************************************************************* --> - - <parent> - <groupId>org.nuiton</groupId> - <artifactId>jaxx</artifactId> - <version>2.0.0-beta-3-SNAPSHOT</version> - </parent> - - <groupId>org.nuiton.jaxx</groupId> - <artifactId>jaxx-runtime</artifactId> - - <dependencies> - - <dependency> - <groupId>org.nuiton</groupId> - <artifactId>nuiton-utils</artifactId> - </dependency> - - <dependency> - <groupId>commons-lang</groupId> - <artifactId>commons-lang</artifactId> - </dependency> - - <!-- pour utiliser javaHelp --> - <dependency> - <groupId>javax.help</groupId> - <artifactId>javahelp</artifactId> - </dependency> - - <dependency> - <groupId>org.swinglabs</groupId> - <artifactId>jxlayer</artifactId> - </dependency> - - <dependency> - <groupId>commons-jxpath</groupId> - <artifactId>commons-jxpath</artifactId> - </dependency> - - <!-- validation framework --> - - <dependency> - <groupId>com.opensymphony</groupId> - <artifactId>xwork</artifactId> - </dependency> - - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - </dependency> - - </dependencies> - - <!-- ************************************************************* --> - <!-- *** Project Information ************************************* --> - <!-- ************************************************************* --> - - <name>JAXX :: Runtime</name> - <description>JAXX Runtime api</description> - - <!-- ************************************************************* --> - <!-- *** Build Settings ****************************************** --> - <!-- ************************************************************* --> - <packaging>jar</packaging> - - <build> - <plugins> - <plugin> - <groupId>org.nuiton.i18n</groupId> - <artifactId>maven-i18n-plugin</artifactId> - <executions> - <execution> - <goals> - <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> - </plugins> - - <pluginManagement> - <plugins> - <plugin> - <artifactId>maven-jar-plugin</artifactId> - <executions> - <execution> - <id>attach-test</id> - <goals> - <goal>test-jar</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </pluginManagement> - </build> - - <!-- ************************************************************* --> - <!-- *** Build Environment ************************************** --> - <!-- ************************************************************* --> - <profiles> - <!-- perform only on a release stage when using the maven-release-plugin --> - <profile> - <id>release-profile</id> - <activation> - <property> - <name>performRelease</name> - <value>true</value> - </property> - </activation> - - <build> - <plugins> - - <!-- always compute tests source jar --> - <plugin> - <artifactId>maven-source-plugin</artifactId> - <executions> - <execution> - <id>attach-test-sources</id> - </execution> - </executions> - </plugin> - - </plugins> - </build> - </profile> - </profiles> - -</project> Copied: trunk/jaxx-runtime/pom.xml (from rev 1672, branches/jaxx-2.X/jaxx-runtime/pom.xml) =================================================================== --- trunk/jaxx-runtime/pom.xml (rev 0) +++ trunk/jaxx-runtime/pom.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,146 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <!-- ************************************************************* --> + <!-- *** POM Relationships *************************************** --> + <!-- ************************************************************* --> + + <parent> + <groupId>org.nuiton</groupId> + <artifactId>jaxx</artifactId> + <version>2.0.0-beta-3-SNAPSHOT</version> + </parent> + + <groupId>org.nuiton.jaxx</groupId> + <artifactId>jaxx-runtime</artifactId> + + <dependencies> + + <dependency> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-utils</artifactId> + </dependency> + + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + </dependency> + + <!-- pour utiliser javaHelp --> + <dependency> + <groupId>javax.help</groupId> + <artifactId>javahelp</artifactId> + </dependency> + + <dependency> + <groupId>org.swinglabs</groupId> + <artifactId>jxlayer</artifactId> + </dependency> + + <dependency> + <groupId>commons-jxpath</groupId> + <artifactId>commons-jxpath</artifactId> + </dependency> + + <!-- validation framework --> + + <dependency> + <groupId>com.opensymphony</groupId> + <artifactId>xwork</artifactId> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </dependency> + + </dependencies> + + <!-- ************************************************************* --> + <!-- *** Project Information ************************************* --> + <!-- ************************************************************* --> + + <name>JAXX :: Runtime</name> + <description>JAXX Runtime api</description> + + <!-- ************************************************************* --> + <!-- *** Build Settings ****************************************** --> + <!-- ************************************************************* --> + <packaging>jar</packaging> + + <build> + <plugins> + <plugin> + <groupId>org.nuiton.i18n</groupId> + <artifactId>maven-i18n-plugin</artifactId> + <executions> + <execution> + <goals> + <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> + </plugins> + + <pluginManagement> + <plugins> + <plugin> + <artifactId>maven-jar-plugin</artifactId> + <executions> + <execution> + <id>attach-test</id> + <goals> + <goal>test-jar</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </pluginManagement> + </build> + + <!-- ************************************************************* --> + <!-- *** Build Environment ************************************** --> + <!-- ************************************************************* --> + <profiles> + <!-- perform only on a release stage when using the maven-release-plugin --> + <profile> + <id>release-profile</id> + <activation> + <property> + <name>performRelease</name> + <value>true</value> + </property> + </activation> + + <build> + <plugins> + + <!-- always compute tests source jar --> + <plugin> + <artifactId>maven-source-plugin</artifactId> + <executions> + <execution> + <id>attach-test-sources</id> + </execution> + </executions> + </plugin> + + </plugins> + </build> + </profile> + </profiles> + +</project> Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/Base64Coder.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Base64Coder.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/Base64Coder.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,260 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.util.zip.GZIPInputStream; -import java.util.zip.GZIPOutputStream; - -/** - * A Base64 Encoder/Decoder. - * <p/> - * <p/> - * This class is used to encode and decode data in Base64 format as described in RFC 1521. - * <p/> - * <p/> - * This is "Open Source" software and released under the <a href="http://www.gnu.org/licenses/lgpl.html">GNU/LGPL</a> license.<br> - * It is provided "as is" without warranty of any kind.<br> - * Copyright 2003: Christian d'Heureuse, Inventec Informatik AG, Switzerland.<br> - * Home page: <a href="http://www.source-code.biz">www.source-code.biz</a><br> - * <p/> - * <p/> - * Version history:<br> - * 2003-07-22 Christian d'Heureuse (chdh): Module created.<br> - * 2005-08-11 chdh: Lincense changed from GPL to LGPL.<br> - * 2006-11-21 chdh:<br> - * Method encode(String) renamed to encodeString(String).<br> - * Method decode(String) renamed to decodeString(String).<br> - * New method encode(byte[],int) added.<br> - * New method decode(String) added.<br> - */ - -public class Base64Coder { - - // Mapping table from 6-bit nibbles to Base64 characters. - private static char[] map1 = new char[64]; - - static { - int i = 0; - for (char c = 'A'; c <= 'Z'; c++) { - map1[i++] = c; - } - for (char c = 'a'; c <= 'z'; c++) { - map1[i++] = c; - } - for (char c = '0'; c <= '9'; c++) { - map1[i++] = c; - } - map1[i++] = '+'; - map1[i] = '/'; - } - - // Mapping table from Base64 characters to 6-bit nibbles. - private static byte[] map2 = new byte[128]; - - static { - for (int i = 0; i < map2.length; i++) { - map2[i] = -1; - } - for (int i = 0; i < 64; i++) { - map2[map1[i]] = (byte) i; - } - } - - /** - * Read the object from Base64 string. - * - * @param s the string representation of serialized object. - * @param gzip if gzip stream - * @return the deserialize object - * @throws java.io.IOException if any io pb - * @throws ClassNotFoundException if class not found ? - */ - public static Object deserialize(String s, boolean gzip) throws IOException, - ClassNotFoundException { - byte[] data = Base64Coder.decode(s); - InputStream stream = new ByteArrayInputStream(data); - if (gzip) { - stream = new GZIPInputStream(stream); - } - ObjectInputStream ois = new ObjectInputStream(stream); - Object o = ois.readObject(); - ois.close(); - return o; - } - - /** - * Write the object to a Base64 string. - * - * @param o the object to serialize - * @param gzip if gzip stream - * @return the string representation - * @throws java.io.IOException if any io pb - */ - public static String serialize(Object o, boolean gzip) throws IOException { - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - ObjectOutputStream oos; - if (gzip) { - oos = new ObjectOutputStream(new GZIPOutputStream(stream)); - } else { - oos = new ObjectOutputStream(stream); - } - oos.writeObject(o); - oos.close(); - return new String(Base64Coder.encode(stream.toByteArray())); - } - - /** - * Encodes a string into Base64 format. - * No blanks or line breaks are inserted. - * - * @param s a String to be encoded. - * @return A String with the Base64 encoded data. - */ - public static String encodeString(String s) { - return new String(encode(s.getBytes())); - } - - /** - * Encodes a byte array into Base64 format. - * No blanks or line breaks are inserted. - * - * @param in an array containing the data bytes to be encoded. - * @return A character array with the Base64 encoded data. - */ - public static char[] encode(byte[] in) { - return encode(in, in.length); - } - - /** - * Encodes a byte array into Base64 format. - * No blanks or line breaks are inserted. - * - * @param in an array containing the data bytes to be encoded. - * @param iLen number of bytes to process in <code>in</code>. - * @return A character array with the Base64 encoded data. - */ - public static char[] encode(byte[] in, int iLen) { - int oDataLen = (iLen * 4 + 2) / 3; // output length without padding - int oLen = ((iLen + 2) / 3) * 4; // output length including padding - char[] out = new char[oLen]; - int ip = 0; - int op = 0; - while (ip < iLen) { - int i0 = in[ip++] & 0xff; - int i1 = ip < iLen ? in[ip++] & 0xff : 0; - int i2 = ip < iLen ? in[ip++] & 0xff : 0; - int o0 = i0 >>> 2; - int o1 = ((i0 & 3) << 4) | (i1 >>> 4); - int o2 = ((i1 & 0xf) << 2) | (i2 >>> 6); - int o3 = i2 & 0x3F; - out[op++] = map1[o0]; - out[op++] = map1[o1]; - out[op] = op < oDataLen ? map1[o2] : '='; - op++; - out[op] = op < oDataLen ? map1[o3] : '='; - op++; - } - return out; - } - - /** - * Decodes a string from Base64 format. - * - * @param s a Base64 String to be decoded. - * @return A String containing the decoded data. - * @throws IllegalArgumentException if the input is not valid Base64 encoded data. - */ - public static String decodeString(String s) { - return new String(decode(s)); - } - - /** - * Decodes a byte array from Base64 format. - * - * @param s a Base64 String to be decoded. - * @return An array containing the decoded data bytes. - * @throws IllegalArgumentException if the input is not valid Base64 encoded data. - */ - public static byte[] decode(String s) { - return decode(s.toCharArray()); - } - - /** - * Decodes a byte array from Base64 format. - * No blanks or line breaks are allowed within the Base64 encoded data. - * - * @param in a character array containing the Base64 encoded data. - * @return An array containing the decoded data bytes. - * @throws IllegalArgumentException if the input is not valid Base64 encoded data. - */ - public static byte[] decode(char[] in) { - int iLen = in.length; - if (iLen % 4 != 0) { - throw new IllegalArgumentException("Length of Base64 encoded input string is not a multiple of 4."); - } - while (iLen > 0 && in[iLen - 1] == '=') { - iLen--; - } - int oLen = (iLen * 3) / 4; - byte[] out = new byte[oLen]; - int ip = 0; - int op = 0; - while (ip < iLen) { - int i0 = in[ip++]; - int i1 = in[ip++]; - int i2 = ip < iLen ? in[ip++] : 'A'; - int i3 = ip < iLen ? in[ip++] : 'A'; - if (i0 > 127 || i1 > 127 || i2 > 127 || i3 > 127) { - throw new IllegalArgumentException("Illegal character in Base64 encoded data."); - } - int b0 = map2[i0]; - int b1 = map2[i1]; - int b2 = map2[i2]; - int b3 = map2[i3]; - if (b0 < 0 || b1 < 0 || b2 < 0 || b3 < 0) { - throw new IllegalArgumentException("Illegal character in Base64 encoded data."); - } - int o0 = (b0 << 2) | (b1 >>> 4); - int o1 = ((b1 & 0xf) << 4) | (b2 >>> 2); - int o2 = ((b2 & 3) << 6) | b3; - out[op++] = (byte) o0; - if (op < oLen) { - out[op++] = (byte) o1; - } - if (op < oLen) { - out[op++] = (byte) o2; - } - } - return out; - } - - // Dummy constructor. - private Base64Coder() { - } - -} // end class Base64Coder - Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/Base64Coder.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Base64Coder.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/Base64Coder.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/Base64Coder.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,260 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.zip.GZIPInputStream; +import java.util.zip.GZIPOutputStream; + +/** + * A Base64 Encoder/Decoder. + * <p/> + * <p/> + * This class is used to encode and decode data in Base64 format as described in RFC 1521. + * <p/> + * <p/> + * This is "Open Source" software and released under the <a href="http://www.gnu.org/licenses/lgpl.html">GNU/LGPL</a> license.<br> + * It is provided "as is" without warranty of any kind.<br> + * Copyright 2003: Christian d'Heureuse, Inventec Informatik AG, Switzerland.<br> + * Home page: <a href="http://www.source-code.biz">www.source-code.biz</a><br> + * <p/> + * <p/> + * Version history:<br> + * 2003-07-22 Christian d'Heureuse (chdh): Module created.<br> + * 2005-08-11 chdh: Lincense changed from GPL to LGPL.<br> + * 2006-11-21 chdh:<br> + * Method encode(String) renamed to encodeString(String).<br> + * Method decode(String) renamed to decodeString(String).<br> + * New method encode(byte[],int) added.<br> + * New method decode(String) added.<br> + */ + +public class Base64Coder { + + // Mapping table from 6-bit nibbles to Base64 characters. + private static char[] map1 = new char[64]; + + static { + int i = 0; + for (char c = 'A'; c <= 'Z'; c++) { + map1[i++] = c; + } + for (char c = 'a'; c <= 'z'; c++) { + map1[i++] = c; + } + for (char c = '0'; c <= '9'; c++) { + map1[i++] = c; + } + map1[i++] = '+'; + map1[i] = '/'; + } + + // Mapping table from Base64 characters to 6-bit nibbles. + private static byte[] map2 = new byte[128]; + + static { + for (int i = 0; i < map2.length; i++) { + map2[i] = -1; + } + for (int i = 0; i < 64; i++) { + map2[map1[i]] = (byte) i; + } + } + + /** + * Read the object from Base64 string. + * + * @param s the string representation of serialized object. + * @param gzip if gzip stream + * @return the deserialize object + * @throws java.io.IOException if any io pb + * @throws ClassNotFoundException if class not found ? + */ + public static Object deserialize(String s, boolean gzip) throws IOException, + ClassNotFoundException { + byte[] data = Base64Coder.decode(s); + InputStream stream = new ByteArrayInputStream(data); + if (gzip) { + stream = new GZIPInputStream(stream); + } + ObjectInputStream ois = new ObjectInputStream(stream); + Object o = ois.readObject(); + ois.close(); + return o; + } + + /** + * Write the object to a Base64 string. + * + * @param o the object to serialize + * @param gzip if gzip stream + * @return the string representation + * @throws java.io.IOException if any io pb + */ + public static String serialize(Object o, boolean gzip) throws IOException { + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + ObjectOutputStream oos; + if (gzip) { + oos = new ObjectOutputStream(new GZIPOutputStream(stream)); + } else { + oos = new ObjectOutputStream(stream); + } + oos.writeObject(o); + oos.close(); + return new String(Base64Coder.encode(stream.toByteArray())); + } + + /** + * Encodes a string into Base64 format. + * No blanks or line breaks are inserted. + * + * @param s a String to be encoded. + * @return A String with the Base64 encoded data. + */ + public static String encodeString(String s) { + return new String(encode(s.getBytes())); + } + + /** + * Encodes a byte array into Base64 format. + * No blanks or line breaks are inserted. + * + * @param in an array containing the data bytes to be encoded. + * @return A character array with the Base64 encoded data. + */ + public static char[] encode(byte[] in) { + return encode(in, in.length); + } + + /** + * Encodes a byte array into Base64 format. + * No blanks or line breaks are inserted. + * + * @param in an array containing the data bytes to be encoded. + * @param iLen number of bytes to process in <code>in</code>. + * @return A character array with the Base64 encoded data. + */ + public static char[] encode(byte[] in, int iLen) { + int oDataLen = (iLen * 4 + 2) / 3; // output length without padding + int oLen = ((iLen + 2) / 3) * 4; // output length including padding + char[] out = new char[oLen]; + int ip = 0; + int op = 0; + while (ip < iLen) { + int i0 = in[ip++] & 0xff; + int i1 = ip < iLen ? in[ip++] & 0xff : 0; + int i2 = ip < iLen ? in[ip++] & 0xff : 0; + int o0 = i0 >>> 2; + int o1 = ((i0 & 3) << 4) | (i1 >>> 4); + int o2 = ((i1 & 0xf) << 2) | (i2 >>> 6); + int o3 = i2 & 0x3F; + out[op++] = map1[o0]; + out[op++] = map1[o1]; + out[op] = op < oDataLen ? map1[o2] : '='; + op++; + out[op] = op < oDataLen ? map1[o3] : '='; + op++; + } + return out; + } + + /** + * Decodes a string from Base64 format. + * + * @param s a Base64 String to be decoded. + * @return A String containing the decoded data. + * @throws IllegalArgumentException if the input is not valid Base64 encoded data. + */ + public static String decodeString(String s) { + return new String(decode(s)); + } + + /** + * Decodes a byte array from Base64 format. + * + * @param s a Base64 String to be decoded. + * @return An array containing the decoded data bytes. + * @throws IllegalArgumentException if the input is not valid Base64 encoded data. + */ + public static byte[] decode(String s) { + return decode(s.toCharArray()); + } + + /** + * Decodes a byte array from Base64 format. + * No blanks or line breaks are allowed within the Base64 encoded data. + * + * @param in a character array containing the Base64 encoded data. + * @return An array containing the decoded data bytes. + * @throws IllegalArgumentException if the input is not valid Base64 encoded data. + */ + public static byte[] decode(char[] in) { + int iLen = in.length; + if (iLen % 4 != 0) { + throw new IllegalArgumentException("Length of Base64 encoded input string is not a multiple of 4."); + } + while (iLen > 0 && in[iLen - 1] == '=') { + iLen--; + } + int oLen = (iLen * 3) / 4; + byte[] out = new byte[oLen]; + int ip = 0; + int op = 0; + while (ip < iLen) { + int i0 = in[ip++]; + int i1 = in[ip++]; + int i2 = ip < iLen ? in[ip++] : 'A'; + int i3 = ip < iLen ? in[ip++] : 'A'; + if (i0 > 127 || i1 > 127 || i2 > 127 || i3 > 127) { + throw new IllegalArgumentException("Illegal character in Base64 encoded data."); + } + int b0 = map2[i0]; + int b1 = map2[i1]; + int b2 = map2[i2]; + int b3 = map2[i3]; + if (b0 < 0 || b1 < 0 || b2 < 0 || b3 < 0) { + throw new IllegalArgumentException("Illegal character in Base64 encoded data."); + } + int o0 = (b0 << 2) | (b1 >>> 4); + int o1 = ((b1 & 0xf) << 4) | (b2 >>> 2); + int o2 = ((b2 & 3) << 6) | b3; + out[op++] = (byte) o0; + if (op < oLen) { + out[op++] = (byte) o1; + } + if (op < oLen) { + out[op++] = (byte) o2; + } + } + return out; + } + + // Dummy constructor. + private Base64Coder() { + } + +} // end class Base64Coder + Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/ComponentDescriptor.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/ComponentDescriptor.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/ComponentDescriptor.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,65 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime; - -import java.io.Serializable; - -public class ComponentDescriptor implements Serializable { - String id; - String javaClassName; - String styleClass; - ComponentDescriptor parent; - private static final long serialVersionUID = 1L; - - - public ComponentDescriptor(String id, String javaClassName, String styleClass, ComponentDescriptor parent) { - this.id = id; - this.javaClassName = javaClassName; - this.styleClass = styleClass; - this.parent = parent; - } - - - public String getId() { - return id; - } - - - public String getJavaClassName() { - return javaClassName; - } - - - public String getStyleClass() { - return styleClass; - } - - - public ComponentDescriptor getParent() { - return parent; - } - - - @Override - public String toString() { - return "ComponentDescriptor[" + id + ", " + javaClassName + ", " + styleClass + "]"; - } -} \ No newline at end of file Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/ComponentDescriptor.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/ComponentDescriptor.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/ComponentDescriptor.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/ComponentDescriptor.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,65 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime; + +import java.io.Serializable; + +public class ComponentDescriptor implements Serializable { + String id; + String javaClassName; + String styleClass; + ComponentDescriptor parent; + private static final long serialVersionUID = 1L; + + + public ComponentDescriptor(String id, String javaClassName, String styleClass, ComponentDescriptor parent) { + this.id = id; + this.javaClassName = javaClassName; + this.styleClass = styleClass; + this.parent = parent; + } + + + public String getId() { + return id; + } + + + public String getJavaClassName() { + return javaClassName; + } + + + public String getStyleClass() { + return styleClass; + } + + + public ComponentDescriptor getParent() { + return parent; + } + + + @Override + public String toString() { + return "ComponentDescriptor[" + id + ", " + javaClassName + ", " + styleClass + "]"; + } +} \ No newline at end of file Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingListener.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingListener.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingListener.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,63 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - - -/** - * A <code>PropertyChangeListener</code> which processes a data binding when it receives a - * <code>PropertyChangeEvent</code>. - */ -public class DataBindingListener implements PropertyChangeListener { - private JAXXObject object; - private String dest; - - /** - * Creates a new <code>DataBindingListener</code> which will run the given data binding - * when it receives a <code>PropertyChangeEvent</code>. - * - * @param object the object in which the data binding exists - * @param dest the name of the data binding to run - */ - public DataBindingListener(JAXXObject object, String dest) { - this.object = object; - this.dest = dest; - } - - - /** - * Processes the data binding in response to a <code>PropertyChangeEvent</code>. - * - * @param e the event which triggered the binding - */ - @Override - public void propertyChange(PropertyChangeEvent e) { - object.processDataBinding(dest); - - // for now, handle dependency changes by always removing & reapplying - // the binding. We should be more efficient and only do this when it's - // actually necessary - object.removeDataBinding(dest); - object.applyDataBinding(dest); - } -} \ No newline at end of file Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingListener.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingListener.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingListener.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingListener.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,63 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + + +/** + * A <code>PropertyChangeListener</code> which processes a data binding when it receives a + * <code>PropertyChangeEvent</code>. + */ +public class DataBindingListener implements PropertyChangeListener { + private JAXXObject object; + private String dest; + + /** + * Creates a new <code>DataBindingListener</code> which will run the given data binding + * when it receives a <code>PropertyChangeEvent</code>. + * + * @param object the object in which the data binding exists + * @param dest the name of the data binding to run + */ + public DataBindingListener(JAXXObject object, String dest) { + this.object = object; + this.dest = dest; + } + + + /** + * Processes the data binding in response to a <code>PropertyChangeEvent</code>. + * + * @param e the event which triggered the binding + */ + @Override + public void propertyChange(PropertyChangeEvent e) { + object.processDataBinding(dest); + + // for now, handle dependency changes by always removing & reapplying + // the binding. We should be more efficient and only do this when it's + // actually necessary + object.removeDataBinding(dest); + object.applyDataBinding(dest); + } +} \ No newline at end of file Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingUpdateListener.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingUpdateListener.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingUpdateListener.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,63 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - - -/** - * A <code>PropertyChangeListener</code> which removes and re-applies a data binding - * when it receives a <code>PropertyChangeEvent</code>. - */ -public class DataBindingUpdateListener implements PropertyChangeListener { - private JAXXObject object; - private String dest; - - /** - * Creates a new <code>DataBindingUpdateListener</code> which will remove and re-apply a - * data binding when it receives a <code>PropertyChangeEvent</code>. - * - * @param object the object in which the data binding exists - * @param dest the name of the data binding to reapply - */ - public DataBindingUpdateListener(JAXXObject object, String dest) { - this.object = object; - this.dest = dest; - } - - - public String getBindingName() { - return dest; - } - - - /** - * Updates the data binding in response to a <code>PropertyChangeEvent</code>. - * - * @param e the event which triggered the binding - */ - @Override - public void propertyChange(PropertyChangeEvent e) { - object.removeDataBinding(dest); - object.applyDataBinding(dest); - } -} \ No newline at end of file Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingUpdateListener.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingUpdateListener.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingUpdateListener.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingUpdateListener.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,63 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + + +/** + * A <code>PropertyChangeListener</code> which removes and re-applies a data binding + * when it receives a <code>PropertyChangeEvent</code>. + */ +public class DataBindingUpdateListener implements PropertyChangeListener { + private JAXXObject object; + private String dest; + + /** + * Creates a new <code>DataBindingUpdateListener</code> which will remove and re-apply a + * data binding when it receives a <code>PropertyChangeEvent</code>. + * + * @param object the object in which the data binding exists + * @param dest the name of the data binding to reapply + */ + public DataBindingUpdateListener(JAXXObject object, String dest) { + this.object = object; + this.dest = dest; + } + + + public String getBindingName() { + return dest; + } + + + /** + * Updates the data binding in response to a <code>PropertyChangeEvent</code>. + * + * @param e the event which triggered the binding + */ + @Override + public void propertyChange(PropertyChangeEvent e) { + object.removeDataBinding(dest); + object.applyDataBinding(dest); + } +} \ No newline at end of file Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXAction.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXAction.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXAction.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,41 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime; - -import jaxx.runtime.context.JAXXInitialContext; - -/** - * This is the contract to be realized by any class to be used as Action class for an ui. - * - * @author chemit - */ -public interface JAXXAction { - - /** - * Prepare the initial context of the ui. - * - * @param parentContent the context of the parent of the ui (can be null if no parent is required) - * @param datas other datas to inject in initial context - * @return the {@link jaxx.runtime.context.JAXXInitialContext} to be injected in the ui via the constructor of the {@link jaxx.runtime.JAXXObject} - */ - JAXXInitialContext init(JAXXContext parentContent, Object... datas); - -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXAction.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXAction.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXAction.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXAction.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,41 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime; + +import jaxx.runtime.context.JAXXInitialContext; + +/** + * This is the contract to be realized by any class to be used as Action class for an ui. + * + * @author chemit + */ +public interface JAXXAction { + + /** + * Prepare the initial context of the ui. + * + * @param parentContent the context of the parent of the ui (can be null if no parent is required) + * @param datas other datas to inject in initial context + * @return the {@link jaxx.runtime.context.JAXXInitialContext} to be injected in the ui via the constructor of the {@link jaxx.runtime.JAXXObject} + */ + JAXXInitialContext init(JAXXContext parentContent, Object... datas); + +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXBinding.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXBinding.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXBinding.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,95 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - - -/** - * A <code>PropertyChangeListener</code> which processes a data binding when it receives a - * <code>PropertyChangeEvent</code>. - */ -public abstract class JAXXBinding implements PropertyChangeListener { - /** - * Id of the binding - */ - private String id; - - /** - * Creates a new Data binding which will run the given data binding - * when it receives a <code>PropertyChangeEvent</code>. - * - * @param id the name of the data binding to run - */ - public JAXXBinding(String id) { - this.id = id; - } - - public String getId() { - return id; - } - - @Override - public String toString() { - return super.toString() + ":" + id; - } - - /** - * Processes the data binding in response to a <code>PropertyChangeEvent</code>. - * - * @param e the event which triggered the binding - */ - @Override - public void propertyChange(PropertyChangeEvent e) { -// object.processDataBinding(id); - - processDataBinding(); - - //TC-20091201 : I really don't see the point - // I comment the code, and still working fine ? Any trick - //TODO-20091201 Must test on a lot of cases before next release 2.0.0-beta-2 - // for now, handle dependency changes by always removing & reapplying - // the binding. We should be more efficient and only do this when it's - // actually necessary -// object.removeDataBinding(id); -// object.applyDataBinding(id); - } - - /** - * Apply the binding without processing it (say just install listeners). - */ - public abstract void applyDataBinding(); - - /** - * Processes the binding. - */ - public abstract void processDataBinding(); - - /** - * Remove the binding. - */ - public abstract void removeDataBinding(); -// -// public void propertyChange() { -// propertyChange(null); -// } -} \ No newline at end of file Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXBinding.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXBinding.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXBinding.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXBinding.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,95 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + + +/** + * A <code>PropertyChangeListener</code> which processes a data binding when it receives a + * <code>PropertyChangeEvent</code>. + */ +public abstract class JAXXBinding implements PropertyChangeListener { + /** + * Id of the binding + */ + private String id; + + /** + * Creates a new Data binding which will run the given data binding + * when it receives a <code>PropertyChangeEvent</code>. + * + * @param id the name of the data binding to run + */ + public JAXXBinding(String id) { + this.id = id; + } + + public String getId() { + return id; + } + + @Override + public String toString() { + return super.toString() + ":" + id; + } + + /** + * Processes the data binding in response to a <code>PropertyChangeEvent</code>. + * + * @param e the event which triggered the binding + */ + @Override + public void propertyChange(PropertyChangeEvent e) { +// object.processDataBinding(id); + + processDataBinding(); + + //TC-20091201 : I really don't see the point + // I comment the code, and still working fine ? Any trick + //TODO-20091201 Must test on a lot of cases before next release 2.0.0-beta-2 + // for now, handle dependency changes by always removing & reapplying + // the binding. We should be more efficient and only do this when it's + // actually necessary +// object.removeDataBinding(id); +// object.applyDataBinding(id); + } + + /** + * Apply the binding without processing it (say just install listeners). + */ + public abstract void applyDataBinding(); + + /** + * Processes the binding. + */ + public abstract void processDataBinding(); + + /** + * Remove the binding. + */ + public abstract void removeDataBinding(); +// +// public void propertyChange() { +// propertyChange(null); +// } +} \ No newline at end of file Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,128 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime; - -/** - * The {@link jaxx.runtime.JAXXContext} contract defines a generic context. - * <p/> - * A context contains two king of entries : - * <p/> - * <h2>Unamed entry</h2> - * a such entry maps filter only on the clas of the object of the entry. - * <p/> - * To add a <b>unamed</b> entry, use {@link #setContextValue(Object)} and {@link #getContextValue(Class)} to reteave a - * such entry. - * <p/> - * <h2>named entry</h2> - * a such entry filter on class of the object and on the name of the entry. - * <p/> - * To add a <b>named</b> entry, use {@link #setContextValue(Object,String)} and {@link #getContextValue(Class,String)} - * to reteave a such entry. - * - * @author letellier - * @author chemit - */ -public interface JAXXContext { - - /** - * Push in the context a new unamed entry. - * <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 - */ - <T> void setContextValue(T o); - - /** - * * Push in the context a new amed entry. - * <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 - */ - <T> void setContextValue(T o, String name); - - /** - * 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 - */ - <T> void removeContextValue(Class<T> klazz); - - /** - * 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 - */ - <T> void removeContextValue(Class<T> klazz, String name); - - /** - * Seek for a unamed entry in the context - * <p/> - * This is an exemple to call a method in JAXX : - * <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. - */ - <T> T getContextValue(Class<T> clazz); - - /** - * 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. - */ - <T> T getContextValue(Class<T> clazz, String name); - -// /** -// * 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 -// * @deprecated since 2.0.0 : breaks neutral since Swing -// */ -// @Deprecated -// public <O extends Container> O getParentContainer(Class<O> clazz); -// -// /** -// * 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 -// * @deprecated since 2.0.0 : breaks neutral since Swing -// */ -// @Deprecated -// public <O extends Container> O getParentContainer(Object top, Class<O> clazz); -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,128 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime; + +/** + * The {@link jaxx.runtime.JAXXContext} contract defines a generic context. + * <p/> + * A context contains two king of entries : + * <p/> + * <h2>Unamed entry</h2> + * a such entry maps filter only on the clas of the object of the entry. + * <p/> + * To add a <b>unamed</b> entry, use {@link #setContextValue(Object)} and {@link #getContextValue(Class)} to reteave a + * such entry. + * <p/> + * <h2>named entry</h2> + * a such entry filter on class of the object and on the name of the entry. + * <p/> + * To add a <b>named</b> entry, use {@link #setContextValue(Object,String)} and {@link #getContextValue(Class,String)} + * to reteave a such entry. + * + * @author letellier + * @author chemit + */ +public interface JAXXContext { + + /** + * Push in the context a new unamed entry. + * <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 + */ + <T> void setContextValue(T o); + + /** + * * Push in the context a new amed entry. + * <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 + */ + <T> void setContextValue(T o, String name); + + /** + * 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 + */ + <T> void removeContextValue(Class<T> klazz); + + /** + * 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 + */ + <T> void removeContextValue(Class<T> klazz, String name); + + /** + * Seek for a unamed entry in the context + * <p/> + * This is an exemple to call a method in JAXX : + * <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. + */ + <T> T getContextValue(Class<T> clazz); + + /** + * 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. + */ + <T> T getContextValue(Class<T> clazz, String name); + +// /** +// * 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 +// * @deprecated since 2.0.0 : breaks neutral since Swing +// */ +// @Deprecated +// public <O extends Container> O getParentContainer(Class<O> clazz); +// +// /** +// * 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 +// * @deprecated since 2.0.0 : breaks neutral since Swing +// */ +// @Deprecated +// public <O extends Container> O getParentContainer(Object top, Class<O> clazz); +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,136 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime; - -import java.awt.*; -import java.io.Serializable; -import java.util.Map; - -/** - * The <code>JAXXObject</code> interface is implemented by all classes - * produced by the JAXX compiler. - */ -public interface JAXXObject extends JAXXContext, Serializable { - - /** - * Retrieves an object defined in an XML tag by its ID. - * - * @param id the id of the component to retrieve - * @return the object - */ - Object getObjectById(String id); - - /** - * Pretrieves the dictonary of knwon objects indexed by their ids. - * - * @return the dictonary of objects. - */ - Map<String, Object> get$objectMap(); - - /** - * @return the {@link JAXXContext} attached to the object - */ - JAXXContext getDelegateContext(); - - /** - * Apply the data bind by name and then process it. - * - * @param id the id of the databinding - */ - void applyDataBinding(String id); - - /** - * Processes a data binding by name. Data binding names are comprised of an object ID and a property name: - * for example, the data binding in the tag <code><JLabel id='label' text='{foo.getText()}'/></code> is - * named <code>"label.text"</code>. Processing a data binding causes it to reevaluate its expression, in this - * case <code>foo.getText()</code>. - * - * @param dest the name of the data binding to run - */ - void processDataBinding(String dest); - - /** - * Remove a databinding by name. - * - * @param id the name of databinding to remove - */ - void removeDataBinding(String id); - - /** - * All <code>JAXXObject</code> implements are capable of broadcasting <code>PropertyChangeEvent</code>, and - * furthermore (for technical reasons) must allow code in outside packages, specifically the JAXX runtime, - * to trigger these events. - * - * @param name the name of the property which changed - * @param oldValue the old value of the property - * @param newValue the new value of the property - */ - void firePropertyChange(String name, Object oldValue, Object newValue); - - /** - * Register a general {@link java.beans.PropertyChangeListener}. - * - * @param listener the listener to register - */ - void addPropertyChangeListener(java.beans.PropertyChangeListener listener); - - /** - * Register a {@link java.beans.PropertyChangeListener}. for the given {@code propertyName}. - * - * @param property the property name to listen - * @param listener the listener to register - */ - void addPropertyChangeListener(String property, java.beans.PropertyChangeListener listener); - - /** - * Unregister a general {@link java.beans.PropertyChangeListener}. - * - * @param listener the listener to unregister - */ - void removePropertyChangeListener(java.beans.PropertyChangeListener listener); - - /** - * Unregister a {@link java.beans.PropertyChangeListener}. for the given {@code propertyName}. - * - * @param property the property name to listen - * @param listener the listener to unregister - */ - void removePropertyChangeListener(String property, java.beans.PropertyChangeListener listener); - - /** - * 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 - */ - <O extends Container> O getParentContainer(Class<O> clazz); - - /** - * 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 - */ - <O extends Container> O getParentContainer(Object top, Class<O> clazz); -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,136 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime; + +import java.awt.*; +import java.io.Serializable; +import java.util.Map; + +/** + * The <code>JAXXObject</code> interface is implemented by all classes + * produced by the JAXX compiler. + */ +public interface JAXXObject extends JAXXContext, Serializable { + + /** + * Retrieves an object defined in an XML tag by its ID. + * + * @param id the id of the component to retrieve + * @return the object + */ + Object getObjectById(String id); + + /** + * Pretrieves the dictonary of knwon objects indexed by their ids. + * + * @return the dictonary of objects. + */ + Map<String, Object> get$objectMap(); + + /** + * @return the {@link JAXXContext} attached to the object + */ + JAXXContext getDelegateContext(); + + /** + * Apply the data bind by name and then process it. + * + * @param id the id of the databinding + */ + void applyDataBinding(String id); + + /** + * Processes a data binding by name. Data binding names are comprised of an object ID and a property name: + * for example, the data binding in the tag <code><JLabel id='label' text='{foo.getText()}'/></code> is + * named <code>"label.text"</code>. Processing a data binding causes it to reevaluate its expression, in this + * case <code>foo.getText()</code>. + * + * @param dest the name of the data binding to run + */ + void processDataBinding(String dest); + + /** + * Remove a databinding by name. + * + * @param id the name of databinding to remove + */ + void removeDataBinding(String id); + + /** + * All <code>JAXXObject</code> implements are capable of broadcasting <code>PropertyChangeEvent</code>, and + * furthermore (for technical reasons) must allow code in outside packages, specifically the JAXX runtime, + * to trigger these events. + * + * @param name the name of the property which changed + * @param oldValue the old value of the property + * @param newValue the new value of the property + */ + void firePropertyChange(String name, Object oldValue, Object newValue); + + /** + * Register a general {@link java.beans.PropertyChangeListener}. + * + * @param listener the listener to register + */ + void addPropertyChangeListener(java.beans.PropertyChangeListener listener); + + /** + * Register a {@link java.beans.PropertyChangeListener}. for the given {@code propertyName}. + * + * @param property the property name to listen + * @param listener the listener to register + */ + void addPropertyChangeListener(String property, java.beans.PropertyChangeListener listener); + + /** + * Unregister a general {@link java.beans.PropertyChangeListener}. + * + * @param listener the listener to unregister + */ + void removePropertyChangeListener(java.beans.PropertyChangeListener listener); + + /** + * Unregister a {@link java.beans.PropertyChangeListener}. for the given {@code propertyName}. + * + * @param property the property name to listen + * @param listener the listener to unregister + */ + void removePropertyChangeListener(String property, java.beans.PropertyChangeListener listener); + + /** + * 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 + */ + <O extends Container> O getParentContainer(Class<O> clazz); + + /** + * 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 + */ + <O extends Container> O getParentContainer(Object top, Class<O> clazz); +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObjectDescriptor.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObjectDescriptor.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObjectDescriptor.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,58 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime; - -import jaxx.runtime.css.Stylesheet; - -import java.io.Serializable; - -public class JAXXObjectDescriptor implements Serializable { - private ComponentDescriptor[] descriptors; - private Stylesheet stylesheet; - private static final long serialVersionUID = 1L; - - - public JAXXObjectDescriptor(ComponentDescriptor[] descriptors, - Stylesheet stylesheet) { - this.descriptors = descriptors; - this.stylesheet = stylesheet; - } - - - public ComponentDescriptor[] getComponentDescriptors() { - return descriptors; - } - - - public Stylesheet getStylesheet() { - return stylesheet; - } - - @Override - public String toString() { - StringBuilder buffer = new StringBuilder(); - for (ComponentDescriptor descriptor : descriptors) { - buffer.append("\n").append(descriptor); - } - buffer.append("\n").append(stylesheet); - return buffer.toString(); - } -} \ No newline at end of file Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObjectDescriptor.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObjectDescriptor.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObjectDescriptor.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObjectDescriptor.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,58 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime; + +import jaxx.runtime.css.Stylesheet; + +import java.io.Serializable; + +public class JAXXObjectDescriptor implements Serializable { + private ComponentDescriptor[] descriptors; + private Stylesheet stylesheet; + private static final long serialVersionUID = 1L; + + + public JAXXObjectDescriptor(ComponentDescriptor[] descriptors, + Stylesheet stylesheet) { + this.descriptors = descriptors; + this.stylesheet = stylesheet; + } + + + public ComponentDescriptor[] getComponentDescriptors() { + return descriptors; + } + + + public Stylesheet getStylesheet() { + return stylesheet; + } + + @Override + public String toString() { + StringBuilder buffer = new StringBuilder(); + for (ComponentDescriptor descriptor : descriptors) { + buffer.append("\n").append(descriptor); + } + buffer.append("\n").append(stylesheet); + return buffer.toString(); + } +} \ No newline at end of file Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXValidator.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXValidator.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXValidator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,45 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime; - - -import java.util.List; -import jaxx.runtime.validator.BeanValidator; - -/** - * The contract of a validator-able object. - * - * @author chemit - */ -public interface JAXXValidator { - - /** - * Obtain a validator from his id - * - * @param validatorId validator id - * @return the associated validator, or <code>null</code> if not find - */ - BeanValidator<?> getValidator(String validatorId); - - /** @return the list of ids of all registred validator */ - List<String> getValidatorIds(); - -} \ No newline at end of file Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXValidator.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXValidator.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXValidator.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXValidator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,45 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime; + + +import java.util.List; +import jaxx.runtime.validator.BeanValidator; + +/** + * The contract of a validator-able object. + * + * @author chemit + */ +public interface JAXXValidator { + + /** + * Obtain a validator from his id + * + * @param validatorId validator id + * @return the associated validator, or <code>null</code> if not find + */ + BeanValidator<?> getValidator(String validatorId); + + /** @return the list of ids of all registred validator */ + List<String> getValidatorIds(); + +} \ No newline at end of file Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,920 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package 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.*; -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.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.renderer.BooleanCellRenderer; -import jaxx.runtime.swing.renderer.EmptyNumberTableCellRenderer; -import jaxx.runtime.swing.renderer.EnumTableCellRenderer; -import jaxx.runtime.swing.renderer.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. - * <p/> - * 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); - public static final String DEFAULT_ICON_PATH = "/icons/"; - public static final String DEFAULT_ICON_PATH_PROPERTY = "default.icon.path"; - 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 list model with some datas, and select after all the given object - * - * @param list the list to fill - * @param data data ot inject in combo - * @param select the object to select in combo after reflling his model - */ - public static void fillList(JList list, Collection<?> data, Object select) { - if (!(list.getModel() instanceof DefaultListModel)) { - throw new IllegalArgumentException("this method need a DefaultListModel for this model but was " + list.getModel().getClass()); - } - DefaultListModel model = (DefaultListModel) list.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); - list.setSelectedValue(select, true); - } - - /** - * TODO move this to JAXXComboBox. - * <p/> - * 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 - * @deprecated since 1.7.XXX this code is moved to JAXXComboBox - */ - @Deprecated - 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); - } - - /** - * 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 - */ - @SuppressWarnings({"unchecked"}) - public static <O extends Container> O getParentContainer(Object top, Class<O> clazz) { - if (top == null) { - throw new IllegalArgumentException("top parameter can not be null"); - } - if (!Container.class.isAssignableFrom(top.getClass())) { - throw new IllegalArgumentException("top parameter " + top + " is not a " + Container.class); - } - Container parent = ((Container) top).getParent(); - if (parent != null && !clazz.isAssignableFrom(parent.getClass())) { - parent = getParentContainer(parent, clazz); - } - return (O) parent; - } - - 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. - * <p/> - * <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. - * <p/> - * Says using method {@link JTabbedPane#getComponent(int)} - * - * @param tabs the - * @return the iterator - * @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}. - * <p/> - * Implements the method {@link #get(int, java.awt.Component)} to obtain - * the data required given the component (or index). - * <p/> - * You can also inverse the order by usin the method {@link #reverse()}. - * <p/> - * 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 = 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 the deppest component - */ - 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}. - * <p/> - * 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); - } - } - } - }); - } - } - }); - } - - /** - * Set the width of the given component - * - * @param component the component to resize - * @param width the new width to apply - */ - public static void setComponentWidth(Component component, int width) { - component.setSize(width, component.getHeight()); - if (component instanceof JComponent) { - JComponent jcomponent = (JComponent) component; - jcomponent.setPreferredSize(new Dimension(width, jcomponent.getPreferredSize().height)); - jcomponent.setMinimumSize(new Dimension(width, jcomponent.getPreferredSize().height)); - if (jcomponent.isDisplayable()) { - jcomponent.revalidate(); - } - } - } - /** - * Set the height of a given component. - * - * @param component the component to resize - * @param height the new height to apply - */ - public static void setComponentHeight(Component component, int height) { - component.setSize(component.getWidth(), height); - if (component instanceof JComponent) { - JComponent jcomponent = (JComponent) component; - jcomponent.setPreferredSize(new Dimension(jcomponent.getPreferredSize().width, height)); - jcomponent.setMinimumSize(new Dimension(jcomponent.getPreferredSize().width, height)); - if (jcomponent.isDisplayable()) { - jcomponent.revalidate(); - } - } - } - - public static ImageIcon createIcon(String path) { - java.net.URL imgURL = Util.class.getResource(path); - if (imgURL != null) { - return new ImageIcon(imgURL); - } else { - throw new IllegalArgumentException("could not find icon " + path); - } - } - - /** - * @param path the location of icons in root directory icons - * @return the icon at {@link #getIconPath()}+path - */ - public static ImageIcon createImageIcon(String path) { - String iconPath = getIconPath(); - return createIcon(iconPath + path); - } - - /** - * @param key the key of the icon to retreave from {@link UIManager} - * @return the icon, or <code>null if no icon found in {@link UIManager} - */ - public static Icon getUIManagerIcon(String key) { - return UIManager.getIcon(key); - } - - /** - * retreave for the {@link UIManager} the icon prefixed by <code>action.</code> - * - * @param key the key of the action icon to retreave from {@link UIManager} - * @return the icon, or <code>null if no icon found in {@link UIManager} - */ - public static Icon getUIManagerActionIcon(String key) { - return getUIManagerIcon("action." + key); - } - - public static ImageIcon createActionIcon(String name) { - String iconPath = getIconPath(); - return createIcon(iconPath + "action-" + name + ".png"); - } - - public static ImageIcon createI18nIcon(String name) { - String iconPath = getIconPath(); - return createIcon(iconPath + "i18n/" + name + ".png"); - } - - private static String getIconPath() { - String iconPath = UIManager.getString(DEFAULT_ICON_PATH_PROPERTY); - if (iconPath == null) { - iconPath = DEFAULT_ICON_PATH; - } else { - if (!iconPath.endsWith("/")) { - iconPath += "/"; - } - } - return iconPath; - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,920 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package 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.*; +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.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.renderer.BooleanCellRenderer; +import jaxx.runtime.swing.renderer.EmptyNumberTableCellRenderer; +import jaxx.runtime.swing.renderer.EnumTableCellRenderer; +import jaxx.runtime.swing.renderer.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. + * <p/> + * 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); + public static final String DEFAULT_ICON_PATH = "/icons/"; + public static final String DEFAULT_ICON_PATH_PROPERTY = "default.icon.path"; + 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 list model with some datas, and select after all the given object + * + * @param list the list to fill + * @param data data ot inject in combo + * @param select the object to select in combo after reflling his model + */ + public static void fillList(JList list, Collection<?> data, Object select) { + if (!(list.getModel() instanceof DefaultListModel)) { + throw new IllegalArgumentException("this method need a DefaultListModel for this model but was " + list.getModel().getClass()); + } + DefaultListModel model = (DefaultListModel) list.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); + list.setSelectedValue(select, true); + } + + /** + * TODO move this to JAXXComboBox. + * <p/> + * 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 + * @deprecated since 1.7.XXX this code is moved to JAXXComboBox + */ + @Deprecated + 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); + } + + /** + * 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 + */ + @SuppressWarnings({"unchecked"}) + public static <O extends Container> O getParentContainer(Object top, Class<O> clazz) { + if (top == null) { + throw new IllegalArgumentException("top parameter can not be null"); + } + if (!Container.class.isAssignableFrom(top.getClass())) { + throw new IllegalArgumentException("top parameter " + top + " is not a " + Container.class); + } + Container parent = ((Container) top).getParent(); + if (parent != null && !clazz.isAssignableFrom(parent.getClass())) { + parent = getParentContainer(parent, clazz); + } + return (O) parent; + } + + 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. + * <p/> + * <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. + * <p/> + * Says using method {@link JTabbedPane#getComponent(int)} + * + * @param tabs the + * @return the iterator + * @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}. + * <p/> + * Implements the method {@link #get(int, java.awt.Component)} to obtain + * the data required given the component (or index). + * <p/> + * You can also inverse the order by usin the method {@link #reverse()}. + * <p/> + * 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 = 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 the deppest component + */ + 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}. + * <p/> + * 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); + } + } + } + }); + } + } + }); + } + + /** + * Set the width of the given component + * + * @param component the component to resize + * @param width the new width to apply + */ + public static void setComponentWidth(Component component, int width) { + component.setSize(width, component.getHeight()); + if (component instanceof JComponent) { + JComponent jcomponent = (JComponent) component; + jcomponent.setPreferredSize(new Dimension(width, jcomponent.getPreferredSize().height)); + jcomponent.setMinimumSize(new Dimension(width, jcomponent.getPreferredSize().height)); + if (jcomponent.isDisplayable()) { + jcomponent.revalidate(); + } + } + } + /** + * Set the height of a given component. + * + * @param component the component to resize + * @param height the new height to apply + */ + public static void setComponentHeight(Component component, int height) { + component.setSize(component.getWidth(), height); + if (component instanceof JComponent) { + JComponent jcomponent = (JComponent) component; + jcomponent.setPreferredSize(new Dimension(jcomponent.getPreferredSize().width, height)); + jcomponent.setMinimumSize(new Dimension(jcomponent.getPreferredSize().width, height)); + if (jcomponent.isDisplayable()) { + jcomponent.revalidate(); + } + } + } + + public static ImageIcon createIcon(String path) { + java.net.URL imgURL = Util.class.getResource(path); + if (imgURL != null) { + return new ImageIcon(imgURL); + } else { + throw new IllegalArgumentException("could not find icon " + path); + } + } + + /** + * @param path the location of icons in root directory icons + * @return the icon at {@link #getIconPath()}+path + */ + public static ImageIcon createImageIcon(String path) { + String iconPath = getIconPath(); + return createIcon(iconPath + path); + } + + /** + * @param key the key of the icon to retreave from {@link UIManager} + * @return the icon, or <code>null if no icon found in {@link UIManager} + */ + public static Icon getUIManagerIcon(String key) { + return UIManager.getIcon(key); + } + + /** + * retreave for the {@link UIManager} the icon prefixed by <code>action.</code> + * + * @param key the key of the action icon to retreave from {@link UIManager} + * @return the icon, or <code>null if no icon found in {@link UIManager} + */ + public static Icon getUIManagerActionIcon(String key) { + return getUIManagerIcon("action." + key); + } + + public static ImageIcon createActionIcon(String name) { + String iconPath = getIconPath(); + return createIcon(iconPath + "action-" + name + ".png"); + } + + public static ImageIcon createI18nIcon(String name) { + String iconPath = getIconPath(); + return createIcon(iconPath + "i18n/" + name + ".png"); + } + + private static String getIconPath() { + String iconPath = UIManager.getString(DEFAULT_ICON_PATH_PROPERTY); + if (iconPath == null) { + iconPath = DEFAULT_ICON_PATH; + } else { + if (!iconPath.endsWith("/")) { + iconPath += "/"; + } + } + return iconPath; + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/Util.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Util.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/Util.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,505 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime; - -import jaxx.runtime.context.JAXXContextEntryDef; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeListenerProxy; -import java.io.IOException; -import java.lang.ref.WeakReference; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; -import java.util.*; - -public class Util { - - // public static final String DEFAULT_ICON_PATH = "/icons/"; - // public static final String DEFAULT_ICON_PATH_PROPERTY = "default.icon.path"; - /** - * Logger - */ - static private final Log log = LogFactory.getLog(Util.class); - public static final String PARENT = "parent"; - // 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; - 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 - * for the rationale behind this (admittedly ugly) approach. - * - * @param descriptor descriptor to decode - * @return the dedoced descriptor - */ - public static JAXXObjectDescriptor decodeJAXXObjectDescriptor(String descriptor) { - try { - return (JAXXObjectDescriptor) Base64Coder.deserialize(descriptor, false); - /*byte[] data = new byte[descriptor.length()]; - // copy low-order bytes into the array. The high-order bytes should all be zero. - System.arraycopy(descriptor.getBytes(), 0, data, 0, data.length); - //descriptor.getBytes(0, descriptor.length(), data, 0); - ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(data)); - return (JAXXObjectDescriptor) in.readObject();*/ - } catch (IOException e) { - throw new RuntimeException("Internal error: can't-happen error", 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); - - /*byte[] data = new byte[descriptor.length()]; - // copy low-order bytes into the array. The high-order bytes should all be zero. - System.arraycopy(descriptor.getBytes(), 0, data, 0, data.length); - //descriptor.getBytes(0, descriptor.length(), data, 0); - ObjectInputStream in = new ObjectInputStream(new GZIPInputStream(new ByteArrayInputStream(data))); - return (JAXXObjectDescriptor) in.readObject();*/ - } catch (IOException e) { - throw new RuntimeException("Internal error: can't-happen error", e); - } catch (ClassNotFoundException e) { - throw new RuntimeException("Internal error: can't-happen error", e); - } - } - - public static <O> JAXXContextEntryDef<O> newContextEntryDef(Class<O> klass) { - return newContextEntryDef(null, klass); - } - - public static <O> JAXXContextEntryDef<O> newContextEntryDef(String name, Class<O> klass) { - return new JAXXContextEntryDef<O>(name, klass); - } - - public static <O> JAXXContextEntryDef<List<O>> newListContextEntryDef() { - return newListContextEntryDef(null); - } - - public static <O> JAXXContextEntryDef<List<O>> newListContextEntryDef(String name) { - Class<List<O>> castList = Util.castList(); - JAXXContextEntryDef<List<O>> contextEntryDef = new JAXXContextEntryDef<List<O>>(name, castList); - return contextEntryDef; - } - -// public static JAXXBinding registerBinding(Map<String, JAXXBinding> bindings, JAXXBinding binding) { -// bindings.put(binding.getId(), binding); -//// binding.applyDataBinding(); -//// binding.processDataBinding(); -// return binding; -// } - -// /** -// * 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 -// */ -// @SuppressWarnings({"unchecked"}) -// public static <O extends Container> O getParentContainer(Object top, Class<O> clazz) { -// if (top == null) { -// throw new IllegalArgumentException("top parameter can not be null"); -// } -// if (!Container.class.isAssignableFrom(top.getClass())) { -// throw new IllegalArgumentException("top parameter " + top + " is not a " + Container.class); -// } -// Container parent = ((Container) top).getParent(); -// if (parent != null && !clazz.isAssignableFrom(parent.getClass())) { -// parent = getParentContainer(parent, clazz); -// } -// return (O) parent; -// } - - @SuppressWarnings({"unchecked"}) - protected static <O> Class<List<O>> castList() { - return (Class<List<O>>) Collections.emptyList().getClass(); - } - - /** - * Method to initialize the context of a ui. - * - * @param ui the ui - * @param parentContext the context to set in ui - */ - public static void initContext(JAXXObject ui, JAXXContext parentContext) { - - if (parentContext instanceof jaxx.runtime.context.JAXXInitialContext) { - ((jaxx.runtime.context.JAXXInitialContext) parentContext).to(ui); - } else { - ui.setContextValue(parentContext); - } - // if parentContext is a JAXXObject then - // add an special parent entry to can go up - if (parentContext instanceof JAXXObject) { - ui.setContextValue(parentContext, PARENT); - } - } - - public static <E extends EventListener> E getEventListener(Class<E> 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; - if (descriptors == null) { - descriptors = new ArrayList<EventListenerDescriptor>(); - eventListeners.put(methodContainer, new WeakReference<List<EventListenerDescriptor>>(descriptors)); - } else { - for (EventListenerDescriptor descriptor : descriptors) { - if (listenerClass == descriptor.listenerClass && - (listenerMethodName == null ? descriptor.listenerMethodName == null : listenerMethodName.equals(descriptor.listenerMethodName)) && - methodName.equals(descriptor.methodName)) { - return (E) descriptor.eventListener; - } - } - } - - // else we need to create a new listener - final EventListenerDescriptor descriptor = new EventListenerDescriptor(); - descriptor.listenerClass = listenerClass; - descriptor.listenerMethodName = listenerMethodName; - descriptor.methodName = methodName; - try { - final List<Method> listenerMethods = Arrays.asList(listenerClass.getMethods()); - Method listenerMethod = null; - if (listenerMethodName != null) { - for (Method listenerMethod1 : listenerMethods) { - if ((listenerMethod1).getName().equals(listenerMethodName)) { - listenerMethod = listenerMethod1; - break; - } - } - } - if (listenerMethodName != null && listenerMethod == null) { - throw new IllegalArgumentException("no method named " + listenerMethodName + " found in class " + listenerClass.getName()); - } - 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 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 { - targetMethod.setAccessible(true); - return targetMethod.invoke(methodContainer, args); - } catch (IllegalAccessException e) { - throw new RuntimeException("could not invoke on container " + methodContainer, e); - } catch (InvocationTargetException e) { - throw new RuntimeException(e); - } - } - if (methodName.equals("toString")) { - return toString(); - } - if (methodName.equals("equals")) { - return descriptor.eventListener == args[0]; - } - if (methodName.equals("hashCode")) { - return hashCode(); - } - return null; - } - }); - descriptors.add(descriptor); - return (E) descriptor.eventListener; - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } - } - - public static <E extends EventListener> E getEventListener(Class<E> 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(); - if (listeners == null) { - listeners = new ArrayList<DataBindingUpdateListener>(); - dataBindingUpdateListeners.put(object, new WeakReference<List<DataBindingUpdateListener>>(listeners)); - } else { - for (DataBindingUpdateListener listener : listeners) { - if (bindingName.equals(listener.getBindingName())) { - return listener; - } - } - } - DataBindingUpdateListener listener = new DataBindingUpdateListener(object, bindingName); - listeners.add(listener); - return listener; - } - -// public static void setComponentWidth(Component component, int width) { -// component.setSize(width, component.getHeight()); -// if (component instanceof JComponent) { -// JComponent jcomponent = (JComponent) component; -// jcomponent.setPreferredSize(new Dimension(width, jcomponent.getPreferredSize().height)); -// jcomponent.setMinimumSize(new Dimension(width, jcomponent.getPreferredSize().height)); -// if (jcomponent.isDisplayable()) { -// jcomponent.revalidate(); -// } -// } -// } - -// public static void setComponentHeight(Component component, int height) { -// component.setSize(component.getWidth(), height); -// if (component instanceof JComponent) { -// JComponent jcomponent = (JComponent) component; -// jcomponent.setPreferredSize(new Dimension(jcomponent.getPreferredSize().width, height)); -// jcomponent.setMinimumSize(new Dimension(jcomponent.getPreferredSize().width, height)); -// if (jcomponent.isDisplayable()) { -// jcomponent.revalidate(); -// } -// } -// } - - 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; - } - - /** - * Compute the string representation of an object. - * <p/> - * Return empty string if given object is null - * - * @param value the value to write - * @return the string representation of the given object or an empty string if object is null. - */ - public static String getStringValue(Object value) { - String result; - result = value == null ? "" : value.toString(); - return result; - } - - /** - * Test if a type of entry exists in a given context and throw an IllegalArgumentException if not found. - * <p/> - * If entry is found, return his value in context. - * - * @param <T> the type of required data - * @param context the context to test - * @param def the definition of the entry to seek in context - * @return the value from the context - * @throws IllegalArgumentException if the entry is not found in context. - */ - public static <T> T checkJAXXContextEntry(JAXXContext context, JAXXContextEntryDef<T> def) throws IllegalArgumentException { - - T value = def.getContextValue(context); - - if (value == null) { - throw new IllegalArgumentException("the context entry [" + def + "] ] was not found in context " + context); - } - - return value; - } - - /** - * Convinient method to apply more than one binding on a JAXX ui. - * - * @param src the ui to treate - * @param bindings the list of binding to process. - */ - public static void applyDataBinding(JAXXObject src, String... bindings) { - for (String binding : bindings) { - src.applyDataBinding(binding); - } - } - - /** - * Convinient method to process more than one binding on a JAXX ui. - * - * @param src the ui to treate - * @param bindings the list of binding to process. - */ - public static void processDataBinding(JAXXObject src, String... bindings) { - for (String binding : bindings) { - src.processDataBinding(binding); - } - } - - /** - * Convinient method to remove more than one binding on a JAXX ui. - * - * @param src the ui to treate - * @param bindings the list of binding to process. - */ - public static void removeDataBinding(JAXXObject src, String... bindings) { - for (String binding : bindings) { - src.removeDataBinding(binding); - } - } - -// public static ImageIcon createIcon(String path) { -// java.net.URL imgURL = Util.class.getResource(path); -// if (imgURL != null) { -// return new ImageIcon(imgURL); -// } else { -// throw new IllegalArgumentException("could not find icon " + path); -// } -// } - -// /** -// * @param path the location of icons in root directory icons -// * @return the icon at {@link #getIconPath()}+path -// */ -// public static ImageIcon createImageIcon(String path) { -// String iconPath = getIconPath(); -// return createIcon(iconPath + path); -// } -// -// /** -// * @param key the key of the icon to retreave from {@link UIManager} -// * @return the icon, or <code>null if no icon found in {@link UIManager} -// */ -// public static Icon getUIManagerIcon(String key) { -// return UIManager.getIcon(key); -// } -// -// /** -// * retreave for the {@link UIManager} the icon prefixed by <code>action.</code> -// * -// * @param key the key of the action icon to retreave from {@link UIManager} -// * @return the icon, or <code>null if no icon found in {@link UIManager} -// */ -// public static Icon getUIManagerActionIcon(String key) { -// return getUIManagerIcon("action." + key); -// } -// -// public static ImageIcon createActionIcon(String name) { -// String iconPath = getIconPath(); -// return createIcon(iconPath + "action-" + name + ".png"); -// } -// -// public static ImageIcon createI18nIcon(String name) { -// String iconPath = getIconPath(); -// return createIcon(iconPath + "i18n/" + name + ".png"); -// } - - /** - * detects all PropertychangedListener added by Jaxx uis - * (should be a {@link DataBindingListener} - * - * @param propertyNames the array of property names to find - * @param listeners the array of listeners to filter - * @return the filtered listeners - */ - public static PropertyChangeListener[] findJaxxPropertyChangeListener(String[] propertyNames, PropertyChangeListener... listeners) { - if (listeners == null || listeners.length == 0) { - return new PropertyChangeListener[0]; - } - List<String> pNames = Arrays.asList(propertyNames); - - List<PropertyChangeListener> toRemove = new ArrayList<PropertyChangeListener>(); - - for (PropertyChangeListener listener : listeners) { - String pName = null; - PropertyChangeListenerProxy plistener = null; - if (listener instanceof PropertyChangeListenerProxy) { - plistener = (PropertyChangeListenerProxy) listener; - if (!pNames.contains(plistener.getPropertyName())) { - // not on the good property - continue; - } - listener = (PropertyChangeListener) plistener.getListener(); - pName = plistener.getPropertyName(); - } - if (plistener != null && pName != null && listener instanceof DataBindingListener) { - if (log.isDebugEnabled()) { - log.debug("find config listener to remove [" + pName + "] : " + listener); - } - toRemove.add(plistener); - //toRemove.add(listener); - } - } - return toRemove.toArray(new PropertyChangeListener[toRemove.size()]); - } - -// private static String getIconPath() { -// String iconPath = UIManager.getString(DEFAULT_ICON_PATH_PROPERTY); -// if (iconPath == null) { -// iconPath = DEFAULT_ICON_PATH; -// } else { -// if (!iconPath.endsWith("/")) { -// iconPath += "/"; -// } -// } -// return iconPath; -// } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/Util.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Util.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/Util.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/Util.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,505 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime; + +import jaxx.runtime.context.JAXXContextEntryDef; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeListenerProxy; +import java.io.IOException; +import java.lang.ref.WeakReference; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.util.*; + +public class Util { + + // public static final String DEFAULT_ICON_PATH = "/icons/"; + // public static final String DEFAULT_ICON_PATH_PROPERTY = "default.icon.path"; + /** + * Logger + */ + static private final Log log = LogFactory.getLog(Util.class); + public static final String PARENT = "parent"; + // 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; + 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 + * for the rationale behind this (admittedly ugly) approach. + * + * @param descriptor descriptor to decode + * @return the dedoced descriptor + */ + public static JAXXObjectDescriptor decodeJAXXObjectDescriptor(String descriptor) { + try { + return (JAXXObjectDescriptor) Base64Coder.deserialize(descriptor, false); + /*byte[] data = new byte[descriptor.length()]; + // copy low-order bytes into the array. The high-order bytes should all be zero. + System.arraycopy(descriptor.getBytes(), 0, data, 0, data.length); + //descriptor.getBytes(0, descriptor.length(), data, 0); + ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(data)); + return (JAXXObjectDescriptor) in.readObject();*/ + } catch (IOException e) { + throw new RuntimeException("Internal error: can't-happen error", 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); + + /*byte[] data = new byte[descriptor.length()]; + // copy low-order bytes into the array. The high-order bytes should all be zero. + System.arraycopy(descriptor.getBytes(), 0, data, 0, data.length); + //descriptor.getBytes(0, descriptor.length(), data, 0); + ObjectInputStream in = new ObjectInputStream(new GZIPInputStream(new ByteArrayInputStream(data))); + return (JAXXObjectDescriptor) in.readObject();*/ + } catch (IOException e) { + throw new RuntimeException("Internal error: can't-happen error", e); + } catch (ClassNotFoundException e) { + throw new RuntimeException("Internal error: can't-happen error", e); + } + } + + public static <O> JAXXContextEntryDef<O> newContextEntryDef(Class<O> klass) { + return newContextEntryDef(null, klass); + } + + public static <O> JAXXContextEntryDef<O> newContextEntryDef(String name, Class<O> klass) { + return new JAXXContextEntryDef<O>(name, klass); + } + + public static <O> JAXXContextEntryDef<List<O>> newListContextEntryDef() { + return newListContextEntryDef(null); + } + + public static <O> JAXXContextEntryDef<List<O>> newListContextEntryDef(String name) { + Class<List<O>> castList = Util.castList(); + JAXXContextEntryDef<List<O>> contextEntryDef = new JAXXContextEntryDef<List<O>>(name, castList); + return contextEntryDef; + } + +// public static JAXXBinding registerBinding(Map<String, JAXXBinding> bindings, JAXXBinding binding) { +// bindings.put(binding.getId(), binding); +//// binding.applyDataBinding(); +//// binding.processDataBinding(); +// return binding; +// } + +// /** +// * 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 +// */ +// @SuppressWarnings({"unchecked"}) +// public static <O extends Container> O getParentContainer(Object top, Class<O> clazz) { +// if (top == null) { +// throw new IllegalArgumentException("top parameter can not be null"); +// } +// if (!Container.class.isAssignableFrom(top.getClass())) { +// throw new IllegalArgumentException("top parameter " + top + " is not a " + Container.class); +// } +// Container parent = ((Container) top).getParent(); +// if (parent != null && !clazz.isAssignableFrom(parent.getClass())) { +// parent = getParentContainer(parent, clazz); +// } +// return (O) parent; +// } + + @SuppressWarnings({"unchecked"}) + protected static <O> Class<List<O>> castList() { + return (Class<List<O>>) Collections.emptyList().getClass(); + } + + /** + * Method to initialize the context of a ui. + * + * @param ui the ui + * @param parentContext the context to set in ui + */ + public static void initContext(JAXXObject ui, JAXXContext parentContext) { + + if (parentContext instanceof jaxx.runtime.context.JAXXInitialContext) { + ((jaxx.runtime.context.JAXXInitialContext) parentContext).to(ui); + } else { + ui.setContextValue(parentContext); + } + // if parentContext is a JAXXObject then + // add an special parent entry to can go up + if (parentContext instanceof JAXXObject) { + ui.setContextValue(parentContext, PARENT); + } + } + + public static <E extends EventListener> E getEventListener(Class<E> 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; + if (descriptors == null) { + descriptors = new ArrayList<EventListenerDescriptor>(); + eventListeners.put(methodContainer, new WeakReference<List<EventListenerDescriptor>>(descriptors)); + } else { + for (EventListenerDescriptor descriptor : descriptors) { + if (listenerClass == descriptor.listenerClass && + (listenerMethodName == null ? descriptor.listenerMethodName == null : listenerMethodName.equals(descriptor.listenerMethodName)) && + methodName.equals(descriptor.methodName)) { + return (E) descriptor.eventListener; + } + } + } + + // else we need to create a new listener + final EventListenerDescriptor descriptor = new EventListenerDescriptor(); + descriptor.listenerClass = listenerClass; + descriptor.listenerMethodName = listenerMethodName; + descriptor.methodName = methodName; + try { + final List<Method> listenerMethods = Arrays.asList(listenerClass.getMethods()); + Method listenerMethod = null; + if (listenerMethodName != null) { + for (Method listenerMethod1 : listenerMethods) { + if ((listenerMethod1).getName().equals(listenerMethodName)) { + listenerMethod = listenerMethod1; + break; + } + } + } + if (listenerMethodName != null && listenerMethod == null) { + throw new IllegalArgumentException("no method named " + listenerMethodName + " found in class " + listenerClass.getName()); + } + 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 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 { + targetMethod.setAccessible(true); + return targetMethod.invoke(methodContainer, args); + } catch (IllegalAccessException e) { + throw new RuntimeException("could not invoke on container " + methodContainer, e); + } catch (InvocationTargetException e) { + throw new RuntimeException(e); + } + } + if (methodName.equals("toString")) { + return toString(); + } + if (methodName.equals("equals")) { + return descriptor.eventListener == args[0]; + } + if (methodName.equals("hashCode")) { + return hashCode(); + } + return null; + } + }); + descriptors.add(descriptor); + return (E) descriptor.eventListener; + } catch (NoSuchMethodException e) { + throw new RuntimeException(e); + } + } + + public static <E extends EventListener> E getEventListener(Class<E> 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(); + if (listeners == null) { + listeners = new ArrayList<DataBindingUpdateListener>(); + dataBindingUpdateListeners.put(object, new WeakReference<List<DataBindingUpdateListener>>(listeners)); + } else { + for (DataBindingUpdateListener listener : listeners) { + if (bindingName.equals(listener.getBindingName())) { + return listener; + } + } + } + DataBindingUpdateListener listener = new DataBindingUpdateListener(object, bindingName); + listeners.add(listener); + return listener; + } + +// public static void setComponentWidth(Component component, int width) { +// component.setSize(width, component.getHeight()); +// if (component instanceof JComponent) { +// JComponent jcomponent = (JComponent) component; +// jcomponent.setPreferredSize(new Dimension(width, jcomponent.getPreferredSize().height)); +// jcomponent.setMinimumSize(new Dimension(width, jcomponent.getPreferredSize().height)); +// if (jcomponent.isDisplayable()) { +// jcomponent.revalidate(); +// } +// } +// } + +// public static void setComponentHeight(Component component, int height) { +// component.setSize(component.getWidth(), height); +// if (component instanceof JComponent) { +// JComponent jcomponent = (JComponent) component; +// jcomponent.setPreferredSize(new Dimension(jcomponent.getPreferredSize().width, height)); +// jcomponent.setMinimumSize(new Dimension(jcomponent.getPreferredSize().width, height)); +// if (jcomponent.isDisplayable()) { +// jcomponent.revalidate(); +// } +// } +// } + + 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; + } + + /** + * Compute the string representation of an object. + * <p/> + * Return empty string if given object is null + * + * @param value the value to write + * @return the string representation of the given object or an empty string if object is null. + */ + public static String getStringValue(Object value) { + String result; + result = value == null ? "" : value.toString(); + return result; + } + + /** + * Test if a type of entry exists in a given context and throw an IllegalArgumentException if not found. + * <p/> + * If entry is found, return his value in context. + * + * @param <T> the type of required data + * @param context the context to test + * @param def the definition of the entry to seek in context + * @return the value from the context + * @throws IllegalArgumentException if the entry is not found in context. + */ + public static <T> T checkJAXXContextEntry(JAXXContext context, JAXXContextEntryDef<T> def) throws IllegalArgumentException { + + T value = def.getContextValue(context); + + if (value == null) { + throw new IllegalArgumentException("the context entry [" + def + "] ] was not found in context " + context); + } + + return value; + } + + /** + * Convinient method to apply more than one binding on a JAXX ui. + * + * @param src the ui to treate + * @param bindings the list of binding to process. + */ + public static void applyDataBinding(JAXXObject src, String... bindings) { + for (String binding : bindings) { + src.applyDataBinding(binding); + } + } + + /** + * Convinient method to process more than one binding on a JAXX ui. + * + * @param src the ui to treate + * @param bindings the list of binding to process. + */ + public static void processDataBinding(JAXXObject src, String... bindings) { + for (String binding : bindings) { + src.processDataBinding(binding); + } + } + + /** + * Convinient method to remove more than one binding on a JAXX ui. + * + * @param src the ui to treate + * @param bindings the list of binding to process. + */ + public static void removeDataBinding(JAXXObject src, String... bindings) { + for (String binding : bindings) { + src.removeDataBinding(binding); + } + } + +// public static ImageIcon createIcon(String path) { +// java.net.URL imgURL = Util.class.getResource(path); +// if (imgURL != null) { +// return new ImageIcon(imgURL); +// } else { +// throw new IllegalArgumentException("could not find icon " + path); +// } +// } + +// /** +// * @param path the location of icons in root directory icons +// * @return the icon at {@link #getIconPath()}+path +// */ +// public static ImageIcon createImageIcon(String path) { +// String iconPath = getIconPath(); +// return createIcon(iconPath + path); +// } +// +// /** +// * @param key the key of the icon to retreave from {@link UIManager} +// * @return the icon, or <code>null if no icon found in {@link UIManager} +// */ +// public static Icon getUIManagerIcon(String key) { +// return UIManager.getIcon(key); +// } +// +// /** +// * retreave for the {@link UIManager} the icon prefixed by <code>action.</code> +// * +// * @param key the key of the action icon to retreave from {@link UIManager} +// * @return the icon, or <code>null if no icon found in {@link UIManager} +// */ +// public static Icon getUIManagerActionIcon(String key) { +// return getUIManagerIcon("action." + key); +// } +// +// public static ImageIcon createActionIcon(String name) { +// String iconPath = getIconPath(); +// return createIcon(iconPath + "action-" + name + ".png"); +// } +// +// public static ImageIcon createI18nIcon(String name) { +// String iconPath = getIconPath(); +// return createIcon(iconPath + "i18n/" + name + ".png"); +// } + + /** + * detects all PropertychangedListener added by Jaxx uis + * (should be a {@link DataBindingListener} + * + * @param propertyNames the array of property names to find + * @param listeners the array of listeners to filter + * @return the filtered listeners + */ + public static PropertyChangeListener[] findJaxxPropertyChangeListener(String[] propertyNames, PropertyChangeListener... listeners) { + if (listeners == null || listeners.length == 0) { + return new PropertyChangeListener[0]; + } + List<String> pNames = Arrays.asList(propertyNames); + + List<PropertyChangeListener> toRemove = new ArrayList<PropertyChangeListener>(); + + for (PropertyChangeListener listener : listeners) { + String pName = null; + PropertyChangeListenerProxy plistener = null; + if (listener instanceof PropertyChangeListenerProxy) { + plistener = (PropertyChangeListenerProxy) listener; + if (!pNames.contains(plistener.getPropertyName())) { + // not on the good property + continue; + } + listener = (PropertyChangeListener) plistener.getListener(); + pName = plistener.getPropertyName(); + } + if (plistener != null && pName != null && listener instanceof DataBindingListener) { + if (log.isDebugEnabled()) { + log.debug("find config listener to remove [" + pName + "] : " + listener); + } + toRemove.add(plistener); + //toRemove.add(listener); + } + } + return toRemove.toArray(new PropertyChangeListener[toRemove.size()]); + } + +// private static String getIconPath() { +// String iconPath = UIManager.getString(DEFAULT_ICON_PATH_PROPERTY); +// if (iconPath == null) { +// iconPath = DEFAULT_ICON_PATH; +// } else { +// if (!iconPath.endsWith("/")) { +// iconPath += "/"; +// } +// } +// return iconPath; +// } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,422 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.context; - -import jaxx.runtime.JAXXContext; -import jaxx.runtime.Util; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.util.Iterator; -import java.util.NoSuchElementException; -import java.util.regex.Pattern; - -/** - * Un contexte de données qui permet l'utilisation des bindings sur les - * entrées du contexte. - * - * TODO javadoc - * - * @author tony - * @since 1.3 - */ -public abstract class DataContext { - - /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(DataContext.class); - /** le context qui contient les données */ - protected final DefaultJAXXContext delegate; - /** la definition de l'entree actuallement selectionnee */ - protected DataContextEntry<?> currentEntry; - /** to manage properties modifications */ - protected final PropertyChangeSupport pcs; - protected DataContextEntry<?>[] entries; - protected final String[] DEFAULT_JAXX_PCS; - - public abstract String getContextPath(Object... e); - - public DataContext(String[] DEFAULT_JAXX_PCS, DataContextEntry<?>[] entries) { - this.DEFAULT_JAXX_PCS = DEFAULT_JAXX_PCS; - this.entries = entries; - delegate = new DefaultJAXXContext() { - -// @Override -// protected void setUi(JAXXObject ui) { -// throw new IllegalStateException("can not use this method for this type of context"); -// } -// -// @Override -// public <O extends Container> O getParentContainer(Class<O> clazz) { -// throw new IllegalStateException("can not use this method for this type of context"); -// } -// -// @Override -// public <O extends Container> O getParentContainer(Object top, Class<O> clazz) { -// throw new IllegalStateException("can not use this method for this type of context"); -// } -// -// @Override -// protected JAXXObject getUi() { -// throw new IllegalStateException("can not use this method for this type of context"); -// } - - @Override - protected void setParentContext(JAXXContext parentContext) { - throw new IllegalStateException("can not use this method for this type of context"); - } - - @Override - protected JAXXContext getParentContext() { - return null; - } - - @Override - public <T> void removeContextValue(Class<T> klazz, String name) { - if (log.isTraceEnabled()) { - log.trace(klazz + " - " + name); - } - super.removeContextValue(klazz, name); - } - - @Override - public <T> void setContextValue(T o, String name) { - if (log.isTraceEnabled()) { - log.trace(name + " - " + o.getClass()); - } - super.setContextValue(o, name); - } - }; - pcs = new PropertyChangeSupport(this); - } - - public DefaultJAXXContext getDelegate() { - return delegate; - } - - public Iterable<? extends DataContextEntry<?>> iterateOnAll() { - return new Iterable<DataContextEntry<?>>() { - - @Override - public Iterator<DataContextEntry<?>> iterator() { - return new DataContextEntryIterator(entries); - } - }; - } - - public Iterable<? extends DataContextEntry<?>> iterateToLevel(final int level) { - return new Iterable<DataContextEntry<?>>() { - - @Override - public Iterator<DataContextEntry<?>> iterator() { - return new DataContextEntryIterator(entries, level); - } - }; - } - - public Iterable<? extends DataContextEntry<?>> reverseIterateOnAll() { - - return new Iterable<DataContextEntry<?>>() { - - @Override - public Iterator<DataContextEntry<?>> iterator() { - return new DataContextEntryIterator(entries, true); - } - }; - } - - public DataContextEntry<?> getCurrentEntry() { - return currentEntry; - } - - public DataContextEntry<?> getEntry(String path) { - for (DataContextEntry<?> scope : reverseIterateOnAll()) { - if (scope.acceptPath(path)) { - return scope; - } - } - return null; - } - - public DataContextEntry<?> getEntry(Class<?> type) { - for (DataContextEntry<?> scope : iterateOnAll()) { - if (scope.acceptType(type)) { - return scope; - } - } - return null; - } - - public <T> T getContextValue(DataContextEntry<T> entry, String key) { - String contextKey = getKey(entry, key); - T result = delegate.getContextValue(entry.getKlass(), contextKey); - return result; - } - - 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) { - String contextKey = getKey(entry, key); - delegate.removeContextValue(value.getClass(), contextKey); - } - - @SuppressWarnings("unchecked") - public void updateSelectedData(String path, Object data, UpdateDataContext updator) { - - if (log.isDebugEnabled()) { - log.debug("----------------------------------------------------------------"); - } - if (currentEntry != null) { - - if (log.isDebugEnabled()) { - log.debug("remove from old entry " + currentEntry); - } - for (DataContextEntry<?> s : currentEntry) { - if (log.isDebugEnabled()) { - log.debug("remove entry " + s); - } - updator.onRemovingData(this, s); - } - } - - currentEntry = getEntry(path); - - if (log.isDebugEnabled()) { - log.debug("new entry " + currentEntry + " for path " + path); - } - - if (currentEntry != null) { - - for (DataContextEntry<?> s : iterateToLevel(currentEntry.getLevel())) { - - if (log.isDebugEnabled()) { - log.debug("add entry " + s); - } - updator.onAddingData(this, s, path); - } - } - } - - 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 synchronized boolean hasListeners(String propertyName) { - return pcs.hasListeners(propertyName); - } - - public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) { - return pcs.getPropertyChangeListeners(propertyName); - } - - public synchronized PropertyChangeListener[] getPropertyChangeListeners() { - return pcs.getPropertyChangeListeners(); - } - - public void removeJaxxPropertyChangeListener() { - PropertyChangeListener[] toRemove = Util.findJaxxPropertyChangeListener(DEFAULT_JAXX_PCS, getPropertyChangeListeners()); - if (toRemove == null || toRemove.length == 0) { - return; - } - if (log.isDebugEnabled()) { - log.debug("before remove : " + getPropertyChangeListeners().length); - log.debug("toRemove : " + toRemove.length); - } - for (PropertyChangeListener listener : toRemove) { - removePropertyChangeListener(listener); - } - if (log.isDebugEnabled()) { - log.debug("after remove : " + getPropertyChangeListeners().length); - } - } - - protected void firePropertyChange(String name, Object oldValue, Object newValue) { - pcs.firePropertyChange(name, oldValue, newValue); - } - - protected String getKey(DataContextEntry<?> entry, String key) { - String result = null; - if (key != null) { - result = entry.hashCode() + "#" + key; - } - return result; - } - - public void close() throws Exception { - clear(); - - // suppression des ecouteurs - - for (PropertyChangeListener l : getPropertyChangeListeners()) { - removePropertyChangeListener(l); - } - } - - public void clear() { - delegate.clear(); - } - - public static abstract class DataContextEntry<E> implements Iterable<DataContextEntry<?>> { - - private final int level; - private final DataContextEntry<?> previous; - 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]; - int i = level; - while (i > 0) { - parents[--i] = previous; - previous = previous.previous; - } - } - - public DataContextEntry(Class<E> klass) { - this.level = 0; - this.klass = klass; - this.previous = null; - this.parents = new DataContextEntry<?>[0]; - } - - public Class<E> getKlass() { - return klass; - } - - public int getLevel() { - return level; - } - - public DataContextEntry<?>[] getParents() { - return parents; - } - - public abstract Pattern getPattern(); - - public abstract String getContextPath(Object... args); - - public boolean acceptPath(String path) { - return getPattern().matcher(path).matches(); - } - - public boolean acceptType(Class<?> type) { - return klass.isAssignableFrom(type); - } - - @Override - public Iterator<DataContextEntry<?>> iterator() { - int length = parents.length; - DataContextEntry<?>[] t = new DataContextEntry<?>[length + 1]; - System.arraycopy(parents, 0, t, 0, length); - t[length] = this; - return new DataContextEntryIterator(t, true); - } - - @Override - public String toString() { - return super.toString() + "<type: " + klass.getSimpleName() + ">"; - } - } - - public static interface UpdateDataContext<D extends DataContext> { - - void onRemovingData(D context, DataContextEntry<D> entry); - - void onAddingData(D context, DataContextEntry<D> entry, String path); - } - - public static class DataContextEntryIterator implements Iterator<DataContextEntry<?>> { - - protected final DataContextEntry<?>[] datas; - protected final boolean reverse; - protected final int level; - protected int index; - - public DataContextEntryIterator(DataContextEntry<?>[] datas) { - this(datas, false, -1); - } - - public DataContextEntryIterator(DataContextEntry<?>[] datas, int level) { - this(datas, false, level); - } - - public DataContextEntryIterator(DataContextEntry<?>[] datas, boolean reverse) { - this(datas, reverse, -1); - } - - DataContextEntryIterator(DataContextEntry<?>[] datas, boolean reverse, int level) { - this.datas = datas; - this.reverse = reverse; - if (reverse) { - index = datas.length; - } else { - index = -1; - } - this.level = level; - } - - @Override - public boolean hasNext() { - if (reverse) { - return index > 0; - } else { - return index + 1 < datas.length && (level == -1 || datas[index + 1].getLevel() <= level); - } - } - - @Override - public DataContextEntry<?> next() { - if (!hasNext()) { - throw new NoSuchElementException(); - } - if (reverse) { - index--; - } else { - index++; - } - return datas[index]; - } - - @Override - public void remove() { - throw new UnsupportedOperationException("Not supported yet."); - } - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,422 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.context; + +import jaxx.runtime.JAXXContext; +import jaxx.runtime.Util; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.regex.Pattern; + +/** + * Un contexte de données qui permet l'utilisation des bindings sur les + * entrées du contexte. + * + * TODO javadoc + * + * @author tony + * @since 1.3 + */ +public abstract class DataContext { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private Log log = LogFactory.getLog(DataContext.class); + /** le context qui contient les données */ + protected final DefaultJAXXContext delegate; + /** la definition de l'entree actuallement selectionnee */ + protected DataContextEntry<?> currentEntry; + /** to manage properties modifications */ + protected final PropertyChangeSupport pcs; + protected DataContextEntry<?>[] entries; + protected final String[] DEFAULT_JAXX_PCS; + + public abstract String getContextPath(Object... e); + + public DataContext(String[] DEFAULT_JAXX_PCS, DataContextEntry<?>[] entries) { + this.DEFAULT_JAXX_PCS = DEFAULT_JAXX_PCS; + this.entries = entries; + delegate = new DefaultJAXXContext() { + +// @Override +// protected void setUi(JAXXObject ui) { +// throw new IllegalStateException("can not use this method for this type of context"); +// } +// +// @Override +// public <O extends Container> O getParentContainer(Class<O> clazz) { +// throw new IllegalStateException("can not use this method for this type of context"); +// } +// +// @Override +// public <O extends Container> O getParentContainer(Object top, Class<O> clazz) { +// throw new IllegalStateException("can not use this method for this type of context"); +// } +// +// @Override +// protected JAXXObject getUi() { +// throw new IllegalStateException("can not use this method for this type of context"); +// } + + @Override + protected void setParentContext(JAXXContext parentContext) { + throw new IllegalStateException("can not use this method for this type of context"); + } + + @Override + protected JAXXContext getParentContext() { + return null; + } + + @Override + public <T> void removeContextValue(Class<T> klazz, String name) { + if (log.isTraceEnabled()) { + log.trace(klazz + " - " + name); + } + super.removeContextValue(klazz, name); + } + + @Override + public <T> void setContextValue(T o, String name) { + if (log.isTraceEnabled()) { + log.trace(name + " - " + o.getClass()); + } + super.setContextValue(o, name); + } + }; + pcs = new PropertyChangeSupport(this); + } + + public DefaultJAXXContext getDelegate() { + return delegate; + } + + public Iterable<? extends DataContextEntry<?>> iterateOnAll() { + return new Iterable<DataContextEntry<?>>() { + + @Override + public Iterator<DataContextEntry<?>> iterator() { + return new DataContextEntryIterator(entries); + } + }; + } + + public Iterable<? extends DataContextEntry<?>> iterateToLevel(final int level) { + return new Iterable<DataContextEntry<?>>() { + + @Override + public Iterator<DataContextEntry<?>> iterator() { + return new DataContextEntryIterator(entries, level); + } + }; + } + + public Iterable<? extends DataContextEntry<?>> reverseIterateOnAll() { + + return new Iterable<DataContextEntry<?>>() { + + @Override + public Iterator<DataContextEntry<?>> iterator() { + return new DataContextEntryIterator(entries, true); + } + }; + } + + public DataContextEntry<?> getCurrentEntry() { + return currentEntry; + } + + public DataContextEntry<?> getEntry(String path) { + for (DataContextEntry<?> scope : reverseIterateOnAll()) { + if (scope.acceptPath(path)) { + return scope; + } + } + return null; + } + + public DataContextEntry<?> getEntry(Class<?> type) { + for (DataContextEntry<?> scope : iterateOnAll()) { + if (scope.acceptType(type)) { + return scope; + } + } + return null; + } + + public <T> T getContextValue(DataContextEntry<T> entry, String key) { + String contextKey = getKey(entry, key); + T result = delegate.getContextValue(entry.getKlass(), contextKey); + return result; + } + + 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) { + String contextKey = getKey(entry, key); + delegate.removeContextValue(value.getClass(), contextKey); + } + + @SuppressWarnings("unchecked") + public void updateSelectedData(String path, Object data, UpdateDataContext updator) { + + if (log.isDebugEnabled()) { + log.debug("----------------------------------------------------------------"); + } + if (currentEntry != null) { + + if (log.isDebugEnabled()) { + log.debug("remove from old entry " + currentEntry); + } + for (DataContextEntry<?> s : currentEntry) { + if (log.isDebugEnabled()) { + log.debug("remove entry " + s); + } + updator.onRemovingData(this, s); + } + } + + currentEntry = getEntry(path); + + if (log.isDebugEnabled()) { + log.debug("new entry " + currentEntry + " for path " + path); + } + + if (currentEntry != null) { + + for (DataContextEntry<?> s : iterateToLevel(currentEntry.getLevel())) { + + if (log.isDebugEnabled()) { + log.debug("add entry " + s); + } + updator.onAddingData(this, s, path); + } + } + } + + 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 synchronized boolean hasListeners(String propertyName) { + return pcs.hasListeners(propertyName); + } + + public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) { + return pcs.getPropertyChangeListeners(propertyName); + } + + public synchronized PropertyChangeListener[] getPropertyChangeListeners() { + return pcs.getPropertyChangeListeners(); + } + + public void removeJaxxPropertyChangeListener() { + PropertyChangeListener[] toRemove = Util.findJaxxPropertyChangeListener(DEFAULT_JAXX_PCS, getPropertyChangeListeners()); + if (toRemove == null || toRemove.length == 0) { + return; + } + if (log.isDebugEnabled()) { + log.debug("before remove : " + getPropertyChangeListeners().length); + log.debug("toRemove : " + toRemove.length); + } + for (PropertyChangeListener listener : toRemove) { + removePropertyChangeListener(listener); + } + if (log.isDebugEnabled()) { + log.debug("after remove : " + getPropertyChangeListeners().length); + } + } + + protected void firePropertyChange(String name, Object oldValue, Object newValue) { + pcs.firePropertyChange(name, oldValue, newValue); + } + + protected String getKey(DataContextEntry<?> entry, String key) { + String result = null; + if (key != null) { + result = entry.hashCode() + "#" + key; + } + return result; + } + + public void close() throws Exception { + clear(); + + // suppression des ecouteurs + + for (PropertyChangeListener l : getPropertyChangeListeners()) { + removePropertyChangeListener(l); + } + } + + public void clear() { + delegate.clear(); + } + + public static abstract class DataContextEntry<E> implements Iterable<DataContextEntry<?>> { + + private final int level; + private final DataContextEntry<?> previous; + 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]; + int i = level; + while (i > 0) { + parents[--i] = previous; + previous = previous.previous; + } + } + + public DataContextEntry(Class<E> klass) { + this.level = 0; + this.klass = klass; + this.previous = null; + this.parents = new DataContextEntry<?>[0]; + } + + public Class<E> getKlass() { + return klass; + } + + public int getLevel() { + return level; + } + + public DataContextEntry<?>[] getParents() { + return parents; + } + + public abstract Pattern getPattern(); + + public abstract String getContextPath(Object... args); + + public boolean acceptPath(String path) { + return getPattern().matcher(path).matches(); + } + + public boolean acceptType(Class<?> type) { + return klass.isAssignableFrom(type); + } + + @Override + public Iterator<DataContextEntry<?>> iterator() { + int length = parents.length; + DataContextEntry<?>[] t = new DataContextEntry<?>[length + 1]; + System.arraycopy(parents, 0, t, 0, length); + t[length] = this; + return new DataContextEntryIterator(t, true); + } + + @Override + public String toString() { + return super.toString() + "<type: " + klass.getSimpleName() + ">"; + } + } + + public static interface UpdateDataContext<D extends DataContext> { + + void onRemovingData(D context, DataContextEntry<D> entry); + + void onAddingData(D context, DataContextEntry<D> entry, String path); + } + + public static class DataContextEntryIterator implements Iterator<DataContextEntry<?>> { + + protected final DataContextEntry<?>[] datas; + protected final boolean reverse; + protected final int level; + protected int index; + + public DataContextEntryIterator(DataContextEntry<?>[] datas) { + this(datas, false, -1); + } + + public DataContextEntryIterator(DataContextEntry<?>[] datas, int level) { + this(datas, false, level); + } + + public DataContextEntryIterator(DataContextEntry<?>[] datas, boolean reverse) { + this(datas, reverse, -1); + } + + DataContextEntryIterator(DataContextEntry<?>[] datas, boolean reverse, int level) { + this.datas = datas; + this.reverse = reverse; + if (reverse) { + index = datas.length; + } else { + index = -1; + } + this.level = level; + } + + @Override + public boolean hasNext() { + if (reverse) { + return index > 0; + } else { + return index + 1 < datas.length && (level == -1 || datas[index + 1].getLevel() <= level); + } + } + + @Override + public DataContextEntry<?> next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + if (reverse) { + index--; + } else { + index++; + } + return datas[index]; + } + + @Override + public void remove() { + throw new UnsupportedOperationException("Not supported yet."); + } + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,304 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.context; - -import jaxx.runtime.*; -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.lang.annotation.*; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * The default context to be used for an application. - * - * This extends the {@link DefaultJAXXContext} and add a possibility to auto-instanciate - * some classes asked via {@link #getContextValue(java.lang.Class)} and - * {@link #getContextValue(java.lang.Class, java.lang.String)} methods. - * - * To registred a such class, just annotate your class with {@link AutoLoad}. - * - * @author chemit - * @since 1.2 - * @see DefaultJAXXContext - */ -public class DefaultApplicationContext extends DefaultJAXXContext { - - /** - * A class annotated @AutoLoad is used by context to auto - * instanciate the class when required. - * - * Note : A such class always have a public default constructor. - * - * @author chemit - * @version 1.0, 21/02/09 - * @since 1.2 - */ - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - public static @interface AutoLoad { - //TODO use this to add a method to init - - String initMethod() default ""; - } - - /** - * A class annotated @MethodAccess is used by context to obtain the value - * of an entry via a declared method. - * - * Note : A such class must have a method called {@link #methodName()} with - * a single String parameter. - * - * @author chemit - * @version 1.0, 21/02/09 - * @since 1.2 - */ - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - public static @interface MethodAccess { - - /** - * Define a forward to a target class. When the target class - * will be asked with method {@link JAXXContext#getContextValue(java.lang.Class, java.lang.String)} - * it will be delegating to this class. - * - * @return the forwarded class - */ - Class<?> target() default Object.class; - - /** - * @return the name of the method to access data - */ - String methodName(); - } - /** - * Map of forwarded classes (key) to classes (values). - */ - protected Map<Class<?>, Class<?>> forwards; - - public DefaultApplicationContext() { - super(); - forwards = new HashMap<Class<?>, Class<?>>(); - pcs = new PropertyChangeSupport(this); - } - -// public DefaultApplicationContext(JAXXObject ui) { -// super(); -// } - /** to use log facility, just put in your code: log.info(\"...\"); */ - static private final Log log = LogFactory.getLog(DefaultApplicationContext.class); - - /** to manage properties modifications */ - protected PropertyChangeSupport pcs; - - @SuppressWarnings({"unchecked"}) - @Override - public <T> T getContextValue(Class<T> clazz, String name) { - Object value; - MethodAccess access; - - Class<?> realClass; - - if (forwards.containsKey(clazz)) { - // this is a forward class - realClass = forwards.get(clazz); - // always call the forwarder with no name - value = getContextValue(realClass, null); - if (log.isDebugEnabled()) { - log.debug("detect forward from " + clazz + " to " + realClass + " (" + value + ")"); - } - - } else { - realClass = clazz; - value = super.getContextValue(realClass, name); - } - - //TC-20091007 TODO Make possible use of named autoload entries - //(add a parameter on AutoLoad annotation) - if (value == null) { - AutoLoad anno = clazz.getAnnotation(AutoLoad.class); - - if (anno == null) { - // no annotation, so do nothing - return null; - } - - if (name != null) { - throw new IllegalArgumentException("an " + AutoLoad.class.getName() + " can not have a named context but was call with this one : " + name); - } - value = newInstance(clazz); - if (!anno.initMethod().trim().isEmpty()){ - // apply method on class - newAccess(clazz, value, anno.initMethod().trim()); - } - if (log.isDebugEnabled()) { - log.debug("new instance " + clazz + " : " + value); - } - // save new instance - setContextValue(value, null); - } - - access = realClass.getAnnotation(MethodAccess.class); - - if (access != null) { - if (name == null) { - if (access.target() != Object.class) { - // register forward - Class<?> targetClass = access.target(); - if (!forwards.containsKey(targetClass)) { - // register forward - forwards.put(targetClass, clazz); - if (log.isDebugEnabled()) { - log.debug("register forward from " + targetClass + " to " + clazz); - } - } - } - } else { - // specialized access - value = newAccess(realClass, value, access.methodName(), name); - } - } - return (T) value; - } - - @Override - public <T> void removeContextValue(Class<T> klazz, String name) { - Entry<Class<?>, Class<?>> entry; - if (name == null && forwards.containsValue(klazz)) { - // remove forward - Iterator<Entry<Class<?>, Class<?>>> itr = forwards.entrySet().iterator(); - while (itr.hasNext()) { - entry = itr.next(); - if (entry.getValue().equals(klazz)) { - itr.remove(); - if (log.isDebugEnabled()) { - log.debug("removed forward from " + entry.getKey() + " to " + klazz); - } - break; - } - } - } - //FIXME should update forwards state - super.removeContextValue(klazz, name); - } - - 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 synchronized boolean hasListeners(String propertyName) { - return pcs.hasListeners(propertyName); - } - - public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) { - return pcs.getPropertyChangeListeners(propertyName); - } - - public synchronized PropertyChangeListener[] getPropertyChangeListeners() { - return pcs.getPropertyChangeListeners(); - } - - protected Object newInstance(Class<?> clazz) throws IllegalArgumentException { - - Object value; - - Constructor<?> constructor; - try { - constructor = clazz.getConstructor(); - // auto instanciate the class - if (constructor == null) { - throw new IllegalArgumentException(clazz + " has no public constructor"); - } - } catch (NoSuchMethodException ex) { - throw new IllegalArgumentException(ex); - } catch (SecurityException ex) { - throw new IllegalArgumentException(ex); - } - try { - value = constructor.newInstance(); - - } catch (InstantiationException ex) { - throw new IllegalArgumentException(ex); - } catch (IllegalAccessException ex) { - throw new IllegalArgumentException(ex); - } catch (InvocationTargetException ex) { - throw new IllegalArgumentException(ex); - } - return value; - } - - protected Object newAccess(Class<?> clazz, Object parent, String methodName, String name) throws IllegalArgumentException { - Object value; - try { - Method m = clazz.getMethod(methodName, String.class); - value = m.invoke(parent, name); - return value; - } catch (NoSuchMethodException ex) { - throw new IllegalArgumentException(ex); - } catch (SecurityException ex) { - throw new IllegalArgumentException(ex); - } catch (IllegalAccessException ex) { - throw new IllegalArgumentException(ex); - } catch (InvocationTargetException ex) { - throw new IllegalArgumentException(ex); - } - } - - protected Object newAccess(Class<?> clazz, Object parent, String methodName) throws IllegalArgumentException { - Object value; - try { - Method m = clazz.getMethod(methodName); - value = m.invoke(parent); - return value; - } catch (NoSuchMethodException ex) { - throw new IllegalArgumentException(ex); - } catch (SecurityException ex) { - throw new IllegalArgumentException(ex); - } catch (IllegalAccessException ex) { - throw new IllegalArgumentException(ex); - } catch (InvocationTargetException ex) { - throw new IllegalArgumentException(ex); - } - } - - protected void firePropertyChange(String name, Object oldValue, Object newValue) { - pcs.firePropertyChange(name, oldValue, newValue); - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,304 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.context; + +import jaxx.runtime.*; +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.lang.annotation.*; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * The default context to be used for an application. + * + * This extends the {@link DefaultJAXXContext} and add a possibility to auto-instanciate + * some classes asked via {@link #getContextValue(java.lang.Class)} and + * {@link #getContextValue(java.lang.Class, java.lang.String)} methods. + * + * To registred a such class, just annotate your class with {@link AutoLoad}. + * + * @author chemit + * @since 1.2 + * @see DefaultJAXXContext + */ +public class DefaultApplicationContext extends DefaultJAXXContext { + + /** + * A class annotated @AutoLoad is used by context to auto + * instanciate the class when required. + * + * Note : A such class always have a public default constructor. + * + * @author chemit + * @version 1.0, 21/02/09 + * @since 1.2 + */ + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + public static @interface AutoLoad { + //TODO use this to add a method to init + + String initMethod() default ""; + } + + /** + * A class annotated @MethodAccess is used by context to obtain the value + * of an entry via a declared method. + * + * Note : A such class must have a method called {@link #methodName()} with + * a single String parameter. + * + * @author chemit + * @version 1.0, 21/02/09 + * @since 1.2 + */ + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + public static @interface MethodAccess { + + /** + * Define a forward to a target class. When the target class + * will be asked with method {@link JAXXContext#getContextValue(java.lang.Class, java.lang.String)} + * it will be delegating to this class. + * + * @return the forwarded class + */ + Class<?> target() default Object.class; + + /** + * @return the name of the method to access data + */ + String methodName(); + } + /** + * Map of forwarded classes (key) to classes (values). + */ + protected Map<Class<?>, Class<?>> forwards; + + public DefaultApplicationContext() { + super(); + forwards = new HashMap<Class<?>, Class<?>>(); + pcs = new PropertyChangeSupport(this); + } + +// public DefaultApplicationContext(JAXXObject ui) { +// super(); +// } + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private final Log log = LogFactory.getLog(DefaultApplicationContext.class); + + /** to manage properties modifications */ + protected PropertyChangeSupport pcs; + + @SuppressWarnings({"unchecked"}) + @Override + public <T> T getContextValue(Class<T> clazz, String name) { + Object value; + MethodAccess access; + + Class<?> realClass; + + if (forwards.containsKey(clazz)) { + // this is a forward class + realClass = forwards.get(clazz); + // always call the forwarder with no name + value = getContextValue(realClass, null); + if (log.isDebugEnabled()) { + log.debug("detect forward from " + clazz + " to " + realClass + " (" + value + ")"); + } + + } else { + realClass = clazz; + value = super.getContextValue(realClass, name); + } + + //TC-20091007 TODO Make possible use of named autoload entries + //(add a parameter on AutoLoad annotation) + if (value == null) { + AutoLoad anno = clazz.getAnnotation(AutoLoad.class); + + if (anno == null) { + // no annotation, so do nothing + return null; + } + + if (name != null) { + throw new IllegalArgumentException("an " + AutoLoad.class.getName() + " can not have a named context but was call with this one : " + name); + } + value = newInstance(clazz); + if (!anno.initMethod().trim().isEmpty()){ + // apply method on class + newAccess(clazz, value, anno.initMethod().trim()); + } + if (log.isDebugEnabled()) { + log.debug("new instance " + clazz + " : " + value); + } + // save new instance + setContextValue(value, null); + } + + access = realClass.getAnnotation(MethodAccess.class); + + if (access != null) { + if (name == null) { + if (access.target() != Object.class) { + // register forward + Class<?> targetClass = access.target(); + if (!forwards.containsKey(targetClass)) { + // register forward + forwards.put(targetClass, clazz); + if (log.isDebugEnabled()) { + log.debug("register forward from " + targetClass + " to " + clazz); + } + } + } + } else { + // specialized access + value = newAccess(realClass, value, access.methodName(), name); + } + } + return (T) value; + } + + @Override + public <T> void removeContextValue(Class<T> klazz, String name) { + Entry<Class<?>, Class<?>> entry; + if (name == null && forwards.containsValue(klazz)) { + // remove forward + Iterator<Entry<Class<?>, Class<?>>> itr = forwards.entrySet().iterator(); + while (itr.hasNext()) { + entry = itr.next(); + if (entry.getValue().equals(klazz)) { + itr.remove(); + if (log.isDebugEnabled()) { + log.debug("removed forward from " + entry.getKey() + " to " + klazz); + } + break; + } + } + } + //FIXME should update forwards state + super.removeContextValue(klazz, name); + } + + 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 synchronized boolean hasListeners(String propertyName) { + return pcs.hasListeners(propertyName); + } + + public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) { + return pcs.getPropertyChangeListeners(propertyName); + } + + public synchronized PropertyChangeListener[] getPropertyChangeListeners() { + return pcs.getPropertyChangeListeners(); + } + + protected Object newInstance(Class<?> clazz) throws IllegalArgumentException { + + Object value; + + Constructor<?> constructor; + try { + constructor = clazz.getConstructor(); + // auto instanciate the class + if (constructor == null) { + throw new IllegalArgumentException(clazz + " has no public constructor"); + } + } catch (NoSuchMethodException ex) { + throw new IllegalArgumentException(ex); + } catch (SecurityException ex) { + throw new IllegalArgumentException(ex); + } + try { + value = constructor.newInstance(); + + } catch (InstantiationException ex) { + throw new IllegalArgumentException(ex); + } catch (IllegalAccessException ex) { + throw new IllegalArgumentException(ex); + } catch (InvocationTargetException ex) { + throw new IllegalArgumentException(ex); + } + return value; + } + + protected Object newAccess(Class<?> clazz, Object parent, String methodName, String name) throws IllegalArgumentException { + Object value; + try { + Method m = clazz.getMethod(methodName, String.class); + value = m.invoke(parent, name); + return value; + } catch (NoSuchMethodException ex) { + throw new IllegalArgumentException(ex); + } catch (SecurityException ex) { + throw new IllegalArgumentException(ex); + } catch (IllegalAccessException ex) { + throw new IllegalArgumentException(ex); + } catch (InvocationTargetException ex) { + throw new IllegalArgumentException(ex); + } + } + + protected Object newAccess(Class<?> clazz, Object parent, String methodName) throws IllegalArgumentException { + Object value; + try { + Method m = clazz.getMethod(methodName); + value = m.invoke(parent); + return value; + } catch (NoSuchMethodException ex) { + throw new IllegalArgumentException(ex); + } catch (SecurityException ex) { + throw new IllegalArgumentException(ex); + } catch (IllegalAccessException ex) { + throw new IllegalArgumentException(ex); + } catch (InvocationTargetException ex) { + throw new IllegalArgumentException(ex); + } + } + + protected void firePropertyChange(String name, Object oldValue, Object newValue) { + pcs.firePropertyChange(name, oldValue, newValue); + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,246 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.context; - -import jaxx.runtime.JAXXContext; -import jaxx.runtime.JAXXObject; -import jaxx.runtime.Util; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -/** - * The default {@link JAXXContext} to be used in a {@link JAXXObject} by delegation. - * <p/> - * The values are store in a {@link Map} but we can not use directly the values as key. - * <p/> - * Because, it does not work if we add for the same object multi entries (named and unamed)... - * <p/> - * We prefer use as entry the {@link JAXXContextEntryDef} associated with the value. - * - * @author chemit - */ -public class DefaultJAXXContext implements JAXXContext { - - /** - * entry of the parent context - */ - protected static final JAXXContextEntryDef<JAXXContext> PARENT_CONTEXT_ENTRY = Util.newContextEntryDef(JAXXContext.class); - /** - * Logger - */ - static private final Log log = LogFactory.getLog(DefaultJAXXContext.class); -// /** -// * l'ui auquel est rattache le context - // */ -// protected JAXXObject ui; - /** - * le context parent - */ - protected JAXXContext parentContext; - /** - * les données contenues dans le context - */ - protected final Map<JAXXContextEntryDef<?>, Object> data; - - public DefaultJAXXContext() { - data = new HashMap<JAXXContextEntryDef<?>, Object>(); - } - -// public DefaultJAXXContext(JAXXObject ui) { -// this(); -// this.ui = ui; -// } - - @Override - public <T> void setContextValue(T o) { - setContextValue(o, null); - } - - @Override - public <T> void setContextValue(T o, String name) { - if (name == null && PARENT_CONTEXT_ENTRY.accept2(o.getClass(), null)) { - setParentContext((JAXXContext) o); - return; - } - JAXXContextEntryDef<?> entry = getKey(name, o.getClass()); - // first remove entry - Object oldValue = remove0(o.getClass(), name); - if (oldValue != null) { - if (log.isDebugEnabled()) { - log.debug("remove value " + oldValue.getClass() + " for " + entry); - } - } - // then can put safely - data.put(entry, o); - } - - @Override - public <T> T getContextValue(Class<T> clazz) { - return getContextValue(clazz, null); - } - - @SuppressWarnings({"unchecked"}) - @Override - public <T> T getContextValue(Class<T> clazz, String name) { - if (parentContext != null && parentContext.getClass() == clazz || PARENT_CONTEXT_ENTRY.accept(clazz, name)) { - return (T) getParentContext(); - } - for (Entry<JAXXContextEntryDef<?>, Object> entry : data.entrySet()) { - if (entry.getKey().accept(clazz, name)) { - return (T) entry.getValue(); - } - } - - // no value found in this context, will try in the parent context - if (JAXXContext.class == clazz) { - // no seek in the parent context, since we are already looking for it - return null; - } - - JAXXContext parent = getParentContext(); - if (parent == null) { - // no parent context, so no value find - return null; - } - // seek in parent context - return parent.getContextValue(clazz, name); - } - - @Override - public <T> void removeContextValue(Class<T> klazz) { - removeContextValue(klazz, null); - } - - @Override - public <T> void removeContextValue(Class<T> klazz, String name) { - remove0(klazz, name); - } - -// @Override -// public <O extends Container> O getParentContainer(Class<O> clazz) { -// return this.getParentContainer(ui, clazz); -// } -// -// @SuppressWarnings({"unchecked"}) -// @Override -// public <O extends Container> O getParentContainer(Object top, Class<O> clazz) { -// if (ui == null) { -// throw new IllegalStateException("no ui attached to this context"); -// } -// if (top == null) { -// throw new IllegalArgumentException("top parameter can not be null"); -// } -// if (!Container.class.isAssignableFrom(top.getClass())) { -// throw new IllegalArgumentException("top parameter " + top + " is not a " + Container.class); -// } -// Container parent = ((Container) top).getParent(); -// if (parent != null && !clazz.isAssignableFrom(parent.getClass())) { -// parent = getParentContainer(parent, clazz); -// } -// return (O) parent; -// } - - /** - * Obtain all the keys of data for a given type. - * - * @param klass the type of searched keys - * @return the array of all names of keys for the given type of data - * @since 1.3 - */ - public String[] getKeys(Class<?> klass) { - List<String> keys = new java.util.ArrayList<String>(); - for (JAXXContextEntryDef<?> key : data.keySet()) { - if (key.getKlass() == klass) { - keys.add(key.getName()); - } - } - return keys.toArray(new String[keys.size()]); - - } - - public void clear() { - data.clear(); - } - -// protected JAXXObject getUi() { -// return ui; -// } -// -// protected void setUi(JAXXObject ui) { -// this.ui = ui; -// } - - protected JAXXContextEntryDef<?> getKey(String name, Class<?> klass) { - return Util.newContextEntryDef(name, klass); - } - - @SuppressWarnings({"unchecked"}) - protected <T> T remove0(Class<T> klazz, String name) { - if (PARENT_CONTEXT_ENTRY.accept(klazz, name)) { - JAXXContext old = getParentContext(); - setParentContext(null); - return (T) old; - } - JAXXContextEntryDef<?> entry = null; - for (JAXXContextEntryDef<?> entryDef : data.keySet()) { - if (entryDef.accept(klazz, name)) { - entry = entryDef; - break; - } - } - if (entry != null) { - return (T) data.remove(entry); - } - - if (JAXXContext.class == klazz) { - return null; - } - // try in parentContext - JAXXContext parent = getParentContext(); - - if (parent == null) { - return null; - } - - if (parent instanceof DefaultJAXXContext) { - return ((DefaultJAXXContext) parent).remove0(klazz, name); - } - - return null; - } - - protected JAXXContext getParentContext() { - return parentContext; - } - - protected void setParentContext(JAXXContext parentContext) { - if (parentContext instanceof JAXXObject) { - // keep the real context, not the ui - parentContext = ((JAXXObject) parentContext).getDelegateContext(); - } - this.parentContext = parentContext; - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,246 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.context; + +import jaxx.runtime.JAXXContext; +import jaxx.runtime.JAXXObject; +import jaxx.runtime.Util; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +/** + * The default {@link JAXXContext} to be used in a {@link JAXXObject} by delegation. + * <p/> + * The values are store in a {@link Map} but we can not use directly the values as key. + * <p/> + * Because, it does not work if we add for the same object multi entries (named and unamed)... + * <p/> + * We prefer use as entry the {@link JAXXContextEntryDef} associated with the value. + * + * @author chemit + */ +public class DefaultJAXXContext implements JAXXContext { + + /** + * entry of the parent context + */ + protected static final JAXXContextEntryDef<JAXXContext> PARENT_CONTEXT_ENTRY = Util.newContextEntryDef(JAXXContext.class); + /** + * Logger + */ + static private final Log log = LogFactory.getLog(DefaultJAXXContext.class); +// /** +// * l'ui auquel est rattache le context + // */ +// protected JAXXObject ui; + /** + * le context parent + */ + protected JAXXContext parentContext; + /** + * les données contenues dans le context + */ + protected final Map<JAXXContextEntryDef<?>, Object> data; + + public DefaultJAXXContext() { + data = new HashMap<JAXXContextEntryDef<?>, Object>(); + } + +// public DefaultJAXXContext(JAXXObject ui) { +// this(); +// this.ui = ui; +// } + + @Override + public <T> void setContextValue(T o) { + setContextValue(o, null); + } + + @Override + public <T> void setContextValue(T o, String name) { + if (name == null && PARENT_CONTEXT_ENTRY.accept2(o.getClass(), null)) { + setParentContext((JAXXContext) o); + return; + } + JAXXContextEntryDef<?> entry = getKey(name, o.getClass()); + // first remove entry + Object oldValue = remove0(o.getClass(), name); + if (oldValue != null) { + if (log.isDebugEnabled()) { + log.debug("remove value " + oldValue.getClass() + " for " + entry); + } + } + // then can put safely + data.put(entry, o); + } + + @Override + public <T> T getContextValue(Class<T> clazz) { + return getContextValue(clazz, null); + } + + @SuppressWarnings({"unchecked"}) + @Override + public <T> T getContextValue(Class<T> clazz, String name) { + if (parentContext != null && parentContext.getClass() == clazz || PARENT_CONTEXT_ENTRY.accept(clazz, name)) { + return (T) getParentContext(); + } + for (Entry<JAXXContextEntryDef<?>, Object> entry : data.entrySet()) { + if (entry.getKey().accept(clazz, name)) { + return (T) entry.getValue(); + } + } + + // no value found in this context, will try in the parent context + if (JAXXContext.class == clazz) { + // no seek in the parent context, since we are already looking for it + return null; + } + + JAXXContext parent = getParentContext(); + if (parent == null) { + // no parent context, so no value find + return null; + } + // seek in parent context + return parent.getContextValue(clazz, name); + } + + @Override + public <T> void removeContextValue(Class<T> klazz) { + removeContextValue(klazz, null); + } + + @Override + public <T> void removeContextValue(Class<T> klazz, String name) { + remove0(klazz, name); + } + +// @Override +// public <O extends Container> O getParentContainer(Class<O> clazz) { +// return this.getParentContainer(ui, clazz); +// } +// +// @SuppressWarnings({"unchecked"}) +// @Override +// public <O extends Container> O getParentContainer(Object top, Class<O> clazz) { +// if (ui == null) { +// throw new IllegalStateException("no ui attached to this context"); +// } +// if (top == null) { +// throw new IllegalArgumentException("top parameter can not be null"); +// } +// if (!Container.class.isAssignableFrom(top.getClass())) { +// throw new IllegalArgumentException("top parameter " + top + " is not a " + Container.class); +// } +// Container parent = ((Container) top).getParent(); +// if (parent != null && !clazz.isAssignableFrom(parent.getClass())) { +// parent = getParentContainer(parent, clazz); +// } +// return (O) parent; +// } + + /** + * Obtain all the keys of data for a given type. + * + * @param klass the type of searched keys + * @return the array of all names of keys for the given type of data + * @since 1.3 + */ + public String[] getKeys(Class<?> klass) { + List<String> keys = new java.util.ArrayList<String>(); + for (JAXXContextEntryDef<?> key : data.keySet()) { + if (key.getKlass() == klass) { + keys.add(key.getName()); + } + } + return keys.toArray(new String[keys.size()]); + + } + + public void clear() { + data.clear(); + } + +// protected JAXXObject getUi() { +// return ui; +// } +// +// protected void setUi(JAXXObject ui) { +// this.ui = ui; +// } + + protected JAXXContextEntryDef<?> getKey(String name, Class<?> klass) { + return Util.newContextEntryDef(name, klass); + } + + @SuppressWarnings({"unchecked"}) + protected <T> T remove0(Class<T> klazz, String name) { + if (PARENT_CONTEXT_ENTRY.accept(klazz, name)) { + JAXXContext old = getParentContext(); + setParentContext(null); + return (T) old; + } + JAXXContextEntryDef<?> entry = null; + for (JAXXContextEntryDef<?> entryDef : data.keySet()) { + if (entryDef.accept(klazz, name)) { + entry = entryDef; + break; + } + } + if (entry != null) { + return (T) data.remove(entry); + } + + if (JAXXContext.class == klazz) { + return null; + } + // try in parentContext + JAXXContext parent = getParentContext(); + + if (parent == null) { + return null; + } + + if (parent instanceof DefaultJAXXContext) { + return ((DefaultJAXXContext) parent).remove0(klazz, name); + } + + return null; + } + + protected JAXXContext getParentContext() { + return parentContext; + } + + protected void setParentContext(JAXXContext parentContext) { + if (parentContext instanceof JAXXObject) { + // keep the real context, not the ui + parentContext = ((JAXXObject) parentContext).getDelegateContext(); + } + this.parentContext = parentContext; + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,144 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.context; - -import java.util.List; -import jaxx.runtime.JAXXContext; - -/** - * To qualify an entry in a {@link JAXXContext}. - * <p/> - * Use the factory methods <code>newContextEntryDef</code> and <code>newListContextEntryDef</code< to obtain new instances. - * - * @param <O> type of the entry associated to the definition - * @author chemit - */ -public class JAXXContextEntryDef<O> implements java.io.Serializable { - - /** name of the entry, can be nuill for a unamed entry. */ - protected String name; - - /** class of the entry, can not be null */ - protected Class<O> klass; - - private static final long serialVersionUID = 1L; - -// public static <O> JAXXContextEntryDef<O> newContextEntryDef(Class<O> klass) { -// return newContextEntryDef(null, klass); -// } -// -// public static <O> JAXXContextEntryDef<O> newContextEntryDef(String name, Class<O> klass) { -// return new JAXXContextEntryDef<O>(name, klass); -// } -// -// public static <O> JAXXContextEntryDef<List<O>> newListContextEntryDef() { -// return newListContextEntryDef(null); -// } -// -// @SuppressWarnings({"unchecked"}) -// public static <O> JAXXContextEntryDef<List<O>> newListContextEntryDef(String name) { -// Class<List<O>> castList = JAXXContextEntryDef.<O>castList(); -// JAXXContextEntryDef<List<O>> contextEntryDef = new JAXXContextEntryDef<List<O>>(name,castList); -// contextEntryDef.klass = castList; -// return contextEntryDef; -// } - - - public String getName() { - return name; - } - - public Class<O> getKlass() { - return klass; - } - - public O getContextValue(JAXXContext context) { - return context.getContextValue(klass, name); - } - - public void removeContextValue(JAXXContext context) { - context.removeContextValue(klass, name); - } - - public void setContextValue(JAXXContext context, O value) { - context.setContextValue(value, name); - } - - @Override - public String toString() { - return super.toString() + "<" + klass + ":" + name + ">"; - } - - public JAXXContextEntryDef(Class<O> klass) { - this(null, klass); - } - - @SuppressWarnings("unchecked") - public JAXXContextEntryDef(String name, Class<O> klass) { - if (klass == null) { - throw new IllegalArgumentException("class can not be null"); - } - this.name = name; - if (List.class.isAssignableFrom(klass)) { - klass = (Class<O>) List.class; - } - this.klass = klass; - } -// -// @SuppressWarnings({"unchecked"}) -// protected static <O> Class<List<O>> castList() { -// return (Class<List<O>>) Collections.emptyList().getClass(); -// } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof JAXXContextEntryDef<?>)) { - return false; - } - JAXXContextEntryDef<?> that = (JAXXContextEntryDef<?>) o; - return klass.equals(that.klass) && !(name != null ? !name.equals(that.name) : that.name != null); - - } - - @Override - public int hashCode() { - int result = (name != null ? name.hashCode() : 0); - return 31 * result + klass.hashCode(); - } - - public boolean accept(Class<?> klass, String name) { - if (klass == Object.class && this.klass != Object.class) { - // try on name only - return (this.name != null && name != null && this.name.equals(name)); - } - return klass.isAssignableFrom(this.klass) && (this.name == null && name == null - || (this.name != null && name != null && this.name.equals(name))); - } - - public boolean accept2(Class<?> klass, String name) { - return !(klass == Object.class && this.klass != Object.class) && - this.klass.isAssignableFrom(klass) && (this.name == null && - name == null || (this.name != null && name != null && this.name.equals(name))); - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,144 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.context; + +import java.util.List; +import jaxx.runtime.JAXXContext; + +/** + * To qualify an entry in a {@link JAXXContext}. + * <p/> + * Use the factory methods <code>newContextEntryDef</code> and <code>newListContextEntryDef</code< to obtain new instances. + * + * @param <O> type of the entry associated to the definition + * @author chemit + */ +public class JAXXContextEntryDef<O> implements java.io.Serializable { + + /** name of the entry, can be nuill for a unamed entry. */ + protected String name; + + /** class of the entry, can not be null */ + protected Class<O> klass; + + private static final long serialVersionUID = 1L; + +// public static <O> JAXXContextEntryDef<O> newContextEntryDef(Class<O> klass) { +// return newContextEntryDef(null, klass); +// } +// +// public static <O> JAXXContextEntryDef<O> newContextEntryDef(String name, Class<O> klass) { +// return new JAXXContextEntryDef<O>(name, klass); +// } +// +// public static <O> JAXXContextEntryDef<List<O>> newListContextEntryDef() { +// return newListContextEntryDef(null); +// } +// +// @SuppressWarnings({"unchecked"}) +// public static <O> JAXXContextEntryDef<List<O>> newListContextEntryDef(String name) { +// Class<List<O>> castList = JAXXContextEntryDef.<O>castList(); +// JAXXContextEntryDef<List<O>> contextEntryDef = new JAXXContextEntryDef<List<O>>(name,castList); +// contextEntryDef.klass = castList; +// return contextEntryDef; +// } + + + public String getName() { + return name; + } + + public Class<O> getKlass() { + return klass; + } + + public O getContextValue(JAXXContext context) { + return context.getContextValue(klass, name); + } + + public void removeContextValue(JAXXContext context) { + context.removeContextValue(klass, name); + } + + public void setContextValue(JAXXContext context, O value) { + context.setContextValue(value, name); + } + + @Override + public String toString() { + return super.toString() + "<" + klass + ":" + name + ">"; + } + + public JAXXContextEntryDef(Class<O> klass) { + this(null, klass); + } + + @SuppressWarnings("unchecked") + public JAXXContextEntryDef(String name, Class<O> klass) { + if (klass == null) { + throw new IllegalArgumentException("class can not be null"); + } + this.name = name; + if (List.class.isAssignableFrom(klass)) { + klass = (Class<O>) List.class; + } + this.klass = klass; + } +// +// @SuppressWarnings({"unchecked"}) +// protected static <O> Class<List<O>> castList() { +// return (Class<List<O>>) Collections.emptyList().getClass(); +// } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof JAXXContextEntryDef<?>)) { + return false; + } + JAXXContextEntryDef<?> that = (JAXXContextEntryDef<?>) o; + return klass.equals(that.klass) && !(name != null ? !name.equals(that.name) : that.name != null); + + } + + @Override + public int hashCode() { + int result = (name != null ? name.hashCode() : 0); + return 31 * result + klass.hashCode(); + } + + public boolean accept(Class<?> klass, String name) { + if (klass == Object.class && this.klass != Object.class) { + // try on name only + return (this.name != null && name != null && this.name.equals(name)); + } + return klass.isAssignableFrom(this.klass) && (this.name == null && name == null + || (this.name != null && name != null && this.name.equals(name))); + } + + public boolean accept2(Class<?> klass, String name) { + return !(klass == Object.class && this.klass != Object.class) && + this.klass.isAssignableFrom(klass) && (this.name == null && + name == null || (this.name != null && name != null && this.name.equals(name))); + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,127 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.context; - -import jaxx.runtime.JAXXContext; -import jaxx.runtime.JAXXObject; - -import java.util.Map.Entry; - -/** - * An initial context to be inject in a {@link JAXXObject}. - * <p/> - * The method {@link #add(Object)} register a simple value. - * <p/> - * The method {@link #add(String, Object)} register a named value. - * <p/> - * The method {@link #to(JAXXContext)} inject in the {@link JAXXObject} the values registred in the initial context. - * <p/> - * The initial context is also a "limited" {@link JAXXContext}, since we can only use the two methods - * <p/> - * {@link #getContextValue(Class)} or {@link #getContextValue(Class, String)}. - * - * @see JAXXContext - */ -public class JAXXInitialContext extends DefaultJAXXContext { - - public JAXXInitialContext() { - super(); - } - - /** - * Register a simple (none named) value in the context. - * - * @param value the value to be registred in the context - * @return the instance of the context - */ - public JAXXInitialContext add(Object value) { - return add((String) null, value); - } - - /** - * Register a named value in the context. - * - * @param name the name of the value - * @param value the value to registred - * @return the instance of the context - */ - public JAXXInitialContext add(String name, Object value) { - super.setContextValue(value, name); - return this; - } - - /** - * Register a named (or not) value in the context. - * - * @param <O> type of data to add - * @param def definition of entry - * @param value the value to registred - * @return the instance of the context - */ - public <O> JAXXInitialContext add(JAXXContextEntryDef<O> def, O value) { - def.setContextValue(this, value); - return this; - } - - /** - * Inject all the registed values into the {@link JAXXObject} - * - * @param dst the object to fill. - */ - public void to(JAXXContext dst) { - if (parentContext != null) { - dst.setContextValue(parentContext); - } - for (Entry<JAXXContextEntryDef<?>, Object> entry : data.entrySet()) { - dst.setContextValue(entry.getValue(), entry.getKey().getName()); - } - } - - @Override - public void setContextValue(Object o) { - throw new RuntimeException("not implemented"); - } - - @Override - public void setContextValue(Object o, String name) { - throw new RuntimeException("not implemented"); - } - - @Override - public <T> void removeContextValue(Class<T> klazz) { - throw new RuntimeException("not implemented"); - } - - @Override - public <T> void removeContextValue(Class<T> klazz, String name) { - throw new RuntimeException("not implemented"); - } - -// @Override -// public <O extends Container> O getParentContainer(Class<O> clazz) { -// throw new RuntimeException("not implemented"); -// } -// -// @Override -// public <O extends Container> O getParentContainer(Object top, Class<O> clazz) { -// throw new RuntimeException("not implemented"); -// } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,127 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.context; + +import jaxx.runtime.JAXXContext; +import jaxx.runtime.JAXXObject; + +import java.util.Map.Entry; + +/** + * An initial context to be inject in a {@link JAXXObject}. + * <p/> + * The method {@link #add(Object)} register a simple value. + * <p/> + * The method {@link #add(String, Object)} register a named value. + * <p/> + * The method {@link #to(JAXXContext)} inject in the {@link JAXXObject} the values registred in the initial context. + * <p/> + * The initial context is also a "limited" {@link JAXXContext}, since we can only use the two methods + * <p/> + * {@link #getContextValue(Class)} or {@link #getContextValue(Class, String)}. + * + * @see JAXXContext + */ +public class JAXXInitialContext extends DefaultJAXXContext { + + public JAXXInitialContext() { + super(); + } + + /** + * Register a simple (none named) value in the context. + * + * @param value the value to be registred in the context + * @return the instance of the context + */ + public JAXXInitialContext add(Object value) { + return add((String) null, value); + } + + /** + * Register a named value in the context. + * + * @param name the name of the value + * @param value the value to registred + * @return the instance of the context + */ + public JAXXInitialContext add(String name, Object value) { + super.setContextValue(value, name); + return this; + } + + /** + * Register a named (or not) value in the context. + * + * @param <O> type of data to add + * @param def definition of entry + * @param value the value to registred + * @return the instance of the context + */ + public <O> JAXXInitialContext add(JAXXContextEntryDef<O> def, O value) { + def.setContextValue(this, value); + return this; + } + + /** + * Inject all the registed values into the {@link JAXXObject} + * + * @param dst the object to fill. + */ + public void to(JAXXContext dst) { + if (parentContext != null) { + dst.setContextValue(parentContext); + } + for (Entry<JAXXContextEntryDef<?>, Object> entry : data.entrySet()) { + dst.setContextValue(entry.getValue(), entry.getKey().getName()); + } + } + + @Override + public void setContextValue(Object o) { + throw new RuntimeException("not implemented"); + } + + @Override + public void setContextValue(Object o, String name) { + throw new RuntimeException("not implemented"); + } + + @Override + public <T> void removeContextValue(Class<T> klazz) { + throw new RuntimeException("not implemented"); + } + + @Override + public <T> void removeContextValue(Class<T> klazz, String name) { + throw new RuntimeException("not implemented"); + } + +// @Override +// public <O extends Container> O getParentContainer(Class<O> clazz) { +// throw new RuntimeException("not implemented"); +// } +// +// @Override +// public <O extends Container> O getParentContainer(Object top, Class<O> clazz) { +// throw new RuntimeException("not implemented"); +// } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/DataBinding.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/DataBinding.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/DataBinding.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,48 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.css; - -/** - * Represents a data binding bound to an attribute at runtime. Used by {@link Pseudoclasses} to keep - * track of which data bindings are in effect. - */ -public class DataBinding { - - private String id; - - public DataBinding(String id) { - this.id = id; - } - - public String getId() { - return id; - } - - @Override - public boolean equals(Object o) { - return o instanceof DataBinding && ((DataBinding) o).getId().equals(getId()); - } - - @Override - public int hashCode() { - return id.hashCode(); - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/DataBinding.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/DataBinding.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/DataBinding.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/DataBinding.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,48 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.css; + +/** + * Represents a data binding bound to an attribute at runtime. Used by {@link Pseudoclasses} to keep + * track of which data bindings are in effect. + */ +public class DataBinding { + + private String id; + + public DataBinding(String id) { + this.id = id; + } + + public String getId() { + return id; + } + + @Override + public boolean equals(Object o) { + return o instanceof DataBinding && ((DataBinding) o).getId().equals(getId()); + } + + @Override + public int hashCode() { + return id.hashCode(); + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/Pseudoclasses.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Pseudoclasses.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/Pseudoclasses.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,199 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.css; - -import jaxx.runtime.JAXXObject; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.WeakHashMap; - -public class Pseudoclasses { - - public static final String NO_PSEUDOCLASS = "no pseudoclass"; - private static Map<Object, Map<String, List<PropertyValue>>> properties = new WeakHashMap<Object, Map<String, List<PropertyValue>>>(); - - private static class PropertyValue implements Comparable<PropertyValue> { - - private Object value; - private int id; - - public PropertyValue(Object value, int id) { - this.value = value; - this.id = id; - } - - public Object getValue() { - return value; - } - - public int getId() { - return id; - } - - @Override - public int compareTo(PropertyValue o) { - return getId() - o.getId(); - } - - @Override - public boolean equals(Object o) { - if (!(o instanceof PropertyValue)) { - return false; - } - PropertyValue that = (PropertyValue) o; - if (that.getId() != getId()) { - return false; - } - if (that.getValue() == null) { - return getValue() == null; - } - return that.getValue().equals(getValue()); - } - - @Override - public int hashCode() { - return (value != null ? value.hashCode() : 0) ^ id; - } - - @Override - public String toString() { - return "PropertyValue[" + value + ", " + id + "]"; - } - } - - private static List<PropertyValue> getPropertyList(Object object, String property) { - Map<String, List<PropertyValue>> propertyMap = properties.get(object); - if (propertyMap == null) { - propertyMap = new HashMap<String, List<PropertyValue>>(); - properties.put(object, propertyMap); - } - - List<PropertyValue> propertyList = propertyMap.get(property); - if (propertyList == null) { - propertyList = new ArrayList<PropertyValue>(); - propertyMap.put(property, propertyList); - } - - return propertyList; - } - - public static boolean isPropertyApplied(Object object, String property, int id) { - for (PropertyValue aPropertyList : getPropertyList(object, property)) { - if (aPropertyList.getId() == id) { - return true; - } - } - return false; - } - - public static void propertyApplied(Object object, String property, Object value, int id) { - List<PropertyValue> propertyList = getPropertyList(object, property); - propertyList.add(new PropertyValue(value, id)); - Collections.sort(propertyList); - } - - public static void propertyRemoved(Object object, String property, Object value, int id) { - List<PropertyValue> propertyList = getPropertyList(object, property); - propertyList.remove(new PropertyValue(value, id)); - } - - public static Object getCurrentValue(Object object, String property) { - List<PropertyValue> propertyList = getPropertyList(object, property); - if (propertyList.size() > 0) { - return propertyList.get(propertyList.size() - 1).getValue(); - } - return NO_PSEUDOCLASS; - } - - public static Object applyProperty(JAXXObject parent, Object object, String property, Object newValue, Object currentValue, int id) { - if (!isPropertyApplied(object, property, id)) { - Object value = getCurrentValue(object, property); - if (value == NO_PSEUDOCLASS) { - propertyApplied(object, property, wrap(currentValue), -1); - } - propertyApplied(object, property, wrap(newValue), id); - value = getCurrentValue(object, property); - if (value instanceof DataBinding) { - parent.applyDataBinding(((DataBinding) value).getId()); - } - return value; - } else { - return currentValue; - } - } - - public static Object removeProperty(JAXXObject parent, Object object, String property, Object oldValue, Object currentValue, int id) { - if (isPropertyApplied(object, property, id)) { - Object value = getCurrentValue(object, property); - if (value == NO_PSEUDOCLASS) { - throw new IllegalStateException("found NO_PSEUDOCLASS value for a property which does not have a default value"); - } - if (value instanceof DataBinding) { - parent.removeDataBinding(((DataBinding) value).getId()); - } - propertyRemoved(object, property, wrap(oldValue), id); - value = getCurrentValue(object, property); - return value; - } else { - return currentValue; - } - } - - public static Object wrap(boolean value) { - return value; - } - - public static Object wrap(byte value) { - return value; - } - - public static Object wrap(short value) { - return value; - } - - public static Object wrap(int value) { - return value; - } - - public static Object wrap(long value) { - return value; - } - - public static Object wrap(float value) { - return value; - } - - public static Object wrap(double value) { - return value; - } - - public static Object wrap(char value) { - return value; - } - - public static Object wrap(Object value) { - return value; - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/Pseudoclasses.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Pseudoclasses.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/Pseudoclasses.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/Pseudoclasses.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,199 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.css; + +import jaxx.runtime.JAXXObject; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.WeakHashMap; + +public class Pseudoclasses { + + public static final String NO_PSEUDOCLASS = "no pseudoclass"; + private static Map<Object, Map<String, List<PropertyValue>>> properties = new WeakHashMap<Object, Map<String, List<PropertyValue>>>(); + + private static class PropertyValue implements Comparable<PropertyValue> { + + private Object value; + private int id; + + public PropertyValue(Object value, int id) { + this.value = value; + this.id = id; + } + + public Object getValue() { + return value; + } + + public int getId() { + return id; + } + + @Override + public int compareTo(PropertyValue o) { + return getId() - o.getId(); + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof PropertyValue)) { + return false; + } + PropertyValue that = (PropertyValue) o; + if (that.getId() != getId()) { + return false; + } + if (that.getValue() == null) { + return getValue() == null; + } + return that.getValue().equals(getValue()); + } + + @Override + public int hashCode() { + return (value != null ? value.hashCode() : 0) ^ id; + } + + @Override + public String toString() { + return "PropertyValue[" + value + ", " + id + "]"; + } + } + + private static List<PropertyValue> getPropertyList(Object object, String property) { + Map<String, List<PropertyValue>> propertyMap = properties.get(object); + if (propertyMap == null) { + propertyMap = new HashMap<String, List<PropertyValue>>(); + properties.put(object, propertyMap); + } + + List<PropertyValue> propertyList = propertyMap.get(property); + if (propertyList == null) { + propertyList = new ArrayList<PropertyValue>(); + propertyMap.put(property, propertyList); + } + + return propertyList; + } + + public static boolean isPropertyApplied(Object object, String property, int id) { + for (PropertyValue aPropertyList : getPropertyList(object, property)) { + if (aPropertyList.getId() == id) { + return true; + } + } + return false; + } + + public static void propertyApplied(Object object, String property, Object value, int id) { + List<PropertyValue> propertyList = getPropertyList(object, property); + propertyList.add(new PropertyValue(value, id)); + Collections.sort(propertyList); + } + + public static void propertyRemoved(Object object, String property, Object value, int id) { + List<PropertyValue> propertyList = getPropertyList(object, property); + propertyList.remove(new PropertyValue(value, id)); + } + + public static Object getCurrentValue(Object object, String property) { + List<PropertyValue> propertyList = getPropertyList(object, property); + if (propertyList.size() > 0) { + return propertyList.get(propertyList.size() - 1).getValue(); + } + return NO_PSEUDOCLASS; + } + + public static Object applyProperty(JAXXObject parent, Object object, String property, Object newValue, Object currentValue, int id) { + if (!isPropertyApplied(object, property, id)) { + Object value = getCurrentValue(object, property); + if (value == NO_PSEUDOCLASS) { + propertyApplied(object, property, wrap(currentValue), -1); + } + propertyApplied(object, property, wrap(newValue), id); + value = getCurrentValue(object, property); + if (value instanceof DataBinding) { + parent.applyDataBinding(((DataBinding) value).getId()); + } + return value; + } else { + return currentValue; + } + } + + public static Object removeProperty(JAXXObject parent, Object object, String property, Object oldValue, Object currentValue, int id) { + if (isPropertyApplied(object, property, id)) { + Object value = getCurrentValue(object, property); + if (value == NO_PSEUDOCLASS) { + throw new IllegalStateException("found NO_PSEUDOCLASS value for a property which does not have a default value"); + } + if (value instanceof DataBinding) { + parent.removeDataBinding(((DataBinding) value).getId()); + } + propertyRemoved(object, property, wrap(oldValue), id); + value = getCurrentValue(object, property); + return value; + } else { + return currentValue; + } + } + + public static Object wrap(boolean value) { + return value; + } + + public static Object wrap(byte value) { + return value; + } + + public static Object wrap(short value) { + return value; + } + + public static Object wrap(int value) { + return value; + } + + public static Object wrap(long value) { + return value; + } + + public static Object wrap(float value) { + return value; + } + + public static Object wrap(double value) { + return value; + } + + public static Object wrap(char value) { + return value; + } + + public static Object wrap(Object value) { + return value; + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/Rule.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Rule.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/Rule.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,68 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.css; - -import java.util.Map; - -public class Rule implements java.io.Serializable, Comparable<Rule> { - - public static final String INLINE_ATTRIBUTE = "<inline attribute>"; - public static final String DATA_BINDING = "<data binding>"; - private Selector[] selectors; - private Map<String, String> properties; - private static final long serialVersionUID = 1L; - - public Rule(Selector[] selectors, Map<String, String> properties) { - this.selectors = selectors; - java.util.Arrays.sort(selectors); - this.properties = properties; - } - - public Rule(Selector[] selectors, String[] keys, String[] values) { - this.selectors = selectors; - java.util.Arrays.sort(selectors); - this.properties = new java.util.HashMap<String, String>(); - if (keys.length != values.length) { - throw new IllegalArgumentException("keys and values must have the same number of entries"); - } - for (int i = 0; i < keys.length; i++) { - properties.put(keys[i], values[i]); - } - } - - public Selector[] getSelectors() { - return selectors; - } - - public Map<String, String> getProperties() { - return properties; - } - - @Override - public int compareTo(Rule o) { - return selectors[0].compareTo(o.selectors[0]); // they are already sorted so we only need to compare the highest-ranked from each one - } - - @Override - public String toString() { - return "Rule[" + java.util.Arrays.asList(selectors) + ", " + properties + "]"; - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/Rule.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Rule.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/Rule.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/Rule.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,68 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.css; + +import java.util.Map; + +public class Rule implements java.io.Serializable, Comparable<Rule> { + + public static final String INLINE_ATTRIBUTE = "<inline attribute>"; + public static final String DATA_BINDING = "<data binding>"; + private Selector[] selectors; + private Map<String, String> properties; + private static final long serialVersionUID = 1L; + + public Rule(Selector[] selectors, Map<String, String> properties) { + this.selectors = selectors; + java.util.Arrays.sort(selectors); + this.properties = properties; + } + + public Rule(Selector[] selectors, String[] keys, String[] values) { + this.selectors = selectors; + java.util.Arrays.sort(selectors); + this.properties = new java.util.HashMap<String, String>(); + if (keys.length != values.length) { + throw new IllegalArgumentException("keys and values must have the same number of entries"); + } + for (int i = 0; i < keys.length; i++) { + properties.put(keys[i], values[i]); + } + } + + public Selector[] getSelectors() { + return selectors; + } + + public Map<String, String> getProperties() { + return properties; + } + + @Override + public int compareTo(Rule o) { + return selectors[0].compareTo(o.selectors[0]); // they are already sorted so we only need to compare the highest-ranked from each one + } + + @Override + public String toString() { + return "Rule[" + java.util.Arrays.asList(selectors) + ", " + properties + "]"; + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/Selector.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Selector.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/Selector.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,108 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.css; - -public class Selector implements java.io.Serializable, Comparable<Selector> { - - public static final int NEVER_APPLIES = 0; - public static final int PSEUDOCLASS_APPLIES_INHERIT_ONLY = 1; - public static final int PSEUDOCLASS_APPLIES = 2; - public static final int ALWAYS_APPLIES_INHERIT_ONLY = 3; - public static final int ALWAYS_APPLIES = 4; - private String javaClassName; - private String styleClass; - private String pseudoClass; - private String id; - private boolean inline; - private static final long serialVersionUID = 1L; - - public Selector(String javaClassName, String styleClass, String pseudoClass, String id) { - this(javaClassName, styleClass, pseudoClass, id, false); - } - - public Selector(String javaClassName, String styleClass, String pseudoClass, String id, boolean inline) { - this.javaClassName = javaClassName; - this.styleClass = styleClass; - this.pseudoClass = pseudoClass; - this.id = id; - this.inline = inline; - } - - public String getJavaClassName() { - return javaClassName; - } - - public String getStyleClass() { - return styleClass; - } - - public String getPseudoClass() { - return pseudoClass; - } - - public String getId() { - return id; - } - - public boolean isInline() { - return inline; - } - - @Override - public int compareTo(Selector selector) { - if (inline && !selector.inline) { - return 1; - } - if (!inline && selector.inline) { - return -1; - } - if (pseudoClass != null && selector.pseudoClass == null) { - return 1; - } - if (pseudoClass == null && selector.pseudoClass != null) { - return -1; - } - if (id != null && selector.id == null) { - return 1; - } - if (id == null && selector.id != null) { - return -1; - } - if (styleClass != null && selector.styleClass == null) { - return 1; - } - if (styleClass == null && selector.styleClass != null) { - return -1; - } - if (javaClassName != null && selector.javaClassName == null) { - return 1; - } - if (javaClassName == null && selector.javaClassName != null) { - return -1; - } - return 0; - } - - @Override - public String toString() { - return "Selector[" + javaClassName + ", " + styleClass + ", " + pseudoClass + ", " + id + "]"; - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/Selector.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Selector.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/Selector.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/Selector.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,108 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.css; + +public class Selector implements java.io.Serializable, Comparable<Selector> { + + public static final int NEVER_APPLIES = 0; + public static final int PSEUDOCLASS_APPLIES_INHERIT_ONLY = 1; + public static final int PSEUDOCLASS_APPLIES = 2; + public static final int ALWAYS_APPLIES_INHERIT_ONLY = 3; + public static final int ALWAYS_APPLIES = 4; + private String javaClassName; + private String styleClass; + private String pseudoClass; + private String id; + private boolean inline; + private static final long serialVersionUID = 1L; + + public Selector(String javaClassName, String styleClass, String pseudoClass, String id) { + this(javaClassName, styleClass, pseudoClass, id, false); + } + + public Selector(String javaClassName, String styleClass, String pseudoClass, String id, boolean inline) { + this.javaClassName = javaClassName; + this.styleClass = styleClass; + this.pseudoClass = pseudoClass; + this.id = id; + this.inline = inline; + } + + public String getJavaClassName() { + return javaClassName; + } + + public String getStyleClass() { + return styleClass; + } + + public String getPseudoClass() { + return pseudoClass; + } + + public String getId() { + return id; + } + + public boolean isInline() { + return inline; + } + + @Override + public int compareTo(Selector selector) { + if (inline && !selector.inline) { + return 1; + } + if (!inline && selector.inline) { + return -1; + } + if (pseudoClass != null && selector.pseudoClass == null) { + return 1; + } + if (pseudoClass == null && selector.pseudoClass != null) { + return -1; + } + if (id != null && selector.id == null) { + return 1; + } + if (id == null && selector.id != null) { + return -1; + } + if (styleClass != null && selector.styleClass == null) { + return 1; + } + if (styleClass == null && selector.styleClass != null) { + return -1; + } + if (javaClassName != null && selector.javaClassName == null) { + return 1; + } + if (javaClassName == null && selector.javaClassName != null) { + return -1; + } + return 0; + } + + @Override + public String toString() { + return "Selector[" + javaClassName + ", " + styleClass + ", " + pseudoClass + ", " + id + "]"; + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/Stylesheet.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Stylesheet.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/Stylesheet.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,61 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.css; - -public class Stylesheet implements java.io.Serializable { - - private Rule[] rules; - private static final long serialVersionUID = 1L; - - public Stylesheet() { - rules = new Rule[0]; - } - - public Stylesheet(Rule[] rules) { - this.rules = rules; - java.util.Arrays.sort(rules); - } - - public Rule[] getRules() { - return rules; - } - - public void add(Rule newRule) { - Rule[] oldRules = rules; - rules = new Rule[oldRules.length + 1]; - System.arraycopy(oldRules, 0, rules, 0, oldRules.length); - rules[rules.length - 1] = newRule; - java.util.Arrays.sort(rules); - } - - public void add(Rule[] newRules) { - Rule[] oldRules = rules; - rules = new Rule[oldRules.length + newRules.length]; - System.arraycopy(oldRules, 0, rules, 0, oldRules.length); - System.arraycopy(newRules, 0, rules, oldRules.length, newRules.length); - java.util.Arrays.sort(rules); - } - - @Override - public String toString() { - return "Stylesheet" + java.util.Arrays.asList(rules); - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/Stylesheet.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Stylesheet.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/Stylesheet.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/css/Stylesheet.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,61 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.css; + +public class Stylesheet implements java.io.Serializable { + + private Rule[] rules; + private static final long serialVersionUID = 1L; + + public Stylesheet() { + rules = new Rule[0]; + } + + public Stylesheet(Rule[] rules) { + this.rules = rules; + java.util.Arrays.sort(rules); + } + + public Rule[] getRules() { + return rules; + } + + public void add(Rule newRule) { + Rule[] oldRules = rules; + rules = new Rule[oldRules.length + 1]; + System.arraycopy(oldRules, 0, rules, 0, oldRules.length); + rules[rules.length - 1] = newRule; + java.util.Arrays.sort(rules); + } + + public void add(Rule[] newRules) { + Rule[] oldRules = rules; + rules = new Rule[oldRules.length + newRules.length]; + System.arraycopy(oldRules, 0, rules, 0, oldRules.length); + System.arraycopy(newRules, 0, rules, oldRules.length, newRules.length); + java.util.Arrays.sort(rules); + } + + @Override + public String toString() { + return "Stylesheet" + java.util.Arrays.asList(rules); + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/Decorator.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/Decorator.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/Decorator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,54 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.decorator; - -/** - * A simple contract to define a String decorator on any java objet. - * - * @param <O> the type of data to decorate - * @author chemit - * @since 1.7.2 (was previously {@code jaxx.runtime.Decorator}) - */ -public abstract class Decorator<O> implements java.io.Serializable { - - private static final long serialVersionUID = -1L; - /** - * Type of the data to decorate - */ - protected final Class<O> internalClass; - - 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 Class<O> getInternalClass() { - return internalClass; - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/Decorator.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/Decorator.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/Decorator.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/Decorator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,54 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.decorator; + +/** + * A simple contract to define a String decorator on any java objet. + * + * @param <O> the type of data to decorate + * @author chemit + * @since 1.7.2 (was previously {@code jaxx.runtime.Decorator}) + */ +public abstract class Decorator<O> implements java.io.Serializable { + + private static final long serialVersionUID = -1L; + /** + * Type of the data to decorate + */ + protected final Class<O> internalClass; + + 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 Class<O> getInternalClass() { + return internalClass; + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorProvider.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorProvider.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorProvider.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,226 +0,0 @@ -package jaxx.runtime.decorator; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.ArrayList; -import java.util.List; - -/** - * A decorator provider. - * <p/> - * Implements the method {@link #loadDecorators()} to fill the decorators availables. - * <p/> - * Then can obtain decorator via the methods {@code getDecorator(...)} - * <p/> - * User: chemit - * Date: 28 oct. 2009 - * Time: 19:40:48 - */ -public abstract class DecoratorProvider { - - /** - * Logger - */ - private static final Log log = LogFactory.getLog(JXPathDecorator.class); - /** - * Registred decorators. - */ - protected List<DecoratorContext<?>> decorators; - - public DecoratorProvider() { - loadDecorators(); - } - - /** - * Load all decorators of the provider - */ - protected abstract void loadDecorators(); - - /** - * Obtain a decorator for the given object. - * - * @param object object of decorated object - * @param <O> object of decorated object - * @return the decorator or {@code null} if not found - */ - @SuppressWarnings({"unchecked"}) - public <O> Decorator<O> getDecorator(O object) { - return getDecorator(object, null); - } - - /** - * Obtain a decorator given a object and an extra name to qualify the context. - * - * @param object object of decorated object - * @param name extra name to qualify the decorator to use - * @param <O> object of decorated object - * @return the decorator or {@code null} if not found - */ - @SuppressWarnings({"unchecked"}) - public <O> Decorator<O> getDecorator(O object, String name) { - Class<O> k = (Class<O>) object.getClass(); - return getDecorator(k, name); - } - - /** - * Obtain a decorator given a type. - * - * @param type type of decorated object - * @param <O> type of decorated object - * @return the decorator or {@code null} if not found - */ - public <O> Decorator<O> getDecorator(Class<O> type) { - return getDecorator(type, null); - } - - /** - * Obtain a decorator given a type and a extra name. - * - * @param type type of decorated object - * @param name extra name to qualify the decorator to use - * @param <O> type of decorated object - * @return the decorator or {@code null} if not found - */ - public <O> Decorator<O> getDecorator(Class<O> type, String name) { - DecoratorContext<O> d = getDecoratorContext(type, name); - return d == null ? null : d.getDecorator(); - } - - public void reload() { - clear(); - loadDecorators(); - } - - public void clear() { - if (decorators != null) { - decorators.clear(); - } - } - - protected void registerPropertyDecorator(Class<?> klass, String expression) { - registerPropertyDecorator(klass, null, expression); - } - - protected void registerJXPathDecorator(Class<?> klass, String expression) { - registerJXPathDecorator(klass, null, expression); - } - - protected void registerMultiJXPathDecorator(Class<?> klass, String expression, String separator, String separatorReplacement) { - registerMultiJXPathDecorator(klass, null, expression, separator, separatorReplacement); - } - - protected void registerPropertyDecorator(Class<?> klass, String name, String expression) { - Decorator<?> decorator = DecoratorUtils.newPropertyDecorator(klass, expression); - registerDecorator(name, decorator); - } - - protected void registerJXPathDecorator(Class<?> klass, String name, String expression) { - Decorator<?> decorator = DecoratorUtils.newJXPathDecorator(klass, expression); - registerDecorator(name, decorator); - } - - protected void registerMultiJXPathDecorator(Class<?> klass, String name, String expression, String separator, String separatorReplacement) { - Decorator<?> decorator = DecoratorUtils.newMultiJXPathDecorator(klass, expression, separator, separatorReplacement); - registerDecorator(name, decorator); - } - - protected void registerDecorator(Decorator<?> decorator) { - registerDecorator(null, decorator); - } - - /** - * Register a new decorator in the cache of the provider. - * - * @param <T> type of data decorated - * @param context the name decorator - * @param decorator the decorator to register - */ - protected <T> void registerDecorator(String context, Decorator<T> decorator) { - - // obtain the decorator context - DecoratorContext<?> result = getDecoratorContext(decorator.getInternalClass(), context); - - if (result != null) { - throw new IllegalArgumentException("there is an already register decorator with context " + result); - } - - DecoratorContext<T> decoratorContext = new DecoratorContext<T>(context, decorator); - if (log.isDebugEnabled()) { - log.debug(decoratorContext); - } - getDecorators().add(decoratorContext); - } - - protected List<DecoratorContext<?>> getDecorators() { - if (decorators == null) { - decorators = new ArrayList<DecoratorContext<?>>(); - } - return decorators; - } - - @SuppressWarnings({"unchecked"}) - protected <T> DecoratorContext<T> getDecoratorContext(Class<T> type, String context) { - DecoratorContext<T> result = null; - if (decorators != null) { - for (DecoratorContext<?> d : decorators) { - 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> { - - /** - * the context name of the decorator - */ - final String context; - /** - * the decorator - */ - 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) { - boolean accept = getType().isAssignableFrom(type) && accept(context); - return accept; - } - - 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 + ">"; - } - } - -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorProvider.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorProvider.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorProvider.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorProvider.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,226 @@ +package jaxx.runtime.decorator; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.util.ArrayList; +import java.util.List; + +/** + * A decorator provider. + * <p/> + * Implements the method {@link #loadDecorators()} to fill the decorators availables. + * <p/> + * Then can obtain decorator via the methods {@code getDecorator(...)} + * <p/> + * User: chemit + * Date: 28 oct. 2009 + * Time: 19:40:48 + */ +public abstract class DecoratorProvider { + + /** + * Logger + */ + private static final Log log = LogFactory.getLog(JXPathDecorator.class); + /** + * Registred decorators. + */ + protected List<DecoratorContext<?>> decorators; + + public DecoratorProvider() { + loadDecorators(); + } + + /** + * Load all decorators of the provider + */ + protected abstract void loadDecorators(); + + /** + * Obtain a decorator for the given object. + * + * @param object object of decorated object + * @param <O> object of decorated object + * @return the decorator or {@code null} if not found + */ + @SuppressWarnings({"unchecked"}) + public <O> Decorator<O> getDecorator(O object) { + return getDecorator(object, null); + } + + /** + * Obtain a decorator given a object and an extra name to qualify the context. + * + * @param object object of decorated object + * @param name extra name to qualify the decorator to use + * @param <O> object of decorated object + * @return the decorator or {@code null} if not found + */ + @SuppressWarnings({"unchecked"}) + public <O> Decorator<O> getDecorator(O object, String name) { + Class<O> k = (Class<O>) object.getClass(); + return getDecorator(k, name); + } + + /** + * Obtain a decorator given a type. + * + * @param type type of decorated object + * @param <O> type of decorated object + * @return the decorator or {@code null} if not found + */ + public <O> Decorator<O> getDecorator(Class<O> type) { + return getDecorator(type, null); + } + + /** + * Obtain a decorator given a type and a extra name. + * + * @param type type of decorated object + * @param name extra name to qualify the decorator to use + * @param <O> type of decorated object + * @return the decorator or {@code null} if not found + */ + public <O> Decorator<O> getDecorator(Class<O> type, String name) { + DecoratorContext<O> d = getDecoratorContext(type, name); + return d == null ? null : d.getDecorator(); + } + + public void reload() { + clear(); + loadDecorators(); + } + + public void clear() { + if (decorators != null) { + decorators.clear(); + } + } + + protected void registerPropertyDecorator(Class<?> klass, String expression) { + registerPropertyDecorator(klass, null, expression); + } + + protected void registerJXPathDecorator(Class<?> klass, String expression) { + registerJXPathDecorator(klass, null, expression); + } + + protected void registerMultiJXPathDecorator(Class<?> klass, String expression, String separator, String separatorReplacement) { + registerMultiJXPathDecorator(klass, null, expression, separator, separatorReplacement); + } + + protected void registerPropertyDecorator(Class<?> klass, String name, String expression) { + Decorator<?> decorator = DecoratorUtils.newPropertyDecorator(klass, expression); + registerDecorator(name, decorator); + } + + protected void registerJXPathDecorator(Class<?> klass, String name, String expression) { + Decorator<?> decorator = DecoratorUtils.newJXPathDecorator(klass, expression); + registerDecorator(name, decorator); + } + + protected void registerMultiJXPathDecorator(Class<?> klass, String name, String expression, String separator, String separatorReplacement) { + Decorator<?> decorator = DecoratorUtils.newMultiJXPathDecorator(klass, expression, separator, separatorReplacement); + registerDecorator(name, decorator); + } + + protected void registerDecorator(Decorator<?> decorator) { + registerDecorator(null, decorator); + } + + /** + * Register a new decorator in the cache of the provider. + * + * @param <T> type of data decorated + * @param context the name decorator + * @param decorator the decorator to register + */ + protected <T> void registerDecorator(String context, Decorator<T> decorator) { + + // obtain the decorator context + DecoratorContext<?> result = getDecoratorContext(decorator.getInternalClass(), context); + + if (result != null) { + throw new IllegalArgumentException("there is an already register decorator with context " + result); + } + + DecoratorContext<T> decoratorContext = new DecoratorContext<T>(context, decorator); + if (log.isDebugEnabled()) { + log.debug(decoratorContext); + } + getDecorators().add(decoratorContext); + } + + protected List<DecoratorContext<?>> getDecorators() { + if (decorators == null) { + decorators = new ArrayList<DecoratorContext<?>>(); + } + return decorators; + } + + @SuppressWarnings({"unchecked"}) + protected <T> DecoratorContext<T> getDecoratorContext(Class<T> type, String context) { + DecoratorContext<T> result = null; + if (decorators != null) { + for (DecoratorContext<?> d : decorators) { + 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> { + + /** + * the context name of the decorator + */ + final String context; + /** + * the decorator + */ + 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) { + boolean accept = getType().isAssignableFrom(type) && accept(context); + return accept; + } + + 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 + ">"; + } + } + +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,203 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.decorator; - -import jaxx.runtime.decorator.JXPathDecorator.Context; -import jaxx.runtime.decorator.JXPathDecorator.JXPathComparator; - -import java.util.*; - -/** - * Some usefull methods on {@link Decorator} to create, and sort data with decorators. - * <p/> - * To create a new decorator, use one of the methods : - * <ul> - * <li>{@link #newPropertyDecorator(Class, String)}</li> - * <li>{@link #newJXPathDecorator(Class, String)}</li> - * <li>{@link #newMultiJXPathDecorator(Class, String, String)})</li> - * <li>{@link #newMultiJXPathDecorator(Class, String, String, String)})</li> - * </ul> - * <p/> - * To sort a list of data, using a {@link JXPathDecorator}, use the method - * {@link #sort(JXPathDecorator, List, int)}. - * <p/> - * - * @author tony - * @since 1.7.2 (was previously {@code jaxx.runtime.DecoratorUtils}) - */ -public class DecoratorUtils { - - /** - * Factory method to instanciate a new {@link PropertyDecorator} for the - * given class {@code internlaClass} 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> newPropertyDecorator(Class<O> internalClass, String property) - throws IllegalArgumentException, NullPointerException { - return new PropertyDecorator<O>(internalClass, property); - } - - /** - * Factory method to instanciate a new {@link JXPathDecorator} for the - * given class {@code internalClass} 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> newJXPathDecorator(Class<O> internalClass, String expression) - throws IllegalArgumentException, NullPointerException { - - Context<O> context = createJXPathContext(expression); - return new JXPathDecorator<O>(internalClass, expression, context); - } - - public static <O> MultiJXPathDecorator<O> newMultiJXPathDecorator(Class<O> internalClass, - String expression, - String separator) - throws IllegalArgumentException, NullPointerException { - - return newMultiJXPathDecorator(internalClass, expression, separator, separator); - } - - public static <O> MultiJXPathDecorator<O> newMultiJXPathDecorator(Class<O> internalClass, - String expression, - String separator, - String separatorReplacement) - throws IllegalArgumentException, NullPointerException { - - Context<O>[] contexts = createMultiJXPathContext(expression, separator, separatorReplacement); - - return new MultiJXPathDecorator<O>(internalClass, expression, separator, separatorReplacement, contexts); - } - - /** - * 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 <O> Context<O> createJXPathContext(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()])); - } - - public static <O> Context<O>[] createMultiJXPathContext(String expression, String separator, String separatorReplacement) { - int sep = expression.indexOf(separator); - if (sep == -1) { - Context<O>[] result = newInstance(1); - result[0] = createJXPathContext(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] = createJXPathContext(buffer.substring(separatorReplacement.length())); - } - return contexts; - } - - @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]; - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,203 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.decorator; + +import jaxx.runtime.decorator.JXPathDecorator.Context; +import jaxx.runtime.decorator.JXPathDecorator.JXPathComparator; + +import java.util.*; + +/** + * Some usefull methods on {@link Decorator} to create, and sort data with decorators. + * <p/> + * To create a new decorator, use one of the methods : + * <ul> + * <li>{@link #newPropertyDecorator(Class, String)}</li> + * <li>{@link #newJXPathDecorator(Class, String)}</li> + * <li>{@link #newMultiJXPathDecorator(Class, String, String)})</li> + * <li>{@link #newMultiJXPathDecorator(Class, String, String, String)})</li> + * </ul> + * <p/> + * To sort a list of data, using a {@link JXPathDecorator}, use the method + * {@link #sort(JXPathDecorator, List, int)}. + * <p/> + * + * @author tony + * @since 1.7.2 (was previously {@code jaxx.runtime.DecoratorUtils}) + */ +public class DecoratorUtils { + + /** + * Factory method to instanciate a new {@link PropertyDecorator} for the + * given class {@code internlaClass} 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> newPropertyDecorator(Class<O> internalClass, String property) + throws IllegalArgumentException, NullPointerException { + return new PropertyDecorator<O>(internalClass, property); + } + + /** + * Factory method to instanciate a new {@link JXPathDecorator} for the + * given class {@code internalClass} 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> newJXPathDecorator(Class<O> internalClass, String expression) + throws IllegalArgumentException, NullPointerException { + + Context<O> context = createJXPathContext(expression); + return new JXPathDecorator<O>(internalClass, expression, context); + } + + public static <O> MultiJXPathDecorator<O> newMultiJXPathDecorator(Class<O> internalClass, + String expression, + String separator) + throws IllegalArgumentException, NullPointerException { + + return newMultiJXPathDecorator(internalClass, expression, separator, separator); + } + + public static <O> MultiJXPathDecorator<O> newMultiJXPathDecorator(Class<O> internalClass, + String expression, + String separator, + String separatorReplacement) + throws IllegalArgumentException, NullPointerException { + + Context<O>[] contexts = createMultiJXPathContext(expression, separator, separatorReplacement); + + return new MultiJXPathDecorator<O>(internalClass, expression, separator, separatorReplacement, contexts); + } + + /** + * 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 <O> Context<O> createJXPathContext(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()])); + } + + public static <O> Context<O>[] createMultiJXPathContext(String expression, String separator, String separatorReplacement) { + int sep = expression.indexOf(separator); + if (sep == -1) { + Context<O>[] result = newInstance(1); + result[0] = createJXPathContext(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] = createJXPathContext(buffer.substring(separatorReplacement.length())); + } + return contexts; + } + + @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]; + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/JXPathDecorator.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/JXPathDecorator.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/JXPathDecorator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,221 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.decorator; - -import org.apache.commons.jxpath.JXPathContext; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.*; - -/** - * 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 = DecoratorUtils.newJXPathDecorator(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> - * - * @author chemit - * @param <O> type of data to decorate - * @see Decorator - * @since 1.7.2 (was previously {@code jaxx.runtime.JXPathDecorator}) - */ -public class JXPathDecorator<O> extends Decorator<O> { - - private static final long serialVersionUID = 1L; - /** - * Logger - */ - private static final Log log = LogFactory.getLog(JXPathDecorator.class); - /** - * 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; - - protected JXPathDecorator(Class<O> internalClass, String expression, Context<O> context) throws IllegalArgumentException, NullPointerException { - super(internalClass); - this.initialExpression = expression; - if (context != null) { - setContext(context); - } - } - - @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); - } - - 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); - } - } - - @SuppressWarnings({"unchecked"}) - protected Comparator<O> getComparator(int pos) { - ensureTokenIndex(this, pos); - return context.getComparator(pos); - } - - @SuppressWarnings({"unchecked"}) - protected Comparable<Comparable<?>> getTokenValue(JXPathContext jxcontext, String token) { - // assume all values are comparable - return (Comparable<Comparable<?>>) jxcontext.getValue(token); - } - - 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) + ">"; - } - } - - 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: trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/JXPathDecorator.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/JXPathDecorator.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/JXPathDecorator.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/JXPathDecorator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,221 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.decorator; + +import org.apache.commons.jxpath.JXPathContext; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.util.*; + +/** + * 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 = DecoratorUtils.newJXPathDecorator(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> + * + * @author chemit + * @param <O> type of data to decorate + * @see Decorator + * @since 1.7.2 (was previously {@code jaxx.runtime.JXPathDecorator}) + */ +public class JXPathDecorator<O> extends Decorator<O> { + + private static final long serialVersionUID = 1L; + /** + * Logger + */ + private static final Log log = LogFactory.getLog(JXPathDecorator.class); + /** + * 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; + + protected JXPathDecorator(Class<O> internalClass, String expression, Context<O> context) throws IllegalArgumentException, NullPointerException { + super(internalClass); + this.initialExpression = expression; + if (context != null) { + setContext(context); + } + } + + @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); + } + + 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); + } + } + + @SuppressWarnings({"unchecked"}) + protected Comparator<O> getComparator(int pos) { + ensureTokenIndex(this, pos); + return context.getComparator(pos); + } + + @SuppressWarnings({"unchecked"}) + protected Comparable<Comparable<?>> getTokenValue(JXPathContext jxcontext, String token) { + // assume all values are comparable + return (Comparable<Comparable<?>>) jxcontext.getValue(token); + } + + 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) + ">"; + } + } + + 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 + "]"); + } + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/MultiJXPathDecorator.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/MultiJXPathDecorator.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/MultiJXPathDecorator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,100 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.decorator; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.Comparator; - -/** - * TODO - * - * @param <O> type of data to decorate - * @author chemit - * @see Decorator - * @since 1.7.2 (was previously {@code jaxx.runtime.MultiJXPathDecorator}) - */ -public class MultiJXPathDecorator<O> extends JXPathDecorator<O> { - - private static final long serialVersionUID = 1L; - /** - * Logger - */ - private static final Log log = LogFactory.getLog(MultiJXPathDecorator.class); - /** - * Contexts of the decorator - */ - protected Context<O>[] contexts; - /** - * context separator - */ - protected String separator; - /** - * context separator replacement - */ - protected String separatorReplacement; - - protected MultiJXPathDecorator(Class<O> internalClass, String expression, - String separator, String separatorReplacement, - Context<O>[] contexts) throws IllegalArgumentException, NullPointerException { - super(internalClass, expression, null); - 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); - } - - protected 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 + "]"); - } - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/MultiJXPathDecorator.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/MultiJXPathDecorator.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/MultiJXPathDecorator.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/MultiJXPathDecorator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,100 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.decorator; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.util.Comparator; + +/** + * TODO + * + * @param <O> type of data to decorate + * @author chemit + * @see Decorator + * @since 1.7.2 (was previously {@code jaxx.runtime.MultiJXPathDecorator}) + */ +public class MultiJXPathDecorator<O> extends JXPathDecorator<O> { + + private static final long serialVersionUID = 1L; + /** + * Logger + */ + private static final Log log = LogFactory.getLog(MultiJXPathDecorator.class); + /** + * Contexts of the decorator + */ + protected Context<O>[] contexts; + /** + * context separator + */ + protected String separator; + /** + * context separator replacement + */ + protected String separatorReplacement; + + protected MultiJXPathDecorator(Class<O> internalClass, String expression, + String separator, String separatorReplacement, + Context<O>[] contexts) throws IllegalArgumentException, NullPointerException { + super(internalClass, expression, null); + 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); + } + + protected 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 + "]"); + } + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/PropertyDecorator.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/PropertyDecorator.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/PropertyDecorator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,96 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.decorator; - -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 = DecoratorUtils.newPropertyDecorator(PropertyDecorator.class,"expressions"); - * </pre> - * - * @param <O> type of data to decorate - * @author chemit - * @see Decorator - * @since 1.7.2 (was previously {@code jaxx.runtime.PropertyDecorator}) - */ -public class PropertyDecorator<O> extends Decorator<O> { - - private static final long serialVersionUID = 1L; - /** - * Logger - */ - static private final Log log = LogFactory.getLog(PropertyDecorator.class); - /** - * name of 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: trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/PropertyDecorator.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/PropertyDecorator.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/PropertyDecorator.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/PropertyDecorator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,96 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.decorator; + +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 = DecoratorUtils.newPropertyDecorator(PropertyDecorator.class,"expressions"); + * </pre> + * + * @param <O> type of data to decorate + * @author chemit + * @see Decorator + * @since 1.7.2 (was previously {@code jaxx.runtime.PropertyDecorator}) + */ +public class PropertyDecorator<O> extends Decorator<O> { + + private static final long serialVersionUID = 1L; + /** + * Logger + */ + static private final Log log = LogFactory.getLog(PropertyDecorator.class); + /** + * name of 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; + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/Application.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Application.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/Application.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,71 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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 { - - private static final long serialVersionUID = 1L; - // 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); - } - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/Application.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Application.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/Application.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/Application.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,71 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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 { + + private static final long serialVersionUID = 1L; + // 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); + } + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,279 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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); - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,279 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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); + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,237 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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); - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,237 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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); + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,241 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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(); - - } - -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,241 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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(); + + } + +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,119 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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); - } - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,119 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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); + } + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/GBC.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/GBC.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/GBC.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,153 +0,0 @@ -/** - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -/* -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; - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/GBC.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/GBC.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/GBC.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/GBC.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,153 @@ +/** + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +/* +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; + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBox.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBox.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBox.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,110 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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; - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBox.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBox.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBox.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBox.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,110 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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; + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxBeanInfo.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxBeanInfo.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxBeanInfo.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,72 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.swing; - -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 { - - @Override - public BeanInfo[] getAdditionalBeanInfo() { - try { - return new BeanInfo[]{Introspector.getBeanInfo(JPanel.class)}; - } catch (IntrospectionException e) { - throw new RuntimeException(e); - } - } - - @Override - 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); - } - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxBeanInfo.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxBeanInfo.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxBeanInfo.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxBeanInfo.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,72 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.swing; + +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 { + + @Override + public BeanInfo[] getAdditionalBeanInfo() { + try { + return new BeanInfo[]{Introspector.getBeanInfo(JPanel.class)}; + } catch (IntrospectionException e) { + throw new RuntimeException(e); + } + } + + @Override + 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); + } + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxLayout.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxLayout.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxLayout.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,143 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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) { - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxLayout.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxLayout.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxLayout.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxLayout.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,143 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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) { + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/Item.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Item.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/Item.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,239 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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 items 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 - * - * @param parent 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 + "]"; - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/Item.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Item.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/Item.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/Item.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,239 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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 items 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 + * + * @param parent 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 + "]"; + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXButtonGroup.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXButtonGroup.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXButtonGroup.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,238 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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); - } - } - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXButtonGroup.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXButtonGroup.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXButtonGroup.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXButtonGroup.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,238 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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); + } + } + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXComboBox.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXComboBox.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXComboBox.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,324 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.swing; - -import javax.swing.*; -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); - } - - /** - * Fill the 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 firstNull add a first null element - * @deprecated since 1.7.XXX this code is moved to JAXXComboBox - */ - public void fillComboBox(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))); - } - } - this.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); - } - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXComboBox.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXComboBox.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXComboBox.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXComboBox.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,324 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.swing; + +import javax.swing.*; +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); + } + + /** + * Fill the 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 firstNull add a first null element + * @deprecated since 1.7.XXX this code is moved to JAXXComboBox + */ + public void fillComboBox(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))); + } + } + this.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); + } + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXList.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXList.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXList.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,412 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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); - } - -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXList.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXList.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXList.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXList.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,412 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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); + } + +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTab.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTab.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTab.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,27 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.swing; - -/** @author chemit */ -public class JAXXTab extends Table { - - private static final long serialVersionUID = 1L; -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTab.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTab.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTab.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTab.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,27 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.swing; + +/** @author chemit */ +public class JAXXTab extends Table { + + private static final long serialVersionUID = 1L; +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXToggleButton.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXToggleButton.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXToggleButton.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,112 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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; - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXToggleButton.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXToggleButton.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXToggleButton.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXToggleButton.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,112 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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; + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTree.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTree.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTree.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,275 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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; - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTree.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTree.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTree.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTree.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,275 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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; + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/OneClicListSelectionModel.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/OneClicListSelectionModel.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/OneClicListSelectionModel.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,201 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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); - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/OneClicListSelectionModel.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/OneClicListSelectionModel.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/OneClicListSelectionModel.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/OneClicListSelectionModel.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,201 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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); + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/Spacer.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Spacer.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/Spacer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,28 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.swing; - -import javax.swing.JComponent; - -public class Spacer extends JComponent { - - private static final long serialVersionUID = 1L; -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/Spacer.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Spacer.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/Spacer.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/Spacer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,28 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.swing; + +import javax.swing.JComponent; + +public class Spacer extends JComponent { + + private static final long serialVersionUID = 1L; +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,181 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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); - } - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,181 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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); + } + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,60 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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()); - } - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,60 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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()); + } + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/Table.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Table.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/Table.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,74 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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(); - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/Table.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Table.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/Table.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/Table.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,74 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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(); + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBox.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBox.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBox.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,110 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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; - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBox.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBox.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBox.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBox.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,110 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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; + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxBeanInfo.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxBeanInfo.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxBeanInfo.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,72 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.swing; - -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 { - - @Override - public BeanInfo[] getAdditionalBeanInfo() { - try { - return new BeanInfo[]{Introspector.getBeanInfo(JPanel.class)}; - } catch (IntrospectionException e) { - throw new RuntimeException(e); - } - } - - @Override - 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); - } - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxBeanInfo.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxBeanInfo.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxBeanInfo.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxBeanInfo.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,72 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.swing; + +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 { + + @Override + public BeanInfo[] getAdditionalBeanInfo() { + try { + return new BeanInfo[]{Introspector.getBeanInfo(JPanel.class)}; + } catch (IntrospectionException e) { + throw new RuntimeException(e); + } + } + + @Override + 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); + } + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxLayout.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxLayout.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxLayout.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,143 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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) { - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxLayout.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxLayout.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxLayout.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxLayout.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,143 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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) { + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/ClassCellEditor.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/ClassCellEditor.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/ClassCellEditor.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,121 +0,0 @@ -/* -* *##% - * JAXX Runtime - * 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>. - * ##%* */ -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; - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/ClassCellEditor.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/ClassCellEditor.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/ClassCellEditor.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/ClassCellEditor.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,121 @@ +/* +* *##% + * JAXX Runtime + * 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>. + * ##%* */ +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; + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/EnumEditor.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/EnumEditor.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/EnumEditor.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,59 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* */ -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()]); - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/EnumEditor.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/EnumEditor.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/EnumEditor.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/EnumEditor.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,59 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* */ +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()]); + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/LocaleEditor.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/LocaleEditor.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/LocaleEditor.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,66 +0,0 @@ -/* -* *##% - * JAXX Runtime - * 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>. - * ##%* */ -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; - } - -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/LocaleEditor.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/LocaleEditor.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/LocaleEditor.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/LocaleEditor.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,66 @@ +/* +* *##% + * JAXX Runtime + * 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>. + * ##%* */ +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; + } + +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/MyDefaultCellEditor.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/MyDefaultCellEditor.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/MyDefaultCellEditor.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,122 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.swing.editor; - -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); - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/MyDefaultCellEditor.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/MyDefaultCellEditor.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/MyDefaultCellEditor.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/MyDefaultCellEditor.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,122 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.swing.editor; + +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); + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpBroker.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpBroker.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpBroker.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,584 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.swing.help; - -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.Locale; -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. - * - * @author tony - * @since 1.4 - */ -public class JAXXHelpBroker { - - public static final String JAXX_CONTEXT_ENTRY = "jaxxcontext"; - /** - * Logger - */ - static private Log log = LogFactory.getLog(JAXXHelpBroker.class); - /** - * name of helpset - */ - protected final String helpsetName; - /** - * default id to use if none given - */ - protected final String defaultID; - /** - * help key - */ - protected final String helpKey; - /** - * helpset to use - */ - protected HelpSet helpset; - /** - * help broker - */ - protected HelpBroker helpBroker; - /** - * current locale used - */ - protected Locale locale; - /** - * cache of cursors modified when in context-sensitive mode - */ - protected Hashtable<Component, Cursor> cursors; - /** - * cursor to use in context-sensitive mode - */ - protected Cursor onItemCursor; - /** - * cache of component which cursor have been modified - */ - protected final Map<Component, String> cache; - /** - * help ui handler - */ - protected JAXXHelpUIHandler handler; - - public JAXXHelpBroker(String helpsetName, String helpKey, String defaultID, JAXXHelpUIHandler handler) { - this(null, helpsetName, helpKey, defaultID, handler); - } - - public JAXXHelpBroker(Locale locale, String helpsetName, String helpKey, String defaultID, JAXXHelpUIHandler handler) { - if (helpsetName == null) { - throw new NullPointerException("parameter helpsetName can not be null!"); - } - if (handler == null) { - throw new NullPointerException("handler can not be null"); - } - this.locale = locale; - this.helpsetName = helpsetName; - this.helpKey = helpKey; - this.defaultID = defaultID; - this.handler = handler; - this.cache = new HashMap<Component, String>(); - } - - 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) { - // no showHelp button - return; - } - - // attach context to button - if (log.isDebugEnabled()) { - log.debug("attach context to showhelp button " + c); - } - help.putClientProperty(JAXX_CONTEXT_ENTRY, c); - - // 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); - } - - - getHelpBroker().enableHelpKey(((Component) c), getDefaultID(), getHelpset()); - } - - public void showHelp(JAXXContext context, String helpId) { - getHandler().showHelp(context, this, helpId); - } - - public JAXXHelpUIHandler getHandler() { - return handler; - } - - public HelpBroker getHelpBroker() { - if (helpBroker == null) { - helpBroker = getHelpset().createHelpBroker(); - } - return helpBroker; - } - - public String getHelpKey() { - return helpKey; - } - - public HelpSet getHelpset() { - if (helpset == null) { - try { - ClassLoader cl = getClass().getClassLoader(); - URL url = HelpSet.findHelpSet(cl, helpsetName, locale); - helpset = new HelpSet(cl, url); - } catch (Exception ee) { - throw new IllegalStateException("could not find help set " + helpsetName + " for reason " + ee.getMessage(), ee); - } - } - return helpset; - } - - public String getHelpsetName() { - return helpsetName; - } - - public String getDefaultID() { - return defaultID; - } - - public void setLocale(Locale locale) { - this.locale = locale; - // need to reload helpset and helpbroker - helpset = null; - helpBroker = null; - getHelpset(); - getHelpBroker(); - } - - public void showHelpSet() { - if (log.isDebugEnabled()) { - log.debug(this); - } - new CSH.DisplayHelpFromSource(getHelpBroker()); - } - - 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); - } - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpBroker.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpBroker.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpBroker.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpBroker.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,584 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.swing.help; + +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.Locale; +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. + * + * @author tony + * @since 1.4 + */ +public class JAXXHelpBroker { + + public static final String JAXX_CONTEXT_ENTRY = "jaxxcontext"; + /** + * Logger + */ + static private Log log = LogFactory.getLog(JAXXHelpBroker.class); + /** + * name of helpset + */ + protected final String helpsetName; + /** + * default id to use if none given + */ + protected final String defaultID; + /** + * help key + */ + protected final String helpKey; + /** + * helpset to use + */ + protected HelpSet helpset; + /** + * help broker + */ + protected HelpBroker helpBroker; + /** + * current locale used + */ + protected Locale locale; + /** + * cache of cursors modified when in context-sensitive mode + */ + protected Hashtable<Component, Cursor> cursors; + /** + * cursor to use in context-sensitive mode + */ + protected Cursor onItemCursor; + /** + * cache of component which cursor have been modified + */ + protected final Map<Component, String> cache; + /** + * help ui handler + */ + protected JAXXHelpUIHandler handler; + + public JAXXHelpBroker(String helpsetName, String helpKey, String defaultID, JAXXHelpUIHandler handler) { + this(null, helpsetName, helpKey, defaultID, handler); + } + + public JAXXHelpBroker(Locale locale, String helpsetName, String helpKey, String defaultID, JAXXHelpUIHandler handler) { + if (helpsetName == null) { + throw new NullPointerException("parameter helpsetName can not be null!"); + } + if (handler == null) { + throw new NullPointerException("handler can not be null"); + } + this.locale = locale; + this.helpsetName = helpsetName; + this.helpKey = helpKey; + this.defaultID = defaultID; + this.handler = handler; + this.cache = new HashMap<Component, String>(); + } + + 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) { + // no showHelp button + return; + } + + // attach context to button + if (log.isDebugEnabled()) { + log.debug("attach context to showhelp button " + c); + } + help.putClientProperty(JAXX_CONTEXT_ENTRY, c); + + // 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); + } + + + getHelpBroker().enableHelpKey(((Component) c), getDefaultID(), getHelpset()); + } + + public void showHelp(JAXXContext context, String helpId) { + getHandler().showHelp(context, this, helpId); + } + + public JAXXHelpUIHandler getHandler() { + return handler; + } + + public HelpBroker getHelpBroker() { + if (helpBroker == null) { + helpBroker = getHelpset().createHelpBroker(); + } + return helpBroker; + } + + public String getHelpKey() { + return helpKey; + } + + public HelpSet getHelpset() { + if (helpset == null) { + try { + ClassLoader cl = getClass().getClassLoader(); + URL url = HelpSet.findHelpSet(cl, helpsetName, locale); + helpset = new HelpSet(cl, url); + } catch (Exception ee) { + throw new IllegalStateException("could not find help set " + helpsetName + " for reason " + ee.getMessage(), ee); + } + } + return helpset; + } + + public String getHelpsetName() { + return helpsetName; + } + + public String getDefaultID() { + return defaultID; + } + + public void setLocale(Locale locale) { + this.locale = locale; + // need to reload helpset and helpbroker + helpset = null; + helpBroker = null; + getHelpset(); + getHelpBroker(); + } + + public void showHelpSet() { + if (log.isDebugEnabled()) { + log.debug(this); + } + new CSH.DisplayHelpFromSource(getHelpBroker()); + } + + 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); + } + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUI.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUI.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUI.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,42 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.swing.help; - -import java.awt.Component; - -/** - * - * Contract to be added on JAXXObject which 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); -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUI.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUI.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUI.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUI.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,42 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.swing.help; + +import java.awt.Component; + +/** + * + * Contract to be added on JAXXObject which 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); +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUIHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUIHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUIHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,32 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.swing.help; - -import jaxx.runtime.JAXXContext; - -/** - * - * @author chemit - */ -public interface JAXXHelpUIHandler { - - void showHelp(JAXXContext context, JAXXHelpBroker broker, String helpID); -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUIHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUIHandler.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUIHandler.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUIHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,32 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.swing.help; + +import jaxx.runtime.JAXXContext; + +/** + * + * @author chemit + */ +public interface JAXXHelpUIHandler { + + void showHelp(JAXXContext context, JAXXHelpBroker broker, String helpID); +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationCardPanel.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationCardPanel.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationCardPanel.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,82 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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) { - Object value = i.getValue(); - if (value != null) { - if (value instanceof Class<?>) { - layout.show(this, ((Class<?>) value).getName()); - } else { - layout.show(this, value.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; - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationCardPanel.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationCardPanel.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationCardPanel.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationCardPanel.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,82 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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) { + Object value = i.getValue(); + if (value != null) { + if (value instanceof Class<?>) { + layout.show(this, ((Class<?>) value).getName()); + } else { + layout.show(this, value.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; + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationPanel.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationPanel.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationPanel.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,44 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ - -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; - } - -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationPanel.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationPanel.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationPanel.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationPanel.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,44 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ + +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; + } + +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemTreeNavigationAdapter.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemTreeNavigationAdapter.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemTreeNavigationAdapter.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,89 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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(); - if (path == null){ - path = e.getOldLeadSelectionPath(); - } - TreeModel model = tree.getModel(); - - if (!(model instanceof JAXXTreeModel)){ - log.error("Its not an JAXXTreeModel"); - return; - } - - // Find item coresponding - Object lastPathComponent = path.getLastPathComponent(); - Item itemSelected = ((JAXXTreeModel) model).findItem(lastPathComponent); - - // 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); -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemTreeNavigationAdapter.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemTreeNavigationAdapter.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemTreeNavigationAdapter.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemTreeNavigationAdapter.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,89 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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(); + if (path == null){ + path = e.getOldLeadSelectionPath(); + } + TreeModel model = tree.getModel(); + + if (!(model instanceof JAXXTreeModel)){ + log.error("Its not an JAXXTreeModel"); + return; + } + + // Find item coresponding + Object lastPathComponent = path.getLastPathComponent(); + Item itemSelected = ((JAXXTreeModel) model).findItem(lastPathComponent); + + // 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); +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationContentUI.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationContentUI.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationContentUI.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,49 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.swing.navigation; - -/** - * Basic contract on a content UI. - * - * @author chemit - * @since 2.0.0 - */ -public interface NavigationContentUI { - - /** - * Init the ui just before been opened by the method - * {@link NavigationTreeHandler#openUI(java.awt.Component, jaxx.runtime.swing.navigation.NavigationTreeNode)}. - * - * @param node the selected node associated to the ui - * @throws Exception - * @see NavigationTreeHandler#openUI(java.awt.Component, jaxx.runtime.swing.navigation.NavigationTreeNode) - */ - void openUI(NavigationTreeNode node) throws Exception; - - /** - * Clean the ui after been closed by the method {@link NavigationTreeHandler#closeUI(java.awt.Component)}. - * - * @param node the selected node associated to the ui - * @throws Exception - * @see NavigationTreeHandler#closeUI(java.awt.Component) - */ - void closeUI(NavigationTreeNode node) throws Exception; -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationContentUI.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationContentUI.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationContentUI.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationContentUI.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,49 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.swing.navigation; + +/** + * Basic contract on a content UI. + * + * @author chemit + * @since 2.0.0 + */ +public interface NavigationContentUI { + + /** + * Init the ui just before been opened by the method + * {@link NavigationTreeHandler#openUI(java.awt.Component, jaxx.runtime.swing.navigation.NavigationTreeNode)}. + * + * @param node the selected node associated to the ui + * @throws Exception + * @see NavigationTreeHandler#openUI(java.awt.Component, jaxx.runtime.swing.navigation.NavigationTreeNode) + */ + void openUI(NavigationTreeNode node) throws Exception; + + /** + * Clean the ui after been closed by the method {@link NavigationTreeHandler#closeUI(java.awt.Component)}. + * + * @param node the selected node associated to the ui + * @throws Exception + * @see NavigationTreeHandler#closeUI(java.awt.Component) + */ + void closeUI(NavigationTreeNode node) throws Exception; +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,195 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.swing.navigation; - -import javax.swing.JTree; - -import jaxx.runtime.JAXXContext; -import jaxx.runtime.Util; -import jaxx.runtime.context.JAXXContextEntryDef; - -import java.awt.*; - -/** - * To help getting and setting navigation tree objects from a {@link JAXXContext}. - * <p/> - * There is six types of data which can be hold in a context : - * <ul> - * <li>tree : the tree </li> - * <li>tree model : the navigation tree model</li> - * <li>tree handler : the navigation tree handler</li> - * <li>selected path : the navigation path of the selected node</li> - * <li>selected node : the selected node</li> - * <li>selected bean : the selected bean</li> - * <li>selected ui : the selected content ui</li> - * </ul> - * <p/> - * To make possible the use of more than one navigation tree system in a same - * context, we <b>MUST</b> distinguish the context entries definition. For this - * purpose, entries definition are normalized and prefixed by a unique {@link #prefix}. - * <p/> - * Here is the keys mapping : - * <ul> - * <li>tree : {@code prefix + "-tree"}</li> - * <li>tree model : {@code prefix + "-tree-model"}</li> - * <li>tree handler : {@code prefix + "-tree-handler"}</li> - * <li>selected path : {@code prefix + "-selected-path"}</li> - * <li>selected node : {@code prefix + "-selected-node"}</li> - * <li>selected bean : {@code prefix + "-selected-bean"}</li> - * <li>selected ui: {@code prefix + "-selected-ui"}</li> - * </ul> - * - * @author chemit - * @since 1.7.2 - */ -public class NavigationTreeContextHelper { - - protected final String prefix; - protected JAXXContextEntryDef<String> selectedPathContextEntry; - protected JAXXContextEntryDef<Object> selectedBeanContextEntry; - protected JAXXContextEntryDef<NavigationTreeNode> selectedNodeContextEntry; - protected JAXXContextEntryDef<NavigationTreeModel> treeModelContextEntry; - protected JAXXContextEntryDef<NavigationTreeHandler> treeHandlerContextEntry; - protected JAXXContextEntryDef<JTree> treeContextEntry; -// protected JAXXContextEntryDef<Component> selectedUIContextEntry; - - public NavigationTreeContextHelper(String prefix) { - this.prefix = prefix; - treeContextEntry = Util.newContextEntryDef(prefix + "-tree", JTree.class); - treeModelContextEntry = Util.newContextEntryDef(prefix + "-tree-model", NavigationTreeModel.class); - treeHandlerContextEntry = Util.newContextEntryDef(prefix + "-tree-handler", NavigationTreeHandler.class); - selectedBeanContextEntry = Util.newContextEntryDef(prefix + "-selected-bean", Object.class); - selectedNodeContextEntry = Util.newContextEntryDef(prefix + "-selected-node", NavigationTreeNode.class); - selectedPathContextEntry = Util.newContextEntryDef(prefix + "-selected-path", String.class); -// selectedUIContextEntry = Util.newContextEntryDef(prefix + "-selected-ui", Component.class); - } - - public String getPrefix() { - return prefix; - } - - public JTree getTree(JAXXContext context) { - JTree r = getTreeContextEntry().getContextValue(context); - return r; - } - - public NavigationTreeModel getTreeModel(JAXXContext context) { - NavigationTreeModel r = getTreeModelContextEntry().getContextValue(context); - return r; - } - - public NavigationTreeHandler getTreeHandler(JAXXContext context) { - NavigationTreeHandler r = getTreeHandlerContextEntry().getContextValue(context); - return r; - } - - public String getSelectedPath(JAXXContext context) { - String r = getSelectedPathContextEntry().getContextValue(context); - return r; - } - - public NavigationTreeNode getSelectedNode(JAXXContext context) { - NavigationTreeNode r = getSelectedNodeContextEntry().getContextValue(context); - return r; - } - - public Object getSelectedBean(JAXXContext context) { - Object r = getSelectedBeanContextEntry().getContextValue(context); - return r; - } - -// public Component getSelectedUI(JAXXContext context) { -// Component r = getSelectedUIContextEntry().getContextValue(context); -// return r; -// } - - public void setTreeModel(JAXXContext context, NavigationTreeModel model) { - getTreeModelContextEntry().setContextValue(context, model); - } - - public void setTree(JAXXContext context, JTree tree) { - getTreeContextEntry().setContextValue(context, tree); - } - - public void setTreeHandler(JAXXContext context, NavigationTreeHandler handler) { - getTreeHandlerContextEntry().setContextValue(context, handler); - } - - public void setSelectedPath(JAXXContext context, String path) { - if (path == null) { - getSelectedPathContextEntry().removeContextValue(context); - } else { - getSelectedPathContextEntry().setContextValue(context, path); - } - } - - public void setSelectedNode(JAXXContext context, NavigationTreeNode node) { - if (node == null) { - getSelectedNodeContextEntry().removeContextValue(context); - } else { - getSelectedNodeContextEntry().setContextValue(context, node); - } - } - - public void setSelectedBean(JAXXContext context, Object bean) { - if (bean == null) { - getSelectedBeanContextEntry().removeContextValue(context); - } else { - getSelectedBeanContextEntry().setContextValue(context, bean); - } - } - -// public void setSelectedUI(JAXXContext context, Component ui) { -// if (ui == null) { -// getSelectedUIContextEntry().removeContextValue(context); -// } else { -// getSelectedUIContextEntry().setContextValue(context, ui); -// } -// } - - protected JAXXContextEntryDef<NavigationTreeModel> getTreeModelContextEntry() { - return treeModelContextEntry; - } - - protected JAXXContextEntryDef<NavigationTreeHandler> getTreeHandlerContextEntry() { - return treeHandlerContextEntry; - } - - protected JAXXContextEntryDef<Object> getSelectedBeanContextEntry() { - return selectedBeanContextEntry; - } - - protected JAXXContextEntryDef<NavigationTreeNode> getSelectedNodeContextEntry() { - return selectedNodeContextEntry; - } - - protected JAXXContextEntryDef<String> getSelectedPathContextEntry() { - return selectedPathContextEntry; - } - - protected JAXXContextEntryDef<JTree> getTreeContextEntry() { - return treeContextEntry; - } - -// public JAXXContextEntryDef<Component> getSelectedUIContextEntry() { -// return selectedUIContextEntry; -// } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,195 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.swing.navigation; + +import javax.swing.JTree; + +import jaxx.runtime.JAXXContext; +import jaxx.runtime.Util; +import jaxx.runtime.context.JAXXContextEntryDef; + +import java.awt.*; + +/** + * To help getting and setting navigation tree objects from a {@link JAXXContext}. + * <p/> + * There is six types of data which can be hold in a context : + * <ul> + * <li>tree : the tree </li> + * <li>tree model : the navigation tree model</li> + * <li>tree handler : the navigation tree handler</li> + * <li>selected path : the navigation path of the selected node</li> + * <li>selected node : the selected node</li> + * <li>selected bean : the selected bean</li> + * <li>selected ui : the selected content ui</li> + * </ul> + * <p/> + * To make possible the use of more than one navigation tree system in a same + * context, we <b>MUST</b> distinguish the context entries definition. For this + * purpose, entries definition are normalized and prefixed by a unique {@link #prefix}. + * <p/> + * Here is the keys mapping : + * <ul> + * <li>tree : {@code prefix + "-tree"}</li> + * <li>tree model : {@code prefix + "-tree-model"}</li> + * <li>tree handler : {@code prefix + "-tree-handler"}</li> + * <li>selected path : {@code prefix + "-selected-path"}</li> + * <li>selected node : {@code prefix + "-selected-node"}</li> + * <li>selected bean : {@code prefix + "-selected-bean"}</li> + * <li>selected ui: {@code prefix + "-selected-ui"}</li> + * </ul> + * + * @author chemit + * @since 1.7.2 + */ +public class NavigationTreeContextHelper { + + protected final String prefix; + protected JAXXContextEntryDef<String> selectedPathContextEntry; + protected JAXXContextEntryDef<Object> selectedBeanContextEntry; + protected JAXXContextEntryDef<NavigationTreeNode> selectedNodeContextEntry; + protected JAXXContextEntryDef<NavigationTreeModel> treeModelContextEntry; + protected JAXXContextEntryDef<NavigationTreeHandler> treeHandlerContextEntry; + protected JAXXContextEntryDef<JTree> treeContextEntry; +// protected JAXXContextEntryDef<Component> selectedUIContextEntry; + + public NavigationTreeContextHelper(String prefix) { + this.prefix = prefix; + treeContextEntry = Util.newContextEntryDef(prefix + "-tree", JTree.class); + treeModelContextEntry = Util.newContextEntryDef(prefix + "-tree-model", NavigationTreeModel.class); + treeHandlerContextEntry = Util.newContextEntryDef(prefix + "-tree-handler", NavigationTreeHandler.class); + selectedBeanContextEntry = Util.newContextEntryDef(prefix + "-selected-bean", Object.class); + selectedNodeContextEntry = Util.newContextEntryDef(prefix + "-selected-node", NavigationTreeNode.class); + selectedPathContextEntry = Util.newContextEntryDef(prefix + "-selected-path", String.class); +// selectedUIContextEntry = Util.newContextEntryDef(prefix + "-selected-ui", Component.class); + } + + public String getPrefix() { + return prefix; + } + + public JTree getTree(JAXXContext context) { + JTree r = getTreeContextEntry().getContextValue(context); + return r; + } + + public NavigationTreeModel getTreeModel(JAXXContext context) { + NavigationTreeModel r = getTreeModelContextEntry().getContextValue(context); + return r; + } + + public NavigationTreeHandler getTreeHandler(JAXXContext context) { + NavigationTreeHandler r = getTreeHandlerContextEntry().getContextValue(context); + return r; + } + + public String getSelectedPath(JAXXContext context) { + String r = getSelectedPathContextEntry().getContextValue(context); + return r; + } + + public NavigationTreeNode getSelectedNode(JAXXContext context) { + NavigationTreeNode r = getSelectedNodeContextEntry().getContextValue(context); + return r; + } + + public Object getSelectedBean(JAXXContext context) { + Object r = getSelectedBeanContextEntry().getContextValue(context); + return r; + } + +// public Component getSelectedUI(JAXXContext context) { +// Component r = getSelectedUIContextEntry().getContextValue(context); +// return r; +// } + + public void setTreeModel(JAXXContext context, NavigationTreeModel model) { + getTreeModelContextEntry().setContextValue(context, model); + } + + public void setTree(JAXXContext context, JTree tree) { + getTreeContextEntry().setContextValue(context, tree); + } + + public void setTreeHandler(JAXXContext context, NavigationTreeHandler handler) { + getTreeHandlerContextEntry().setContextValue(context, handler); + } + + public void setSelectedPath(JAXXContext context, String path) { + if (path == null) { + getSelectedPathContextEntry().removeContextValue(context); + } else { + getSelectedPathContextEntry().setContextValue(context, path); + } + } + + public void setSelectedNode(JAXXContext context, NavigationTreeNode node) { + if (node == null) { + getSelectedNodeContextEntry().removeContextValue(context); + } else { + getSelectedNodeContextEntry().setContextValue(context, node); + } + } + + public void setSelectedBean(JAXXContext context, Object bean) { + if (bean == null) { + getSelectedBeanContextEntry().removeContextValue(context); + } else { + getSelectedBeanContextEntry().setContextValue(context, bean); + } + } + +// public void setSelectedUI(JAXXContext context, Component ui) { +// if (ui == null) { +// getSelectedUIContextEntry().removeContextValue(context); +// } else { +// getSelectedUIContextEntry().setContextValue(context, ui); +// } +// } + + protected JAXXContextEntryDef<NavigationTreeModel> getTreeModelContextEntry() { + return treeModelContextEntry; + } + + protected JAXXContextEntryDef<NavigationTreeHandler> getTreeHandlerContextEntry() { + return treeHandlerContextEntry; + } + + protected JAXXContextEntryDef<Object> getSelectedBeanContextEntry() { + return selectedBeanContextEntry; + } + + protected JAXXContextEntryDef<NavigationTreeNode> getSelectedNodeContextEntry() { + return selectedNodeContextEntry; + } + + protected JAXXContextEntryDef<String> getSelectedPathContextEntry() { + return selectedPathContextEntry; + } + + protected JAXXContextEntryDef<JTree> getTreeContextEntry() { + return treeContextEntry; + } + +// public JAXXContextEntryDef<Component> getSelectedUIContextEntry() { +// return selectedUIContextEntry; +// } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,303 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.swing.navigation; - -import java.awt.Component; -import javax.swing.event.TreeSelectionEvent; -import javax.swing.event.TreeSelectionListener; -import javax.swing.tree.DefaultTreeSelectionModel; -import javax.swing.tree.TreePath; -import jaxx.runtime.JAXXAction; -import jaxx.runtime.JAXXContext; -import jaxx.runtime.context.JAXXInitialContext; -import jaxx.runtime.JAXXObject; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * The handler of a navigation tree. - * - * This is also the selection model to use, since we must check before moving - * from a node we can not just listen selection model changed, we must control - * it. - * - * @author tony - * @since 1.7.2 - */ -public abstract class NavigationTreeHandler extends DefaultTreeSelectionModel { - - private static final long serialVersionUID = 1L; - /** - * Logger - */ - static private final Log log = LogFactory.getLog(NavigationTreeHandler.class); - - /** - * Strategy of instanciation of ui. - * <p/> - * For a given {@code node}, the method {@link #getId(NavigationTreeNode)} - * returns the id of ui to use. - */ - public enum Strategy { - - /** - * instanciate a ui for a node - */ - PER_NODE { - - @Override - public String getId(NavigationTreeNode node) { - return node.getFullPath(); - } - }, - /** - * instanciate only one a ui for a type,nodes will share the instanciation - */ - PER_UI_TYPE { - - @Override - public String getId(NavigationTreeNode node) { - return node.getUIClass().getName(); - } - }; - - public abstract String getId(NavigationTreeNode node); - } - /** - * UI which contains navigation tree - */ - protected JAXXContext context; - /** - * UI Instanciation strategy - */ - protected Strategy strategy; - /** - * JAXXContext access helper. - * - * @since 1.7.2 - */ - protected NavigationTreeContextHelper contextHelper; - - protected NavigationTreeHandler(String contextPrefix, JAXXObject context, Strategy strategy) { - this.contextHelper = new NavigationTreeContextHelper(contextPrefix); - this.context = context; - this.strategy = strategy; - addTreeSelectionListener(new TreeSelectionListener() { - - @Override - public void valueChanged(TreeSelectionEvent event) { - if (event.getOldLeadSelectionPath() != null && event.getOldLeadSelectionPath().equals(event.getPath())) { - // do not treate this if no path changed - return; - } - NavigationTreeNode node = (NavigationTreeNode) event.getPath().getLastPathComponent(); - selectNodeUI(node); - } - }); - } - - /** - * @return le modèle de navigation associé - */ - protected abstract NavigationTreeModel getNavigationTreeModel(); - - /** - * @return le composent actuellement visible associé au noeud courant ou - * au noeud précédent lors d'un changement de noeud. - */ - protected abstract Component getCurrentUI(); - - /** - * @param node le noeud associé à l'ui à retrouver - * @return l'ui associé au novueau noeud sélectionné - */ - protected abstract Component getUI(NavigationTreeNode node); - - /** - * @param component le composent actuellement visible - * @return <code>true</code> si le composent a bien été fermé, <code>false</code> sinon - * @throws Exception if any - */ - protected abstract boolean closeUI(Component component) throws Exception; - - /** - * Instancie une nouvelle ui associé à un noeud de l'arbre de navigation - * - * @param node le noeud associé à l'ui à créer - * @return la nouvelle ui associée au noeud - * @throws Exception if any - */ - protected abstract Component createUI(NavigationTreeNode node) throws Exception; - - /** - * Ouvre l'ui associée au noeud sélectionné dans l'arbre de navigation. - * - * @param newUI l'ui associé au noeud sélectionné à ouvrir - * @param node le node de l'ui a ouvrir - * @throws Exception if any - */ - protected abstract void openUI(Component newUI, NavigationTreeNode node) throws Exception; - - /** - * Traitement des exceptions. - * - * @param e l'erreur recontrée (ou null si pas d"erreur) - */ - protected abstract void treateError(Exception e); - - public JAXXContext getContext() { - return context; - } - - public NavigationTreeContextHelper getContextHelper() { - return contextHelper; - } - - @Override - public void setSelectionPath(TreePath path) { - if (path.equals(getSelectionPath())) { - // stay on same node, can skip - if (log.isDebugEnabled()) { - log.debug("skip stay on path " + path); - } - return; - } - Component component = getCurrentUI(); - - try { - if (!closeUI(component)) { - if (log.isDebugEnabled()) { - log.debug("changing node canceled!"); - } - // can not changed current node - return; - } - if (component instanceof NavigationContentUI) { - ((NavigationContentUI) component).closeUI((NavigationTreeNode) path.getLastPathComponent()); - } - } catch (Exception ex) { - treateError(ex); - return; - } - if (log.isDebugEnabled()) { - log.debug("will select path " + path); - } - // ok can safely select the new path - super.setSelectionPath(path); - } - - protected void selectNodeUI(NavigationTreeNode node) { - - try { - - String path = node.getFullPath(); - - if (log.isTraceEnabled()) { - log.trace(path); - } - - Component newUI = getUI(node); - - // now, we are free to open the ui associated with the selected node in navigation - - // get the bean associated with the node - Object data = getNavigationTreeModel().getBean(path); - - // save it in context (must be done before init ui) - addSelectedBeanInContext(node, data); - - if (newUI == null) { - - // a new ui instance is required - newUI = createUI(node); - } - - JAXXContext ctxt = getContext(); - NavigationTreeContextHelper helper = getContextHelper(); - - // save in context current node context path - helper.setSelectedPath(ctxt, node.getFullPath()); - - // save in context current node - helper.setSelectedNode(ctxt, node); - - // save in context current ui -// helper.setSelectedUI(ctxt, newUI); - - // really open the ui associated with the selected node - // init ui before to be visible - if (newUI instanceof NavigationContentUI) { - ((NavigationContentUI) newUI).openUI(node); - } - - // set ui in content - openUI(newUI, node); - - } catch (Exception e) { - // remove data from context - - // if any error, go back to previvous node - treateError(e); - } - } - - /** - * Prepare le context a utiliser pour initialiser une nouvelle ui. - * - * @param node le noeud associé à l'ui à créer - * @return le context à utiliser pour instancier l'ui - * @throws Exception if any - */ - protected JAXXContext createUIContext(NavigationTreeNode node) throws Exception { - - if (node.getUIHandlerClass() == null) { - if (log.isWarnEnabled()) { - log.warn("no action associated with ui " + node.getUIClass()); - } - // no action associated, just - return getContext(); - } - - JAXXAction action = node.getUIHandlerClass().newInstance(); - - // init context with - JAXXInitialContext uiContext = action.init(getContext()); - return uiContext; - } - - protected void addSelectedBeanInContext(NavigationTreeNode node, Object data) { - - if (log.isDebugEnabled()) { - log.debug("find data for contextPath <" + node.getFullPath() + "> : " + (data == null ? null : data.getClass())); - } - JAXXContext ctxt = getContext(); - NavigationTreeContextHelper helper = getContextHelper(); - - // remove previous selected bean - //TODO-TC-20091004 should have an automatic clean context method while - helper.setSelectedBean(ctxt, null); - - if (data != null) { - - helper.setSelectedBean(ctxt, data); - } - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,303 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.swing.navigation; + +import java.awt.Component; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.DefaultTreeSelectionModel; +import javax.swing.tree.TreePath; +import jaxx.runtime.JAXXAction; +import jaxx.runtime.JAXXContext; +import jaxx.runtime.context.JAXXInitialContext; +import jaxx.runtime.JAXXObject; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * The handler of a navigation tree. + * + * This is also the selection model to use, since we must check before moving + * from a node we can not just listen selection model changed, we must control + * it. + * + * @author tony + * @since 1.7.2 + */ +public abstract class NavigationTreeHandler extends DefaultTreeSelectionModel { + + private static final long serialVersionUID = 1L; + /** + * Logger + */ + static private final Log log = LogFactory.getLog(NavigationTreeHandler.class); + + /** + * Strategy of instanciation of ui. + * <p/> + * For a given {@code node}, the method {@link #getId(NavigationTreeNode)} + * returns the id of ui to use. + */ + public enum Strategy { + + /** + * instanciate a ui for a node + */ + PER_NODE { + + @Override + public String getId(NavigationTreeNode node) { + return node.getFullPath(); + } + }, + /** + * instanciate only one a ui for a type,nodes will share the instanciation + */ + PER_UI_TYPE { + + @Override + public String getId(NavigationTreeNode node) { + return node.getUIClass().getName(); + } + }; + + public abstract String getId(NavigationTreeNode node); + } + /** + * UI which contains navigation tree + */ + protected JAXXContext context; + /** + * UI Instanciation strategy + */ + protected Strategy strategy; + /** + * JAXXContext access helper. + * + * @since 1.7.2 + */ + protected NavigationTreeContextHelper contextHelper; + + protected NavigationTreeHandler(String contextPrefix, JAXXObject context, Strategy strategy) { + this.contextHelper = new NavigationTreeContextHelper(contextPrefix); + this.context = context; + this.strategy = strategy; + addTreeSelectionListener(new TreeSelectionListener() { + + @Override + public void valueChanged(TreeSelectionEvent event) { + if (event.getOldLeadSelectionPath() != null && event.getOldLeadSelectionPath().equals(event.getPath())) { + // do not treate this if no path changed + return; + } + NavigationTreeNode node = (NavigationTreeNode) event.getPath().getLastPathComponent(); + selectNodeUI(node); + } + }); + } + + /** + * @return le modèle de navigation associé + */ + protected abstract NavigationTreeModel getNavigationTreeModel(); + + /** + * @return le composent actuellement visible associé au noeud courant ou + * au noeud précédent lors d'un changement de noeud. + */ + protected abstract Component getCurrentUI(); + + /** + * @param node le noeud associé à l'ui à retrouver + * @return l'ui associé au novueau noeud sélectionné + */ + protected abstract Component getUI(NavigationTreeNode node); + + /** + * @param component le composent actuellement visible + * @return <code>true</code> si le composent a bien été fermé, <code>false</code> sinon + * @throws Exception if any + */ + protected abstract boolean closeUI(Component component) throws Exception; + + /** + * Instancie une nouvelle ui associé à un noeud de l'arbre de navigation + * + * @param node le noeud associé à l'ui à créer + * @return la nouvelle ui associée au noeud + * @throws Exception if any + */ + protected abstract Component createUI(NavigationTreeNode node) throws Exception; + + /** + * Ouvre l'ui associée au noeud sélectionné dans l'arbre de navigation. + * + * @param newUI l'ui associé au noeud sélectionné à ouvrir + * @param node le node de l'ui a ouvrir + * @throws Exception if any + */ + protected abstract void openUI(Component newUI, NavigationTreeNode node) throws Exception; + + /** + * Traitement des exceptions. + * + * @param e l'erreur recontrée (ou null si pas d"erreur) + */ + protected abstract void treateError(Exception e); + + public JAXXContext getContext() { + return context; + } + + public NavigationTreeContextHelper getContextHelper() { + return contextHelper; + } + + @Override + public void setSelectionPath(TreePath path) { + if (path.equals(getSelectionPath())) { + // stay on same node, can skip + if (log.isDebugEnabled()) { + log.debug("skip stay on path " + path); + } + return; + } + Component component = getCurrentUI(); + + try { + if (!closeUI(component)) { + if (log.isDebugEnabled()) { + log.debug("changing node canceled!"); + } + // can not changed current node + return; + } + if (component instanceof NavigationContentUI) { + ((NavigationContentUI) component).closeUI((NavigationTreeNode) path.getLastPathComponent()); + } + } catch (Exception ex) { + treateError(ex); + return; + } + if (log.isDebugEnabled()) { + log.debug("will select path " + path); + } + // ok can safely select the new path + super.setSelectionPath(path); + } + + protected void selectNodeUI(NavigationTreeNode node) { + + try { + + String path = node.getFullPath(); + + if (log.isTraceEnabled()) { + log.trace(path); + } + + Component newUI = getUI(node); + + // now, we are free to open the ui associated with the selected node in navigation + + // get the bean associated with the node + Object data = getNavigationTreeModel().getBean(path); + + // save it in context (must be done before init ui) + addSelectedBeanInContext(node, data); + + if (newUI == null) { + + // a new ui instance is required + newUI = createUI(node); + } + + JAXXContext ctxt = getContext(); + NavigationTreeContextHelper helper = getContextHelper(); + + // save in context current node context path + helper.setSelectedPath(ctxt, node.getFullPath()); + + // save in context current node + helper.setSelectedNode(ctxt, node); + + // save in context current ui +// helper.setSelectedUI(ctxt, newUI); + + // really open the ui associated with the selected node + // init ui before to be visible + if (newUI instanceof NavigationContentUI) { + ((NavigationContentUI) newUI).openUI(node); + } + + // set ui in content + openUI(newUI, node); + + } catch (Exception e) { + // remove data from context + + // if any error, go back to previvous node + treateError(e); + } + } + + /** + * Prepare le context a utiliser pour initialiser une nouvelle ui. + * + * @param node le noeud associé à l'ui à créer + * @return le context à utiliser pour instancier l'ui + * @throws Exception if any + */ + protected JAXXContext createUIContext(NavigationTreeNode node) throws Exception { + + if (node.getUIHandlerClass() == null) { + if (log.isWarnEnabled()) { + log.warn("no action associated with ui " + node.getUIClass()); + } + // no action associated, just + return getContext(); + } + + JAXXAction action = node.getUIHandlerClass().newInstance(); + + // init context with + JAXXInitialContext uiContext = action.init(getContext()); + return uiContext; + } + + protected void addSelectedBeanInContext(NavigationTreeNode node, Object data) { + + if (log.isDebugEnabled()) { + log.debug("find data for contextPath <" + node.getFullPath() + "> : " + (data == null ? null : data.getClass())); + } + JAXXContext ctxt = getContext(); + NavigationTreeContextHelper helper = getContextHelper(); + + // remove previous selected bean + //TODO-TC-20091004 should have an automatic clean context method while + helper.setSelectedBean(ctxt, null); + + if (data != null) { + + helper.setSelectedBean(ctxt, data); + } + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,120 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.swing.navigation; - -import jaxx.runtime.JAXXContext; -import jaxx.runtime.JAXXObject; -import jaxx.runtime.swing.CardLayout2; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.swing.JPanel; -import java.awt.Component; - -/** - * Simple {@link NavigationTreeHandler} implementation with a {@link CardLayout2} to manage components to - * associated with tree's nodes. - * <p/> - * For each node, the ui associated has a constraints in a cardlayout which is the node context path. - * <p/> - * A single container managed by the cardlayout is used to display the components associated with tree's nodes. - * - * @author chemit - */ -public abstract class NavigationTreeHandlerWithCardLayout extends NavigationTreeHandler { - - /** - * Logger - */ - static private final Log log = LogFactory.getLog(NavigationTreeHandlerWithCardLayout.class); - - /** - * All components associated with a tree's node is displayed in a single container. - * - * @return the containter of components - */ - protected abstract JPanel getContentContainer(); - - /** - * the cardlayout managing components associated with tree node. The constraints - * of each component is the node contextPath. - * - * @return the layout used to display components associated with tree's nodes. - */ - protected abstract CardLayout2 getContentLayout(); - - public NavigationTreeHandlerWithCardLayout(String contextPrefix, JAXXObject context, Strategy strategy) { - super(contextPrefix, context, strategy); - if (getContentContainer() == null) { - throw new IllegalArgumentException("could not have a null 'contentContainer' in ui " + context); - } - if (getContentLayout() == null) { - throw new IllegalArgumentException("could not have a null 'contentLayout' in ui " + context); - } - } - - @Override - protected Component getCurrentUI() { - CardLayout2 layout = getContentLayout(); - JPanel container = getContentContainer(); - return layout.getVisibleComponent(container); - } - - @Override - protected Component getUI(NavigationTreeNode node) { - CardLayout2 layout = getContentLayout(); - JPanel container = getContentContainer(); - String constraints = strategy.getId(node); - return layout.contains(constraints) ? layout.getComponent(container, constraints) : null; - } - - @Override - protected void openUI(Component newUI, NavigationTreeNode node) throws Exception { - - CardLayout2 layout = getContentLayout(); - JPanel container = getContentContainer(); - // switch layout - String constraints = strategy.getId(node); - layout.show(container, constraints); - } - - @Override - protected boolean closeUI(Component component) throws Exception { - // by default, we says that component was succesfull closed - return true; - } - - @Override - protected Component createUI(NavigationTreeNode node) throws Exception { - - JAXXContext uiContext = createUIContext(node); - - JAXXObject newUI = node.getUIClass().getConstructor(JAXXContext.class).newInstance(uiContext); - - if (log.isDebugEnabled()) { - log.debug("instanciate new ui " + newUI); - } - String constraints = strategy.getId(node); - getContentContainer().add((Component) newUI, constraints); - return (Component) newUI; - } -} - Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,120 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.swing.navigation; + +import jaxx.runtime.JAXXContext; +import jaxx.runtime.JAXXObject; +import jaxx.runtime.swing.CardLayout2; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.swing.JPanel; +import java.awt.Component; + +/** + * Simple {@link NavigationTreeHandler} implementation with a {@link CardLayout2} to manage components to + * associated with tree's nodes. + * <p/> + * For each node, the ui associated has a constraints in a cardlayout which is the node context path. + * <p/> + * A single container managed by the cardlayout is used to display the components associated with tree's nodes. + * + * @author chemit + */ +public abstract class NavigationTreeHandlerWithCardLayout extends NavigationTreeHandler { + + /** + * Logger + */ + static private final Log log = LogFactory.getLog(NavigationTreeHandlerWithCardLayout.class); + + /** + * All components associated with a tree's node is displayed in a single container. + * + * @return the containter of components + */ + protected abstract JPanel getContentContainer(); + + /** + * the cardlayout managing components associated with tree node. The constraints + * of each component is the node contextPath. + * + * @return the layout used to display components associated with tree's nodes. + */ + protected abstract CardLayout2 getContentLayout(); + + public NavigationTreeHandlerWithCardLayout(String contextPrefix, JAXXObject context, Strategy strategy) { + super(contextPrefix, context, strategy); + if (getContentContainer() == null) { + throw new IllegalArgumentException("could not have a null 'contentContainer' in ui " + context); + } + if (getContentLayout() == null) { + throw new IllegalArgumentException("could not have a null 'contentLayout' in ui " + context); + } + } + + @Override + protected Component getCurrentUI() { + CardLayout2 layout = getContentLayout(); + JPanel container = getContentContainer(); + return layout.getVisibleComponent(container); + } + + @Override + protected Component getUI(NavigationTreeNode node) { + CardLayout2 layout = getContentLayout(); + JPanel container = getContentContainer(); + String constraints = strategy.getId(node); + return layout.contains(constraints) ? layout.getComponent(container, constraints) : null; + } + + @Override + protected void openUI(Component newUI, NavigationTreeNode node) throws Exception { + + CardLayout2 layout = getContentLayout(); + JPanel container = getContentContainer(); + // switch layout + String constraints = strategy.getId(node); + layout.show(container, constraints); + } + + @Override + protected boolean closeUI(Component component) throws Exception { + // by default, we says that component was succesfull closed + return true; + } + + @Override + protected Component createUI(NavigationTreeNode node) throws Exception { + + JAXXContext uiContext = createUIContext(node); + + JAXXObject newUI = node.getUIClass().getConstructor(JAXXContext.class).newInstance(uiContext); + + if (log.isDebugEnabled()) { + log.debug("instanciate new ui " + newUI); + } + String constraints = strategy.getId(node); + getContentContainer().add((Component) newUI, constraints); + return (Component) newUI; + } +} + Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,258 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.swing.navigation; - -import java.lang.reflect.InvocationTargetException; -import java.util.Enumeration; -import java.util.regex.Pattern; -import javax.swing.JTree; -import javax.swing.tree.TreePath; -import jaxx.runtime.JAXXContext; -import jaxx.runtime.JAXXObject; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Helper object associated to a given navigation tree system. - * - * To helper is context safe (base on a {@link NavigationTreeContextHelper}. - * - * @author chemit - * @since 1.7.2 - * @see NavigationTreeModel - */ -public abstract class NavigationTreeHelper extends NavigationTreeContextHelper { - - /** - * Logger - */ - static private final Log log = LogFactory.getLog(NavigationTreeHelper.class); - - /** - * Create the tree model. - * - * @param context the context to associate with fresh model - * @return the new model build with data from the given context - */ - public abstract NavigationTreeModel createTreeModel(JAXXContext context); - - /** - * Create the tree handler. - * - * @param context the context to associate with fresh handler - * @return the new handler - */ - public abstract NavigationTreeHandler createTreeHandler(JAXXObject context); - - public NavigationTreeHelper(String contextPrefix) { - super(contextPrefix); - } - - public Object getContextValue(JAXXContext context, String path) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException { - NavigationTreeModel treeModel = getSafeTreeModel(context); - return treeModel.getBean(path); - } - - public NavigationTreeNode findNode(JAXXContext context, String path) { - NavigationTreeModel treeModel = getSafeTreeModel(context); - return treeModel.findNode(path); - } - - public NavigationTreeNode findNode(JAXXContext context, String path, String regex) { - NavigationTreeModel treeModel = getSafeTreeModel(context); - return treeModel.findNode(path, regex); - } - - public NavigationTreeNode findNode(JAXXContext context, String path, Pattern regex) { - - NavigationTreeModel treeModel = getSafeTreeModel(context); - return treeModel.findNode(path, regex); - } - - public NavigationTreeNode findNode(JAXXContext context, String path, String regex, String suffix) { - - NavigationTreeModel treeModel = getSafeTreeModel(context); - - NavigationTreeNode navigationTreeNode = treeModel.findNode(path, regex); - if (navigationTreeNode != null && suffix != null) { - navigationTreeNode = treeModel.findNode(navigationTreeNode, suffix); - } - return navigationTreeNode; - } - - public NavigationTreeNode findNode(JAXXContext context, String path, Pattern regex, String suffix) { - - NavigationTreeModel treeModel = getSafeTreeModel(context); - - NavigationTreeNode navigationTreeNode = treeModel.findNode(path, regex); - if (navigationTreeNode != null && suffix != null) { - navigationTreeNode = treeModel.findNode(navigationTreeNode, suffix); - } - return navigationTreeNode; - } - - /** - * Sélection d'un noeud dans l'arbre de navigation à partir de son path. - * - * @param context le contexte applicatif - * @param path le path absolue du noeud dans l'arbre - */ - public void selectNode(JAXXContext context, String path) { - NavigationTreeNode node = findNode(context, path); - if (log.isDebugEnabled()) { - log.debug(path + " :: " + node); - } - if (node != null) { - selectNode(context, node); - } - } - - /** - * Sélection d'un noeud dans l'arbre de navigation. - * - * @param context le contexte applicatif - * @param node le noeud à sélectionner dans l'arbre - */ - public void selectNode(JAXXContext context, NavigationTreeNode node) { - - - NavigationTreeModel navigationModel = getSafeTreeModel(context); - if (log.isDebugEnabled()) { - log.debug(node); - } - TreePath path = new TreePath(navigationModel.getPathToRoot(node)); - JTree tree = getSafeTree(context); - tree.setSelectionPath(path); - tree.scrollPathToVisible(path); - } - - /** - * Sélection du parent du noeud selectionne dans l'arbre de navigation. - * - * @param context le contexte applicatif - */ - public void gotoParentNode(JAXXContext context) { - - NavigationTreeNode node = getSelectedNode(context); - - if (node == null) { - // pas de noeud selectionne - throw new NullPointerException("no selected node in context"); - } - node = node.getParent(); - - selectNode(context, node); - } - - /** - * Obtain the first ancestor with the matching internalClass - * - * @param current the node to test - * @param beanClass the type of the internal class to seek of - * @return the first ancestor node with the matching class or {@code null} if not found - */ - public NavigationTreeNode getParentNode(NavigationTreeNode current, Class<?> beanClass) { - if (current == null) { - // ancestor not found - return null; - } - if (beanClass.isAssignableFrom(current.getInternalClass())) { - // matching node - return current; - } - // try in the parent of node - return getParentNode(current.getParent(), beanClass); - } - - /** - * Sélection d'un fils du noeud selectionne dans l'arbre de navigation. - * - * @param context le contexte applicatif - * @param childIndex index du fils a selectionner - */ - public void gotoChildNode(JAXXContext context, int childIndex) { - - NavigationTreeNode node = getSelectedNode(context); - - if (node == null) { - // pas de noeud selectionne - throw new NullPointerException("no selected node in context"); - } - node = node.getChildAt(childIndex); - - selectNode(context, node); - } - - /** - * Demande une opération de repaint sur un noeud de l'arbre de navigation. - * - * <b>Note:</b> La descendance du noeud n'est pas repainte. - * - * @param context le contexte applicatif - * @param node le noeud à repaindre - */ - public void repaintNode(JAXXContext context, NavigationTreeNode node) { - repaintNode(context, node, false); - } - - /** - * Demande une opération de repaint sur un noeud de l'arbre de navigation. - * - * <b>Note:</b> La descendance du noeud est repainte si le paramètre - * <code>deep</code> est à <code>true</code>. - * - * @param context le contexte applicatif - * @param node le noeud à repaindre - * @param deep un flag pour activer la repainte de la descendance du noeud - */ - public void repaintNode(JAXXContext context, NavigationTreeNode node, boolean deep) { - NavigationTreeModel navigationModel = getSafeTreeModel(context); - if (log.isDebugEnabled()) { - log.debug(node); - } - navigationModel.nodeChanged(node); - if (deep) { - // repaint childs nodes - //todo we should only repaint necessary nodes ? - Enumeration<?> e = node.children(); - while (e.hasMoreElements()) { - NavigationTreeNode child = (NavigationTreeNode) e.nextElement(); - repaintNode(context, child, true); - } - } - } - - public NavigationTreeModel getSafeTreeModel(JAXXContext context) throws NullPointerException { - NavigationTreeModel treeModel = getTreeModel(context); - if (treeModel == null) { - throw new NullPointerException("could not find tree model with key " + getTreeModelContextEntry() + " in context " + context); - } - return treeModel; - } - - public JTree getSafeTree(JAXXContext context) throws NullPointerException { - JTree tree = getTree(context); - if (tree == null) { - throw new NullPointerException("could not find tree with key " + getTreeContextEntry() + " in context " + context); - } - return tree; - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,258 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.swing.navigation; + +import java.lang.reflect.InvocationTargetException; +import java.util.Enumeration; +import java.util.regex.Pattern; +import javax.swing.JTree; +import javax.swing.tree.TreePath; +import jaxx.runtime.JAXXContext; +import jaxx.runtime.JAXXObject; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Helper object associated to a given navigation tree system. + * + * To helper is context safe (base on a {@link NavigationTreeContextHelper}. + * + * @author chemit + * @since 1.7.2 + * @see NavigationTreeModel + */ +public abstract class NavigationTreeHelper extends NavigationTreeContextHelper { + + /** + * Logger + */ + static private final Log log = LogFactory.getLog(NavigationTreeHelper.class); + + /** + * Create the tree model. + * + * @param context the context to associate with fresh model + * @return the new model build with data from the given context + */ + public abstract NavigationTreeModel createTreeModel(JAXXContext context); + + /** + * Create the tree handler. + * + * @param context the context to associate with fresh handler + * @return the new handler + */ + public abstract NavigationTreeHandler createTreeHandler(JAXXObject context); + + public NavigationTreeHelper(String contextPrefix) { + super(contextPrefix); + } + + public Object getContextValue(JAXXContext context, String path) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException { + NavigationTreeModel treeModel = getSafeTreeModel(context); + return treeModel.getBean(path); + } + + public NavigationTreeNode findNode(JAXXContext context, String path) { + NavigationTreeModel treeModel = getSafeTreeModel(context); + return treeModel.findNode(path); + } + + public NavigationTreeNode findNode(JAXXContext context, String path, String regex) { + NavigationTreeModel treeModel = getSafeTreeModel(context); + return treeModel.findNode(path, regex); + } + + public NavigationTreeNode findNode(JAXXContext context, String path, Pattern regex) { + + NavigationTreeModel treeModel = getSafeTreeModel(context); + return treeModel.findNode(path, regex); + } + + public NavigationTreeNode findNode(JAXXContext context, String path, String regex, String suffix) { + + NavigationTreeModel treeModel = getSafeTreeModel(context); + + NavigationTreeNode navigationTreeNode = treeModel.findNode(path, regex); + if (navigationTreeNode != null && suffix != null) { + navigationTreeNode = treeModel.findNode(navigationTreeNode, suffix); + } + return navigationTreeNode; + } + + public NavigationTreeNode findNode(JAXXContext context, String path, Pattern regex, String suffix) { + + NavigationTreeModel treeModel = getSafeTreeModel(context); + + NavigationTreeNode navigationTreeNode = treeModel.findNode(path, regex); + if (navigationTreeNode != null && suffix != null) { + navigationTreeNode = treeModel.findNode(navigationTreeNode, suffix); + } + return navigationTreeNode; + } + + /** + * Sélection d'un noeud dans l'arbre de navigation à partir de son path. + * + * @param context le contexte applicatif + * @param path le path absolue du noeud dans l'arbre + */ + public void selectNode(JAXXContext context, String path) { + NavigationTreeNode node = findNode(context, path); + if (log.isDebugEnabled()) { + log.debug(path + " :: " + node); + } + if (node != null) { + selectNode(context, node); + } + } + + /** + * Sélection d'un noeud dans l'arbre de navigation. + * + * @param context le contexte applicatif + * @param node le noeud à sélectionner dans l'arbre + */ + public void selectNode(JAXXContext context, NavigationTreeNode node) { + + + NavigationTreeModel navigationModel = getSafeTreeModel(context); + if (log.isDebugEnabled()) { + log.debug(node); + } + TreePath path = new TreePath(navigationModel.getPathToRoot(node)); + JTree tree = getSafeTree(context); + tree.setSelectionPath(path); + tree.scrollPathToVisible(path); + } + + /** + * Sélection du parent du noeud selectionne dans l'arbre de navigation. + * + * @param context le contexte applicatif + */ + public void gotoParentNode(JAXXContext context) { + + NavigationTreeNode node = getSelectedNode(context); + + if (node == null) { + // pas de noeud selectionne + throw new NullPointerException("no selected node in context"); + } + node = node.getParent(); + + selectNode(context, node); + } + + /** + * Obtain the first ancestor with the matching internalClass + * + * @param current the node to test + * @param beanClass the type of the internal class to seek of + * @return the first ancestor node with the matching class or {@code null} if not found + */ + public NavigationTreeNode getParentNode(NavigationTreeNode current, Class<?> beanClass) { + if (current == null) { + // ancestor not found + return null; + } + if (beanClass.isAssignableFrom(current.getInternalClass())) { + // matching node + return current; + } + // try in the parent of node + return getParentNode(current.getParent(), beanClass); + } + + /** + * Sélection d'un fils du noeud selectionne dans l'arbre de navigation. + * + * @param context le contexte applicatif + * @param childIndex index du fils a selectionner + */ + public void gotoChildNode(JAXXContext context, int childIndex) { + + NavigationTreeNode node = getSelectedNode(context); + + if (node == null) { + // pas de noeud selectionne + throw new NullPointerException("no selected node in context"); + } + node = node.getChildAt(childIndex); + + selectNode(context, node); + } + + /** + * Demande une opération de repaint sur un noeud de l'arbre de navigation. + * + * <b>Note:</b> La descendance du noeud n'est pas repainte. + * + * @param context le contexte applicatif + * @param node le noeud à repaindre + */ + public void repaintNode(JAXXContext context, NavigationTreeNode node) { + repaintNode(context, node, false); + } + + /** + * Demande une opération de repaint sur un noeud de l'arbre de navigation. + * + * <b>Note:</b> La descendance du noeud est repainte si le paramètre + * <code>deep</code> est à <code>true</code>. + * + * @param context le contexte applicatif + * @param node le noeud à repaindre + * @param deep un flag pour activer la repainte de la descendance du noeud + */ + public void repaintNode(JAXXContext context, NavigationTreeNode node, boolean deep) { + NavigationTreeModel navigationModel = getSafeTreeModel(context); + if (log.isDebugEnabled()) { + log.debug(node); + } + navigationModel.nodeChanged(node); + if (deep) { + // repaint childs nodes + //todo we should only repaint necessary nodes ? + Enumeration<?> e = node.children(); + while (e.hasMoreElements()) { + NavigationTreeNode child = (NavigationTreeNode) e.nextElement(); + repaintNode(context, child, true); + } + } + } + + public NavigationTreeModel getSafeTreeModel(JAXXContext context) throws NullPointerException { + NavigationTreeModel treeModel = getTreeModel(context); + if (treeModel == null) { + throw new NullPointerException("could not find tree model with key " + getTreeModelContextEntry() + " in context " + context); + } + return treeModel; + } + + public JTree getSafeTree(JAXXContext context) throws NullPointerException { + JTree tree = getTree(context); + if (tree == null) { + throw new NullPointerException("could not find tree with key " + getTreeContextEntry() + " in context " + context); + } + return tree; + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,270 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.swing.navigation; - -import jaxx.runtime.JAXXContext; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.swing.tree.DefaultTreeModel; -import javax.swing.tree.TreeNode; -import java.util.Enumeration; -import java.util.StringTokenizer; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Model of the tree used for a navigation tree. - * <p/> - * Il est composé de {@link NavigationTreeNode} - * - * @author chemit - * @since 1.7.2 - */ -public class NavigationTreeModel extends DefaultTreeModel { - - static private final long serialVersionUID = 1L; - /** - * Logger - */ - static private final Log log = LogFactory.getLog(NavigationTreeModel.class); - /** - * The path separator used to build the {@link NavigationTreeNode#fullPath}. - * - * @see NavigationTreeNode#getNodePath() - * @see NavigationTreeNode#getFullPath() - */ - protected final String pathSeparator; - /** - * Context to retrieve beans - */ - private JAXXContext context; - - public NavigationTreeModel(String pathSeparator, JAXXContext context) { - super(null); - this.pathSeparator = pathSeparator; - this.context = context; - } - - @Override - public NavigationTreeNode getRoot() { - return (NavigationTreeNode) super.getRoot(); - } - - /** - * Search from the root node a node named by his fully path (concatenation of nodes - * {@link NavigationTreeNode#path} valued separated by dot. - * <p/> - * Example : - * <p/> - * <pre>$root.child1.leaf1</pre> - * - * @param path the fully path of the searched node. - * @return the node matching the fully context from the root node, or <code>null</code> if not find. - */ - public NavigationTreeNode findNode(String path) { - return findNode(getRoot(), path, (Pattern) null); - } - - /** - * Apply first the regex pattern to obtain the searched node fi the given <code>regex</code> is not null. - * <p/> - * Search then from the root node a node named by his fully path (concatenation of nodes - * {@link NavigationTreeNode#path} valued separated by {@link #pathSeparator}. - * <p/> - * <p/> - * Example : - * <p/> - * <pre>$root.child1.leaf1</pre> - * - * @param path the fully path of the searched node. - * @param regex a optional regex to apply to path before searching - * @return the node matching the fully context from the root node, or <code>null</code> if not found. - */ - public NavigationTreeNode findNode(String path, String regex) { - return findNode(getRoot(), path, regex); - } - - /** - * Apply first the regex pattern to obtain the searched node. - * <p/> - * Search then from the root node a node named by his fully path (concatenation of nodes - * {@link NavigationTreeNode#path} valued separated by {@link #pathSeparator}. - * <p/> - * Example : - * <p/> - * <pre>$root.child1.leaf1</pre> - * - * @param path the fully path of the searched node. - * @param regex a optional regex to apply to path before searching - * @return the node matching the fully context from the root node, or <code>null</code> if not found. - */ - public NavigationTreeNode findNode(String path, Pattern regex) { - return findNode(getRoot(), path, regex); - } - - /** - * Search from a given root node a node named by his fully path (concatenation of nodes - * {@link NavigationTreeNode#path} valued separated by {@link #pathSeparator}. - * - * @param root root node to be used - * @param path the fully path of the searched node. - * @return the node matching the fully context from the given root node, or <code>null</code> if not found. - */ - public NavigationTreeNode findNode(NavigationTreeNode root, String path) { - return findNode(root, path, (Pattern) null); - } - - /** - * Apply first the regex pattern to obtain the searched node. - * <p/> - * Search then from a given root node a node named by his fully path (concatenation of nodes) - * {@link NavigationTreeNode#path} valued separated by {@link #pathSeparator}. - * - * @param root root node to be used - * @param path the fully path of the searched node. - * @param regex a previous regex to apply to path : must have a matches - * @return the node matching the fully context from the given root node, or <code>null</code> if not found. - */ - public NavigationTreeNode findNode(NavigationTreeNode root, String path, String regex) { - return findNode(root, path, regex == null ? null : Pattern.compile(regex)); - } - - /** - * Apply first the regex pattern to obtain the searched node. - * <p/> - * Search then from a given root node a node named by his fully path (concatenation of nodes - * {@link NavigationTreeNode#path} valued separated by {@link #pathSeparator}. - * - * @param root root node to be used - * @param path the fully path of the searched node. - * @param regex a previous regex to apply to path : must have a matches - * @return the node matching the fully context from the given root node, or <code>null</code> if not found. - */ - public NavigationTreeNode findNode(NavigationTreeNode root, String path, Pattern regex) { - if (regex != null) { - Matcher matcher = regex.matcher(path); - if (!matcher.matches() || matcher.groupCount() < 1) { - log.warn("no matching regex " + regex + " to " + path); - return null; - } - path = matcher.group(1); - if (log.isDebugEnabled()) { - log.debug("matching regex " + regex + " : " + path); - } - } - StringTokenizer stk = new StringTokenizer(path, pathSeparator); - NavigationTreeNode result = root; - // pas the first token (matches the root node) - if (root.isRoot() && stk.hasMoreTokens()) { - String rootPath = stk.nextToken(); - if (!rootPath.equals(root.getNodePath())) { - return null; - } - } - while (stk.hasMoreTokens()) { - result = result.getChild(stk.nextToken()); - } - return result; - } - - public JAXXContext getContext() { - return context; - } - - /** - * Obtain the associated bean value from context corresponding to node from given navigation path. - * - * @param navigationPath the current context path of the node - * @return the value associated in context with the given navigation path - */ - public Object getBean(String navigationPath) { - Object result; - NavigationTreeNode node = findNode(navigationPath, (Pattern) null); - result = getBean(node); - return result; - } - - /** - * Obtain the associated bean value from context corresponding to node - * - * @param node the current node - * @return the value associated in context with the given node. - */ - public Object getBean(NavigationTreeNode node) { - if (node == null) { - return null; - //fixme should throw a NPE exception - //throw new NullPointerException("node can not be null"); - } - return node.getBean(getContext()); - } - - @Override - public void nodeChanged(TreeNode node) { - nodeChanged(node, false); - if (log.isDebugEnabled()) { - log.debug(node); - } - } - - @Override - public void nodeStructureChanged(TreeNode node) { - NavigationTreeNode n = (NavigationTreeNode) node; - //TC-20091004 never launch a deep reload - reload(n, true); - super.nodeStructureChanged(node); - if (log.isDebugEnabled()) { - log.debug(node); - } - } - - public void nodeChanged(TreeNode node, boolean deep) { - - NavigationTreeNode n = (NavigationTreeNode) node; - //TC-20091004 never launch a deep clean, since we do a deep nodeChanged. - reload(n, deep); - super.nodeChanged(node); - } - - protected void reload(NavigationTreeNode node) { - reload(node, false); - } - - protected void reload(NavigationTreeNode node, boolean deep) { - if (node == null) { - return; - } - node.reload(getContext()); - - if (deep) { - Enumeration<?> childs = node.children(); - while (childs.hasMoreElements()) { - NavigationTreeNode o = (NavigationTreeNode) childs.nextElement(); - reload(o, true); - } - } - } - - public String getPathSeparator() { - return pathSeparator; - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,270 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.swing.navigation; + +import jaxx.runtime.JAXXContext; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreeNode; +import java.util.Enumeration; +import java.util.StringTokenizer; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Model of the tree used for a navigation tree. + * <p/> + * Il est composé de {@link NavigationTreeNode} + * + * @author chemit + * @since 1.7.2 + */ +public class NavigationTreeModel extends DefaultTreeModel { + + static private final long serialVersionUID = 1L; + /** + * Logger + */ + static private final Log log = LogFactory.getLog(NavigationTreeModel.class); + /** + * The path separator used to build the {@link NavigationTreeNode#fullPath}. + * + * @see NavigationTreeNode#getNodePath() + * @see NavigationTreeNode#getFullPath() + */ + protected final String pathSeparator; + /** + * Context to retrieve beans + */ + private JAXXContext context; + + public NavigationTreeModel(String pathSeparator, JAXXContext context) { + super(null); + this.pathSeparator = pathSeparator; + this.context = context; + } + + @Override + public NavigationTreeNode getRoot() { + return (NavigationTreeNode) super.getRoot(); + } + + /** + * Search from the root node a node named by his fully path (concatenation of nodes + * {@link NavigationTreeNode#path} valued separated by dot. + * <p/> + * Example : + * <p/> + * <pre>$root.child1.leaf1</pre> + * + * @param path the fully path of the searched node. + * @return the node matching the fully context from the root node, or <code>null</code> if not find. + */ + public NavigationTreeNode findNode(String path) { + return findNode(getRoot(), path, (Pattern) null); + } + + /** + * Apply first the regex pattern to obtain the searched node fi the given <code>regex</code> is not null. + * <p/> + * Search then from the root node a node named by his fully path (concatenation of nodes + * {@link NavigationTreeNode#path} valued separated by {@link #pathSeparator}. + * <p/> + * <p/> + * Example : + * <p/> + * <pre>$root.child1.leaf1</pre> + * + * @param path the fully path of the searched node. + * @param regex a optional regex to apply to path before searching + * @return the node matching the fully context from the root node, or <code>null</code> if not found. + */ + public NavigationTreeNode findNode(String path, String regex) { + return findNode(getRoot(), path, regex); + } + + /** + * Apply first the regex pattern to obtain the searched node. + * <p/> + * Search then from the root node a node named by his fully path (concatenation of nodes + * {@link NavigationTreeNode#path} valued separated by {@link #pathSeparator}. + * <p/> + * Example : + * <p/> + * <pre>$root.child1.leaf1</pre> + * + * @param path the fully path of the searched node. + * @param regex a optional regex to apply to path before searching + * @return the node matching the fully context from the root node, or <code>null</code> if not found. + */ + public NavigationTreeNode findNode(String path, Pattern regex) { + return findNode(getRoot(), path, regex); + } + + /** + * Search from a given root node a node named by his fully path (concatenation of nodes + * {@link NavigationTreeNode#path} valued separated by {@link #pathSeparator}. + * + * @param root root node to be used + * @param path the fully path of the searched node. + * @return the node matching the fully context from the given root node, or <code>null</code> if not found. + */ + public NavigationTreeNode findNode(NavigationTreeNode root, String path) { + return findNode(root, path, (Pattern) null); + } + + /** + * Apply first the regex pattern to obtain the searched node. + * <p/> + * Search then from a given root node a node named by his fully path (concatenation of nodes) + * {@link NavigationTreeNode#path} valued separated by {@link #pathSeparator}. + * + * @param root root node to be used + * @param path the fully path of the searched node. + * @param regex a previous regex to apply to path : must have a matches + * @return the node matching the fully context from the given root node, or <code>null</code> if not found. + */ + public NavigationTreeNode findNode(NavigationTreeNode root, String path, String regex) { + return findNode(root, path, regex == null ? null : Pattern.compile(regex)); + } + + /** + * Apply first the regex pattern to obtain the searched node. + * <p/> + * Search then from a given root node a node named by his fully path (concatenation of nodes + * {@link NavigationTreeNode#path} valued separated by {@link #pathSeparator}. + * + * @param root root node to be used + * @param path the fully path of the searched node. + * @param regex a previous regex to apply to path : must have a matches + * @return the node matching the fully context from the given root node, or <code>null</code> if not found. + */ + public NavigationTreeNode findNode(NavigationTreeNode root, String path, Pattern regex) { + if (regex != null) { + Matcher matcher = regex.matcher(path); + if (!matcher.matches() || matcher.groupCount() < 1) { + log.warn("no matching regex " + regex + " to " + path); + return null; + } + path = matcher.group(1); + if (log.isDebugEnabled()) { + log.debug("matching regex " + regex + " : " + path); + } + } + StringTokenizer stk = new StringTokenizer(path, pathSeparator); + NavigationTreeNode result = root; + // pas the first token (matches the root node) + if (root.isRoot() && stk.hasMoreTokens()) { + String rootPath = stk.nextToken(); + if (!rootPath.equals(root.getNodePath())) { + return null; + } + } + while (stk.hasMoreTokens()) { + result = result.getChild(stk.nextToken()); + } + return result; + } + + public JAXXContext getContext() { + return context; + } + + /** + * Obtain the associated bean value from context corresponding to node from given navigation path. + * + * @param navigationPath the current context path of the node + * @return the value associated in context with the given navigation path + */ + public Object getBean(String navigationPath) { + Object result; + NavigationTreeNode node = findNode(navigationPath, (Pattern) null); + result = getBean(node); + return result; + } + + /** + * Obtain the associated bean value from context corresponding to node + * + * @param node the current node + * @return the value associated in context with the given node. + */ + public Object getBean(NavigationTreeNode node) { + if (node == null) { + return null; + //fixme should throw a NPE exception + //throw new NullPointerException("node can not be null"); + } + return node.getBean(getContext()); + } + + @Override + public void nodeChanged(TreeNode node) { + nodeChanged(node, false); + if (log.isDebugEnabled()) { + log.debug(node); + } + } + + @Override + public void nodeStructureChanged(TreeNode node) { + NavigationTreeNode n = (NavigationTreeNode) node; + //TC-20091004 never launch a deep reload + reload(n, true); + super.nodeStructureChanged(node); + if (log.isDebugEnabled()) { + log.debug(node); + } + } + + public void nodeChanged(TreeNode node, boolean deep) { + + NavigationTreeNode n = (NavigationTreeNode) node; + //TC-20091004 never launch a deep clean, since we do a deep nodeChanged. + reload(n, deep); + super.nodeChanged(node); + } + + protected void reload(NavigationTreeNode node) { + reload(node, false); + } + + protected void reload(NavigationTreeNode node, boolean deep) { + if (node == null) { + return; + } + node.reload(getContext()); + + if (deep) { + Enumeration<?> childs = node.children(); + while (childs.hasMoreElements()) { + NavigationTreeNode o = (NavigationTreeNode) childs.nextElement(); + reload(o, true); + } + } + } + + public String getPathSeparator() { + return pathSeparator; + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,262 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.swing.navigation; - -import java.util.Enumeration; -import jaxx.runtime.JAXXAction; -import jaxx.runtime.JAXXContext; -import jaxx.runtime.context.JAXXContextEntryDef; -import jaxx.runtime.JAXXObject; -import jaxx.runtime.decorator.Decorator; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * This object is design to build a {@link NavigationTreeModel}. - * - * @author chemit - * @since 17.2 - */ -public class NavigationTreeModelBuilder { - - /** - * Logger - */ - static private final Log log = LogFactory.getLog(NavigationTreeModelBuilder.class); - /** - * The model dealed by the builder. - * - * <b>Note:</b> It is a good idea to keep only one instance of the model. - * If reset is required, should empty the model but not reinstanciate it. - */ - protected NavigationTreeModel model; - /** - * default ui class to use if node does not define an ui class - */ - protected Class<? extends JAXXObject> defaultUIClass; - /** - * [optional] default action class - */ - protected Class<? extends JAXXAction> defaultUIHandlerClass; - - public NavigationTreeModelBuilder(String pathSeparator, JAXXContext context, Class<? extends JAXXObject> defaultUIClass, Class<? extends JAXXAction> defaultUIHandlerClass) { - this(defaultUIClass, defaultUIHandlerClass, new NavigationTreeModel(pathSeparator, context)); - } - - public NavigationTreeModelBuilder(Class<? extends JAXXObject> defaultUIClass, Class<? extends JAXXAction> defaultUIHandlerClass, NavigationTreeModel model) { - this.defaultUIClass = defaultUIClass; - this.defaultUIHandlerClass = defaultUIHandlerClass; - this.model = model; - } - - public NavigationTreeModel getModel() { - return model; - } - - public NavigationTreeNode buildEmptyRoot(JAXXContextEntryDef<?> entryDef, String contextName) { - NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryDef, null); - addI18nNodeRenderer(node, ""); - return addChildNode(null, node); - } - - public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle, - JAXXContextEntryDef<?> entryDef, - String entryPath, - String contextName, - Class<? extends JAXXObject> uiClass, - Class<? extends JAXXAction> actionClass) { - NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryDef, entryPath); - addI18nNodeRenderer(node, libelle); - addNodeJaxxClasses(node, uiClass, actionClass); - return addChildNode(parentNode, node); - } - - public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle, - JAXXContextEntryDef<?> entryDef, - String contextName, - Class<? extends JAXXObject> uiClass, - Class<? extends JAXXAction> actionClass) { - NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryDef); - addI18nNodeRenderer(node, libelle); - addNodeJaxxClasses(node, uiClass, actionClass); - return addChildNode(parentNode, node); - } - - public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle, - String entryPath, - String contextName, - Class<? extends JAXXObject> uiClass, - Class<? extends JAXXAction> actionClass) { - NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryPath); - addI18nNodeRenderer(node, libelle); - addNodeJaxxClasses(node, uiClass, actionClass); - return addChildNode(parentNode, node); - } - - public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator, - JAXXContextEntryDef<?> entryDef, - String entryPath, - String contextName, - Class<? extends JAXXObject> uiClass, - Class<? extends JAXXAction> actionClass) { - NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryDef, entryPath); - addDecoratorNodeRenderer(node, decorator); - addNodeJaxxClasses(node, uiClass, actionClass); - return addChildNode(parentNode, node); - } - - public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator, - JAXXContextEntryDef<?> entryDef, - String contextName, - Class<? extends JAXXObject> uiClass, - Class<? extends JAXXAction> actionClass) { - NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryDef); - addDecoratorNodeRenderer(node, decorator); - addNodeJaxxClasses(node, uiClass, actionClass); - return addChildNode(parentNode, node); - } - - public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator, - String entryPath, - String contextName, - Class<? extends JAXXObject> uiClass, - Class<? extends JAXXAction> actionClass) { - NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, null, entryPath); - addDecoratorNodeRenderer(node, decorator); - addNodeJaxxClasses(node, uiClass, actionClass); - return addChildNode(parentNode, node); - } - - protected NavigationTreeNode addChildNode(NavigationTreeNode parentNode, NavigationTreeNode node) { - - if (node.getUIClass() == null) { - // no ui is associated with this node, use the default one - node.setUIClass(defaultUIClass); - } - - if (node.getUIHandlerClass() == null) { - // no ui handler associated with this node, use the default one - node.setUIHandlerClass(defaultUIHandlerClass); - } - if (parentNode == null) { - model.setRoot(node); - } else { - parentNode.add(node); - } - model.nodeStructureChanged(parentNode); - return node; - } - - public NavigationTreeNode removeChildNode(NavigationTreeNode node) { - NavigationTreeNode parentNode = node.getParent(); - model.removeNodeFromParent(node); - return parentNode; - } - - public void addI18nNodeRenderer(NavigationTreeNode node, String libelle) { - node.setRenderer(new NavigationTreeNodeRendererI18nImpl(libelle)); - } - - public void addDecoratorNodeRenderer(NavigationTreeNode node, Decorator<?> decorator) { - node.setRenderer(new NavigationTreeNodeRendererDecoratorImpl(decorator)); - } - - public void addNodeJaxxClasses( - NavigationTreeNode node, - Class<? extends JAXXObject> uIClass, - Class<? extends JAXXAction> uIHandlerClass) { - node.setUIClass(uIClass); - node.setUIHandlerClass(uIHandlerClass); - } - - public void printModel(NavigationTreeNode node) { - if (node == null) { - return; - } - log.info("node " + node.getFullPath() + ", jxpath: " + node.getJaxxContextEntryPath() + ", entryContextDef: " + node.getJaxxContextEntryDef()); - if (log.isDebugEnabled()) { - log.debug("node userObject" + node.getUserObject()); - log.debug("value from node " + node.getBean(getModel().getContext())); - log.debug("value from model " + getModel().getBean(node)); - } - Enumeration<?> children = node.children(); - while (children.hasMoreElements()) { - printModel((NavigationTreeNode) children.nextElement()); - } - } - - public static abstract class ChildBuilder<O> { - - protected NavigationTreeModelBuilder builder; - - protected ChildBuilder(NavigationTreeModelBuilder builder) { - this.builder = builder; - } - - protected abstract void init(Class<? extends O> klass); - - protected abstract Decorator<? extends O> getDecorator(O child); - - protected abstract String getJXPath(O child); - - protected abstract String getNavigationPath(O child); - - public void build(NavigationTreeNode parent, boolean cacheValues, Class<? extends O> klass, java.util.Collection<? extends O> beans, Class<? extends JAXXObject> ui, Class<? extends JAXXAction> actionClass) { - - if (beans == null || beans.isEmpty()) { - // no bean to treate - return; - } - - init(klass); - - NavigationTreeNode node; - - for (O o : beans) { - node = builder.build(parent, getDecorator(o), getJXPath(o), getNavigationPath(o), ui, actionClass); - if (cacheValues) { - // cache the bean value to improve performance - node.setBean(o); - } - } - } - - public void build(NavigationTreeNode parent, boolean cacheValues, Class<? extends O> klass, O[] beans, Class<? extends JAXXObject> ui, Class<? extends JAXXAction> actionClass) { - - if (beans == null || beans.length == 0) { - // no bean to treate - return; - } - - init(klass); - - NavigationTreeNode node; - - for (O o : beans) { - node = builder.build(parent, getDecorator(o), getJXPath(o), getNavigationPath(o), ui, actionClass); - if (cacheValues) { - // cache the bean value to improve performance - node.setBean(o); - } - } - } - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,262 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.swing.navigation; + +import java.util.Enumeration; +import jaxx.runtime.JAXXAction; +import jaxx.runtime.JAXXContext; +import jaxx.runtime.context.JAXXContextEntryDef; +import jaxx.runtime.JAXXObject; +import jaxx.runtime.decorator.Decorator; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * This object is design to build a {@link NavigationTreeModel}. + * + * @author chemit + * @since 17.2 + */ +public class NavigationTreeModelBuilder { + + /** + * Logger + */ + static private final Log log = LogFactory.getLog(NavigationTreeModelBuilder.class); + /** + * The model dealed by the builder. + * + * <b>Note:</b> It is a good idea to keep only one instance of the model. + * If reset is required, should empty the model but not reinstanciate it. + */ + protected NavigationTreeModel model; + /** + * default ui class to use if node does not define an ui class + */ + protected Class<? extends JAXXObject> defaultUIClass; + /** + * [optional] default action class + */ + protected Class<? extends JAXXAction> defaultUIHandlerClass; + + public NavigationTreeModelBuilder(String pathSeparator, JAXXContext context, Class<? extends JAXXObject> defaultUIClass, Class<? extends JAXXAction> defaultUIHandlerClass) { + this(defaultUIClass, defaultUIHandlerClass, new NavigationTreeModel(pathSeparator, context)); + } + + public NavigationTreeModelBuilder(Class<? extends JAXXObject> defaultUIClass, Class<? extends JAXXAction> defaultUIHandlerClass, NavigationTreeModel model) { + this.defaultUIClass = defaultUIClass; + this.defaultUIHandlerClass = defaultUIHandlerClass; + this.model = model; + } + + public NavigationTreeModel getModel() { + return model; + } + + public NavigationTreeNode buildEmptyRoot(JAXXContextEntryDef<?> entryDef, String contextName) { + NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryDef, null); + addI18nNodeRenderer(node, ""); + return addChildNode(null, node); + } + + public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle, + JAXXContextEntryDef<?> entryDef, + String entryPath, + String contextName, + Class<? extends JAXXObject> uiClass, + Class<? extends JAXXAction> actionClass) { + NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryDef, entryPath); + addI18nNodeRenderer(node, libelle); + addNodeJaxxClasses(node, uiClass, actionClass); + return addChildNode(parentNode, node); + } + + public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle, + JAXXContextEntryDef<?> entryDef, + String contextName, + Class<? extends JAXXObject> uiClass, + Class<? extends JAXXAction> actionClass) { + NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryDef); + addI18nNodeRenderer(node, libelle); + addNodeJaxxClasses(node, uiClass, actionClass); + return addChildNode(parentNode, node); + } + + public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle, + String entryPath, + String contextName, + Class<? extends JAXXObject> uiClass, + Class<? extends JAXXAction> actionClass) { + NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryPath); + addI18nNodeRenderer(node, libelle); + addNodeJaxxClasses(node, uiClass, actionClass); + return addChildNode(parentNode, node); + } + + public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator, + JAXXContextEntryDef<?> entryDef, + String entryPath, + String contextName, + Class<? extends JAXXObject> uiClass, + Class<? extends JAXXAction> actionClass) { + NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryDef, entryPath); + addDecoratorNodeRenderer(node, decorator); + addNodeJaxxClasses(node, uiClass, actionClass); + return addChildNode(parentNode, node); + } + + public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator, + JAXXContextEntryDef<?> entryDef, + String contextName, + Class<? extends JAXXObject> uiClass, + Class<? extends JAXXAction> actionClass) { + NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryDef); + addDecoratorNodeRenderer(node, decorator); + addNodeJaxxClasses(node, uiClass, actionClass); + return addChildNode(parentNode, node); + } + + public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator, + String entryPath, + String contextName, + Class<? extends JAXXObject> uiClass, + Class<? extends JAXXAction> actionClass) { + NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, null, entryPath); + addDecoratorNodeRenderer(node, decorator); + addNodeJaxxClasses(node, uiClass, actionClass); + return addChildNode(parentNode, node); + } + + protected NavigationTreeNode addChildNode(NavigationTreeNode parentNode, NavigationTreeNode node) { + + if (node.getUIClass() == null) { + // no ui is associated with this node, use the default one + node.setUIClass(defaultUIClass); + } + + if (node.getUIHandlerClass() == null) { + // no ui handler associated with this node, use the default one + node.setUIHandlerClass(defaultUIHandlerClass); + } + if (parentNode == null) { + model.setRoot(node); + } else { + parentNode.add(node); + } + model.nodeStructureChanged(parentNode); + return node; + } + + public NavigationTreeNode removeChildNode(NavigationTreeNode node) { + NavigationTreeNode parentNode = node.getParent(); + model.removeNodeFromParent(node); + return parentNode; + } + + public void addI18nNodeRenderer(NavigationTreeNode node, String libelle) { + node.setRenderer(new NavigationTreeNodeRendererI18nImpl(libelle)); + } + + public void addDecoratorNodeRenderer(NavigationTreeNode node, Decorator<?> decorator) { + node.setRenderer(new NavigationTreeNodeRendererDecoratorImpl(decorator)); + } + + public void addNodeJaxxClasses( + NavigationTreeNode node, + Class<? extends JAXXObject> uIClass, + Class<? extends JAXXAction> uIHandlerClass) { + node.setUIClass(uIClass); + node.setUIHandlerClass(uIHandlerClass); + } + + public void printModel(NavigationTreeNode node) { + if (node == null) { + return; + } + log.info("node " + node.getFullPath() + ", jxpath: " + node.getJaxxContextEntryPath() + ", entryContextDef: " + node.getJaxxContextEntryDef()); + if (log.isDebugEnabled()) { + log.debug("node userObject" + node.getUserObject()); + log.debug("value from node " + node.getBean(getModel().getContext())); + log.debug("value from model " + getModel().getBean(node)); + } + Enumeration<?> children = node.children(); + while (children.hasMoreElements()) { + printModel((NavigationTreeNode) children.nextElement()); + } + } + + public static abstract class ChildBuilder<O> { + + protected NavigationTreeModelBuilder builder; + + protected ChildBuilder(NavigationTreeModelBuilder builder) { + this.builder = builder; + } + + protected abstract void init(Class<? extends O> klass); + + protected abstract Decorator<? extends O> getDecorator(O child); + + protected abstract String getJXPath(O child); + + protected abstract String getNavigationPath(O child); + + public void build(NavigationTreeNode parent, boolean cacheValues, Class<? extends O> klass, java.util.Collection<? extends O> beans, Class<? extends JAXXObject> ui, Class<? extends JAXXAction> actionClass) { + + if (beans == null || beans.isEmpty()) { + // no bean to treate + return; + } + + init(klass); + + NavigationTreeNode node; + + for (O o : beans) { + node = builder.build(parent, getDecorator(o), getJXPath(o), getNavigationPath(o), ui, actionClass); + if (cacheValues) { + // cache the bean value to improve performance + node.setBean(o); + } + } + } + + public void build(NavigationTreeNode parent, boolean cacheValues, Class<? extends O> klass, O[] beans, Class<? extends JAXXObject> ui, Class<? extends JAXXAction> actionClass) { + + if (beans == null || beans.length == 0) { + // no bean to treate + return; + } + + init(klass); + + NavigationTreeNode node; + + for (O o : beans) { + node = builder.build(parent, getDecorator(o), getJXPath(o), getNavigationPath(o), ui, actionClass); + if (cacheValues) { + // cache the bean value to improve performance + node.setBean(o); + } + } + } + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,444 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.swing.navigation; - -import java.util.Enumeration; -import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.TreeNode; -import jaxx.runtime.JAXXAction; -import jaxx.runtime.JAXXContext; -import jaxx.runtime.context.JAXXContextEntryDef; -import jaxx.runtime.JAXXObject; -import org.apache.commons.jxpath.JXPathContext; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Node of the {@link NavigationTreeModel}. - * - * Each node is associated with : - * <ul> - * <li> a {@code bean} coming from a {@link JAXXContext} </li> - * <li> a {@code uiClass} to build the associated ui </li> - * </ul> - * <p/> - * To retrieve the bean from the context, there is a huge logic in the - * method {@link #getBean(JAXXContext)}. - * - * In few words, if the {@link #jaxxContextEntryDef} is defined, it means - * that the object is taken from the {@code context}. - * <p/> - * Otherwise, find the first ancestor with an context entry and retrieve from - * here the bean. - * <p/> - * Then go down to the initial node by applying the jxpath expressions - * {@link #jaxxContextEntryPath} of each node on road back. - * <p/> - * - * To identify easly a node, each node has a {@link #path} and a - * {@link #fullPath} (full path from root node). - * <p/> - * - * To display the node we use a {@link NavigationTreeNodeRenderer} which is in - * fact the {@link #userObject}, the object can be synch with the bean via the - * {@link NavigationTreeNodeRenderer#reload(java.lang.Object)} method. - * - * @author chemit - * @see NavigationTreeModel - * @see NavigationTreeNodeRenderer - * @since 1.7.2 - */ -public class NavigationTreeNode extends DefaultMutableTreeNode { - - private static final long serialVersionUID = 1L; - /** - * Logger - */ - static private final Log log = LogFactory.getLog(NavigationTreeNode.class); - /** - * The path separator used to build the {@link #fullPath}. - * - * @see #path - * @see #fullPath - */ - protected final String pathSeparator; - /** - * The node path. - * <p/> - * Used to build the {@link #fullPath} which gives a unique identifier of the - * node. - * @see #pathSeparator - * @see #fullPath - */ - protected String path; - /** - * The full path for the node from the rood node. - * <p/> - * This path is build by appending nodes {@link #path} from the root node - * to this node, between each path we introduce the {@link #pathSeparator}. - * <p> - * Exemple : - * <pre> - * root - * $root - * `-- child1 - * `-- child2 - * </pre> - * will given {@code $root/child1/child2}. - * @see #pathSeparator - * @see #path - */ - protected String fullPath; - /** - * The UI class associated with the node. - * <p/> - * This class can be {@code null}, in that case, the - * {@link NavigationTreeModelBuilder#defaultUIClass} will be used while - * building the model. - */ - protected Class<? extends JAXXObject> uIClass; - /** - * The UI handler class associated with the node. - * <p/> - * This class can be {@code null}, in that case, the - * {@link NavigationTreeModelBuilder#defaultUIHandlerClass} will be used - * while building the model. - */ - protected Class<? extends JAXXAction> uIHandlerClass; - /** - * The context entry definition to retrieve the bean. - * - * <b>Note:</b> If not set - the {@code bean} will be retrieve on a ancestor - * node. - */ - protected JAXXContextEntryDef<?> jaxxContextEntryDef; - /** - * The jxPath to process to obtain real {@code bean} from the data retrieve - * in the context. - * - * <b>Note:</b> If not set -no jxpath will be apply on the bean from context. - */ - protected String jaxxContextEntryPath; - /** - * The bean associated with the node ( the value can be obtain via the - * method {@link #getBean(JAXXContext)} or directly set via method - * {@link #setBean(Object)}. - * <p/> - * cache of bean associated with bean to improve performance - */ - protected transient Object bean; - /** - * The type of the related bean associated with the node. - * <p/> - * Note: This type is here to override the NodeRenderer internalClass, since - * we could need to override this data. - * <p/> - * If this property is let to null, then we will use the NodeRenderer one - */ - protected Class<?> internalClass; - - public NavigationTreeNode(String pathSeparator, String navigationPath, Object jaxxContextEntryDef) { - super(); - this.pathSeparator = pathSeparator; - this.path = navigationPath; - if (jaxxContextEntryDef instanceof JAXXContextEntryDef<?>) { - this.jaxxContextEntryDef = ((JAXXContextEntryDef<?>) jaxxContextEntryDef); - } else if (jaxxContextEntryDef instanceof String) { - this.jaxxContextEntryPath = (String) jaxxContextEntryDef; - } else if (jaxxContextEntryDef != null) { - // wrong context definition type - throw new IllegalArgumentException("to define a context link, must be a String (jxpath) or a " + JAXXContextEntryDef.class + ", but was " + jaxxContextEntryDef); - } - } - - public NavigationTreeNode(String pathSeparator, String navigationPath, JAXXContextEntryDef<?> jaxxContextEntryDef, String jaxxContextEntryPath) { - super(); - this.pathSeparator = pathSeparator; - this.path = navigationPath; - this.jaxxContextEntryDef = jaxxContextEntryDef; - this.jaxxContextEntryPath = jaxxContextEntryPath; - } - - /** - * - * @return the text node renderer (store in {@link #userObject} property. - */ - public NavigationTreeNodeRenderer getRenderer() { - NavigationTreeNodeRenderer render = null; - Object o = getUserObject(); - if (o != null && o instanceof NavigationTreeNodeRenderer) { - render = (NavigationTreeNodeRenderer) o; - } - return render; - } - - public void setRenderer(NavigationTreeNodeRenderer renderer) { - // clear all cache - bean = null; - setUserObject(renderer); - } - - public String getPathSeparator() { - return pathSeparator; - } - - public String getNodePath() { - return path; - } - - public void setNodePath(String navigationPath) { - this.path = navigationPath; - } - - public Class<? extends JAXXObject> getUIClass() { - return uIClass; - } - - public void setUIClass(Class<? extends JAXXObject> uIClass) { - this.uIClass = uIClass; - } - - public void setInternalClass(Class<?> internalClass) { - this.internalClass = internalClass; - } - - public Class<? extends JAXXAction> getUIHandlerClass() { - return uIHandlerClass; - } - - public void setUIHandlerClass(Class<? extends JAXXAction> uIHandlerClass) { - this.uIHandlerClass = uIHandlerClass; - } - - public JAXXContextEntryDef<?> getJaxxContextEntryDef() { - return jaxxContextEntryDef; - } - - public void setJaxxContextEntryDef(JAXXContextEntryDef<?> jaxxContextEntryDef) { - this.jaxxContextEntryDef = jaxxContextEntryDef; - } - - public String getJaxxContextEntryPath() { - return jaxxContextEntryPath; - } - - public void setJaxxContextEntryPath(String jaxxContextEntryPath) { - this.jaxxContextEntryPath = jaxxContextEntryPath; - } - - public Class<?> getInternalClass() { - if (internalClass == null && getRenderer() != null) { - return getRenderer().getInternalClass(); - } - return internalClass; - } - - /** @return the fully context path of the node from the root node to this. */ - public String getFullPath() { - if (fullPath == null) { - StringBuilder sb = new StringBuilder(); - for (TreeNode treeNode : getPath()) { - NavigationTreeNode myNode = (NavigationTreeNode) treeNode; - sb.append(pathSeparator).append(myNode.getNodePath()); - } - fullPath = sb.substring(1); - } - return fullPath; - } - - @Override - public NavigationTreeNode getChildAt(int index) { - return (NavigationTreeNode) super.getChildAt(index); - } - - @Override - public NavigationTreeNode getParent() { - return (NavigationTreeNode) super.getParent(); - } - - /** - * @param path the name of the {@link #path} to be matched in the child of this node. - * @return the child of this node with given {@link #path} value. - */ - public NavigationTreeNode getChild(String path) { - Enumeration<?> childs = children(); - while (childs.hasMoreElements()) { - NavigationTreeNode son = (NavigationTreeNode) childs.nextElement(); - if (path.equals(son.getNodePath())) { - return son; - } - } - return null; - } - - public Object getBean() { - return bean; - } - - public void setBean(Object bean) { - this.bean = bean; - } - - public void reload(JAXXContext context) { - - // clear bean cache - bean = null; - - // clear context navigation cache - fullPath = null; - - NavigationTreeNodeRenderer renderer = getRenderer(); - if (renderer == null) { - // this can't be ! - throw new NullPointerException("could not find the renderer for node " + this); - } - - Object b = getBean(context); - - renderer.reload(b); - } - - /** - * Obtain the associated bean value from context corresponding to node - * - * @param context the context to seek - * @return the value associated in context with the given context path - */ - public Object getBean(JAXXContext context) { - if (bean != null) { - // use cached bean - return bean; - } - Object result; - if (getJaxxContextEntryDef() != null && jaxxContextEntryPath == null) { - // the node maps directly a value in context, with no jxpath resolving - result = getJaxxContextEntryDef().getContextValue(context); - // save in cache - setBean(result); - return result; - } - // find the first ancestor node with a context def - NavigationTreeNode parentNode = getFirstAncestorWithDef(); - if (parentNode == null) { - log.warn("could not find a ancestor node with a definition of a context entry from node (" + this + ")"); - // todo must be an error - // no parent found - return null; - } - Object parentBean = parentNode.getJaxxContextEntryDef().getContextValue(context); - if (parentBean == null) { - // must be an error no bean found - log.warn("could not find a bean attached in context from context entry definition " + parentNode.getJaxxContextEntryDef()); - return null; - } - if (parentNode.jaxxContextEntryPath != null) { - // apply the jxpath on parentBean - JXPathContext jxcontext = JXPathContext.newContext(parentBean); - parentBean = jxcontext.getValue(parentNode.jaxxContextEntryPath); - } - // save in cache - parentNode.setBean(parentBean); - if (this == parentNode) { - // current node is the node matching the context entry value and no jxpath is found - return parentBean; - } - if (jaxxContextEntryPath == null) { - // todo must be an error - log.warn("must find a jaxxContextEntryPath on node (" + this + ")"); - return null; - } - String jxpathExpression = computeJXPath(jaxxContextEntryPath, parentNode); - if (jxpathExpression == null) { - /// todo must be an error - log.warn("could not build jxpath from node " + parentNode + " to " + this); - // could not retreave the jxpath... - return null; - } - if (jxpathExpression.startsWith("[")) { - // special case when we want to access a collection - jxpathExpression = '.' + jxpathExpression; - } - if (log.isDebugEnabled()) { - log.debug("jxpath : " + jxpathExpression); - } - JXPathContext jxcontext = JXPathContext.newContext(parentBean); - result = jxcontext.getValue(jxpathExpression); - // save in cache - setBean(result); - return result; - } - - /** - * @return the first ancestor with a none null {@link #jaxxContextEntryDef} - * or <code>null</code> if none find.. - */ - protected NavigationTreeNode getFirstAncestorWithDef() { - if (jaxxContextEntryDef != null) { - // find a node with a direct link with the context - return this; - } - // the node is not linked to context - // seek in his parent - NavigationTreeNode ancestor = getParent(); - return ancestor == null ? null : ancestor.getFirstAncestorWithDef(); - } - - protected String computeJXPath(String expr, NavigationTreeNode parentNode) { - if (parentNode == this) { - // reach the parent limit node, return the expr computed - return expr; - } - int firstIndex = expr.indexOf(".."); - int lastIndex = expr.lastIndexOf(".."); - if (firstIndex == -1) { - // this is a error, since current node is not parent limit node, - // we must find somewhere a way to go up in nodes - throw new IllegalArgumentException(expr + " should contains at least one \"..\""); - } - if (firstIndex != 0) { - // this is a error, the ../ must be at the beginning of the expression - throw new IllegalArgumentException("\"..\" must be at the beginning but was : " + expr); - } - NavigationTreeNode ancestor = getParent(); - if (firstIndex == lastIndex) { - // found only one go up, so must be substitute by the parent node context - String newExpr = expr.substring(2); - //String newExpr = expr.substring(expr.startsWith("../") ? 3 : 2); - if (getParent().equals(parentNode)) { - // parent node is the final parent node, so no substitution needed - return newExpr; - } - // ancestor must have a jaxxContextEntryPath - if (ancestor.jaxxContextEntryPath == null) { - throw new IllegalArgumentException("with the expression " + expr + ", the ancestor node (" + ancestor + ") must have a jaxxContextEntryPath definition, but was not "); - } - newExpr = ancestor.jaxxContextEntryPath + newExpr; - return ancestor.computeJXPath(newExpr, parentNode); - } - // have more than one go up, so the ancestor node can not have a jaxxContextEntryPath - if (ancestor.jaxxContextEntryPath != null) { - throw new IllegalArgumentException("with the expression " + expr + ", the ancestor node can not have a jaxxContextEntryPath definition"); - } - // substitute the last ..[/] and delegate to ancestor - String newExpr = expr.substring(0, lastIndex - 1) + expr.substring(lastIndex + (expr.charAt(lastIndex + 3) == '/' ? 3 : 2)); - return ancestor.computeJXPath(newExpr, parentNode); - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,444 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.swing.navigation; + +import java.util.Enumeration; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreeNode; +import jaxx.runtime.JAXXAction; +import jaxx.runtime.JAXXContext; +import jaxx.runtime.context.JAXXContextEntryDef; +import jaxx.runtime.JAXXObject; +import org.apache.commons.jxpath.JXPathContext; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Node of the {@link NavigationTreeModel}. + * + * Each node is associated with : + * <ul> + * <li> a {@code bean} coming from a {@link JAXXContext} </li> + * <li> a {@code uiClass} to build the associated ui </li> + * </ul> + * <p/> + * To retrieve the bean from the context, there is a huge logic in the + * method {@link #getBean(JAXXContext)}. + * + * In few words, if the {@link #jaxxContextEntryDef} is defined, it means + * that the object is taken from the {@code context}. + * <p/> + * Otherwise, find the first ancestor with an context entry and retrieve from + * here the bean. + * <p/> + * Then go down to the initial node by applying the jxpath expressions + * {@link #jaxxContextEntryPath} of each node on road back. + * <p/> + * + * To identify easly a node, each node has a {@link #path} and a + * {@link #fullPath} (full path from root node). + * <p/> + * + * To display the node we use a {@link NavigationTreeNodeRenderer} which is in + * fact the {@link #userObject}, the object can be synch with the bean via the + * {@link NavigationTreeNodeRenderer#reload(java.lang.Object)} method. + * + * @author chemit + * @see NavigationTreeModel + * @see NavigationTreeNodeRenderer + * @since 1.7.2 + */ +public class NavigationTreeNode extends DefaultMutableTreeNode { + + private static final long serialVersionUID = 1L; + /** + * Logger + */ + static private final Log log = LogFactory.getLog(NavigationTreeNode.class); + /** + * The path separator used to build the {@link #fullPath}. + * + * @see #path + * @see #fullPath + */ + protected final String pathSeparator; + /** + * The node path. + * <p/> + * Used to build the {@link #fullPath} which gives a unique identifier of the + * node. + * @see #pathSeparator + * @see #fullPath + */ + protected String path; + /** + * The full path for the node from the rood node. + * <p/> + * This path is build by appending nodes {@link #path} from the root node + * to this node, between each path we introduce the {@link #pathSeparator}. + * <p> + * Exemple : + * <pre> + * root + * $root + * `-- child1 + * `-- child2 + * </pre> + * will given {@code $root/child1/child2}. + * @see #pathSeparator + * @see #path + */ + protected String fullPath; + /** + * The UI class associated with the node. + * <p/> + * This class can be {@code null}, in that case, the + * {@link NavigationTreeModelBuilder#defaultUIClass} will be used while + * building the model. + */ + protected Class<? extends JAXXObject> uIClass; + /** + * The UI handler class associated with the node. + * <p/> + * This class can be {@code null}, in that case, the + * {@link NavigationTreeModelBuilder#defaultUIHandlerClass} will be used + * while building the model. + */ + protected Class<? extends JAXXAction> uIHandlerClass; + /** + * The context entry definition to retrieve the bean. + * + * <b>Note:</b> If not set - the {@code bean} will be retrieve on a ancestor + * node. + */ + protected JAXXContextEntryDef<?> jaxxContextEntryDef; + /** + * The jxPath to process to obtain real {@code bean} from the data retrieve + * in the context. + * + * <b>Note:</b> If not set -no jxpath will be apply on the bean from context. + */ + protected String jaxxContextEntryPath; + /** + * The bean associated with the node ( the value can be obtain via the + * method {@link #getBean(JAXXContext)} or directly set via method + * {@link #setBean(Object)}. + * <p/> + * cache of bean associated with bean to improve performance + */ + protected transient Object bean; + /** + * The type of the related bean associated with the node. + * <p/> + * Note: This type is here to override the NodeRenderer internalClass, since + * we could need to override this data. + * <p/> + * If this property is let to null, then we will use the NodeRenderer one + */ + protected Class<?> internalClass; + + public NavigationTreeNode(String pathSeparator, String navigationPath, Object jaxxContextEntryDef) { + super(); + this.pathSeparator = pathSeparator; + this.path = navigationPath; + if (jaxxContextEntryDef instanceof JAXXContextEntryDef<?>) { + this.jaxxContextEntryDef = ((JAXXContextEntryDef<?>) jaxxContextEntryDef); + } else if (jaxxContextEntryDef instanceof String) { + this.jaxxContextEntryPath = (String) jaxxContextEntryDef; + } else if (jaxxContextEntryDef != null) { + // wrong context definition type + throw new IllegalArgumentException("to define a context link, must be a String (jxpath) or a " + JAXXContextEntryDef.class + ", but was " + jaxxContextEntryDef); + } + } + + public NavigationTreeNode(String pathSeparator, String navigationPath, JAXXContextEntryDef<?> jaxxContextEntryDef, String jaxxContextEntryPath) { + super(); + this.pathSeparator = pathSeparator; + this.path = navigationPath; + this.jaxxContextEntryDef = jaxxContextEntryDef; + this.jaxxContextEntryPath = jaxxContextEntryPath; + } + + /** + * + * @return the text node renderer (store in {@link #userObject} property. + */ + public NavigationTreeNodeRenderer getRenderer() { + NavigationTreeNodeRenderer render = null; + Object o = getUserObject(); + if (o != null && o instanceof NavigationTreeNodeRenderer) { + render = (NavigationTreeNodeRenderer) o; + } + return render; + } + + public void setRenderer(NavigationTreeNodeRenderer renderer) { + // clear all cache + bean = null; + setUserObject(renderer); + } + + public String getPathSeparator() { + return pathSeparator; + } + + public String getNodePath() { + return path; + } + + public void setNodePath(String navigationPath) { + this.path = navigationPath; + } + + public Class<? extends JAXXObject> getUIClass() { + return uIClass; + } + + public void setUIClass(Class<? extends JAXXObject> uIClass) { + this.uIClass = uIClass; + } + + public void setInternalClass(Class<?> internalClass) { + this.internalClass = internalClass; + } + + public Class<? extends JAXXAction> getUIHandlerClass() { + return uIHandlerClass; + } + + public void setUIHandlerClass(Class<? extends JAXXAction> uIHandlerClass) { + this.uIHandlerClass = uIHandlerClass; + } + + public JAXXContextEntryDef<?> getJaxxContextEntryDef() { + return jaxxContextEntryDef; + } + + public void setJaxxContextEntryDef(JAXXContextEntryDef<?> jaxxContextEntryDef) { + this.jaxxContextEntryDef = jaxxContextEntryDef; + } + + public String getJaxxContextEntryPath() { + return jaxxContextEntryPath; + } + + public void setJaxxContextEntryPath(String jaxxContextEntryPath) { + this.jaxxContextEntryPath = jaxxContextEntryPath; + } + + public Class<?> getInternalClass() { + if (internalClass == null && getRenderer() != null) { + return getRenderer().getInternalClass(); + } + return internalClass; + } + + /** @return the fully context path of the node from the root node to this. */ + public String getFullPath() { + if (fullPath == null) { + StringBuilder sb = new StringBuilder(); + for (TreeNode treeNode : getPath()) { + NavigationTreeNode myNode = (NavigationTreeNode) treeNode; + sb.append(pathSeparator).append(myNode.getNodePath()); + } + fullPath = sb.substring(1); + } + return fullPath; + } + + @Override + public NavigationTreeNode getChildAt(int index) { + return (NavigationTreeNode) super.getChildAt(index); + } + + @Override + public NavigationTreeNode getParent() { + return (NavigationTreeNode) super.getParent(); + } + + /** + * @param path the name of the {@link #path} to be matched in the child of this node. + * @return the child of this node with given {@link #path} value. + */ + public NavigationTreeNode getChild(String path) { + Enumeration<?> childs = children(); + while (childs.hasMoreElements()) { + NavigationTreeNode son = (NavigationTreeNode) childs.nextElement(); + if (path.equals(son.getNodePath())) { + return son; + } + } + return null; + } + + public Object getBean() { + return bean; + } + + public void setBean(Object bean) { + this.bean = bean; + } + + public void reload(JAXXContext context) { + + // clear bean cache + bean = null; + + // clear context navigation cache + fullPath = null; + + NavigationTreeNodeRenderer renderer = getRenderer(); + if (renderer == null) { + // this can't be ! + throw new NullPointerException("could not find the renderer for node " + this); + } + + Object b = getBean(context); + + renderer.reload(b); + } + + /** + * Obtain the associated bean value from context corresponding to node + * + * @param context the context to seek + * @return the value associated in context with the given context path + */ + public Object getBean(JAXXContext context) { + if (bean != null) { + // use cached bean + return bean; + } + Object result; + if (getJaxxContextEntryDef() != null && jaxxContextEntryPath == null) { + // the node maps directly a value in context, with no jxpath resolving + result = getJaxxContextEntryDef().getContextValue(context); + // save in cache + setBean(result); + return result; + } + // find the first ancestor node with a context def + NavigationTreeNode parentNode = getFirstAncestorWithDef(); + if (parentNode == null) { + log.warn("could not find a ancestor node with a definition of a context entry from node (" + this + ")"); + // todo must be an error + // no parent found + return null; + } + Object parentBean = parentNode.getJaxxContextEntryDef().getContextValue(context); + if (parentBean == null) { + // must be an error no bean found + log.warn("could not find a bean attached in context from context entry definition " + parentNode.getJaxxContextEntryDef()); + return null; + } + if (parentNode.jaxxContextEntryPath != null) { + // apply the jxpath on parentBean + JXPathContext jxcontext = JXPathContext.newContext(parentBean); + parentBean = jxcontext.getValue(parentNode.jaxxContextEntryPath); + } + // save in cache + parentNode.setBean(parentBean); + if (this == parentNode) { + // current node is the node matching the context entry value and no jxpath is found + return parentBean; + } + if (jaxxContextEntryPath == null) { + // todo must be an error + log.warn("must find a jaxxContextEntryPath on node (" + this + ")"); + return null; + } + String jxpathExpression = computeJXPath(jaxxContextEntryPath, parentNode); + if (jxpathExpression == null) { + /// todo must be an error + log.warn("could not build jxpath from node " + parentNode + " to " + this); + // could not retreave the jxpath... + return null; + } + if (jxpathExpression.startsWith("[")) { + // special case when we want to access a collection + jxpathExpression = '.' + jxpathExpression; + } + if (log.isDebugEnabled()) { + log.debug("jxpath : " + jxpathExpression); + } + JXPathContext jxcontext = JXPathContext.newContext(parentBean); + result = jxcontext.getValue(jxpathExpression); + // save in cache + setBean(result); + return result; + } + + /** + * @return the first ancestor with a none null {@link #jaxxContextEntryDef} + * or <code>null</code> if none find.. + */ + protected NavigationTreeNode getFirstAncestorWithDef() { + if (jaxxContextEntryDef != null) { + // find a node with a direct link with the context + return this; + } + // the node is not linked to context + // seek in his parent + NavigationTreeNode ancestor = getParent(); + return ancestor == null ? null : ancestor.getFirstAncestorWithDef(); + } + + protected String computeJXPath(String expr, NavigationTreeNode parentNode) { + if (parentNode == this) { + // reach the parent limit node, return the expr computed + return expr; + } + int firstIndex = expr.indexOf(".."); + int lastIndex = expr.lastIndexOf(".."); + if (firstIndex == -1) { + // this is a error, since current node is not parent limit node, + // we must find somewhere a way to go up in nodes + throw new IllegalArgumentException(expr + " should contains at least one \"..\""); + } + if (firstIndex != 0) { + // this is a error, the ../ must be at the beginning of the expression + throw new IllegalArgumentException("\"..\" must be at the beginning but was : " + expr); + } + NavigationTreeNode ancestor = getParent(); + if (firstIndex == lastIndex) { + // found only one go up, so must be substitute by the parent node context + String newExpr = expr.substring(2); + //String newExpr = expr.substring(expr.startsWith("../") ? 3 : 2); + if (getParent().equals(parentNode)) { + // parent node is the final parent node, so no substitution needed + return newExpr; + } + // ancestor must have a jaxxContextEntryPath + if (ancestor.jaxxContextEntryPath == null) { + throw new IllegalArgumentException("with the expression " + expr + ", the ancestor node (" + ancestor + ") must have a jaxxContextEntryPath definition, but was not "); + } + newExpr = ancestor.jaxxContextEntryPath + newExpr; + return ancestor.computeJXPath(newExpr, parentNode); + } + // have more than one go up, so the ancestor node can not have a jaxxContextEntryPath + if (ancestor.jaxxContextEntryPath != null) { + throw new IllegalArgumentException("with the expression " + expr + ", the ancestor node can not have a jaxxContextEntryPath definition"); + } + // substitute the last ..[/] and delegate to ancestor + String newExpr = expr.substring(0, lastIndex - 1) + expr.substring(lastIndex + (expr.charAt(lastIndex + 3) == '/' ? 3 : 2)); + return ancestor.computeJXPath(newExpr, parentNode); + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRenderer.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRenderer.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRenderer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,64 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.swing.navigation; - -import javax.swing.tree.TreeCellRenderer; - -/** - * Text Renderer of a {@link NavigationTreeNode}. - * <p/> - * This object will be placed as the {@link NavigationTreeNode#userObject} of - * nodes. - * <p/> - * - * In that way, we can use the {@link #toString()} value to render the node - * without writing any {@link TreeCellRenderer}. - * <p/> - * To rebuild the renderer text of a node use the method {@link #reload(Object)} - * with the {@code bean} provides by the model for the node. - * - * @author chemit - * @since 1.7.2, replace {@code NavigationUtil#NodeRenderer} which disappear soon... - */ -public interface NavigationTreeNodeRenderer extends java.io.Serializable { - - /** - * - * @return the render value of the node - */ - @Override - String toString(); - - /** - * - * Can override the the node internal class for display purpose. - * - * @return the type of data to be displayed. - */ - Class<?> getInternalClass(); - - /** - * Reload the render value from the {@code bean} of node. - * - * @param bean the bean associated to the node to render - */ - void reload(Object bean); -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRenderer.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRenderer.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRenderer.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRenderer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,64 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.swing.navigation; + +import javax.swing.tree.TreeCellRenderer; + +/** + * Text Renderer of a {@link NavigationTreeNode}. + * <p/> + * This object will be placed as the {@link NavigationTreeNode#userObject} of + * nodes. + * <p/> + * + * In that way, we can use the {@link #toString()} value to render the node + * without writing any {@link TreeCellRenderer}. + * <p/> + * To rebuild the renderer text of a node use the method {@link #reload(Object)} + * with the {@code bean} provides by the model for the node. + * + * @author chemit + * @since 1.7.2, replace {@code NavigationUtil#NodeRenderer} which disappear soon... + */ +public interface NavigationTreeNodeRenderer extends java.io.Serializable { + + /** + * + * @return the render value of the node + */ + @Override + String toString(); + + /** + * + * Can override the the node internal class for display purpose. + * + * @return the type of data to be displayed. + */ + Class<?> getInternalClass(); + + /** + * Reload the render value from the {@code bean} of node. + * + * @param bean the bean associated to the node to render + */ + void reload(Object bean); +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererDecoratorImpl.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererDecoratorImpl.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererDecoratorImpl.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,73 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.swing.navigation; - -import jaxx.runtime.decorator.Decorator; - -/** - * Decorator Renderer of a {@link NavigationTreeNode}. - * - * Apply a {@link Decorator} to the {@code bean} associated to the node. - * - * @author chemit - * @since 1.7.2, replace {@code NavigationUtil#NodeRenderer} which disappear soon... - */ -public class NavigationTreeNodeRendererDecoratorImpl implements NavigationTreeNodeRenderer { - - private static final long serialVersionUID = -1L; - /** - * Decorator - */ - protected final Decorator<?> decorator; - /** - * internal class of representing data - */ - protected final Class<?> internalClass; - /** - * last renderered value - */ - protected String text; - - public NavigationTreeNodeRendererDecoratorImpl(Decorator<?> decorator) { - this.internalClass = decorator.getInternalClass(); - this.decorator = decorator; - } - - @Override - public String toString() { - return text; - } - - @Override - public void reload(Object bean) { - try { - text = decorator.toString(bean); - - } catch (Exception e) { - text = ""; - } - } - - @Override - public Class<?> getInternalClass() { - return internalClass; - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererDecoratorImpl.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererDecoratorImpl.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererDecoratorImpl.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererDecoratorImpl.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,73 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.swing.navigation; + +import jaxx.runtime.decorator.Decorator; + +/** + * Decorator Renderer of a {@link NavigationTreeNode}. + * + * Apply a {@link Decorator} to the {@code bean} associated to the node. + * + * @author chemit + * @since 1.7.2, replace {@code NavigationUtil#NodeRenderer} which disappear soon... + */ +public class NavigationTreeNodeRendererDecoratorImpl implements NavigationTreeNodeRenderer { + + private static final long serialVersionUID = -1L; + /** + * Decorator + */ + protected final Decorator<?> decorator; + /** + * internal class of representing data + */ + protected final Class<?> internalClass; + /** + * last renderered value + */ + protected String text; + + public NavigationTreeNodeRendererDecoratorImpl(Decorator<?> decorator) { + this.internalClass = decorator.getInternalClass(); + this.decorator = decorator; + } + + @Override + public String toString() { + return text; + } + + @Override + public void reload(Object bean) { + try { + text = decorator.toString(bean); + + } catch (Exception e) { + text = ""; + } + } + + @Override + public Class<?> getInternalClass() { + return internalClass; + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererI18nImpl.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererI18nImpl.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererI18nImpl.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,68 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.swing.navigation; - -import static org.nuiton.i18n.I18n._; - -/** - * I18n label Renderer of a {@link NavigationTreeNode}. - * - * Just apply a i18n translation on the given {@link #libelle}. - * - * @author chemit - * @since 1.7.2, replace {@code NavigationUtil#NodeRenderer} which disappear soon... - */ -public class NavigationTreeNodeRendererI18nImpl implements NavigationTreeNodeRenderer { - - private static final long serialVersionUID = -1L; - /** - * Static i18n label to render - */ - protected final String libelle; - /** - * internal class of representing data - */ - protected final Class<?> internalClass; - /** - * last renderered value - */ - protected String text; - - public NavigationTreeNodeRendererI18nImpl(String libelle) { - this.libelle = libelle; - this.internalClass = String.class; - } - - @Override - public String toString() { - return text; - } - - @Override - public void reload(Object data) { - text = _(libelle); - } - - @Override - public Class<?> getInternalClass() { - return internalClass; - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererI18nImpl.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererI18nImpl.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererI18nImpl.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererI18nImpl.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,68 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.swing.navigation; + +import static org.nuiton.i18n.I18n._; + +/** + * I18n label Renderer of a {@link NavigationTreeNode}. + * + * Just apply a i18n translation on the given {@link #libelle}. + * + * @author chemit + * @since 1.7.2, replace {@code NavigationUtil#NodeRenderer} which disappear soon... + */ +public class NavigationTreeNodeRendererI18nImpl implements NavigationTreeNodeRenderer { + + private static final long serialVersionUID = -1L; + /** + * Static i18n label to render + */ + protected final String libelle; + /** + * internal class of representing data + */ + protected final Class<?> internalClass; + /** + * last renderered value + */ + protected String text; + + public NavigationTreeNodeRendererI18nImpl(String libelle) { + this.libelle = libelle; + this.internalClass = String.class; + } + + @Override + public String toString() { + return text; + } + + @Override + public void reload(Object data) { + text = _(libelle); + } + + @Override + public Class<?> getInternalClass() { + return internalClass; + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/package.html =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/package.html 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/package.html 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,12 +0,0 @@ -<html> - <body> - <h1>JAXX - tree utilities</h1> - - This package contains all the classes of the navigation tree framework. - - <p> - Replace the previous framework from package - <code>jaxx.runtime.swing.navigation</code> - </p> - </body> -</html> \ No newline at end of file Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/package.html (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/package.html) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/package.html (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/package.html 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,12 @@ +<html> + <body> + <h1>JAXX - tree utilities</h1> + + This package contains all the classes of the navigation tree framework. + + <p> + Replace the previous framework from package + <code>jaxx.runtime.swing.navigation</code> + </p> + </body> +</html> \ No newline at end of file Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/BooleanCellRenderer.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/BooleanCellRenderer.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/BooleanCellRenderer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,81 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.swing.renderer; - -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; - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/BooleanCellRenderer.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/BooleanCellRenderer.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/BooleanCellRenderer.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/BooleanCellRenderer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,81 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.swing.renderer; + +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; + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorListCellRenderer.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorListCellRenderer.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorListCellRenderer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,67 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.swing.renderer; - -import jaxx.runtime.decorator.*; -import java.awt.Component; -import javax.swing.DefaultListCellRenderer; -import javax.swing.JList; -import javax.swing.ListCellRenderer; - -/** - * A {@link ListCellRenderer} which compute text with the given {@link #decorator} - * and leave the hand to the {@link #delegate} to perform the visual renderer. - * - * @author chemit - * @since 1.7.2 - */ -public class DecoratorListCellRenderer implements ListCellRenderer { - - /** - * Delegate cell renderer - */ - protected ListCellRenderer delegate; - /** - * Decorator to produce text to render - */ - protected Decorator<?> decorator; - - public DecoratorListCellRenderer(Decorator<?> decorator) { - this(new DefaultListCellRenderer(), decorator); - } - - public DecoratorListCellRenderer(ListCellRenderer delegate, Decorator<?> decorator) { - this.delegate = delegate; - this.decorator = decorator; - } - - @Override - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - if (value != null) { - if (value instanceof String) { - value = (String) value; - } else { - value = decorator.toString(value); - } - } - return delegate.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorListCellRenderer.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorListCellRenderer.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorListCellRenderer.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorListCellRenderer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,67 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.swing.renderer; + +import jaxx.runtime.decorator.*; +import java.awt.Component; +import javax.swing.DefaultListCellRenderer; +import javax.swing.JList; +import javax.swing.ListCellRenderer; + +/** + * A {@link ListCellRenderer} which compute text with the given {@link #decorator} + * and leave the hand to the {@link #delegate} to perform the visual renderer. + * + * @author chemit + * @since 1.7.2 + */ +public class DecoratorListCellRenderer implements ListCellRenderer { + + /** + * Delegate cell renderer + */ + protected ListCellRenderer delegate; + /** + * Decorator to produce text to render + */ + protected Decorator<?> decorator; + + public DecoratorListCellRenderer(Decorator<?> decorator) { + this(new DefaultListCellRenderer(), decorator); + } + + public DecoratorListCellRenderer(ListCellRenderer delegate, Decorator<?> decorator) { + this.delegate = delegate; + this.decorator = decorator; + } + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + if (value != null) { + if (value instanceof String) { + value = (String) value; + } else { + value = decorator.toString(value); + } + } + return delegate.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorProviderListCellRenderer.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorProviderListCellRenderer.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorProviderListCellRenderer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,53 +0,0 @@ -package jaxx.runtime.swing.renderer; - -import jaxx.runtime.decorator.Decorator; -import jaxx.runtime.decorator.DecoratorProvider; - -import javax.swing.*; -import java.awt.*; - -/** - * A {@link ListCellRenderer} which use decorators from the {@link #provider} to obtain the text to display. - * - * The interest of this renderer is to define a unique renderer for your application (put it in JAXXContext) - * and then use it simply :) - * - * User: chemit - * Date: 29 oct. 2009 - * Time: 03:00:53 - * @since 2.0.0 - * @see DecoratorProvider - */ -public class DecoratorProviderListCellRenderer implements ListCellRenderer { - - /** - * Delegate cell renderer - */ - protected ListCellRenderer delegate; - - /** - * provider of decorators - */ - protected DecoratorProvider provider; - - public DecoratorProviderListCellRenderer(DecoratorProvider provider) { - this(new DefaultListCellRenderer(), provider); - } - - public DecoratorProviderListCellRenderer(ListCellRenderer delegate, DecoratorProvider provider) { - this.delegate = delegate; - this.provider = provider; - } - - @Override - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - if (value != null) { - Decorator<?> decorator = provider.getDecorator(value); - - if (decorator != null) { - value = decorator.toString(value); - } - } - return delegate.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorProviderListCellRenderer.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorProviderListCellRenderer.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorProviderListCellRenderer.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorProviderListCellRenderer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,53 @@ +package jaxx.runtime.swing.renderer; + +import jaxx.runtime.decorator.Decorator; +import jaxx.runtime.decorator.DecoratorProvider; + +import javax.swing.*; +import java.awt.*; + +/** + * A {@link ListCellRenderer} which use decorators from the {@link #provider} to obtain the text to display. + * + * The interest of this renderer is to define a unique renderer for your application (put it in JAXXContext) + * and then use it simply :) + * + * User: chemit + * Date: 29 oct. 2009 + * Time: 03:00:53 + * @since 2.0.0 + * @see DecoratorProvider + */ +public class DecoratorProviderListCellRenderer implements ListCellRenderer { + + /** + * Delegate cell renderer + */ + protected ListCellRenderer delegate; + + /** + * provider of decorators + */ + protected DecoratorProvider provider; + + public DecoratorProviderListCellRenderer(DecoratorProvider provider) { + this(new DefaultListCellRenderer(), provider); + } + + public DecoratorProviderListCellRenderer(ListCellRenderer delegate, DecoratorProvider provider) { + this.delegate = delegate; + this.provider = provider; + } + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + if (value != null) { + Decorator<?> decorator = provider.getDecorator(value); + + if (decorator != null) { + value = decorator.toString(value); + } + } + return delegate.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorProviderTableCellRenderer.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorProviderTableCellRenderer.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorProviderTableCellRenderer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,56 +0,0 @@ -package jaxx.runtime.swing.renderer; - -import jaxx.runtime.decorator.Decorator; -import jaxx.runtime.decorator.DecoratorProvider; - -import javax.swing.*; -import javax.swing.table.DefaultTableCellRenderer; -import javax.swing.table.TableCellRenderer; -import java.awt.*; - -/** - * A {@link TableCellRenderer} which use decorators from the {@link #provider} to obtain the text to display. - * <p/> - * The interest of this renderer is to define a unique renderer for your application (put it in JAXXContext) - * and then use it simply :) - * <p/> - * User: chemit - * Date: 29 oct. 2009 - * Time: 03:00:53 - * - * @see DecoratorProvider - * @since 2.0.0 - */ -public class DecoratorProviderTableCellRenderer implements TableCellRenderer { - - /** - * Delegate cell renderer - */ - protected TableCellRenderer delegate; - - /** - * provider of decorators - */ - protected DecoratorProvider provider; - - public DecoratorProviderTableCellRenderer(DecoratorProvider provider) { - this(new DefaultTableCellRenderer(), provider); - } - - public DecoratorProviderTableCellRenderer(TableCellRenderer delegate, DecoratorProvider provider) { - this.delegate = delegate; - this.provider = provider; - } - - @Override - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasfocus, int row, int column) { - if (value != null) { - Decorator<?> decorator = provider.getDecorator(value); - - if (decorator != null) { - value = decorator.toString(value); - } - } - return delegate.getTableCellRendererComponent(table, value, isSelected, hasfocus, row, column); - } -} \ No newline at end of file Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorProviderTableCellRenderer.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorProviderTableCellRenderer.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorProviderTableCellRenderer.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorProviderTableCellRenderer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,56 @@ +package jaxx.runtime.swing.renderer; + +import jaxx.runtime.decorator.Decorator; +import jaxx.runtime.decorator.DecoratorProvider; + +import javax.swing.*; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableCellRenderer; +import java.awt.*; + +/** + * A {@link TableCellRenderer} which use decorators from the {@link #provider} to obtain the text to display. + * <p/> + * The interest of this renderer is to define a unique renderer for your application (put it in JAXXContext) + * and then use it simply :) + * <p/> + * User: chemit + * Date: 29 oct. 2009 + * Time: 03:00:53 + * + * @see DecoratorProvider + * @since 2.0.0 + */ +public class DecoratorProviderTableCellRenderer implements TableCellRenderer { + + /** + * Delegate cell renderer + */ + protected TableCellRenderer delegate; + + /** + * provider of decorators + */ + protected DecoratorProvider provider; + + public DecoratorProviderTableCellRenderer(DecoratorProvider provider) { + this(new DefaultTableCellRenderer(), provider); + } + + public DecoratorProviderTableCellRenderer(TableCellRenderer delegate, DecoratorProvider provider) { + this.delegate = delegate; + this.provider = provider; + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasfocus, int row, int column) { + if (value != null) { + Decorator<?> decorator = provider.getDecorator(value); + + if (decorator != null) { + value = decorator.toString(value); + } + } + return delegate.getTableCellRendererComponent(table, value, isSelected, hasfocus, row, column); + } +} \ No newline at end of file Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorTableCellRenderer.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorTableCellRenderer.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorTableCellRenderer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,63 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.swing.renderer; - -import jaxx.runtime.decorator.*; -import javax.swing.JTable; -import javax.swing.table.TableCellRenderer; -import java.awt.Component; -import javax.swing.table.DefaultTableCellRenderer; - -/** - * A {@link TableCellRenderer} which compute text with the given {@link #decorator} - * and leave the hand to the {@link #delegate} to perform the visual renderer. - * - * @author chemit - * @since 1.7.2 (was previously {@code jaxx.runtime.swing.DecoratorTableCellRenderer}). - */ -public class DecoratorTableCellRenderer implements TableCellRenderer { - - /** - * Delegate cell renderer - */ - protected TableCellRenderer delegate; - /** - * Decorator to produce text to render - */ - protected Decorator<?> decorator; - - public DecoratorTableCellRenderer(Decorator<?> decorator) { - this(new DefaultTableCellRenderer(), decorator); - } - - public DecoratorTableCellRenderer(TableCellRenderer delegate, Decorator<?> decorator) { - this.delegate = delegate; - this.decorator = decorator; - } - - @Override - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasfocus, int row, int column) { - if (value != null) { - value = decorator.toString(value); - } - return delegate.getTableCellRendererComponent(table, value, isSelected, hasfocus, row, column); - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorTableCellRenderer.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorTableCellRenderer.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorTableCellRenderer.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/DecoratorTableCellRenderer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,63 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.swing.renderer; + +import jaxx.runtime.decorator.*; +import javax.swing.JTable; +import javax.swing.table.TableCellRenderer; +import java.awt.Component; +import javax.swing.table.DefaultTableCellRenderer; + +/** + * A {@link TableCellRenderer} which compute text with the given {@link #decorator} + * and leave the hand to the {@link #delegate} to perform the visual renderer. + * + * @author chemit + * @since 1.7.2 (was previously {@code jaxx.runtime.swing.DecoratorTableCellRenderer}). + */ +public class DecoratorTableCellRenderer implements TableCellRenderer { + + /** + * Delegate cell renderer + */ + protected TableCellRenderer delegate; + /** + * Decorator to produce text to render + */ + protected Decorator<?> decorator; + + public DecoratorTableCellRenderer(Decorator<?> decorator) { + this(new DefaultTableCellRenderer(), decorator); + } + + public DecoratorTableCellRenderer(TableCellRenderer delegate, Decorator<?> decorator) { + this.delegate = delegate; + this.decorator = decorator; + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasfocus, int row, int column) { + if (value != null) { + value = decorator.toString(value); + } + return delegate.getTableCellRendererComponent(table, value, isSelected, hasfocus, row, column); + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EmptyNumberTableCellRenderer.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EmptyNumberTableCellRenderer.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EmptyNumberTableCellRenderer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,57 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.swing.renderer; - -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); - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EmptyNumberTableCellRenderer.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EmptyNumberTableCellRenderer.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EmptyNumberTableCellRenderer.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EmptyNumberTableCellRenderer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,57 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.swing.renderer; + +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); + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EnumTableCellRenderer.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EnumTableCellRenderer.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EnumTableCellRenderer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,67 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.swing.renderer; - -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); - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EnumTableCellRenderer.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EnumTableCellRenderer.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EnumTableCellRenderer.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EnumTableCellRenderer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,67 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.swing.renderer; + +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); + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/I18nTableCellRenderer.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/I18nTableCellRenderer.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/I18nTableCellRenderer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,86 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.swing.renderer; - -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; - } - -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/I18nTableCellRenderer.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/I18nTableCellRenderer.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/I18nTableCellRenderer.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/I18nTableCellRenderer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,86 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.swing.renderer; + +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; + } + +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/LocaleListCellRenderer.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/LocaleListCellRenderer.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/LocaleListCellRenderer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,146 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.swing.renderer; - -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 final 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 = getSafeText(locale); - } - return text; - } - - public Icon getIcon(Locale locale) { - if (!showIcon) { - return null; - } - synchronized (cache) { - Icon icon = getSafeIcon(locale); - return icon; - } - } - - 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 String getSafeText(Locale locale) { - String text = locale.getDisplayName(Locale.getDefault()); - return text; - } - - public synchronized Icon getSafeIcon(Locale locale) { - 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; - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/LocaleListCellRenderer.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/LocaleListCellRenderer.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/LocaleListCellRenderer.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/LocaleListCellRenderer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,146 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.swing.renderer; + +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 final 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 = getSafeText(locale); + } + return text; + } + + public Icon getIcon(Locale locale) { + if (!showIcon) { + return null; + } + synchronized (cache) { + Icon icon = getSafeIcon(locale); + return icon; + } + } + + 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 String getSafeText(Locale locale) { + String text = locale.getDisplayName(Locale.getDefault()); + return text; + } + + public synchronized Icon getSafeIcon(Locale locale) { + 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; + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/MultiDecoratorListCellRenderer.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/MultiDecoratorListCellRenderer.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/MultiDecoratorListCellRenderer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,84 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.swing.renderer; - -import java.awt.Component; -import java.util.ArrayList; -import java.util.List; -import javax.swing.DefaultListCellRenderer; -import javax.swing.JList; -import javax.swing.ListCellRenderer; -import jaxx.runtime.decorator.Decorator; -import jaxx.runtime.decorator.JXPathDecorator; - -/** - * A {@link ListCellRenderer} which compute text with the matching decorator - * from {@link #decorators} and leave the hand to the {@link #delegate} to - * perform the visual renderer. - * - * @author chemit - * @since 2.0.0 - */ -public class MultiDecoratorListCellRenderer implements ListCellRenderer { - - /** - * Delegate cell renderer - */ - protected ListCellRenderer delegate; - /** - * accepted types - */ - protected List<Class<?>> types; - /** - * decorators for accepted types - */ - protected Decorator<?>[] decorators; - - public MultiDecoratorListCellRenderer(ListCellRenderer delegate, JXPathDecorator<?>... decorator) { - this.delegate = delegate; - this.types = new ArrayList<Class<?>>(); - List<Decorator<?>> tmp = new ArrayList<Decorator<?>>(); - for (JXPathDecorator<?> d : decorator) { - if (types.contains(d.getInternalClass())) { - throw new IllegalArgumentException("can not have twice a decorator of type " + d.getInternalClass()); - } - types.add(d.getInternalClass()); - tmp.add(d); - } - decorators = tmp.toArray(new Decorator<?>[tmp.size()]); - } - - public MultiDecoratorListCellRenderer(JXPathDecorator<?>... decorator) { - this(new DefaultListCellRenderer(), decorator); - } - - @Override - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - if (value != null) { - int i = types.indexOf(value.getClass()); - if (i != -1) { - Decorator<?> d = decorators[i]; - value = d.toString(value); - } - } - return delegate.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/MultiDecoratorListCellRenderer.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/MultiDecoratorListCellRenderer.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/MultiDecoratorListCellRenderer.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/MultiDecoratorListCellRenderer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,84 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.swing.renderer; + +import java.awt.Component; +import java.util.ArrayList; +import java.util.List; +import javax.swing.DefaultListCellRenderer; +import javax.swing.JList; +import javax.swing.ListCellRenderer; +import jaxx.runtime.decorator.Decorator; +import jaxx.runtime.decorator.JXPathDecorator; + +/** + * A {@link ListCellRenderer} which compute text with the matching decorator + * from {@link #decorators} and leave the hand to the {@link #delegate} to + * perform the visual renderer. + * + * @author chemit + * @since 2.0.0 + */ +public class MultiDecoratorListCellRenderer implements ListCellRenderer { + + /** + * Delegate cell renderer + */ + protected ListCellRenderer delegate; + /** + * accepted types + */ + protected List<Class<?>> types; + /** + * decorators for accepted types + */ + protected Decorator<?>[] decorators; + + public MultiDecoratorListCellRenderer(ListCellRenderer delegate, JXPathDecorator<?>... decorator) { + this.delegate = delegate; + this.types = new ArrayList<Class<?>>(); + List<Decorator<?>> tmp = new ArrayList<Decorator<?>>(); + for (JXPathDecorator<?> d : decorator) { + if (types.contains(d.getInternalClass())) { + throw new IllegalArgumentException("can not have twice a decorator of type " + d.getInternalClass()); + } + types.add(d.getInternalClass()); + tmp.add(d); + } + decorators = tmp.toArray(new Decorator<?>[tmp.size()]); + } + + public MultiDecoratorListCellRenderer(JXPathDecorator<?>... decorator) { + this(new DefaultListCellRenderer(), decorator); + } + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + if (value != null) { + int i = types.indexOf(value.getClass()); + if (i != -1) { + Decorator<?> d = decorators[i]; + value = d.toString(value); + } + } + return delegate.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/MultiDecoratorTableCelleRenderer.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/MultiDecoratorTableCelleRenderer.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/MultiDecoratorTableCelleRenderer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,85 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.swing.renderer; - -import java.awt.Component; -import java.util.ArrayList; -import java.util.List; -import javax.swing.JTable; -import javax.swing.table.DefaultTableCellRenderer; -import javax.swing.table.TableCellRenderer; -import jaxx.runtime.decorator.Decorator; -import jaxx.runtime.decorator.JXPathDecorator; - -/** - * A {@link TableCellRenderer} which compute text with the matching decorator - * from {@link #decorators} based on the type of value and leave the hand to - * the {@link #delegate} to perform the visual renderer. - * - * @author chemit - * @since 2.0.0 - */ -public class MultiDecoratorTableCelleRenderer implements TableCellRenderer { - - /** - * Delegate cell renderer - */ - protected TableCellRenderer delegate; - /** - * accepted types - */ - protected List<Class<?>> types; - /** - * decorators for accepted types - */ - protected Decorator<?>[] decorators; - - public MultiDecoratorTableCelleRenderer(JXPathDecorator<?>... decorator) { - this(new DefaultTableCellRenderer(), decorator); - } - - public MultiDecoratorTableCelleRenderer(TableCellRenderer delegate, JXPathDecorator<?>... decorator) { - this.delegate = delegate; - - this.types = new ArrayList<Class<?>>(); - List<Decorator<?>> tmp = new ArrayList<Decorator<?>>(); - for (JXPathDecorator<?> d : decorator) { - if (types.contains(d.getInternalClass())) { - throw new IllegalArgumentException("can not have twice a decorator of type " + d.getInternalClass()); - } - types.add(d.getInternalClass()); - tmp.add(d); - } - decorators = tmp.toArray(new Decorator<?>[tmp.size()]); - } - - @Override - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasfocus, int row, int column) { - if (value != null) { - int i = types.indexOf(value.getClass()); - if (i != -1) { - Decorator<?> d = decorators[i]; - value = d.toString(value); - } - } - return delegate.getTableCellRendererComponent(table, value, isSelected, hasfocus, row, column); - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/MultiDecoratorTableCelleRenderer.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/MultiDecoratorTableCelleRenderer.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/MultiDecoratorTableCelleRenderer.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/MultiDecoratorTableCelleRenderer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,85 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.swing.renderer; + +import java.awt.Component; +import java.util.ArrayList; +import java.util.List; +import javax.swing.JTable; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableCellRenderer; +import jaxx.runtime.decorator.Decorator; +import jaxx.runtime.decorator.JXPathDecorator; + +/** + * A {@link TableCellRenderer} which compute text with the matching decorator + * from {@link #decorators} based on the type of value and leave the hand to + * the {@link #delegate} to perform the visual renderer. + * + * @author chemit + * @since 2.0.0 + */ +public class MultiDecoratorTableCelleRenderer implements TableCellRenderer { + + /** + * Delegate cell renderer + */ + protected TableCellRenderer delegate; + /** + * accepted types + */ + protected List<Class<?>> types; + /** + * decorators for accepted types + */ + protected Decorator<?>[] decorators; + + public MultiDecoratorTableCelleRenderer(JXPathDecorator<?>... decorator) { + this(new DefaultTableCellRenderer(), decorator); + } + + public MultiDecoratorTableCelleRenderer(TableCellRenderer delegate, JXPathDecorator<?>... decorator) { + this.delegate = delegate; + + this.types = new ArrayList<Class<?>>(); + List<Decorator<?>> tmp = new ArrayList<Decorator<?>>(); + for (JXPathDecorator<?> d : decorator) { + if (types.contains(d.getInternalClass())) { + throw new IllegalArgumentException("can not have twice a decorator of type " + d.getInternalClass()); + } + types.add(d.getInternalClass()); + tmp.add(d); + } + decorators = tmp.toArray(new Decorator<?>[tmp.size()]); + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasfocus, int row, int column) { + if (value != null) { + int i = types.indexOf(value.getClass()); + if (i != -1) { + Decorator<?> d = decorators[i]; + value = d.toString(value); + } + } + return delegate.getTableCellRendererComponent(table, value, isSelected, hasfocus, row, column); + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,264 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,264 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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() { + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,128 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,128 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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; + } + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,224 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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(WizardOperationStep)}. - * - * 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: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,224 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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(WizardOperationStep)}. + * + * 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(); + } + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,289 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,289 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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; + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,52 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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 -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,52 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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 +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,54 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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(); -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,54 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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(); +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,40 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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(); -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,40 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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(); +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,34 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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(); -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,34 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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(); +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,114 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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) ; - -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,114 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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) ; + +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,182 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.swing.wizard; - -import java.awt.Window; -import javax.swing.ImageIcon; -import jaxx.runtime.JAXXContext; -import jaxx.runtime.context.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; - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,182 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.swing.wizard; + +import java.awt.Window; +import javax.swing.ImageIcon; +import jaxx.runtime.JAXXContext; +import jaxx.runtime.context.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; + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,177 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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); - } - } - }); - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,177 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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); + } + } + }); + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,9 +0,0 @@ -<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 Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html 2009-12-02 13:59:28 UTC (rev 1673) @@ -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 Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,509 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator; - -import java.beans.EventSetDescriptor; -import org.apache.commons.beanutils.ConversionException; -import org.apache.commons.beanutils.Converter; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.util.ConverterUtil; - -import java.beans.Introspector; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.util.ArrayList; -import java.util.EnumMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.TreeMap; -import javax.swing.event.EventListenerList; - -/** - * - * A customized validator for a given bean. - * - * <b>Note:</b> The bean must be listenable on properyChange events (means - * must have public addPropertychangeListener and removePropertyChangeListener methods). - * - * @param <B> type of the bean to validate. - * - * @author chemit - */ -public class BeanValidator<B> { - - /** la nom de la propriété bean */ - static public final String BEAN_PROERTY = "bean"; - /** la nom de la propriété contextName */ - static public final String CONTEXT_NAME_PROPERTY = "contextName"; - /** la nom de l'état valid */ - static public final String VALID_PROERTY = "valid"; - /** la nom de l'état changed */ - static public final String CHANGED_PROERTY = "changed"; - /** to use log facility, just put in your code: log.info(\"...\"); */ - static protected final Log log = LogFactory.getLog(BeanValidator.class); - /** the type of bean to watch */ - protected final Class<B> beanClass; - /** the validation named context (can be null) */ - protected String contextName; - /** to chain to a prent validator */ - protected BeanValidator<?> parentValidator; - /** state to indicate that validator has changed since the last time bean was setted */ - protected boolean changed = false; - /** state of the validator (is true if no errors of error scope is found) */ - protected boolean valid = true; - /** bean to be watched */ - protected B bean = null; - /** to add and remove PropertyChangeListener on watched beans */ - protected EventSetDescriptor beanEventDescriptor; - /** list of fields watched by this validator */ - protected Set<BeanValidatorField<B>> fields; - /** map of conversion errors detected by this validator */ - protected Map<String, String> conversionErrors; - /** xworks scope validator **/ - protected EnumMap<BeanValidatorScope, XWorkBeanValidator<B>> validators; - /** listener that listens on bean modification */ - protected PropertyChangeListener l; - /** delegate property change support */ - protected PropertyChangeSupport pcs; - /** A list of event listeners for this validators */ - protected EventListenerList listenerList = new EventListenerList(); - - public BeanValidator(Class<B> beanClass, String contextName) { - this.beanClass = beanClass; - this.pcs = new PropertyChangeSupport(this); - this.conversionErrors = new TreeMap<String, String>(); - this.validators = new EnumMap<BeanValidatorScope, XWorkBeanValidator<B>>(BeanValidatorScope.class); - - setContextName(contextName); - - l = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - doValidate(); - } - }; - } - - public Class<B> getBeanClass() { - return beanClass; - } - - public BeanValidator<?> getParentValidator() { - return parentValidator; - } - - public String getContextName() { - return contextName; - } - - public Set<BeanValidatorField<B>> getFields() { - return fields; - } - - public Set<BeanValidatorScope> getScopes() { - return new java.util.HashSet<BeanValidatorScope>(validators.keySet()); - } - - /** - * Retourne vrai si l'objet bean a ete modifie depuis le dernier - * {@link #setBean} - * - * @return <code>true</code> if bean was modify since last {@link #setBean(Object)} invocation - */ - public boolean isChanged() { - return changed; - } - - public boolean isValid() { - return valid; - } - - public B getBean() { - return bean; - } - - public BeanValidatorField<B> getField(String fieldName) { - for (BeanValidatorField<B> field : fields) { - if (fieldName.equals(field.getName())) { - return field; - } - } - return null; - } - - public boolean hasErrors() { - for (BeanValidatorField<B> field : fields) { - if (field.hasErrors()) { - return true; - } - } - return false; - } - - public boolean hasWarnings() { - for (BeanValidatorField<B> field : fields) { - if (field.hasWarnings()) { - return true; - } - } - return false; - } - - public boolean hasInfos() { - for (BeanValidatorField<B> field : fields) { - if (field.hasInfos()) { - return true; - } - } - return false; - } - - /** - * Test a the validator contains the field given his name - * - * @param fieldName the name of the searched field - * @return <code>true</code> if validator contaisn this field, <code>false</code> otherwise - */ - public boolean containsField(String fieldName) { - BeanValidatorField<B> field = getField(fieldName); - return field != null; - } - - public boolean isValid(String fieldName) { - BeanValidatorField<B> field = getField(fieldName); - if (field == null) { - throw new IllegalArgumentException("could not find a validator field " + fieldName); - } - return field.isValid(); - } - - /** - * Permet de force la remise a false de l'etat de changement du bean - * - * @param changed flag to force reset of property {@link #changed} - */ - public void setChanged(boolean changed) { - this.changed = changed; - // force the property to be fired (never pass the older value) - pcs.firePropertyChange(CHANGED_PROERTY, null, changed); - } - - public void setValid(boolean valid) { - this.valid = valid; - // force the property to be fired (never pass the older value) - pcs.firePropertyChange(VALID_PROERTY, null, valid); - } - - public void setBean(B bean) { - B oldBean = this.bean; - if (log.isDebugEnabled()) { - log.debug(this + " : " + bean); - } - - // clean conversions of previous bean - conversionErrors.clear(); - - if (oldBean != null) { - try { - getBeanEventDescriptor(oldBean).getRemoveListenerMethod().invoke(oldBean, l); - } catch (Exception eee) { - log.info("Can't register as listener for bean " + beanClass + " for reason " + eee.getMessage(), eee); - } - } - this.bean = bean; - - if (bean == null) { - - // remove all messages for all fields of the validator - - for (BeanValidatorField<B> f : fields) { - - f.updateMessages(this, null, null); - } - - } else { - try { - getBeanEventDescriptor(bean).getAddListenerMethod().invoke(bean, l); - } catch (Exception eee) { - log.info("Can't register as listener for bean " + beanClass + " for reason " + eee.getMessage(), eee); - } - validate(); - } - setChanged(false); - setValid(!hasErrors()); - pcs.firePropertyChange(BEAN_PROERTY, oldBean, bean); - } - - public void setContextName(String contextName) { - String oldValidationContextName = this.contextName; - this.contextName = contextName; - // changing contextName could change fields definition - // so dettach bean, must rebuild the fields - if (bean != null) { - setBean(null); - } - // rebuild the fields - initFields(); - pcs.firePropertyChange(CONTEXT_NAME_PROPERTY, oldValidationContextName, contextName); - } - - public void setParentValidator(BeanValidator<?> parentValidator) { - this.parentValidator = parentValidator; - } - - /** - * Convert a value. - * <p/> - * If an error occurs, then add an error in validator. - * - * @param <T> the type of conversion - * @param fieldName the name of the bean property - * @param value the value to convert - * @param valueClass the type of converted value - * @return the converted value, or null if conversion was not ok - */ - @SuppressWarnings({"unchecked"}) - public <T> T convert(String fieldName, String value, Class<T> valueClass) { - if (fieldName == null) { - throw new IllegalArgumentException("fieldName can not be null"); - } - if (valueClass == null) { - throw new IllegalArgumentException("valueClass can not be null"); - } - - // on ne convertit pas si il y a un bean et que le resultat de la validation - // pourra etre affiche quelque part - if (!canValidate() || value == null) { - return null; - } - - // remove the previous conversion error for the field - conversionErrors.remove(fieldName); - - T result; - try { - Converter converter = ConverterUtil.getConverter(valueClass); - if (converter == null) { - throw new RuntimeException("could not find converter for the type " + valueClass); - } - result = (T) converter.convert(valueClass, value); - /* Why this test ? if (result != null && !value.equals(result.toString())) { - conversionErrors.put(fieldName, "error.convertor." + Introspector.decapitalize(valueClass.getSimpleName())); - result = null; - validate(); - }*/ - } catch (ConversionException e) { - // get - conversionErrors.put(fieldName, "error.convertor." + Introspector.decapitalize(valueClass.getSimpleName())); - result = null; - validate(); - } - return result; - } - - /** - * Methode pour forcer la revalidation d'un bean en mettant a jour les etats - * internes. - * - * La méthode appelle {@link #validate()} puis met à jour les etats internes - * {@link #valid} et {@link #changed}. - * - * @since 1.5 - */ - public void doValidate() { - validate(); - setValid(!hasErrors()); - setChanged(true); - } - - /** - * il faut eviter le code re-intrant (durant une validation, une autre est - * demandee). Pour cela on fait la validation dans un thread, et tant - * que la premiere validation n'est pas fini, on ne repond pas aux - * solicitations. - * Cette method est public pour permettre de force une validation par - * programmation, ce qui est utile par exemple si le bean ne supporte - * pas les {@link PropertyChangeListener} - * - * TODO la methode devra repasser en protected et on utilise la - * methode {@link #doValidate()} car {@link #validate()} ne modifie pas - * les etats internes et cela en rend son utilisation delicate (le - * validateur entre dans un etat incoherent par rapport aux messages envoyés). - */ - public void validate() { - - // on ne valide que si il y a un bean et que le resultat de la validation - // pourra etre affiche quelque part - if (!canValidate()) { - return; - } - - for (BeanValidatorScope scope : validators.keySet()) { - - XWorkBeanValidator<B> validator = validators.get(scope); - - Map<String, List<String>> newMessages = validator.validate(bean); - - if (scope == BeanValidatorScope.ERROR) { - // treate conversion errors - // reinject them - for (Entry<String, String> entry : conversionErrors.entrySet()) { - // remove from validation, errors occurs on this field - List<String> errors = newMessages.get(entry.getKey()); - String conversionError = entry.getValue(); - if (errors != null) { - errors.clear(); - errors.add(conversionError); - } else { - errors = java.util.Collections.singletonList(conversionError); - if (newMessages == XWorkBeanValidator.EMPTY_RESULT) { - newMessages = new java.util.HashMap<String, List<String>>(); - } - // add the concrete conversion error - newMessages.put(entry.getKey(), errors); - } - } - } - - // for each field, update his list of messages - for (BeanValidatorField<B> field : fields) { - List<String> messagesForField = newMessages.get(field.getName()); - if (field.getScopes().contains(scope)) { - field.updateMessages(this, scope, messagesForField); - } - } - } - - if (parentValidator != null) { - // chained validation - // the parent validator should not be changed from this validation - boolean wasModified = parentValidator.isChanged(); - parentValidator.doValidate(); - if (!wasModified) { - // push back old state - parentValidator.setChanged(false); - } - } - - } - - @Override - public String toString() { - return super.toString() + "<beanClass:" + beanClass + ", contextName:" + contextName + ">"; - } - - public void addBeanValidatorListener(BeanValidatorListener listener) { - listenerList.add(BeanValidatorListener.class, listener); - } - - public void removeBeanValidatorListener(BeanValidatorListener listener) { - listenerList.remove(BeanValidatorListener.class, listener); - } - - public BeanValidatorListener[] getBeanValidatorListeners() { - return listenerList.getListeners(BeanValidatorListener.class); - } - - 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); - } - - /** @return <code>true</code> if validation is enabled, <code>false</code> otherwise. */ - protected boolean canValidate() { - return !(bean == null || fields.isEmpty()); - } - - protected void fireFieldChanged(BeanValidatorField<B> field, BeanValidatorScope scope, String[] toAdd, String[] toDelete) { - - BeanValidatorEvent evt = new BeanValidatorEvent(this, field, scope, toAdd, toDelete); - - for (BeanValidatorListener listener : listenerList.getListeners(BeanValidatorListener.class)) { - listener.onFieldChanged(evt); - } - } - - protected synchronized void initFields() { - - Set<String> detectedFieldNames = new java.util.HashSet<String>(); - EnumMap<BeanValidatorScope, Set<String>> tmp = new EnumMap<BeanValidatorScope, Set<String>>(BeanValidatorScope.class); - Set<BeanValidatorField<B>> detectedFields = new java.util.HashSet<BeanValidatorField<B>>(); - - validators.clear(); - - for (BeanValidatorScope scope : BeanValidatorScope.values()) { - String scopeContext = (contextName == null ? "" : contextName + "-") + scope.name().toLowerCase(); - - XWorkBeanValidator<B> newValidator = new XWorkBeanValidator<B>(beanClass, scopeContext, false); - Set<String> fieldNames = newValidator.getFieldNames(); - if (log.isDebugEnabled()) { - log.debug("detected validators for scope " + scopeContext + " : " + fieldNames); - } - if (!fieldNames.isEmpty()) { - // fields detected in this validator, keep it - validators.put(scope, newValidator); - detectedFieldNames.addAll(fieldNames); - tmp.put(scope, fieldNames); - } - } - - List<BeanValidatorScope> scopes = new ArrayList<BeanValidatorScope>(); - for (String fieldName : detectedFieldNames) { - scopes.clear(); - // detect scopes for the field - for (BeanValidatorScope scope : BeanValidatorScope.values()) { - if (tmp.containsKey(scope) && tmp.get(scope).contains(fieldName)) { - scopes.add(scope); - } - } - BeanValidatorField<B> f = new BeanValidatorField<B>(beanClass, fieldName, scopes); - detectedFields.add(f); - } - tmp.clear(); - detectedFieldNames.clear(); - - this.fields = java.util.Collections.unmodifiableSet(detectedFields); - } - - protected EventSetDescriptor getBeanEventDescriptor(B bean) { - if (beanEventDescriptor == null) { - // check that the bean is listenable, otherwise, can't use the validator on it - this.beanEventDescriptor = BeanValidatorUtil.getPropertyChangeListenerDescriptor(bean.getClass()); - } - return beanEventDescriptor; - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,509 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator; + +import java.beans.EventSetDescriptor; +import org.apache.commons.beanutils.ConversionException; +import org.apache.commons.beanutils.Converter; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.util.ConverterUtil; + +import java.beans.Introspector; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.util.ArrayList; +import java.util.EnumMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.TreeMap; +import javax.swing.event.EventListenerList; + +/** + * + * A customized validator for a given bean. + * + * <b>Note:</b> The bean must be listenable on properyChange events (means + * must have public addPropertychangeListener and removePropertyChangeListener methods). + * + * @param <B> type of the bean to validate. + * + * @author chemit + */ +public class BeanValidator<B> { + + /** la nom de la propriété bean */ + static public final String BEAN_PROERTY = "bean"; + /** la nom de la propriété contextName */ + static public final String CONTEXT_NAME_PROPERTY = "contextName"; + /** la nom de l'état valid */ + static public final String VALID_PROERTY = "valid"; + /** la nom de l'état changed */ + static public final String CHANGED_PROERTY = "changed"; + /** to use log facility, just put in your code: log.info(\"...\"); */ + static protected final Log log = LogFactory.getLog(BeanValidator.class); + /** the type of bean to watch */ + protected final Class<B> beanClass; + /** the validation named context (can be null) */ + protected String contextName; + /** to chain to a prent validator */ + protected BeanValidator<?> parentValidator; + /** state to indicate that validator has changed since the last time bean was setted */ + protected boolean changed = false; + /** state of the validator (is true if no errors of error scope is found) */ + protected boolean valid = true; + /** bean to be watched */ + protected B bean = null; + /** to add and remove PropertyChangeListener on watched beans */ + protected EventSetDescriptor beanEventDescriptor; + /** list of fields watched by this validator */ + protected Set<BeanValidatorField<B>> fields; + /** map of conversion errors detected by this validator */ + protected Map<String, String> conversionErrors; + /** xworks scope validator **/ + protected EnumMap<BeanValidatorScope, XWorkBeanValidator<B>> validators; + /** listener that listens on bean modification */ + protected PropertyChangeListener l; + /** delegate property change support */ + protected PropertyChangeSupport pcs; + /** A list of event listeners for this validators */ + protected EventListenerList listenerList = new EventListenerList(); + + public BeanValidator(Class<B> beanClass, String contextName) { + this.beanClass = beanClass; + this.pcs = new PropertyChangeSupport(this); + this.conversionErrors = new TreeMap<String, String>(); + this.validators = new EnumMap<BeanValidatorScope, XWorkBeanValidator<B>>(BeanValidatorScope.class); + + setContextName(contextName); + + l = new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent evt) { + doValidate(); + } + }; + } + + public Class<B> getBeanClass() { + return beanClass; + } + + public BeanValidator<?> getParentValidator() { + return parentValidator; + } + + public String getContextName() { + return contextName; + } + + public Set<BeanValidatorField<B>> getFields() { + return fields; + } + + public Set<BeanValidatorScope> getScopes() { + return new java.util.HashSet<BeanValidatorScope>(validators.keySet()); + } + + /** + * Retourne vrai si l'objet bean a ete modifie depuis le dernier + * {@link #setBean} + * + * @return <code>true</code> if bean was modify since last {@link #setBean(Object)} invocation + */ + public boolean isChanged() { + return changed; + } + + public boolean isValid() { + return valid; + } + + public B getBean() { + return bean; + } + + public BeanValidatorField<B> getField(String fieldName) { + for (BeanValidatorField<B> field : fields) { + if (fieldName.equals(field.getName())) { + return field; + } + } + return null; + } + + public boolean hasErrors() { + for (BeanValidatorField<B> field : fields) { + if (field.hasErrors()) { + return true; + } + } + return false; + } + + public boolean hasWarnings() { + for (BeanValidatorField<B> field : fields) { + if (field.hasWarnings()) { + return true; + } + } + return false; + } + + public boolean hasInfos() { + for (BeanValidatorField<B> field : fields) { + if (field.hasInfos()) { + return true; + } + } + return false; + } + + /** + * Test a the validator contains the field given his name + * + * @param fieldName the name of the searched field + * @return <code>true</code> if validator contaisn this field, <code>false</code> otherwise + */ + public boolean containsField(String fieldName) { + BeanValidatorField<B> field = getField(fieldName); + return field != null; + } + + public boolean isValid(String fieldName) { + BeanValidatorField<B> field = getField(fieldName); + if (field == null) { + throw new IllegalArgumentException("could not find a validator field " + fieldName); + } + return field.isValid(); + } + + /** + * Permet de force la remise a false de l'etat de changement du bean + * + * @param changed flag to force reset of property {@link #changed} + */ + public void setChanged(boolean changed) { + this.changed = changed; + // force the property to be fired (never pass the older value) + pcs.firePropertyChange(CHANGED_PROERTY, null, changed); + } + + public void setValid(boolean valid) { + this.valid = valid; + // force the property to be fired (never pass the older value) + pcs.firePropertyChange(VALID_PROERTY, null, valid); + } + + public void setBean(B bean) { + B oldBean = this.bean; + if (log.isDebugEnabled()) { + log.debug(this + " : " + bean); + } + + // clean conversions of previous bean + conversionErrors.clear(); + + if (oldBean != null) { + try { + getBeanEventDescriptor(oldBean).getRemoveListenerMethod().invoke(oldBean, l); + } catch (Exception eee) { + log.info("Can't register as listener for bean " + beanClass + " for reason " + eee.getMessage(), eee); + } + } + this.bean = bean; + + if (bean == null) { + + // remove all messages for all fields of the validator + + for (BeanValidatorField<B> f : fields) { + + f.updateMessages(this, null, null); + } + + } else { + try { + getBeanEventDescriptor(bean).getAddListenerMethod().invoke(bean, l); + } catch (Exception eee) { + log.info("Can't register as listener for bean " + beanClass + " for reason " + eee.getMessage(), eee); + } + validate(); + } + setChanged(false); + setValid(!hasErrors()); + pcs.firePropertyChange(BEAN_PROERTY, oldBean, bean); + } + + public void setContextName(String contextName) { + String oldValidationContextName = this.contextName; + this.contextName = contextName; + // changing contextName could change fields definition + // so dettach bean, must rebuild the fields + if (bean != null) { + setBean(null); + } + // rebuild the fields + initFields(); + pcs.firePropertyChange(CONTEXT_NAME_PROPERTY, oldValidationContextName, contextName); + } + + public void setParentValidator(BeanValidator<?> parentValidator) { + this.parentValidator = parentValidator; + } + + /** + * Convert a value. + * <p/> + * If an error occurs, then add an error in validator. + * + * @param <T> the type of conversion + * @param fieldName the name of the bean property + * @param value the value to convert + * @param valueClass the type of converted value + * @return the converted value, or null if conversion was not ok + */ + @SuppressWarnings({"unchecked"}) + public <T> T convert(String fieldName, String value, Class<T> valueClass) { + if (fieldName == null) { + throw new IllegalArgumentException("fieldName can not be null"); + } + if (valueClass == null) { + throw new IllegalArgumentException("valueClass can not be null"); + } + + // on ne convertit pas si il y a un bean et que le resultat de la validation + // pourra etre affiche quelque part + if (!canValidate() || value == null) { + return null; + } + + // remove the previous conversion error for the field + conversionErrors.remove(fieldName); + + T result; + try { + Converter converter = ConverterUtil.getConverter(valueClass); + if (converter == null) { + throw new RuntimeException("could not find converter for the type " + valueClass); + } + result = (T) converter.convert(valueClass, value); + /* Why this test ? if (result != null && !value.equals(result.toString())) { + conversionErrors.put(fieldName, "error.convertor." + Introspector.decapitalize(valueClass.getSimpleName())); + result = null; + validate(); + }*/ + } catch (ConversionException e) { + // get + conversionErrors.put(fieldName, "error.convertor." + Introspector.decapitalize(valueClass.getSimpleName())); + result = null; + validate(); + } + return result; + } + + /** + * Methode pour forcer la revalidation d'un bean en mettant a jour les etats + * internes. + * + * La méthode appelle {@link #validate()} puis met à jour les etats internes + * {@link #valid} et {@link #changed}. + * + * @since 1.5 + */ + public void doValidate() { + validate(); + setValid(!hasErrors()); + setChanged(true); + } + + /** + * il faut eviter le code re-intrant (durant une validation, une autre est + * demandee). Pour cela on fait la validation dans un thread, et tant + * que la premiere validation n'est pas fini, on ne repond pas aux + * solicitations. + * Cette method est public pour permettre de force une validation par + * programmation, ce qui est utile par exemple si le bean ne supporte + * pas les {@link PropertyChangeListener} + * + * TODO la methode devra repasser en protected et on utilise la + * methode {@link #doValidate()} car {@link #validate()} ne modifie pas + * les etats internes et cela en rend son utilisation delicate (le + * validateur entre dans un etat incoherent par rapport aux messages envoyés). + */ + public void validate() { + + // on ne valide que si il y a un bean et que le resultat de la validation + // pourra etre affiche quelque part + if (!canValidate()) { + return; + } + + for (BeanValidatorScope scope : validators.keySet()) { + + XWorkBeanValidator<B> validator = validators.get(scope); + + Map<String, List<String>> newMessages = validator.validate(bean); + + if (scope == BeanValidatorScope.ERROR) { + // treate conversion errors + // reinject them + for (Entry<String, String> entry : conversionErrors.entrySet()) { + // remove from validation, errors occurs on this field + List<String> errors = newMessages.get(entry.getKey()); + String conversionError = entry.getValue(); + if (errors != null) { + errors.clear(); + errors.add(conversionError); + } else { + errors = java.util.Collections.singletonList(conversionError); + if (newMessages == XWorkBeanValidator.EMPTY_RESULT) { + newMessages = new java.util.HashMap<String, List<String>>(); + } + // add the concrete conversion error + newMessages.put(entry.getKey(), errors); + } + } + } + + // for each field, update his list of messages + for (BeanValidatorField<B> field : fields) { + List<String> messagesForField = newMessages.get(field.getName()); + if (field.getScopes().contains(scope)) { + field.updateMessages(this, scope, messagesForField); + } + } + } + + if (parentValidator != null) { + // chained validation + // the parent validator should not be changed from this validation + boolean wasModified = parentValidator.isChanged(); + parentValidator.doValidate(); + if (!wasModified) { + // push back old state + parentValidator.setChanged(false); + } + } + + } + + @Override + public String toString() { + return super.toString() + "<beanClass:" + beanClass + ", contextName:" + contextName + ">"; + } + + public void addBeanValidatorListener(BeanValidatorListener listener) { + listenerList.add(BeanValidatorListener.class, listener); + } + + public void removeBeanValidatorListener(BeanValidatorListener listener) { + listenerList.remove(BeanValidatorListener.class, listener); + } + + public BeanValidatorListener[] getBeanValidatorListeners() { + return listenerList.getListeners(BeanValidatorListener.class); + } + + 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); + } + + /** @return <code>true</code> if validation is enabled, <code>false</code> otherwise. */ + protected boolean canValidate() { + return !(bean == null || fields.isEmpty()); + } + + protected void fireFieldChanged(BeanValidatorField<B> field, BeanValidatorScope scope, String[] toAdd, String[] toDelete) { + + BeanValidatorEvent evt = new BeanValidatorEvent(this, field, scope, toAdd, toDelete); + + for (BeanValidatorListener listener : listenerList.getListeners(BeanValidatorListener.class)) { + listener.onFieldChanged(evt); + } + } + + protected synchronized void initFields() { + + Set<String> detectedFieldNames = new java.util.HashSet<String>(); + EnumMap<BeanValidatorScope, Set<String>> tmp = new EnumMap<BeanValidatorScope, Set<String>>(BeanValidatorScope.class); + Set<BeanValidatorField<B>> detectedFields = new java.util.HashSet<BeanValidatorField<B>>(); + + validators.clear(); + + for (BeanValidatorScope scope : BeanValidatorScope.values()) { + String scopeContext = (contextName == null ? "" : contextName + "-") + scope.name().toLowerCase(); + + XWorkBeanValidator<B> newValidator = new XWorkBeanValidator<B>(beanClass, scopeContext, false); + Set<String> fieldNames = newValidator.getFieldNames(); + if (log.isDebugEnabled()) { + log.debug("detected validators for scope " + scopeContext + " : " + fieldNames); + } + if (!fieldNames.isEmpty()) { + // fields detected in this validator, keep it + validators.put(scope, newValidator); + detectedFieldNames.addAll(fieldNames); + tmp.put(scope, fieldNames); + } + } + + List<BeanValidatorScope> scopes = new ArrayList<BeanValidatorScope>(); + for (String fieldName : detectedFieldNames) { + scopes.clear(); + // detect scopes for the field + for (BeanValidatorScope scope : BeanValidatorScope.values()) { + if (tmp.containsKey(scope) && tmp.get(scope).contains(fieldName)) { + scopes.add(scope); + } + } + BeanValidatorField<B> f = new BeanValidatorField<B>(beanClass, fieldName, scopes); + detectedFields.add(f); + } + tmp.clear(); + detectedFieldNames.clear(); + + this.fields = java.util.Collections.unmodifiableSet(detectedFields); + } + + protected EventSetDescriptor getBeanEventDescriptor(B bean) { + if (beanEventDescriptor == null) { + // check that the bean is listenable, otherwise, can't use the validator on it + this.beanEventDescriptor = BeanValidatorUtil.getPropertyChangeListenerDescriptor(bean.getClass()); + } + return beanEventDescriptor; + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorDetector.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorDetector.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorDetector.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,228 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator; - -import java.io.File; -import java.io.FilenameFilter; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.List; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Un detecteur de validateurs pour un liste de classes données et un - * répertoire où chercher les fichiers de validation. - * - * @author chemit - * - * @since 1.6.0 - */ -public class BeanValidatorDetector { - - /** to use log facility, just put in your code: log.info(\"...\"); */ - private static final Log log = LogFactory.getLog(BeanValidatorDetector.class); - - public SortedSet<BeanValidator<?>> detect(File sourceRoot, Class<?>... types) { - SortedSet<BeanValidator<?>> result = detect(BeanValidator.class, sourceRoot, null, types); - return result; - } - - public SortedSet<BeanValidator<?>> detect(Class<?> validatorClass, File sourceRoot, Pattern contextFilter, Class<?>... types) { - - SortedSet<BeanValidator<?>> result = new TreeSet<BeanValidator<?>>(new BeanValidatorComparator()); - - for (Class<?> c : types) { - File dir = getClassDir(sourceRoot, c); - if (!dir.exists()) { - // pas de repertoire adequate - log.debug("skip non existing directory " + dir); - continue; - } - String[] contexts = getContexts(c, dir); - if (log.isDebugEnabled()) { - log.debug("contexts : " + Arrays.toString(contexts)); - } - - if (contexts.length > 0) { - String[] realContexts = getContextsWithoutScopes(contexts); - - if (log.isDebugEnabled()) { - log.debug("realContexts : " + Arrays.toString(realContexts)); - } - - if (contextFilter != null) { - // filter contexts - realContexts = getFilterContexts(contextFilter, realContexts); - if (log.isDebugEnabled()) { - log.debug("filterContexts : " + Arrays.toString(realContexts)); - } - } - - for (String context : realContexts) { - - // on cherche le validateur - BeanValidator<?> validator = getValidator(validatorClass, c, context.isEmpty() ? null : context); - if (validator != null) { - // on enregistre le validateur - result.add(validator); - } - } - } - } - return result; - } - - /** - * Pour un context et un type d'entité donné, instancie un validateur - * et test si ce validateur est utilisable (i.e qu'il admet des champs - * à valider). - * - * Si aucun champ n'est trouvé dans le validateur, alors on retourne null. - * - * @param <B> le type du bean - * @param validatorClass le type de validateur a instancie - * @param klass le type du bean - * @param context le context du validateur - * @return le validateur initialisé, ou <code>null</code> si aucun scope - * détecté dans le validateur. - */ - protected <B> BeanValidator<B> getValidator(Class<?> validatorClass, Class<B> klass, String context) { - -// BeanValidator<B> valitator = new BeanValidator<B>(klass, context); - BeanValidator<B> valitator; - try { - valitator = (BeanValidator<B>) validatorClass.getConstructor(Class.class, String.class).newInstance(klass, context); - } catch (Exception ex) { - throw new RuntimeException("could not instanciate validator " + validatorClass + " for reason " + ex.getMessage(), ex); - } - - Set<BeanValidatorScope> scopes = valitator.getScopes(); - if (scopes.isEmpty()) { - valitator = null; - if (log.isDebugEnabled()) { - log.debug(klass + " : validator skip (no scopes detected)"); - } - } else { - if (log.isDebugEnabled()) { - log.debug(klass + " : keep validator " + valitator); - } - } - return valitator; - } - - protected File getClassDir(File sourceRoot, Class<?> clazz) { - String path = clazz.getPackage().getName().replaceAll("\\.", File.separator); - File dir = new File(sourceRoot, path); - return dir; - } - - protected String[] getContexts(Class<?> clazz, File dir) { - Set<String> result = new TreeSet<String>(); - ValidatorFilenameFilter filter = new ValidatorFilenameFilter(clazz); - if (log.isDebugEnabled()) { - log.debug("dir : " + dir); - } - String[] files = dir.list(filter); - for (String file : files) { - if (log.isDebugEnabled()) { - log.debug("file " + file); - } - String context = file.substring(filter.prefix.length(), file.length() - ValidatorFilenameFilter.SUFFIX.length()); - if (log.isDebugEnabled()) { - log.debug("detect " + clazz.getSimpleName() + " context [" + context + "]"); - } - result.add(context); - } - return result.toArray(new String[result.size()]); - } - - protected String[] getContextsWithoutScopes(String[] contexts) { - Set<String> result = new TreeSet<String>(); - BeanValidatorScope[] scopes = BeanValidatorScope.values(); - for (String context : contexts) { - for (BeanValidatorScope scope : scopes) { - String scopeName = scope.name().toLowerCase(); - if (!context.endsWith(scopeName)) { - // pas concerne par ce scope - continue; - } - if (log.isDebugEnabled()) { - log.debug("detect context : " + context); - } - String realContext = context.substring(0, context.length() - scopeName.length()); - if (realContext.endsWith("-")) { - realContext = realContext.substring(0, realContext.length() - 1); - } - result.add(realContext); - } - } - return result.toArray(new String[result.size()]); - } - - protected String[] getFilterContexts(Pattern contextFilter, String[] realContexts) { - List<String> result = new ArrayList<String>(); - for (String c : realContexts) { - Matcher m = contextFilter.matcher(c); - if (m.matches()) { - result.add(c); - } - } - return result.toArray(new String[result.size()]); - } - - protected static class ValidatorFilenameFilter implements FilenameFilter { - - protected static final String SUFFIX = "-validation.xml"; - protected Class<?> clazz; - protected String prefix; - - public ValidatorFilenameFilter(Class<?> clazz) { - this.clazz = clazz; - this.prefix = clazz.getSimpleName() + "-"; - } - - @Override - public boolean accept(File dir, String name) { - boolean result = name.endsWith(SUFFIX); - if (result) { - result = name.startsWith(prefix); - } - return result; - } - } - - protected static class BeanValidatorComparator implements Comparator<BeanValidator<?>> { - - @Override - public int compare(BeanValidator<?> o1, BeanValidator<?> o2) { - String contextName1 = o1.getBeanClass().getSimpleName() + "-" + (o1.getContextName() == null ? "" : o1.getContextName()); - String contextName2 = o2.getBeanClass().getSimpleName() + "-" + (o2.getContextName() == null ? "" : o2.getContextName()); - return contextName1.compareTo(contextName2); - } - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorDetector.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorDetector.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorDetector.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorDetector.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,228 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator; + +import java.io.File; +import java.io.FilenameFilter; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Un detecteur de validateurs pour un liste de classes données et un + * répertoire où chercher les fichiers de validation. + * + * @author chemit + * + * @since 1.6.0 + */ +public class BeanValidatorDetector { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + private static final Log log = LogFactory.getLog(BeanValidatorDetector.class); + + public SortedSet<BeanValidator<?>> detect(File sourceRoot, Class<?>... types) { + SortedSet<BeanValidator<?>> result = detect(BeanValidator.class, sourceRoot, null, types); + return result; + } + + public SortedSet<BeanValidator<?>> detect(Class<?> validatorClass, File sourceRoot, Pattern contextFilter, Class<?>... types) { + + SortedSet<BeanValidator<?>> result = new TreeSet<BeanValidator<?>>(new BeanValidatorComparator()); + + for (Class<?> c : types) { + File dir = getClassDir(sourceRoot, c); + if (!dir.exists()) { + // pas de repertoire adequate + log.debug("skip non existing directory " + dir); + continue; + } + String[] contexts = getContexts(c, dir); + if (log.isDebugEnabled()) { + log.debug("contexts : " + Arrays.toString(contexts)); + } + + if (contexts.length > 0) { + String[] realContexts = getContextsWithoutScopes(contexts); + + if (log.isDebugEnabled()) { + log.debug("realContexts : " + Arrays.toString(realContexts)); + } + + if (contextFilter != null) { + // filter contexts + realContexts = getFilterContexts(contextFilter, realContexts); + if (log.isDebugEnabled()) { + log.debug("filterContexts : " + Arrays.toString(realContexts)); + } + } + + for (String context : realContexts) { + + // on cherche le validateur + BeanValidator<?> validator = getValidator(validatorClass, c, context.isEmpty() ? null : context); + if (validator != null) { + // on enregistre le validateur + result.add(validator); + } + } + } + } + return result; + } + + /** + * Pour un context et un type d'entité donné, instancie un validateur + * et test si ce validateur est utilisable (i.e qu'il admet des champs + * à valider). + * + * Si aucun champ n'est trouvé dans le validateur, alors on retourne null. + * + * @param <B> le type du bean + * @param validatorClass le type de validateur a instancie + * @param klass le type du bean + * @param context le context du validateur + * @return le validateur initialisé, ou <code>null</code> si aucun scope + * détecté dans le validateur. + */ + protected <B> BeanValidator<B> getValidator(Class<?> validatorClass, Class<B> klass, String context) { + +// BeanValidator<B> valitator = new BeanValidator<B>(klass, context); + BeanValidator<B> valitator; + try { + valitator = (BeanValidator<B>) validatorClass.getConstructor(Class.class, String.class).newInstance(klass, context); + } catch (Exception ex) { + throw new RuntimeException("could not instanciate validator " + validatorClass + " for reason " + ex.getMessage(), ex); + } + + Set<BeanValidatorScope> scopes = valitator.getScopes(); + if (scopes.isEmpty()) { + valitator = null; + if (log.isDebugEnabled()) { + log.debug(klass + " : validator skip (no scopes detected)"); + } + } else { + if (log.isDebugEnabled()) { + log.debug(klass + " : keep validator " + valitator); + } + } + return valitator; + } + + protected File getClassDir(File sourceRoot, Class<?> clazz) { + String path = clazz.getPackage().getName().replaceAll("\\.", File.separator); + File dir = new File(sourceRoot, path); + return dir; + } + + protected String[] getContexts(Class<?> clazz, File dir) { + Set<String> result = new TreeSet<String>(); + ValidatorFilenameFilter filter = new ValidatorFilenameFilter(clazz); + if (log.isDebugEnabled()) { + log.debug("dir : " + dir); + } + String[] files = dir.list(filter); + for (String file : files) { + if (log.isDebugEnabled()) { + log.debug("file " + file); + } + String context = file.substring(filter.prefix.length(), file.length() - ValidatorFilenameFilter.SUFFIX.length()); + if (log.isDebugEnabled()) { + log.debug("detect " + clazz.getSimpleName() + " context [" + context + "]"); + } + result.add(context); + } + return result.toArray(new String[result.size()]); + } + + protected String[] getContextsWithoutScopes(String[] contexts) { + Set<String> result = new TreeSet<String>(); + BeanValidatorScope[] scopes = BeanValidatorScope.values(); + for (String context : contexts) { + for (BeanValidatorScope scope : scopes) { + String scopeName = scope.name().toLowerCase(); + if (!context.endsWith(scopeName)) { + // pas concerne par ce scope + continue; + } + if (log.isDebugEnabled()) { + log.debug("detect context : " + context); + } + String realContext = context.substring(0, context.length() - scopeName.length()); + if (realContext.endsWith("-")) { + realContext = realContext.substring(0, realContext.length() - 1); + } + result.add(realContext); + } + } + return result.toArray(new String[result.size()]); + } + + protected String[] getFilterContexts(Pattern contextFilter, String[] realContexts) { + List<String> result = new ArrayList<String>(); + for (String c : realContexts) { + Matcher m = contextFilter.matcher(c); + if (m.matches()) { + result.add(c); + } + } + return result.toArray(new String[result.size()]); + } + + protected static class ValidatorFilenameFilter implements FilenameFilter { + + protected static final String SUFFIX = "-validation.xml"; + protected Class<?> clazz; + protected String prefix; + + public ValidatorFilenameFilter(Class<?> clazz) { + this.clazz = clazz; + this.prefix = clazz.getSimpleName() + "-"; + } + + @Override + public boolean accept(File dir, String name) { + boolean result = name.endsWith(SUFFIX); + if (result) { + result = name.startsWith(prefix); + } + return result; + } + } + + protected static class BeanValidatorComparator implements Comparator<BeanValidator<?>> { + + @Override + public int compare(BeanValidator<?> o1, BeanValidator<?> o2) { + String contextName1 = o1.getBeanClass().getSimpleName() + "-" + (o1.getContextName() == null ? "" : o1.getContextName()); + String contextName2 = o2.getBeanClass().getSimpleName() + "-" + (o2.getContextName() == null ? "" : o2.getContextName()); + return contextName1.compareTo(contextName2); + } + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,72 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator; - -/** - * The definition of an event on {@link BeanValidatorListener} - * to be fired by a {@link BeanValidator}. - * - * @author chemit - * @since 1.3 - */ -public class BeanValidatorEvent extends java.util.EventObject { - - private static final long serialVersionUID = 1L; - /** the field impacted by the validator */ - BeanValidatorField<?> field; - /** the scope impacted by the event */ - BeanValidatorScope scope; - String[] messagestoAdd; - String[] messagestoDelete; - - public BeanValidatorEvent(BeanValidator<?> source, BeanValidatorField<?> field, BeanValidatorScope scope, String[] toAdd, String[] toDelete) { - super(source); - this.field = field; - this.scope = scope; - this.messagestoAdd = toAdd; - this.messagestoDelete = toDelete; - } - - @Override - public BeanValidator<?> getSource() { - return (BeanValidator<?>) super.getSource(); - } - - public String getFieldName() { - return field.getName(); - } - - public String[] getMessagesToAdd() { - return messagestoAdd; - } - - public String[] getMessagesToDelete() { - return messagestoDelete; - } - - public BeanValidatorScope getScope() { - return scope; - } - - public BeanValidatorField<?> getField() { - return field; - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,72 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator; + +/** + * The definition of an event on {@link BeanValidatorListener} + * to be fired by a {@link BeanValidator}. + * + * @author chemit + * @since 1.3 + */ +public class BeanValidatorEvent extends java.util.EventObject { + + private static final long serialVersionUID = 1L; + /** the field impacted by the validator */ + BeanValidatorField<?> field; + /** the scope impacted by the event */ + BeanValidatorScope scope; + String[] messagestoAdd; + String[] messagestoDelete; + + public BeanValidatorEvent(BeanValidator<?> source, BeanValidatorField<?> field, BeanValidatorScope scope, String[] toAdd, String[] toDelete) { + super(source); + this.field = field; + this.scope = scope; + this.messagestoAdd = toAdd; + this.messagestoDelete = toDelete; + } + + @Override + public BeanValidator<?> getSource() { + return (BeanValidator<?>) super.getSource(); + } + + public String getFieldName() { + return field.getName(); + } + + public String[] getMessagesToAdd() { + return messagestoAdd; + } + + public String[] getMessagesToDelete() { + return messagestoDelete; + } + + public BeanValidatorScope getScope() { + return scope; + } + + public BeanValidatorField<?> getField() { + return field; + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorField.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorField.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorField.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,259 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator; - -import static org.nuiton.i18n.I18n._; - -import javax.swing.event.EventListenerList; -import java.util.ArrayList; -import java.util.EnumMap; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.StringTokenizer; - -/** - * Definition of a field to be handled in a {@link BeanValidator}. - * <p/> - * A such class is only registred in {@link BeanValidator } when the field of the bean - * was found in validator xml configuration file for a {@link com.opensymphony.xwork2.validator.FieldValidator} only. - * <p/> - * This class use properties {@link #beanClass}, {@link #name} to define - * his naturel order. - * - * @author chemit - * @param <B> the type of the bean handled by the validator and this field of validation. - * @since 1.3 - */ -public class BeanValidatorField<B> { - - /** the class of bean */ - protected final Class<B> beanClass; - /** name of field in bean */ - protected final String name; - protected EnumMap<BeanValidatorScope, Set<String>> messages; - /** A list of event listeners for this validators */ - protected EventListenerList listenerList = new EventListenerList(); - - public BeanValidatorField(Class<B> beanClass, String name, List<BeanValidatorScope> scopes) { - this.beanClass = beanClass; - this.name = name; - messages = new EnumMap<BeanValidatorScope, Set<String>>(BeanValidatorScope.class); - for (BeanValidatorScope scope : scopes) { - messages.put(scope, new HashSet<String>()); - } - } - - public String getName() { - return name; - } - - public Class<B> getBeanClass() { - return beanClass; - } - - /** - * @return <code>true</code> if this field is valid (says is in error - * scope and has errors), <code>false</code> otherwise. - */ - public boolean isValid() { - return !hasErrors(); - } - - public BeanValidatorScope getScope() { - if (hasErrors()) { - return BeanValidatorScope.ERROR; - } - if (hasWarnings()) { - return BeanValidatorScope.WARNING; - } - if (hasInfos()) { - return BeanValidatorScope.INFO; - } - return null; - } - - public Set<BeanValidatorScope> getScopes() { - return messages.keySet(); - } - - public boolean hasErrors() { - return hasMessages(BeanValidatorScope.ERROR); - } - - public boolean hasWarnings() { - return hasMessages(BeanValidatorScope.WARNING); - } - - public boolean hasInfos() { - return hasMessages(BeanValidatorScope.INFO); - } - - public Set<String> getErrors() { - return getMessages(BeanValidatorScope.ERROR); - } - - public Set<String> getWarnings() { - return getMessages(BeanValidatorScope.WARNING); - } - - public Set<String> getInfos() { - return getMessages(BeanValidatorScope.INFO); - } - - public boolean hasMessages(BeanValidatorScope scope) { - return messages.containsKey(scope) && !getMessages(scope).isEmpty(); - } - - public Set<String> getMessages(BeanValidatorScope scope) { - return messages.get(scope); - } - - public void updateMessages(BeanValidator<B> validator, BeanValidatorScope scope, List<String> messages) { - - if (scope == null) { - - // special case to reset all messages from all scopes - - for (BeanValidatorScope s : getScopes()) { - - clearMessages(s, validator); - } - return; - } - - if (!this.messages.containsKey(scope)) { - throw new IllegalArgumentException("the scope " + scope + " was not registred for " + this); - } - - if (messages == null || messages.isEmpty()) { - - // no incoming message for this scope - - clearMessages(scope, validator); - return; - } - - // build the diff of messages (the one to delete, the one to add) - - boolean hasChanged = false; - - Set<String> currentMessages = getMessages(scope); - - // detect messages to delete - Set<String> toDelete = new java.util.HashSet<String>(currentMessages); - toDelete.removeAll(messages); - - if (!toDelete.isEmpty()) { - // apply delete - currentMessages.removeAll(toDelete); - hasChanged = true; - } - - // detect messages to add - Set<String> toAdd = new java.util.HashSet<String>(messages); - toAdd.removeAll(currentMessages); - - if (!toAdd.isEmpty()) { - // apply add - currentMessages.addAll(toAdd); - hasChanged = true; - } - - if (hasChanged) { - - // something has changed, fire notifications - String[] del = toDelete.toArray(new String[toDelete.size()]); - String[] add = toAdd.toArray(new String[toAdd.size()]); - - validator.fireFieldChanged(this, scope, add, del); - } - toAdd.clear(); - toDelete.clear(); - - } - - public String getI18nError(String error) { - String text; - if (error.indexOf("##") == -1) { - text = _(error); - } else { - StringTokenizer stk = new StringTokenizer(error, "##"); - String errorName = stk.nextToken(); - List<String> args = new ArrayList<String>(); - while (stk.hasMoreTokens()) { - args.add(stk.nextToken()); - } - text = _(errorName, args.toArray()); - } - return text; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof BeanValidatorField<?>)) { - return false; - } - - BeanValidatorField<?> that = (BeanValidatorField<?>) o; - return beanClass.equals(that.beanClass) && name.equals(that.name); - } - - @Override - public int hashCode() { - int result = beanClass.hashCode(); - result = 31 * result + name.hashCode(); - return result; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("<").append(super.toString()); - sb.append(" beanClass:").append(beanClass); - sb.append(", name:").append(name); - sb.append(", scopes:").append(messages == null ? "[]" : messages.keySet()); - sb.append(", scope:").append(getScope()); - //sb.append(", errors:").append(errors); - sb.append('>'); - return sb.toString(); - } - - protected void clearMessages(BeanValidatorScope scope, BeanValidator<B> validator) { - // remove all messages - Set<String> toDelete = getMessages(scope); - - if (!toDelete.isEmpty()) { - - // there is some messages to delete - String[] toDel = toDelete.toArray(new String[toDelete.size()]); - - // apply deletion - toDelete.clear(); - - // fire - validator.fireFieldChanged(this, scope, null, toDel); - } - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorField.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorField.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorField.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorField.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,259 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator; + +import static org.nuiton.i18n.I18n._; + +import javax.swing.event.EventListenerList; +import java.util.ArrayList; +import java.util.EnumMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.StringTokenizer; + +/** + * Definition of a field to be handled in a {@link BeanValidator}. + * <p/> + * A such class is only registred in {@link BeanValidator } when the field of the bean + * was found in validator xml configuration file for a {@link com.opensymphony.xwork2.validator.FieldValidator} only. + * <p/> + * This class use properties {@link #beanClass}, {@link #name} to define + * his naturel order. + * + * @author chemit + * @param <B> the type of the bean handled by the validator and this field of validation. + * @since 1.3 + */ +public class BeanValidatorField<B> { + + /** the class of bean */ + protected final Class<B> beanClass; + /** name of field in bean */ + protected final String name; + protected EnumMap<BeanValidatorScope, Set<String>> messages; + /** A list of event listeners for this validators */ + protected EventListenerList listenerList = new EventListenerList(); + + public BeanValidatorField(Class<B> beanClass, String name, List<BeanValidatorScope> scopes) { + this.beanClass = beanClass; + this.name = name; + messages = new EnumMap<BeanValidatorScope, Set<String>>(BeanValidatorScope.class); + for (BeanValidatorScope scope : scopes) { + messages.put(scope, new HashSet<String>()); + } + } + + public String getName() { + return name; + } + + public Class<B> getBeanClass() { + return beanClass; + } + + /** + * @return <code>true</code> if this field is valid (says is in error + * scope and has errors), <code>false</code> otherwise. + */ + public boolean isValid() { + return !hasErrors(); + } + + public BeanValidatorScope getScope() { + if (hasErrors()) { + return BeanValidatorScope.ERROR; + } + if (hasWarnings()) { + return BeanValidatorScope.WARNING; + } + if (hasInfos()) { + return BeanValidatorScope.INFO; + } + return null; + } + + public Set<BeanValidatorScope> getScopes() { + return messages.keySet(); + } + + public boolean hasErrors() { + return hasMessages(BeanValidatorScope.ERROR); + } + + public boolean hasWarnings() { + return hasMessages(BeanValidatorScope.WARNING); + } + + public boolean hasInfos() { + return hasMessages(BeanValidatorScope.INFO); + } + + public Set<String> getErrors() { + return getMessages(BeanValidatorScope.ERROR); + } + + public Set<String> getWarnings() { + return getMessages(BeanValidatorScope.WARNING); + } + + public Set<String> getInfos() { + return getMessages(BeanValidatorScope.INFO); + } + + public boolean hasMessages(BeanValidatorScope scope) { + return messages.containsKey(scope) && !getMessages(scope).isEmpty(); + } + + public Set<String> getMessages(BeanValidatorScope scope) { + return messages.get(scope); + } + + public void updateMessages(BeanValidator<B> validator, BeanValidatorScope scope, List<String> messages) { + + if (scope == null) { + + // special case to reset all messages from all scopes + + for (BeanValidatorScope s : getScopes()) { + + clearMessages(s, validator); + } + return; + } + + if (!this.messages.containsKey(scope)) { + throw new IllegalArgumentException("the scope " + scope + " was not registred for " + this); + } + + if (messages == null || messages.isEmpty()) { + + // no incoming message for this scope + + clearMessages(scope, validator); + return; + } + + // build the diff of messages (the one to delete, the one to add) + + boolean hasChanged = false; + + Set<String> currentMessages = getMessages(scope); + + // detect messages to delete + Set<String> toDelete = new java.util.HashSet<String>(currentMessages); + toDelete.removeAll(messages); + + if (!toDelete.isEmpty()) { + // apply delete + currentMessages.removeAll(toDelete); + hasChanged = true; + } + + // detect messages to add + Set<String> toAdd = new java.util.HashSet<String>(messages); + toAdd.removeAll(currentMessages); + + if (!toAdd.isEmpty()) { + // apply add + currentMessages.addAll(toAdd); + hasChanged = true; + } + + if (hasChanged) { + + // something has changed, fire notifications + String[] del = toDelete.toArray(new String[toDelete.size()]); + String[] add = toAdd.toArray(new String[toAdd.size()]); + + validator.fireFieldChanged(this, scope, add, del); + } + toAdd.clear(); + toDelete.clear(); + + } + + public String getI18nError(String error) { + String text; + if (error.indexOf("##") == -1) { + text = _(error); + } else { + StringTokenizer stk = new StringTokenizer(error, "##"); + String errorName = stk.nextToken(); + List<String> args = new ArrayList<String>(); + while (stk.hasMoreTokens()) { + args.add(stk.nextToken()); + } + text = _(errorName, args.toArray()); + } + return text; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof BeanValidatorField<?>)) { + return false; + } + + BeanValidatorField<?> that = (BeanValidatorField<?>) o; + return beanClass.equals(that.beanClass) && name.equals(that.name); + } + + @Override + public int hashCode() { + int result = beanClass.hashCode(); + result = 31 * result + name.hashCode(); + return result; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("<").append(super.toString()); + sb.append(" beanClass:").append(beanClass); + sb.append(", name:").append(name); + sb.append(", scopes:").append(messages == null ? "[]" : messages.keySet()); + sb.append(", scope:").append(getScope()); + //sb.append(", errors:").append(errors); + sb.append('>'); + return sb.toString(); + } + + protected void clearMessages(BeanValidatorScope scope, BeanValidator<B> validator) { + // remove all messages + Set<String> toDelete = getMessages(scope); + + if (!toDelete.isEmpty()) { + + // there is some messages to delete + String[] toDel = toDelete.toArray(new String[toDelete.size()]); + + // apply deletion + toDelete.clear(); + + // fire + validator.fireFieldChanged(this, scope, null, toDel); + } + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,37 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator; - -/** - * The listener contract to be used on {@link BeanValidator} - * - * @author chemit - * @since 1.3 - */ -public interface BeanValidatorListener extends java.util.EventListener { - - /** - * Invoked when a validator detects some changes on a field. - * - * @param event the event - */ - void onFieldChanged(BeanValidatorEvent event); -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,37 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator; + +/** + * The listener contract to be used on {@link BeanValidator} + * + * @author chemit + * @since 1.3 + */ +public interface BeanValidatorListener extends java.util.EventListener { + + /** + * Invoked when a validator detects some changes on a field. + * + * @param event the event + */ + void onFieldChanged(BeanValidatorEvent event); +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,92 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator; - -/** - * The object to box a validation message. - * - * @param <E> type of message (use for override {@link #compareTo(Object)} method. - * - * @author chemit - * @since 1.3 - */ -public class BeanValidatorMessage<E extends BeanValidatorMessage<?>> implements Comparable<E> { - - /** - * the validator that produce the message - */ - protected BeanValidator<?> validator; - /** - * the field that produce the message - */ - protected BeanValidatorField<?> field; - /** - * the label of the message (to be displayed somewhere) - */ - protected String message; - /** - * the scope of the message - */ - protected 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() { - return validator; - } - - public BeanValidatorField<?> getField() { - return field; - } - - public BeanValidatorScope getScope() { - return scope; - } - - public String getMessage() { - return message; - } - - @Override - public int compareTo(E o) { - // sort on scope - int result = getScope().compareTo(o.getScope()); - if (result == 0) { - // sort on field name - result = field.getName().compareTo(o.field.getName()); - if (result == 0) { - // sort on message - result = message.compareTo(o.message); - } - } - return result; - } - - @Override - public String toString() { - return scope + " - " + field.getI18nError(message); - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,92 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator; + +/** + * The object to box a validation message. + * + * @param <E> type of message (use for override {@link #compareTo(Object)} method. + * + * @author chemit + * @since 1.3 + */ +public class BeanValidatorMessage<E extends BeanValidatorMessage<?>> implements Comparable<E> { + + /** + * the validator that produce the message + */ + protected BeanValidator<?> validator; + /** + * the field that produce the message + */ + protected BeanValidatorField<?> field; + /** + * the label of the message (to be displayed somewhere) + */ + protected String message; + /** + * the scope of the message + */ + protected 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() { + return validator; + } + + public BeanValidatorField<?> getField() { + return field; + } + + public BeanValidatorScope getScope() { + return scope; + } + + public String getMessage() { + return message; + } + + @Override + public int compareTo(E o) { + // sort on scope + int result = getScope().compareTo(o.getScope()); + if (result == 0) { + // sort on field name + result = field.getName().compareTo(o.field.getName()); + if (result == 0) { + // sort on message + result = message.compareTo(o.message); + } + } + return result; + } + + @Override + public String toString() { + return scope + " - " + field.getI18nError(message); + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorScope.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorScope.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorScope.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,66 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator; - -import static org.nuiton.i18n.I18n.n_; - -/** - * The differents levels of messages in validation process. - * <p/> - * The order of the enum defines the severity of validation. - * <p/> - * Always begin with error, then if no error found, try warning, then info... - * - * @author chemit - */ -public enum BeanValidatorScope { - - /** - * the error scope level. - * - * When a message of a such scope is found on a validator, then the validator - * is invalid and modified. - */ - ERROR(n_("validator.scope.error.label")), - /** - * the warning scope level. - * - * When a message of a such scope is found on a validator, then the validator - * is still valid but modified. - */ - WARNING(n_("validator.scope.warning.label")), - /** - * the information scope level. - * - * When a message of a sucg scope is found on a validator, then the - * validator is still valid and not modified. - */ - INFO(n_("validator.scope.info.label")); - private final String label; - - private BeanValidatorScope(String label) { - this.label = label; - } - - public String getLabel() { - return label; - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorScope.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorScope.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorScope.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorScope.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,66 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator; + +import static org.nuiton.i18n.I18n.n_; + +/** + * The differents levels of messages in validation process. + * <p/> + * The order of the enum defines the severity of validation. + * <p/> + * Always begin with error, then if no error found, try warning, then info... + * + * @author chemit + */ +public enum BeanValidatorScope { + + /** + * the error scope level. + * + * When a message of a such scope is found on a validator, then the validator + * is invalid and modified. + */ + ERROR(n_("validator.scope.error.label")), + /** + * the warning scope level. + * + * When a message of a such scope is found on a validator, then the validator + * is still valid but modified. + */ + WARNING(n_("validator.scope.warning.label")), + /** + * the information scope level. + * + * When a message of a sucg scope is found on a validator, then the + * validator is still valid and not modified. + */ + INFO(n_("validator.scope.info.label")); + private final String label; + + private BeanValidatorScope(String label) { + this.label = label; + } + + public String getLabel() { + return label; + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,195 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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 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); - } - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,195 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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 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); + } + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,271 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator; - -import com.opensymphony.xwork2.ActionContext; -import com.opensymphony.xwork2.ValidationAwareSupport; -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 com.opensymphony.xwork2.validator.ActionValidatorManager; -import com.opensymphony.xwork2.validator.DelegatingValidatorContext; -import com.opensymphony.xwork2.validator.FieldValidator; -import com.opensymphony.xwork2.validator.ValidationException; -import com.opensymphony.xwork2.validator.Validator; -import java.util.Collection; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * - * A customized validator for a given bean. - * - * Use the method {@link #validate(java.lang.Object)} to obtain the messages - * detected by the validator for the given bean. - * - * @param <B> type of the bean to validate. - * - * @author chemit - * @since 1.3 - */ -public class XWorkBeanValidator<B> { - - /** to use log facility, just put in your code: log.info(\"...\"); */ - private static final Log log = LogFactory.getLog(XWorkBeanValidator.class); - protected final static Map<String, List<String>> EMPTY_RESULT = Collections.unmodifiableMap(new HashMap<String, List<String>>()); - /** the type of bean to validate */ - protected final Class<B> beanClass; - /** the validation named context (can be null) */ - protected String contextName; - /** the list of field names detected for this validator */ - protected Set<String> fieldNames; - /** a flag to include or not the default context validators */ - protected boolean includeDefaultContext; - // -- - // XWorks fields - // -- - protected ValidationAwareSupport validationSupport; - protected DelegatingValidatorContext validationContext; - protected transient ActionValidatorManager validator; - protected ActionContext context; - - public XWorkBeanValidator(Class<B> beanClass, String contextName) { - this(beanClass, contextName, true, BeanValidatorUtil.getSharedValueStack()); - } - - public XWorkBeanValidator(Class<B> beanClass, String contextName, ValueStack vs) { - this(beanClass, contextName, true, vs); - } - - public XWorkBeanValidator(Class<B> beanClass, String contextName, boolean includeDefaultContext) { - this(beanClass, contextName, includeDefaultContext, BeanValidatorUtil.getSharedValueStack()); - } - - public XWorkBeanValidator(Class<B> beanClass, String contextName, boolean includeDefaultContext, ValueStack vs) { - - this.beanClass = beanClass; - this.includeDefaultContext = includeDefaultContext; - validationSupport = new ValidationAwareSupport(); - validationContext = new DelegatingValidatorContext(validationSupport); - - if (vs == null) { - // create a standalone value stack - ConfigurationManager confManager = new ConfigurationManager(); - Configuration conf = confManager.getConfiguration(); - vs = conf.getContainer().getInstance(ValueStackFactory.class).createValueStack(); - if (log.isDebugEnabled()) { - log.info("create a standalone value stack " + vs); - } - } else { - if (log.isDebugEnabled()) { - log.debug("use given value stack " + vs); - } - } - - context = new ActionContext(vs.getContext()); - ActionContext.setContext(context); - - // init validator - validator = context.getContainer().getInstance(ActionValidatorManager.class, "no-annotations"); - - // init context - setContextName(contextName); - } - - public boolean isIncludeDefaultContext() { - return includeDefaultContext; - } - - public Class<B> getBeanClass() { - return beanClass; - } - - public String getContextName() { - return contextName; - } - - public Set<String> getFieldNames() { - return fieldNames; - } - - public ActionValidatorManager getValidator() { - return validator; - } - - /** - * Test a the validator contains the field given his name - * - * @param fieldName the name of the searched field - * @return <code>true</code> if validator contaisn this field, <code>false</code> otherwise - */ - public boolean containsField(String fieldName) { - return fieldNames.contains(fieldName); - } - - public void setIncludeDefaultContext(boolean includeDefaultContext) { - this.includeDefaultContext = includeDefaultContext; - if (contextName != null) { - // reload context - setContextName(contextName); - } - } - - public void setContextName(String contextName) { - this.contextName = contextName; - // changing contextName may change fields definition - // so reload fields - initFields(); - } - - /** - * Valide le bean donné et retourne les messages produits. - * - * @param bean le bean a valider (il doit etre non null) - * - * @return le dictionnaire des messages produits par la validation indexées - * par le nom du champs du bean impacté. - */ - public Map<String, List<String>> validate(B bean) { - - if (bean == null) { - throw new NullPointerException("bean can not be null in method validate"); - } - - Map<String, List<String>> result = EMPTY_RESULT; - - // on lance la validation uniquement si des champs sont a valider - if (!fieldNames.isEmpty()) { - - try { - - //TC - 20081024 : since context is in a ThreadLocal variable, we must do the check - if (ActionContext.getContext() == null) { - ActionContext.setContext(context); - } - - validator.validate(bean, contextName, validationContext); - - if (log.isTraceEnabled()) { - log.trace("Action errors: " + validationContext.getActionErrors()); - log.trace("Action messages: " + validationContext.getActionMessages()); - log.trace("Field errors: " + validationContext.getFieldErrors()); - } - - if (log.isDebugEnabled()) { - log.debug(this + " : " + validationContext.getFieldErrors()); - } - - if (validationContext.hasFieldErrors()) { - Map<?,?> messages = validationContext.getFieldErrors(); - result = new HashMap<String, List<String>>(messages.size()); - for (Object fieldName : messages.keySet()) { - Collection<?> c = (Collection<?>) messages.get(fieldName); - List<String> mm = new java.util.ArrayList<String>(c.size()); - for (Object message : c) { - mm.add(message + ""); - } - result.put(fieldName + "", mm); - } - } - - } catch (ValidationException eee) { - log.warn("Error during validation on " + beanClass + " for reason : " + eee.getMessage(), eee); - - } finally { - // on nettoye toujours le validateur apres operation - validationSupport.clearErrorsAndMessages(); - } - } - - return result; - } - - @Override - public String toString() { - return super.toString() + "<beanClass:" + beanClass + ", contextName:" + contextName + ">"; - } - - /** - * update the property {@link #fieldNames}, says search in XWorks - */ - protected synchronized void initFields() { - - if (fieldNames != null) { - fieldNames = null; - } - - Set<String> detectedFieldNames = new java.util.HashSet<String>(); - - int skip = 0; - if (contextName != null && !includeDefaultContext) { - // count the number of validator to skip - for (Validator<?> v : validator.getValidators(beanClass, null)) { - // we only work on FieldValidator at the moment - if (v instanceof FieldValidator) { - skip++; - } - } - } - - for (Validator<?> v : validator.getValidators(beanClass, contextName)) { - // we only work on FieldValidator at the moment - if (v instanceof FieldValidator) { - if (skip > 0) { - skip--; - continue; - } - FieldValidator fieldValidator = (FieldValidator) v; - log.debug("context " + contextName + " - field " + fieldValidator.getFieldName()); - String fName = fieldValidator.getFieldName(); - detectedFieldNames.add(fName); - } - } - - fieldNames = Collections.unmodifiableSet(detectedFieldNames); - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,271 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator; + +import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.ValidationAwareSupport; +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 com.opensymphony.xwork2.validator.ActionValidatorManager; +import com.opensymphony.xwork2.validator.DelegatingValidatorContext; +import com.opensymphony.xwork2.validator.FieldValidator; +import com.opensymphony.xwork2.validator.ValidationException; +import com.opensymphony.xwork2.validator.Validator; +import java.util.Collection; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * + * A customized validator for a given bean. + * + * Use the method {@link #validate(java.lang.Object)} to obtain the messages + * detected by the validator for the given bean. + * + * @param <B> type of the bean to validate. + * + * @author chemit + * @since 1.3 + */ +public class XWorkBeanValidator<B> { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + private static final Log log = LogFactory.getLog(XWorkBeanValidator.class); + protected final static Map<String, List<String>> EMPTY_RESULT = Collections.unmodifiableMap(new HashMap<String, List<String>>()); + /** the type of bean to validate */ + protected final Class<B> beanClass; + /** the validation named context (can be null) */ + protected String contextName; + /** the list of field names detected for this validator */ + protected Set<String> fieldNames; + /** a flag to include or not the default context validators */ + protected boolean includeDefaultContext; + // -- + // XWorks fields + // -- + protected ValidationAwareSupport validationSupport; + protected DelegatingValidatorContext validationContext; + protected transient ActionValidatorManager validator; + protected ActionContext context; + + public XWorkBeanValidator(Class<B> beanClass, String contextName) { + this(beanClass, contextName, true, BeanValidatorUtil.getSharedValueStack()); + } + + public XWorkBeanValidator(Class<B> beanClass, String contextName, ValueStack vs) { + this(beanClass, contextName, true, vs); + } + + public XWorkBeanValidator(Class<B> beanClass, String contextName, boolean includeDefaultContext) { + this(beanClass, contextName, includeDefaultContext, BeanValidatorUtil.getSharedValueStack()); + } + + public XWorkBeanValidator(Class<B> beanClass, String contextName, boolean includeDefaultContext, ValueStack vs) { + + this.beanClass = beanClass; + this.includeDefaultContext = includeDefaultContext; + validationSupport = new ValidationAwareSupport(); + validationContext = new DelegatingValidatorContext(validationSupport); + + if (vs == null) { + // create a standalone value stack + ConfigurationManager confManager = new ConfigurationManager(); + Configuration conf = confManager.getConfiguration(); + vs = conf.getContainer().getInstance(ValueStackFactory.class).createValueStack(); + if (log.isDebugEnabled()) { + log.info("create a standalone value stack " + vs); + } + } else { + if (log.isDebugEnabled()) { + log.debug("use given value stack " + vs); + } + } + + context = new ActionContext(vs.getContext()); + ActionContext.setContext(context); + + // init validator + validator = context.getContainer().getInstance(ActionValidatorManager.class, "no-annotations"); + + // init context + setContextName(contextName); + } + + public boolean isIncludeDefaultContext() { + return includeDefaultContext; + } + + public Class<B> getBeanClass() { + return beanClass; + } + + public String getContextName() { + return contextName; + } + + public Set<String> getFieldNames() { + return fieldNames; + } + + public ActionValidatorManager getValidator() { + return validator; + } + + /** + * Test a the validator contains the field given his name + * + * @param fieldName the name of the searched field + * @return <code>true</code> if validator contaisn this field, <code>false</code> otherwise + */ + public boolean containsField(String fieldName) { + return fieldNames.contains(fieldName); + } + + public void setIncludeDefaultContext(boolean includeDefaultContext) { + this.includeDefaultContext = includeDefaultContext; + if (contextName != null) { + // reload context + setContextName(contextName); + } + } + + public void setContextName(String contextName) { + this.contextName = contextName; + // changing contextName may change fields definition + // so reload fields + initFields(); + } + + /** + * Valide le bean donné et retourne les messages produits. + * + * @param bean le bean a valider (il doit etre non null) + * + * @return le dictionnaire des messages produits par la validation indexées + * par le nom du champs du bean impacté. + */ + public Map<String, List<String>> validate(B bean) { + + if (bean == null) { + throw new NullPointerException("bean can not be null in method validate"); + } + + Map<String, List<String>> result = EMPTY_RESULT; + + // on lance la validation uniquement si des champs sont a valider + if (!fieldNames.isEmpty()) { + + try { + + //TC - 20081024 : since context is in a ThreadLocal variable, we must do the check + if (ActionContext.getContext() == null) { + ActionContext.setContext(context); + } + + validator.validate(bean, contextName, validationContext); + + if (log.isTraceEnabled()) { + log.trace("Action errors: " + validationContext.getActionErrors()); + log.trace("Action messages: " + validationContext.getActionMessages()); + log.trace("Field errors: " + validationContext.getFieldErrors()); + } + + if (log.isDebugEnabled()) { + log.debug(this + " : " + validationContext.getFieldErrors()); + } + + if (validationContext.hasFieldErrors()) { + Map<?,?> messages = validationContext.getFieldErrors(); + result = new HashMap<String, List<String>>(messages.size()); + for (Object fieldName : messages.keySet()) { + Collection<?> c = (Collection<?>) messages.get(fieldName); + List<String> mm = new java.util.ArrayList<String>(c.size()); + for (Object message : c) { + mm.add(message + ""); + } + result.put(fieldName + "", mm); + } + } + + } catch (ValidationException eee) { + log.warn("Error during validation on " + beanClass + " for reason : " + eee.getMessage(), eee); + + } finally { + // on nettoye toujours le validateur apres operation + validationSupport.clearErrorsAndMessages(); + } + } + + return result; + } + + @Override + public String toString() { + return super.toString() + "<beanClass:" + beanClass + ", contextName:" + contextName + ">"; + } + + /** + * update the property {@link #fieldNames}, says search in XWorks + */ + protected synchronized void initFields() { + + if (fieldNames != null) { + fieldNames = null; + } + + Set<String> detectedFieldNames = new java.util.HashSet<String>(); + + int skip = 0; + if (contextName != null && !includeDefaultContext) { + // count the number of validator to skip + for (Validator<?> v : validator.getValidators(beanClass, null)) { + // we only work on FieldValidator at the moment + if (v instanceof FieldValidator) { + skip++; + } + } + } + + for (Validator<?> v : validator.getValidators(beanClass, contextName)) { + // we only work on FieldValidator at the moment + if (v instanceof FieldValidator) { + if (skip > 0) { + skip--; + continue; + } + FieldValidator fieldValidator = (FieldValidator) v; + log.debug("context " + contextName + " - field " + fieldValidator.getFieldName()); + String fName = fieldValidator.getFieldName(); + detectedFieldNames.add(fName); + } + } + + fieldNames = Collections.unmodifiableSet(detectedFieldNames); + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/CollectionFieldExpressionValidator.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/CollectionFieldExpressionValidator.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/CollectionFieldExpressionValidator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,468 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator.field; - -import com.opensymphony.xwork2.util.ValueStack; -import com.opensymphony.xwork2.validator.ValidationException; -import com.opensymphony.xwork2.validator.validators.FieldExpressionValidator; - -import java.util.Collection; -import java.util.Set; -import org.apache.commons.lang.builder.HashCodeBuilder; - -/** - * Un validateur basé sur {@link FieldExpressionValidator} qui valide sur une collection de propriéte. - * - * @author chemit - */ -public class CollectionFieldExpressionValidator extends FieldExpressionValidator { - - public enum Mode { - - /** au moins une entrée de la collection doit etre valide */ - AT_LEAST_ONE, - /** exactement une entrée dela collection doit être valide */ - EXACTLY_ONE, - /** toutes les valeurs de la collection doivent etre valides */ - ALL, - /** aucune valeur de la collection doivent etre valides */ - NONE, - /** detection de clef unique */ - UNIQUE_KEY - } - /** le mode de validation sur la liste */ - protected Mode mode; - /** - * pour indiquer la propriété qui contient la liste à valider. - * - * Si cette prorpiété n'est pas renseignée alors on utilise la - * {@link #getFieldName()} pour obtenir la collection. - * - * Cela permet d'effectuer une validation si une collection mais portant - * en fait sur un autre champs - * @since 1.5 - */ - protected String collectionFieldName; - /** - * drapeau pour utiliser le contexte de parcours pour valider - * l'expression, on dispose donc alors des variables previous, current, - * index, size et empty dans l'expression. - * - * Sinon l'expression s'applique directement sur l'entrée courant dans le - * parcours sans préfixe. - */ - protected boolean useSensitiveContext; - /** - * expression a valider sur la premiètre entrée de la collection. - * - * Note : Pour le moment, on autorise uniquement cela en mode ALL. - */ - protected String expressionForFirst; - /** - * expression a valider sur la dernière entrée de la collection. - * - * Note : Pour le moment, on autorise uniquement cela en mode ALL. - */ - protected String expressionForLast; - /** - * la liste des propriétés d'une entrée de la collection qui définit la - * clef unique (en mode UNIQUE_KEY). - */ - protected String[] keys; - /** le context de parcours */ - protected WalkerContext c; - private boolean useFirst, useLast; - - public Mode getMode() { - return mode; - } - - public void setMode(Mode mode) { - this.mode = mode; - } - - public String getCollectionFieldName() { - return collectionFieldName; - } - - public void setCollectionFieldName(String collectionFieldName) { - this.collectionFieldName = collectionFieldName; - } - - public boolean isUseSensitiveContext() { - return useSensitiveContext; - } - - public void setUseSensitiveContext(boolean useSensitiveContext) { - this.useSensitiveContext = useSensitiveContext; - } - - public String getExpressionForFirst() { - return expressionForFirst; - } - - public void setExpressionForFirst(String expressionForFirst) { - this.expressionForFirst = expressionForFirst; - } - - public String getExpressionForLast() { - return expressionForLast; - } - - public void setExpressionForLast(String expressionForLast) { - this.expressionForLast = expressionForLast; - } - - public String[] getKeys() { - return keys; - } - - public void setKeys(String[] keys) { - if (keys != null && keys.length == 1 && keys[0].indexOf(",") != -1) { - this.keys = keys[0].split(","); - } else { - this.keys = keys; - } - } - - @Override - public void validate(Object object) throws ValidationException { - if (mode == null) { - throw new ValidationException("no mode defined!"); - } - useFirst = expressionForFirst != null && !expressionForFirst.trim().isEmpty(); - useLast = expressionForLast != null && !expressionForLast.trim().isEmpty(); - - if (useFirst && mode != Mode.ALL) { - throw new ValidationException("can only use expressionForFirst in mode ALL but was " + mode); - } - if (useLast && mode != Mode.ALL) { - throw new ValidationException("can only use expressionForLast in mode ALL but was " + mode); - } - - String fieldName = getFieldName(); - - Collection<?> col = getCollection(object); - - if (useSensitiveContext) { - c = new WalkerContext(col.size()); - } - - boolean answer; - - boolean pop = false; - - if (!stack.getRoot().contains(object)) { - stack.push(object); - pop = true; - } - - switch (mode) { - case ALL: - answer = validateAllEntries(col); - break; - case AT_LEAST_ONE: - answer = validateAtLeastOneEntry(col); - break; - case EXACTLY_ONE: - answer = validateExtacltyOneEntry(col); - break; - case NONE: - answer = validateNoneEntry(col); - break; - case UNIQUE_KEY: - if (keys == null || keys.length == 0) { - throw new ValidationException("no unique keys defined"); - } - answer = validateUniqueKey(col); - break; - - default: - // should never come here... - answer = false; - } - - if (!answer) { - addFieldError(fieldName, object); - } - if (pop) { - stack.pop(); - } - } - protected ValueStack stack; - - @Override - public void setValueStack(ValueStack stack) { - super.setValueStack(stack); - this.stack = stack; - } - - @Override - public String getMessage(Object object) { - boolean pop = false; - - if (useSensitiveContext && !stack.getRoot().contains(c)) { - stack.push(c); - pop = true; - } - String message = super.getMessage(object); - - if (pop) { - stack.pop(); - } - return message; - } - - protected Boolean validateAllEntries(Collection<?> col) throws ValidationException { - boolean answer = true; - for (Object entry : col) { - answer = validateOneEntry(entry); - if (!answer) { - // validation on one entry has failed - // no need to continue - break; - } - } - return answer; - } - - protected Boolean validateNoneEntry(Collection<?> col) throws ValidationException { - boolean answer = true; - for (Object entry : col) { - boolean b = validateOneEntry(entry); - if (b) { - // one entry has sucessed, validation has failed - // no need to continue - answer = false; - break; - } - } - return answer; - } - - protected Boolean validateAtLeastOneEntry(Collection<?> col) throws ValidationException { - boolean answer = false; - for (Object entry : col) { - answer = validateOneEntry(entry); - if (answer) { - // one entry was succes, validation is ok, - // no need to continue - break; - } - } - return answer; - } - - protected Boolean validateExtacltyOneEntry(Collection<?> col) throws ValidationException { - int count = 0; - for (Object entry : col) { - boolean answer = validateOneEntry(entry); - if (answer) { - // one entry has succed - count++; - if (count > 1) { - // more than one entriy was successfull - // so validation has failed - break; - } - - } - } - return count == 1; - } - - protected Boolean validateUniqueKey(Collection<?> col) throws ValidationException { - boolean answer = true; - - Set<Integer> hashCodes = new java.util.HashSet<Integer>(); - int index = -1; - for (Object entry : col) { - index++; - // construction du hash de la clef d'unicite - Integer hash = getUniqueKeyHashCode(entry); - if (!hashCodes.contains(hash)) { - hashCodes.add(hash); - continue; - } - // une entree avec ce hash a deja ete trouvee - // on est donc en violation sur la clef unique - answer = false; - if (log.isDebugEnabled()) { - log.debug("duplicated uniquekey " + hash + " for entry " + index); - } - } - hashCodes.clear(); - return answer; - } - - protected boolean validateOneEntry(Object object) throws ValidationException { - - Boolean answer = Boolean.FALSE; - - boolean extraExpression = false; - - if (useSensitiveContext) { - c.addCurrent(object); - object = c; - - if (c.isFirst() && useFirst) { - // on valide l'expression sur la premiètre entrée - answer = evaluateExpression(expressionForFirst, object); - extraExpression = true; - } - if (c.isLast() && useLast) { - // on valide l'expression sur la dernière entrée - answer = (!extraExpression || answer) && evaluateExpression(expressionForLast, object); - extraExpression = true; - } - } - - answer = (!extraExpression || answer) && evaluateExpression(getExpression(), object); - - return answer; - } - - protected boolean evaluateExpression(String expression, Object object) throws ValidationException { - Object obj = null; - try { - obj = getFieldValue(expression, object); - } catch (ValidationException e) { - throw e; - } catch (Exception e) { - log.error(e.getMessage(), e); - // let this pass, but it will be logged right below - } - - Boolean answer = Boolean.FALSE; - - if (obj != null && obj instanceof Boolean) { - answer = (Boolean) obj; - } else { - log.warn("Got result of " + obj + " when trying to get Boolean for expression " + expression); - } - return answer; - } - - /** - * @param object the incoming object containing the collection to test - * @return the collection of the incoming object given by the fieldName property - * @throws ValidationException if any pb to retreave the collection - */ - protected Collection<?> getCollection(Object object) throws ValidationException { - String fieldName = getCollectionFieldName(); - if (fieldName == null || fieldName.trim().isEmpty()) { - // on travaille directement sur le fieldName - fieldName = getFieldName(); - } - - Object obj = null; - - // obtain the collection to test - try { - obj = getFieldValue(fieldName, object); - } catch (ValidationException e) { - throw e; - } catch (Exception e) { - // let this pass, but it will be logged right below - } - - if (obj == null) { - // la collection est nulle, donc on renvoie une collection vide - return java.util.Collections.EMPTY_LIST; - } - - if (!Collection.class.isInstance(obj)) { - throw new ValidationException("field " + fieldName + " is not a collection type! (" + obj.getClass() + ")"); - } - return (Collection<?>) obj; - } - - /** - * Calcule pour une entrée donné, le hash de la clef unique - * - * @param o l'entree de la collection dont on va calculer le hash de la clef unique - * @return le hashCode calclé de la clef unique sur l'entrée donné - * @throws ValidationException if any pb to retreave properties values - */ - protected Integer getUniqueKeyHashCode(Object o) throws ValidationException { - // calcul du hash à la volée - HashCodeBuilder builder = new HashCodeBuilder(); - for (String key : this.keys) { - Object property = getFieldValue(key, o); - if (log.isDebugEnabled()) { - log.debug("key " + key + " : " + property); - } - builder.append(property); - } - return builder.toHashCode(); - } - - @Override - public String getValidatorType() { - return "collectionFieldExpression"; - } - - public class WalkerContext { - - protected final int size; - - public WalkerContext(int size) { - this.size = size; - } - protected int index = -1; - protected Object current; - protected Object previous; - - public void addCurrent(Object current) { - index++; - previous = this.current; - this.current = current; - } - - public Object getCurrent() { - return current; - } - - public int getIndex() { - return index; - } - - public Object getPrevious() { - return previous; - } - - public int getSize() { - return size; - } - - public boolean isEmpty() { - return size == 0; - } - - public boolean isFirst() { - return index == 0; - } - - public boolean isLast() { - return index == size - 1; - } - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/CollectionFieldExpressionValidator.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/CollectionFieldExpressionValidator.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/CollectionFieldExpressionValidator.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/CollectionFieldExpressionValidator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,468 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator.field; + +import com.opensymphony.xwork2.util.ValueStack; +import com.opensymphony.xwork2.validator.ValidationException; +import com.opensymphony.xwork2.validator.validators.FieldExpressionValidator; + +import java.util.Collection; +import java.util.Set; +import org.apache.commons.lang.builder.HashCodeBuilder; + +/** + * Un validateur basé sur {@link FieldExpressionValidator} qui valide sur une collection de propriéte. + * + * @author chemit + */ +public class CollectionFieldExpressionValidator extends FieldExpressionValidator { + + public enum Mode { + + /** au moins une entrée de la collection doit etre valide */ + AT_LEAST_ONE, + /** exactement une entrée dela collection doit être valide */ + EXACTLY_ONE, + /** toutes les valeurs de la collection doivent etre valides */ + ALL, + /** aucune valeur de la collection doivent etre valides */ + NONE, + /** detection de clef unique */ + UNIQUE_KEY + } + /** le mode de validation sur la liste */ + protected Mode mode; + /** + * pour indiquer la propriété qui contient la liste à valider. + * + * Si cette prorpiété n'est pas renseignée alors on utilise la + * {@link #getFieldName()} pour obtenir la collection. + * + * Cela permet d'effectuer une validation si une collection mais portant + * en fait sur un autre champs + * @since 1.5 + */ + protected String collectionFieldName; + /** + * drapeau pour utiliser le contexte de parcours pour valider + * l'expression, on dispose donc alors des variables previous, current, + * index, size et empty dans l'expression. + * + * Sinon l'expression s'applique directement sur l'entrée courant dans le + * parcours sans préfixe. + */ + protected boolean useSensitiveContext; + /** + * expression a valider sur la premiètre entrée de la collection. + * + * Note : Pour le moment, on autorise uniquement cela en mode ALL. + */ + protected String expressionForFirst; + /** + * expression a valider sur la dernière entrée de la collection. + * + * Note : Pour le moment, on autorise uniquement cela en mode ALL. + */ + protected String expressionForLast; + /** + * la liste des propriétés d'une entrée de la collection qui définit la + * clef unique (en mode UNIQUE_KEY). + */ + protected String[] keys; + /** le context de parcours */ + protected WalkerContext c; + private boolean useFirst, useLast; + + public Mode getMode() { + return mode; + } + + public void setMode(Mode mode) { + this.mode = mode; + } + + public String getCollectionFieldName() { + return collectionFieldName; + } + + public void setCollectionFieldName(String collectionFieldName) { + this.collectionFieldName = collectionFieldName; + } + + public boolean isUseSensitiveContext() { + return useSensitiveContext; + } + + public void setUseSensitiveContext(boolean useSensitiveContext) { + this.useSensitiveContext = useSensitiveContext; + } + + public String getExpressionForFirst() { + return expressionForFirst; + } + + public void setExpressionForFirst(String expressionForFirst) { + this.expressionForFirst = expressionForFirst; + } + + public String getExpressionForLast() { + return expressionForLast; + } + + public void setExpressionForLast(String expressionForLast) { + this.expressionForLast = expressionForLast; + } + + public String[] getKeys() { + return keys; + } + + public void setKeys(String[] keys) { + if (keys != null && keys.length == 1 && keys[0].indexOf(",") != -1) { + this.keys = keys[0].split(","); + } else { + this.keys = keys; + } + } + + @Override + public void validate(Object object) throws ValidationException { + if (mode == null) { + throw new ValidationException("no mode defined!"); + } + useFirst = expressionForFirst != null && !expressionForFirst.trim().isEmpty(); + useLast = expressionForLast != null && !expressionForLast.trim().isEmpty(); + + if (useFirst && mode != Mode.ALL) { + throw new ValidationException("can only use expressionForFirst in mode ALL but was " + mode); + } + if (useLast && mode != Mode.ALL) { + throw new ValidationException("can only use expressionForLast in mode ALL but was " + mode); + } + + String fieldName = getFieldName(); + + Collection<?> col = getCollection(object); + + if (useSensitiveContext) { + c = new WalkerContext(col.size()); + } + + boolean answer; + + boolean pop = false; + + if (!stack.getRoot().contains(object)) { + stack.push(object); + pop = true; + } + + switch (mode) { + case ALL: + answer = validateAllEntries(col); + break; + case AT_LEAST_ONE: + answer = validateAtLeastOneEntry(col); + break; + case EXACTLY_ONE: + answer = validateExtacltyOneEntry(col); + break; + case NONE: + answer = validateNoneEntry(col); + break; + case UNIQUE_KEY: + if (keys == null || keys.length == 0) { + throw new ValidationException("no unique keys defined"); + } + answer = validateUniqueKey(col); + break; + + default: + // should never come here... + answer = false; + } + + if (!answer) { + addFieldError(fieldName, object); + } + if (pop) { + stack.pop(); + } + } + protected ValueStack stack; + + @Override + public void setValueStack(ValueStack stack) { + super.setValueStack(stack); + this.stack = stack; + } + + @Override + public String getMessage(Object object) { + boolean pop = false; + + if (useSensitiveContext && !stack.getRoot().contains(c)) { + stack.push(c); + pop = true; + } + String message = super.getMessage(object); + + if (pop) { + stack.pop(); + } + return message; + } + + protected Boolean validateAllEntries(Collection<?> col) throws ValidationException { + boolean answer = true; + for (Object entry : col) { + answer = validateOneEntry(entry); + if (!answer) { + // validation on one entry has failed + // no need to continue + break; + } + } + return answer; + } + + protected Boolean validateNoneEntry(Collection<?> col) throws ValidationException { + boolean answer = true; + for (Object entry : col) { + boolean b = validateOneEntry(entry); + if (b) { + // one entry has sucessed, validation has failed + // no need to continue + answer = false; + break; + } + } + return answer; + } + + protected Boolean validateAtLeastOneEntry(Collection<?> col) throws ValidationException { + boolean answer = false; + for (Object entry : col) { + answer = validateOneEntry(entry); + if (answer) { + // one entry was succes, validation is ok, + // no need to continue + break; + } + } + return answer; + } + + protected Boolean validateExtacltyOneEntry(Collection<?> col) throws ValidationException { + int count = 0; + for (Object entry : col) { + boolean answer = validateOneEntry(entry); + if (answer) { + // one entry has succed + count++; + if (count > 1) { + // more than one entriy was successfull + // so validation has failed + break; + } + + } + } + return count == 1; + } + + protected Boolean validateUniqueKey(Collection<?> col) throws ValidationException { + boolean answer = true; + + Set<Integer> hashCodes = new java.util.HashSet<Integer>(); + int index = -1; + for (Object entry : col) { + index++; + // construction du hash de la clef d'unicite + Integer hash = getUniqueKeyHashCode(entry); + if (!hashCodes.contains(hash)) { + hashCodes.add(hash); + continue; + } + // une entree avec ce hash a deja ete trouvee + // on est donc en violation sur la clef unique + answer = false; + if (log.isDebugEnabled()) { + log.debug("duplicated uniquekey " + hash + " for entry " + index); + } + } + hashCodes.clear(); + return answer; + } + + protected boolean validateOneEntry(Object object) throws ValidationException { + + Boolean answer = Boolean.FALSE; + + boolean extraExpression = false; + + if (useSensitiveContext) { + c.addCurrent(object); + object = c; + + if (c.isFirst() && useFirst) { + // on valide l'expression sur la premiètre entrée + answer = evaluateExpression(expressionForFirst, object); + extraExpression = true; + } + if (c.isLast() && useLast) { + // on valide l'expression sur la dernière entrée + answer = (!extraExpression || answer) && evaluateExpression(expressionForLast, object); + extraExpression = true; + } + } + + answer = (!extraExpression || answer) && evaluateExpression(getExpression(), object); + + return answer; + } + + protected boolean evaluateExpression(String expression, Object object) throws ValidationException { + Object obj = null; + try { + obj = getFieldValue(expression, object); + } catch (ValidationException e) { + throw e; + } catch (Exception e) { + log.error(e.getMessage(), e); + // let this pass, but it will be logged right below + } + + Boolean answer = Boolean.FALSE; + + if (obj != null && obj instanceof Boolean) { + answer = (Boolean) obj; + } else { + log.warn("Got result of " + obj + " when trying to get Boolean for expression " + expression); + } + return answer; + } + + /** + * @param object the incoming object containing the collection to test + * @return the collection of the incoming object given by the fieldName property + * @throws ValidationException if any pb to retreave the collection + */ + protected Collection<?> getCollection(Object object) throws ValidationException { + String fieldName = getCollectionFieldName(); + if (fieldName == null || fieldName.trim().isEmpty()) { + // on travaille directement sur le fieldName + fieldName = getFieldName(); + } + + Object obj = null; + + // obtain the collection to test + try { + obj = getFieldValue(fieldName, object); + } catch (ValidationException e) { + throw e; + } catch (Exception e) { + // let this pass, but it will be logged right below + } + + if (obj == null) { + // la collection est nulle, donc on renvoie une collection vide + return java.util.Collections.EMPTY_LIST; + } + + if (!Collection.class.isInstance(obj)) { + throw new ValidationException("field " + fieldName + " is not a collection type! (" + obj.getClass() + ")"); + } + return (Collection<?>) obj; + } + + /** + * Calcule pour une entrée donné, le hash de la clef unique + * + * @param o l'entree de la collection dont on va calculer le hash de la clef unique + * @return le hashCode calclé de la clef unique sur l'entrée donné + * @throws ValidationException if any pb to retreave properties values + */ + protected Integer getUniqueKeyHashCode(Object o) throws ValidationException { + // calcul du hash à la volée + HashCodeBuilder builder = new HashCodeBuilder(); + for (String key : this.keys) { + Object property = getFieldValue(key, o); + if (log.isDebugEnabled()) { + log.debug("key " + key + " : " + property); + } + builder.append(property); + } + return builder.toHashCode(); + } + + @Override + public String getValidatorType() { + return "collectionFieldExpression"; + } + + public class WalkerContext { + + protected final int size; + + public WalkerContext(int size) { + this.size = size; + } + protected int index = -1; + protected Object current; + protected Object previous; + + public void addCurrent(Object current) { + index++; + previous = this.current; + this.current = current; + } + + public Object getCurrent() { + return current; + } + + public int getIndex() { + return index; + } + + public Object getPrevious() { + return previous; + } + + public int getSize() { + return size; + } + + public boolean isEmpty() { + return size == 0; + } + + public boolean isFirst() { + return index == 0; + } + + public boolean isLast() { + return index == size - 1; + } + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidator.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidator.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,228 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator.field; - -import com.opensymphony.xwork2.validator.ValidationException; -import com.opensymphony.xwork2.validator.validators.FieldExpressionValidator; -import org.apache.commons.lang.builder.HashCodeBuilder; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -/** - * Un validateur basé sur {@link FieldExpressionValidator} qui valide une clef - * unique sur une collection. - * <p/> - * Le {@link #fieldName} sert à récupérer la propriété de type de collection du bean. - * - * @author chemit - */ -public class CollectionUniqueKeyValidator extends FieldExpressionValidator { - - /** - * pour indiquer la propriété qui contient la liste à valider. - * - * Si cette prorpiété n'est pas renseignée alors on utilise la - * {@link #getFieldName()} pour obtenir la collection. - * - * Cela permet d'effectuer une validation si une collection mais portant - * en fait sur un autre champs - * @since 1.5 - */ - protected String collectionFieldName; - /** - * la liste des propriétés d'une entrée de la collection qui définit la - * clef unique. - */ - protected String[] keys; - /** - * Une propriété optionnelle pour valider que l'objet reflétée par cette - * propriété ne viole pas l'intégrité de la clef unique. - * Cela permet de valider l'unicité sans que l'objet soit dans la collection - */ - protected String againstProperty; - /** - * Lors de l'utilisation de la againstProperty et qu'un ne peut pas utiliser - * le equals sur l'objet, on peut spécifier une expression pour exclure des tests - * à exclure lors de la recherche de la violation de clef unique. - */ - protected String againstIndexExpression; - - public String getCollectionFieldName() { - return collectionFieldName; - } - - public void setCollectionFieldName(String collectionFieldName) { - this.collectionFieldName = collectionFieldName; - } - - public String[] getKeys() { - return keys; - } - - public void setKeys(String[] keys) { - if (keys != null && keys.length == 1 && keys[0].indexOf(",") != -1) { - this.keys = keys[0].split(","); - } else { - this.keys = keys; - } - } - - public String getAgainstProperty() { - return againstProperty; - } - - public void setAgainstProperty(String againstProperty) { - this.againstProperty = againstProperty; - } - - public String getAgainstIndexExpression() { - return againstIndexExpression; - } - - public void setAgainstIndexExpression(String againstIndexExpression) { - this.againstIndexExpression = againstIndexExpression; - } - - @Override - public void validate(Object object) throws ValidationException { - - if (keys == null || keys.length == 0) { - throw new ValidationException("no unique keys defined"); - } - - String fieldName = getFieldName(); - - Collection<?> col = getCollection(object); - - Object againstBean = againstProperty == null ? null : getFieldValue(againstProperty, object); - - Integer againstIndex = (Integer) (againstIndexExpression == null ? -1 : getFieldValue(againstIndexExpression, object)); - if (againstIndex == null) { - againstIndex = -1; - } - if (againstBean == null && col.size() < 2) { - // la liste ne contient pas deux entrées donc c'est valide - return; - } - - boolean answer = true; - - Integer againstHashCode = againstBean == null ? null : getUniqueKeyHashCode(againstBean); - - List<Integer> hashCodes = new ArrayList<Integer>(); - - int index = 0; - for (Object o : col) { - Integer hash = getUniqueKeyHashCode(o); - if (againstBean == null) { - if (hashCodes.contains(hash)) { - // on a deja rencontre cette clef unique, - // donc la validation a echouee - answer = false; - break; - } - } else { - // utilisation de againstBean - if (againstIndex != -1) { - if (index != againstIndex && hash.equals(againstHashCode)) { - // on a deja rencontre cette clef unique, - // donc la validation a echouee - answer = false; - break; - } - } else { - if (!againstBean.equals(o) && hash.equals(againstHashCode)) { - // on a deja rencontre cette clef unique, - // donc la validation a echouee - answer = false; - break; - } - } - } - // nouveau hashcode enregistre - hashCodes.add(hash); - // index suivant - index++; - } - - if (!answer) { - addFieldError(fieldName, object); - } - } - - /** - * Calcule pour une entrée donné, le hash de la clef unique - * - * @param o l'entree de la collection dont on va calculer le hash de la clef unique - * @return le hashCode calclé de la clef unique sur l'entrée donné - * @throws ValidationException if any pb to retreave properties values - */ - protected Integer getUniqueKeyHashCode(Object o) throws ValidationException { - // calcul du hash à la volée - HashCodeBuilder builder = new HashCodeBuilder(); - for (String key : this.keys) { - Object property = getFieldValue(key, o); - builder.append(property); - } - return builder.toHashCode(); - } - - /** - * @param object the incoming object containing the collection to test - * @return the collection of the incoming object given by the fieldName property - * @throws ValidationException if any pb to retreave the collection - */ - protected Collection<?> getCollection(Object object) throws ValidationException { - String fieldName = getCollectionFieldName(); - if (fieldName == null || fieldName.trim().isEmpty()) { - // on travaille directement sur le fieldName - fieldName = getFieldName(); - } - - Object obj = null; - - // obtain the collection to test - try { - obj = getFieldValue(fieldName, object); - } catch (ValidationException e) { - throw e; - } catch (Exception e) { - // let this pass, but it will be logged right below - } - - if (obj == null) { - // la collection est nulle, donc on renvoie une collection vide - return java.util.Collections.EMPTY_LIST; - } - - if (!Collection.class.isInstance(obj)) { - throw new ValidationException("field " + fieldName + " is not a collection type! (" + obj.getClass() + ")"); - } - return (Collection<?>) obj; - } - - @Override - public String getValidatorType() { - return "collectionUniqueKey"; - } -} \ No newline at end of file Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidator.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidator.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidator.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,228 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator.field; + +import com.opensymphony.xwork2.validator.ValidationException; +import com.opensymphony.xwork2.validator.validators.FieldExpressionValidator; +import org.apache.commons.lang.builder.HashCodeBuilder; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * Un validateur basé sur {@link FieldExpressionValidator} qui valide une clef + * unique sur une collection. + * <p/> + * Le {@link #fieldName} sert à récupérer la propriété de type de collection du bean. + * + * @author chemit + */ +public class CollectionUniqueKeyValidator extends FieldExpressionValidator { + + /** + * pour indiquer la propriété qui contient la liste à valider. + * + * Si cette prorpiété n'est pas renseignée alors on utilise la + * {@link #getFieldName()} pour obtenir la collection. + * + * Cela permet d'effectuer une validation si une collection mais portant + * en fait sur un autre champs + * @since 1.5 + */ + protected String collectionFieldName; + /** + * la liste des propriétés d'une entrée de la collection qui définit la + * clef unique. + */ + protected String[] keys; + /** + * Une propriété optionnelle pour valider que l'objet reflétée par cette + * propriété ne viole pas l'intégrité de la clef unique. + * Cela permet de valider l'unicité sans que l'objet soit dans la collection + */ + protected String againstProperty; + /** + * Lors de l'utilisation de la againstProperty et qu'un ne peut pas utiliser + * le equals sur l'objet, on peut spécifier une expression pour exclure des tests + * à exclure lors de la recherche de la violation de clef unique. + */ + protected String againstIndexExpression; + + public String getCollectionFieldName() { + return collectionFieldName; + } + + public void setCollectionFieldName(String collectionFieldName) { + this.collectionFieldName = collectionFieldName; + } + + public String[] getKeys() { + return keys; + } + + public void setKeys(String[] keys) { + if (keys != null && keys.length == 1 && keys[0].indexOf(",") != -1) { + this.keys = keys[0].split(","); + } else { + this.keys = keys; + } + } + + public String getAgainstProperty() { + return againstProperty; + } + + public void setAgainstProperty(String againstProperty) { + this.againstProperty = againstProperty; + } + + public String getAgainstIndexExpression() { + return againstIndexExpression; + } + + public void setAgainstIndexExpression(String againstIndexExpression) { + this.againstIndexExpression = againstIndexExpression; + } + + @Override + public void validate(Object object) throws ValidationException { + + if (keys == null || keys.length == 0) { + throw new ValidationException("no unique keys defined"); + } + + String fieldName = getFieldName(); + + Collection<?> col = getCollection(object); + + Object againstBean = againstProperty == null ? null : getFieldValue(againstProperty, object); + + Integer againstIndex = (Integer) (againstIndexExpression == null ? -1 : getFieldValue(againstIndexExpression, object)); + if (againstIndex == null) { + againstIndex = -1; + } + if (againstBean == null && col.size() < 2) { + // la liste ne contient pas deux entrées donc c'est valide + return; + } + + boolean answer = true; + + Integer againstHashCode = againstBean == null ? null : getUniqueKeyHashCode(againstBean); + + List<Integer> hashCodes = new ArrayList<Integer>(); + + int index = 0; + for (Object o : col) { + Integer hash = getUniqueKeyHashCode(o); + if (againstBean == null) { + if (hashCodes.contains(hash)) { + // on a deja rencontre cette clef unique, + // donc la validation a echouee + answer = false; + break; + } + } else { + // utilisation de againstBean + if (againstIndex != -1) { + if (index != againstIndex && hash.equals(againstHashCode)) { + // on a deja rencontre cette clef unique, + // donc la validation a echouee + answer = false; + break; + } + } else { + if (!againstBean.equals(o) && hash.equals(againstHashCode)) { + // on a deja rencontre cette clef unique, + // donc la validation a echouee + answer = false; + break; + } + } + } + // nouveau hashcode enregistre + hashCodes.add(hash); + // index suivant + index++; + } + + if (!answer) { + addFieldError(fieldName, object); + } + } + + /** + * Calcule pour une entrée donné, le hash de la clef unique + * + * @param o l'entree de la collection dont on va calculer le hash de la clef unique + * @return le hashCode calclé de la clef unique sur l'entrée donné + * @throws ValidationException if any pb to retreave properties values + */ + protected Integer getUniqueKeyHashCode(Object o) throws ValidationException { + // calcul du hash à la volée + HashCodeBuilder builder = new HashCodeBuilder(); + for (String key : this.keys) { + Object property = getFieldValue(key, o); + builder.append(property); + } + return builder.toHashCode(); + } + + /** + * @param object the incoming object containing the collection to test + * @return the collection of the incoming object given by the fieldName property + * @throws ValidationException if any pb to retreave the collection + */ + protected Collection<?> getCollection(Object object) throws ValidationException { + String fieldName = getCollectionFieldName(); + if (fieldName == null || fieldName.trim().isEmpty()) { + // on travaille directement sur le fieldName + fieldName = getFieldName(); + } + + Object obj = null; + + // obtain the collection to test + try { + obj = getFieldValue(fieldName, object); + } catch (ValidationException e) { + throw e; + } catch (Exception e) { + // let this pass, but it will be logged right below + } + + if (obj == null) { + // la collection est nulle, donc on renvoie une collection vide + return java.util.Collections.EMPTY_LIST; + } + + if (!Collection.class.isInstance(obj)) { + throw new ValidationException("field " + fieldName + " is not a collection type! (" + obj.getClass() + ")"); + } + return (Collection<?>) obj; + } + + @Override + public String getValidatorType() { + return "collectionUniqueKey"; + } +} \ No newline at end of file Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidator.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidator.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,93 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator.field; - -import com.opensymphony.xwork2.validator.ValidationException; -import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport; - -import java.io.File; - -/** - * <!-- START SNIPPET: javadoc --> - * ExistingDirectoryFieldValidator checks that a File field exists and is a directory. - * <!-- END SNIPPET: javadoc --> - * <p/> - * <p/> - * <!-- START SNIPPET: parameters --> - * <ul> - * <li>fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required</li> - * </ul> - * <!-- END SNIPPET: parameters --> - * <p/> - * <p/> - * <pre> - * <!-- START SNIPPET: examples --> - * <validators> - * <!-- Plain-Validator Syntax --> - * <validator type="existingDirectory"> - * <param name="fieldName">tmp</param> - * <message>tmp is not an existing directory</message> - * </validator> - * <p/> - * <!-- Field-Validator Syntax --> - * <field name="tmp"> - * <field-validator type="existingDirectory"> - * <message>tmp is not an existing directory</message> - * </field-validator> - * </field> - * </validators> - * <!-- END SNIPPET: examples --> - * </pre> - * - * @author chemit - */ -public class ExistingDirectoryFieldValidator extends FieldValidatorSupport { - - @Override - public void validate(Object object) throws ValidationException { - String fieldName = getFieldName(); - Object value = this.getFieldValue(fieldName, object); - if (value==null) { - // no value defined - addFieldError(fieldName, object); - return; - } - File f; - if (value instanceof File) { - f = (File) value; - } else if (value instanceof String) { - f = new File((String) value); - } else { - addFieldError(fieldName, object); - return; - } - - if (!(f.isDirectory() && f.exists())) { - // f is not a directory, nor exists - addFieldError(fieldName, object); - } - } - - @Override - public String getValidatorType() { - return "existingDirectory"; - } -} \ No newline at end of file Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidator.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidator.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidator.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,93 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator.field; + +import com.opensymphony.xwork2.validator.ValidationException; +import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport; + +import java.io.File; + +/** + * <!-- START SNIPPET: javadoc --> + * ExistingDirectoryFieldValidator checks that a File field exists and is a directory. + * <!-- END SNIPPET: javadoc --> + * <p/> + * <p/> + * <!-- START SNIPPET: parameters --> + * <ul> + * <li>fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required</li> + * </ul> + * <!-- END SNIPPET: parameters --> + * <p/> + * <p/> + * <pre> + * <!-- START SNIPPET: examples --> + * <validators> + * <!-- Plain-Validator Syntax --> + * <validator type="existingDirectory"> + * <param name="fieldName">tmp</param> + * <message>tmp is not an existing directory</message> + * </validator> + * <p/> + * <!-- Field-Validator Syntax --> + * <field name="tmp"> + * <field-validator type="existingDirectory"> + * <message>tmp is not an existing directory</message> + * </field-validator> + * </field> + * </validators> + * <!-- END SNIPPET: examples --> + * </pre> + * + * @author chemit + */ +public class ExistingDirectoryFieldValidator extends FieldValidatorSupport { + + @Override + public void validate(Object object) throws ValidationException { + String fieldName = getFieldName(); + Object value = this.getFieldValue(fieldName, object); + if (value==null) { + // no value defined + addFieldError(fieldName, object); + return; + } + File f; + if (value instanceof File) { + f = (File) value; + } else if (value instanceof String) { + f = new File((String) value); + } else { + addFieldError(fieldName, object); + return; + } + + if (!(f.isDirectory() && f.exists())) { + // f is not a directory, nor exists + addFieldError(fieldName, object); + } + } + + @Override + public String getValidatorType() { + return "existingDirectory"; + } +} \ No newline at end of file Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingFileFieldValidator.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingFileFieldValidator.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingFileFieldValidator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,93 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator.field; - -import com.opensymphony.xwork2.validator.ValidationException; -import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport; - -import java.io.File; - -/** - * <!-- START SNIPPET: javadoc --> - * ExistingFileFieldValidator checks that a File field exists. * - * <!-- END SNIPPET: javadoc --> - * <p/> - * <p/> - * <!-- START SNIPPET: parameters --> - * <ul> - * <li>fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required</li> - * </ul> - * <!-- END SNIPPET: parameters --> - * <p/> - * <p/> - * <pre> - * <!-- START SNIPPET: examples --> - * <validators> - * <!-- Plain-Validator Syntax --> - * <validator type="fileExisting"> - * <param name="fieldName">tmp</param> - * <message>tmp is not an existing file</message> - * </validator> - * <p/> - * <!-- Field-Validator Syntax --> - * <field name="tmp"> - * <field-validator type="fileExisting"> - * <message>tmp is not an existing file</message> - * </field-validator> - * </field> - * </validators> - * <!-- END SNIPPET: examples --> - * </pre> - * - * @author chemit - */ -public class ExistingFileFieldValidator extends FieldValidatorSupport { - - @Override - public void validate(Object object) throws ValidationException { - String fieldName = getFieldName(); - Object value = this.getFieldValue(fieldName, object); - if (value == null) { - // no value defined - addFieldError(fieldName, object); - return; - } - File f; - if (value instanceof File) { - f = (File) value; - } else if (value instanceof String) { - f = new File((String) value); - } else { - addFieldError(fieldName, object); - return; - } - - if (!(f.isFile() && f.exists())) { - // f is not a file nor exists - addFieldError(fieldName, object); - } - } - - @Override - public String getValidatorType() { - return "existingFile"; - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingFileFieldValidator.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingFileFieldValidator.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingFileFieldValidator.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingFileFieldValidator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,93 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator.field; + +import com.opensymphony.xwork2.validator.ValidationException; +import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport; + +import java.io.File; + +/** + * <!-- START SNIPPET: javadoc --> + * ExistingFileFieldValidator checks that a File field exists. * + * <!-- END SNIPPET: javadoc --> + * <p/> + * <p/> + * <!-- START SNIPPET: parameters --> + * <ul> + * <li>fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required</li> + * </ul> + * <!-- END SNIPPET: parameters --> + * <p/> + * <p/> + * <pre> + * <!-- START SNIPPET: examples --> + * <validators> + * <!-- Plain-Validator Syntax --> + * <validator type="fileExisting"> + * <param name="fieldName">tmp</param> + * <message>tmp is not an existing file</message> + * </validator> + * <p/> + * <!-- Field-Validator Syntax --> + * <field name="tmp"> + * <field-validator type="fileExisting"> + * <message>tmp is not an existing file</message> + * </field-validator> + * </field> + * </validators> + * <!-- END SNIPPET: examples --> + * </pre> + * + * @author chemit + */ +public class ExistingFileFieldValidator extends FieldValidatorSupport { + + @Override + public void validate(Object object) throws ValidationException { + String fieldName = getFieldName(); + Object value = this.getFieldValue(fieldName, object); + if (value == null) { + // no value defined + addFieldError(fieldName, object); + return; + } + File f; + if (value instanceof File) { + f = (File) value; + } else if (value instanceof String) { + f = new File((String) value); + } else { + addFieldError(fieldName, object); + return; + } + + if (!(f.isFile() && f.exists())) { + // f is not a file nor exists + addFieldError(fieldName, object); + } + } + + @Override + public String getValidatorType() { + return "existingFile"; + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/FieldExpressionWithParamsValidator.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/FieldExpressionWithParamsValidator.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/FieldExpressionWithParamsValidator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,195 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator.field; - -import com.opensymphony.xwork2.util.ValueStack; -import com.opensymphony.xwork2.validator.ValidationException; -import com.opensymphony.xwork2.validator.validators.FieldExpressionValidator; -import java.util.Map; -import java.util.StringTokenizer; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.nuiton.util.ConverterUtil; - -/** - * Extends {@link FieldExpressionValidator} to add some extra parameters available - * in the {@link #getExpression()} - * - * @author tony - * @since 1.3 - */ -public class FieldExpressionWithParamsValidator extends FieldExpressionValidator { - - protected static final Pattern EXTRA_BOOLEAN_PARAM_ENTRY_PATTERN = Pattern.compile("(\\w+)\\:(false|true)"); - protected static final Pattern EXTRA_SHORT_PARAM_ENTRY_PATTERN = Pattern.compile("(\\w+)\\:(\\d+)"); - protected static final Pattern EXTRA_INT_PARAM_ENTRY_PATTERN = Pattern.compile("(\\w+)\\:(\\d+)"); - protected static final Pattern EXTRA_LONG_PARAM_ENTRY_PATTERN = Pattern.compile("(\\w+)\\:(\\d+)"); - protected static final Pattern EXTRA_DOUBLE_PARAM_ENTRY_PATTERN = Pattern.compile("(\\w+)\\:(\\d+\\.\\d+)"); - protected static final Pattern EXTRA_STRING_PARAM_ENTRY_PATTERN = Pattern.compile("(\\w+)\\:(.+)"); - protected ValueStack stack; - protected String booleanParams; - protected String shortParams; - protected String intParams; - protected String longParams; - protected String doubleParams; - protected String stringParams; - protected Map<String, Boolean> booleans; - protected Map<String, Short> shorts; - protected Map<String, Integer> ints; - protected Map<String, Long> longs; - protected Map<String, Double> doubles; - protected Map<String, String> strings; - - public String getBooleanParams() { - return booleanParams; - } - - public void setBooleanParams(String booleanParams) { - this.booleanParams = booleanParams; - } - - public String getDoubleParams() { - return doubleParams; - } - - public void setDoubleParams(String doubleParams) { - this.doubleParams = doubleParams; - } - - public String getIntParams() { - return intParams; - } - - public void setIntParams(String intParams) { - this.intParams = intParams; - } - - public String getLongParams() { - return longParams; - } - - public void setLongParams(String longParams) { - this.longParams = longParams; - } - - public String getShortParams() { - return shortParams; - } - - public void setShortParams(String shortParams) { - this.shortParams = shortParams; - } - - public String getStringParams() { - return stringParams; - } - - public void setStringParams(String stringParams) { - this.stringParams = stringParams; - } - - public Map<String, Boolean> getBooleans() { - return booleans; - } - - public Map<String, Double> getDoubles() { - return doubles; - } - - public Map<String, Integer> getInts() { - return ints; - } - - public Map<String, Long> getLongs() { - return longs; - } - - public Map<String, Short> getShorts() { - return shorts; - } - - public Map<String, String> getStrings() { - return strings; - } - - @Override - public String getValidatorType() { - return "fieldexpressionwithparams"; - } - - @Override - public void setValueStack(ValueStack stack) { - super.setValueStack(stack); - this.stack = stack; - } - - @Override - public void validate(Object object) throws ValidationException { - - booleans = initParams(Boolean.class, booleanParams, EXTRA_BOOLEAN_PARAM_ENTRY_PATTERN); - shorts = initParams(Short.class, shortParams, EXTRA_SHORT_PARAM_ENTRY_PATTERN); - ints = initParams(Integer.class, intParams, EXTRA_INT_PARAM_ENTRY_PATTERN); - longs = initParams(Long.class, longParams, EXTRA_LONG_PARAM_ENTRY_PATTERN); - doubles = initParams(Double.class, doubleParams, EXTRA_DOUBLE_PARAM_ENTRY_PATTERN); - strings = initParams(String.class, stringParams, EXTRA_STRING_PARAM_ENTRY_PATTERN); - - boolean pop = false; - if (!stack.getRoot().contains(this)) { - stack.push(this); - pop = true; - } - - try { - super.validate(object); - } finally { - if (pop) { - stack.pop(); - } - } - - } - - protected <T> Map<String, T> initParams(Class<T> klass, String extraParams, Pattern pattern) throws ValidationException { - - if (extraParams == null || extraParams.isEmpty()) { - // not using - return null; - } - - StringTokenizer stk = new StringTokenizer(extraParams, "|"); - Map<String, T> result = new java.util.TreeMap<String, T>(); - while (stk.hasMoreTokens()) { - String entry = stk.nextToken(); - Matcher matcher = pattern.matcher(entry); - if (!matcher.matches()) { - throw new ValidationException("could not parse for extra params " + extraParams + " for type " + klass.getName()); - } - String paramName = matcher.group(1); - String paramValueStr = matcher.group(2); - T paramValue = ConverterUtil.convert(klass, paramValueStr); - if (log.isDebugEnabled()) { - log.debug("detected extra param : <type:" + klass + ", name:" + paramName + ", value:" + paramValue + ">"); - } - result.put(paramName, paramValue); - } - return result; - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/FieldExpressionWithParamsValidator.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/FieldExpressionWithParamsValidator.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/FieldExpressionWithParamsValidator.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/FieldExpressionWithParamsValidator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,195 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator.field; + +import com.opensymphony.xwork2.util.ValueStack; +import com.opensymphony.xwork2.validator.ValidationException; +import com.opensymphony.xwork2.validator.validators.FieldExpressionValidator; +import java.util.Map; +import java.util.StringTokenizer; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.nuiton.util.ConverterUtil; + +/** + * Extends {@link FieldExpressionValidator} to add some extra parameters available + * in the {@link #getExpression()} + * + * @author tony + * @since 1.3 + */ +public class FieldExpressionWithParamsValidator extends FieldExpressionValidator { + + protected static final Pattern EXTRA_BOOLEAN_PARAM_ENTRY_PATTERN = Pattern.compile("(\\w+)\\:(false|true)"); + protected static final Pattern EXTRA_SHORT_PARAM_ENTRY_PATTERN = Pattern.compile("(\\w+)\\:(\\d+)"); + protected static final Pattern EXTRA_INT_PARAM_ENTRY_PATTERN = Pattern.compile("(\\w+)\\:(\\d+)"); + protected static final Pattern EXTRA_LONG_PARAM_ENTRY_PATTERN = Pattern.compile("(\\w+)\\:(\\d+)"); + protected static final Pattern EXTRA_DOUBLE_PARAM_ENTRY_PATTERN = Pattern.compile("(\\w+)\\:(\\d+\\.\\d+)"); + protected static final Pattern EXTRA_STRING_PARAM_ENTRY_PATTERN = Pattern.compile("(\\w+)\\:(.+)"); + protected ValueStack stack; + protected String booleanParams; + protected String shortParams; + protected String intParams; + protected String longParams; + protected String doubleParams; + protected String stringParams; + protected Map<String, Boolean> booleans; + protected Map<String, Short> shorts; + protected Map<String, Integer> ints; + protected Map<String, Long> longs; + protected Map<String, Double> doubles; + protected Map<String, String> strings; + + public String getBooleanParams() { + return booleanParams; + } + + public void setBooleanParams(String booleanParams) { + this.booleanParams = booleanParams; + } + + public String getDoubleParams() { + return doubleParams; + } + + public void setDoubleParams(String doubleParams) { + this.doubleParams = doubleParams; + } + + public String getIntParams() { + return intParams; + } + + public void setIntParams(String intParams) { + this.intParams = intParams; + } + + public String getLongParams() { + return longParams; + } + + public void setLongParams(String longParams) { + this.longParams = longParams; + } + + public String getShortParams() { + return shortParams; + } + + public void setShortParams(String shortParams) { + this.shortParams = shortParams; + } + + public String getStringParams() { + return stringParams; + } + + public void setStringParams(String stringParams) { + this.stringParams = stringParams; + } + + public Map<String, Boolean> getBooleans() { + return booleans; + } + + public Map<String, Double> getDoubles() { + return doubles; + } + + public Map<String, Integer> getInts() { + return ints; + } + + public Map<String, Long> getLongs() { + return longs; + } + + public Map<String, Short> getShorts() { + return shorts; + } + + public Map<String, String> getStrings() { + return strings; + } + + @Override + public String getValidatorType() { + return "fieldexpressionwithparams"; + } + + @Override + public void setValueStack(ValueStack stack) { + super.setValueStack(stack); + this.stack = stack; + } + + @Override + public void validate(Object object) throws ValidationException { + + booleans = initParams(Boolean.class, booleanParams, EXTRA_BOOLEAN_PARAM_ENTRY_PATTERN); + shorts = initParams(Short.class, shortParams, EXTRA_SHORT_PARAM_ENTRY_PATTERN); + ints = initParams(Integer.class, intParams, EXTRA_INT_PARAM_ENTRY_PATTERN); + longs = initParams(Long.class, longParams, EXTRA_LONG_PARAM_ENTRY_PATTERN); + doubles = initParams(Double.class, doubleParams, EXTRA_DOUBLE_PARAM_ENTRY_PATTERN); + strings = initParams(String.class, stringParams, EXTRA_STRING_PARAM_ENTRY_PATTERN); + + boolean pop = false; + if (!stack.getRoot().contains(this)) { + stack.push(this); + pop = true; + } + + try { + super.validate(object); + } finally { + if (pop) { + stack.pop(); + } + } + + } + + protected <T> Map<String, T> initParams(Class<T> klass, String extraParams, Pattern pattern) throws ValidationException { + + if (extraParams == null || extraParams.isEmpty()) { + // not using + return null; + } + + StringTokenizer stk = new StringTokenizer(extraParams, "|"); + Map<String, T> result = new java.util.TreeMap<String, T>(); + while (stk.hasMoreTokens()) { + String entry = stk.nextToken(); + Matcher matcher = pattern.matcher(entry); + if (!matcher.matches()) { + throw new ValidationException("could not parse for extra params " + extraParams + " for type " + klass.getName()); + } + String paramName = matcher.group(1); + String paramValueStr = matcher.group(2); + T paramValue = ConverterUtil.convert(klass, paramValueStr); + if (log.isDebugEnabled()) { + log.debug("detected extra param : <type:" + klass + ", name:" + paramName + ", value:" + paramValue + ">"); + } + result.put(paramName, paramValue); + } + return result; + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/NotExistingDirectoryFieldValidator.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/NotExistingDirectoryFieldValidator.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/NotExistingDirectoryFieldValidator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,92 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator.field; - -import com.opensymphony.xwork2.validator.ValidationException; -import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport; - -import java.io.File; - -/** - * <!-- START SNIPPET: javadoc --> - * NotExistingDirectoryFieldValidator checks that a File field as a directory does not exist. * - * <!-- END SNIPPET: javadoc --> - * <p/> - * <p/> - * <!-- START SNIPPET: parameters --> - * <ul> - * <li>fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required</li> - * </ul> - * <!-- END SNIPPET: parameters --> - * <p/> - * <p/> - * <pre> - * <!-- START SNIPPET: examples --> - * <validators> - * <!-- Plain-Validator Syntax --> - * <validator type="notExistingDirectory"> - * <param name="fieldName">tmp</param> - * <message>tmp is an existing directory</message> - * </validator> - * <p/> - * <!-- Field-Validator Syntax --> - * <field name="tmp"> - * <field-validator type="notExistingDirectory"> - * <message>tmp is an existing directory</message> - * </field-validator> - * </field> - * </validators> - * <!-- END SNIPPET: examples --> - * </pre> - * - * @author chemit - */ -public class NotExistingDirectoryFieldValidator extends FieldValidatorSupport { - - @Override - public void validate(Object object) throws ValidationException { - String fieldName = getFieldName(); - Object value = this.getFieldValue(fieldName, object); - if (value == null) { - // no value defined - addFieldError(fieldName, object); - return; - } - File f; - if (value instanceof File) { - f = (File) value; - } else if (value instanceof String) { - f = new File((String) value); - } else { - addFieldError(fieldName, object); - return; - } - - if (f.exists() || f.isFile()) { - addFieldError(fieldName, object); - } - } - - @Override - public String getValidatorType() { - return "notExistingDirectory"; - } -} \ No newline at end of file Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/NotExistingDirectoryFieldValidator.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/NotExistingDirectoryFieldValidator.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/NotExistingDirectoryFieldValidator.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/NotExistingDirectoryFieldValidator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,92 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator.field; + +import com.opensymphony.xwork2.validator.ValidationException; +import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport; + +import java.io.File; + +/** + * <!-- START SNIPPET: javadoc --> + * NotExistingDirectoryFieldValidator checks that a File field as a directory does not exist. * + * <!-- END SNIPPET: javadoc --> + * <p/> + * <p/> + * <!-- START SNIPPET: parameters --> + * <ul> + * <li>fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required</li> + * </ul> + * <!-- END SNIPPET: parameters --> + * <p/> + * <p/> + * <pre> + * <!-- START SNIPPET: examples --> + * <validators> + * <!-- Plain-Validator Syntax --> + * <validator type="notExistingDirectory"> + * <param name="fieldName">tmp</param> + * <message>tmp is an existing directory</message> + * </validator> + * <p/> + * <!-- Field-Validator Syntax --> + * <field name="tmp"> + * <field-validator type="notExistingDirectory"> + * <message>tmp is an existing directory</message> + * </field-validator> + * </field> + * </validators> + * <!-- END SNIPPET: examples --> + * </pre> + * + * @author chemit + */ +public class NotExistingDirectoryFieldValidator extends FieldValidatorSupport { + + @Override + public void validate(Object object) throws ValidationException { + String fieldName = getFieldName(); + Object value = this.getFieldValue(fieldName, object); + if (value == null) { + // no value defined + addFieldError(fieldName, object); + return; + } + File f; + if (value instanceof File) { + f = (File) value; + } else if (value instanceof String) { + f = new File((String) value); + } else { + addFieldError(fieldName, object); + return; + } + + if (f.exists() || f.isFile()) { + addFieldError(fieldName, object); + } + } + + @Override + public String getValidatorType() { + return "notExistingDirectory"; + } +} \ No newline at end of file Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/NotExistingFileFieldValidator.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/NotExistingFileFieldValidator.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/NotExistingFileFieldValidator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,93 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator.field; - -import com.opensymphony.xwork2.validator.ValidationException; -import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport; - -import java.io.File; - -/** - * <!-- START SNIPPET: javadoc --> - * NotExistingFileFieldValidator checks that a File field as a file does not exist. * - * <!-- END SNIPPET: javadoc --> - * <p/> - * <p/> - * <!-- START SNIPPET: parameters --> - * <ul> - * <li>fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required</li> - * </ul> - * <!-- END SNIPPET: parameters --> - * <p/> - * <p/> - * <pre> - * <!-- START SNIPPET: examples --> - * <validators> - * <!-- Plain-Validator Syntax --> - * <validator type="notExistingFile"> - * <param name="fieldName">tmp</param> - * <message>tmp is an existing file</message> - * </validator> - * <p/> - * <!-- Field-Validator Syntax --> - * <field name="tmp"> - * <field-validator type="notExistingFile"> - * <message>tmp is an existing file</message> - * </field-validator> - * </field> - * </validators> - * <!-- END SNIPPET: examples --> - * </pre> - * - * @author chemit - */ -public class NotExistingFileFieldValidator extends FieldValidatorSupport { - - @Override - public void validate(Object object) throws ValidationException { - String fieldName = getFieldName(); - Object value = this.getFieldValue(fieldName, object); - if (value==null) { - // no value defined - addFieldError(fieldName, object); - return; - } - File f; - if (value instanceof File) { - f = (File) value; - } else if (value instanceof String) { - f = new File((String) value); - } else { - addFieldError(fieldName, object); - return; - } - - if (f.exists() || f.isDirectory()) { - // f is not a file and exist - addFieldError(fieldName, object); - } - } - - @Override - public String getValidatorType() { - return "notExistingFile"; - } -} \ No newline at end of file Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/NotExistingFileFieldValidator.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/NotExistingFileFieldValidator.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/NotExistingFileFieldValidator.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/NotExistingFileFieldValidator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,93 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator.field; + +import com.opensymphony.xwork2.validator.ValidationException; +import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport; + +import java.io.File; + +/** + * <!-- START SNIPPET: javadoc --> + * NotExistingFileFieldValidator checks that a File field as a file does not exist. * + * <!-- END SNIPPET: javadoc --> + * <p/> + * <p/> + * <!-- START SNIPPET: parameters --> + * <ul> + * <li>fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required</li> + * </ul> + * <!-- END SNIPPET: parameters --> + * <p/> + * <p/> + * <pre> + * <!-- START SNIPPET: examples --> + * <validators> + * <!-- Plain-Validator Syntax --> + * <validator type="notExistingFile"> + * <param name="fieldName">tmp</param> + * <message>tmp is an existing file</message> + * </validator> + * <p/> + * <!-- Field-Validator Syntax --> + * <field name="tmp"> + * <field-validator type="notExistingFile"> + * <message>tmp is an existing file</message> + * </field-validator> + * </field> + * </validators> + * <!-- END SNIPPET: examples --> + * </pre> + * + * @author chemit + */ +public class NotExistingFileFieldValidator extends FieldValidatorSupport { + + @Override + public void validate(Object object) throws ValidationException { + String fieldName = getFieldName(); + Object value = this.getFieldValue(fieldName, object); + if (value==null) { + // no value defined + addFieldError(fieldName, object); + return; + } + File f; + if (value instanceof File) { + f = (File) value; + } else if (value instanceof String) { + f = new File((String) value); + } else { + addFieldError(fieldName, object); + return; + } + + if (f.exists() || f.isDirectory()) { + // f is not a file and exist + addFieldError(fieldName, object); + } + } + + @Override + public String getValidatorType() { + return "notExistingFile"; + } +} \ No newline at end of file Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/RequiredFileFieldValidator.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/RequiredFileFieldValidator.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/RequiredFileFieldValidator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,93 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator.field; - -import com.opensymphony.xwork2.validator.ValidationException; -import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport; - -import java.io.File; - -/** - * <!-- START SNIPPET: javadoc --> - * RequiredFileFieldValidator checks that a File field is not null nor have an empty filename. - * <!-- END SNIPPET: javadoc --> - * <p/> - * <p/> - * <!-- START SNIPPET: parameters --> - * <ul> - * <li>fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required</li> - * </ul> - * <!-- END SNIPPET: parameters --> - * <p/> - * <p/> - * <pre> - * <!-- START SNIPPET: examples --> - * <validators> - * <!-- Plain-Validator Syntax --> - * <validator type="requiredFile"> - * <param name="fieldName">tmp</param> - * <message>tmp is required</message> - * </validator> - * <p/> - * <!-- Field-Validator Syntax --> - * <field name="tmp"> - * <field-validator type="requiredFile"> - * <message>tmp is required</message> - * </field-validator> - * </field> - * </validators> - * <!-- END SNIPPET: examples --> - * </pre> - * - * @author chemit - */ -public class RequiredFileFieldValidator extends FieldValidatorSupport { - - @Override - public void validate(Object object) throws ValidationException { - String fieldName = getFieldName(); - Object value = this.getFieldValue(fieldName, object); - if (value == null) { - // no value defined - addFieldError(fieldName, object); - return; - } - File f; - if (value instanceof File) { - f = (File) value; - } else if (value instanceof String) { - f = new File((String) value); - } else { - addFieldError(fieldName, object); - return; - } - - if (f.getPath().trim().isEmpty()) { - // f is not a directory nor exists - addFieldError(fieldName, object); - } - } - - @Override - public String getValidatorType() { - return "requiredFile"; - } -} \ No newline at end of file Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/RequiredFileFieldValidator.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/RequiredFileFieldValidator.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/RequiredFileFieldValidator.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/RequiredFileFieldValidator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,93 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator.field; + +import com.opensymphony.xwork2.validator.ValidationException; +import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport; + +import java.io.File; + +/** + * <!-- START SNIPPET: javadoc --> + * RequiredFileFieldValidator checks that a File field is not null nor have an empty filename. + * <!-- END SNIPPET: javadoc --> + * <p/> + * <p/> + * <!-- START SNIPPET: parameters --> + * <ul> + * <li>fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required</li> + * </ul> + * <!-- END SNIPPET: parameters --> + * <p/> + * <p/> + * <pre> + * <!-- START SNIPPET: examples --> + * <validators> + * <!-- Plain-Validator Syntax --> + * <validator type="requiredFile"> + * <param name="fieldName">tmp</param> + * <message>tmp is required</message> + * </validator> + * <p/> + * <!-- Field-Validator Syntax --> + * <field name="tmp"> + * <field-validator type="requiredFile"> + * <message>tmp is required</message> + * </field-validator> + * </field> + * </validators> + * <!-- END SNIPPET: examples --> + * </pre> + * + * @author chemit + */ +public class RequiredFileFieldValidator extends FieldValidatorSupport { + + @Override + public void validate(Object object) throws ValidationException { + String fieldName = getFieldName(); + Object value = this.getFieldValue(fieldName, object); + if (value == null) { + // no value defined + addFieldError(fieldName, object); + return; + } + File f; + if (value instanceof File) { + f = (File) value; + } else if (value instanceof String) { + f = new File((String) value); + } else { + addFieldError(fieldName, object); + return; + } + + if (f.getPath().trim().isEmpty()) { + // f is not a directory nor exists + addFieldError(fieldName, object); + } + } + + @Override + public String getValidatorType() { + return "requiredFile"; + } +} \ No newline at end of file Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,299 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,299 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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); + } + } + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,86 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,86 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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; + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,162 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,162 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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); + } + } + } + } +} Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,80 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,80 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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 Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,109 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,109 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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 Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,353 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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. - * <p/> - * 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. - * <p/> - * <p/> - * 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: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,353 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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. + * <p/> + * 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. + * <p/> + * <p/> + * 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 Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,114 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,114 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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 Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,103 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,103 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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 Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,216 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator.swing; - -import jaxx.runtime.*; -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 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 = SwingUtil.createImageIcon("error.png"); - } - return errorIcon; - } - - public static ImageIcon getInfoIcon() { - if (infoIcon == null) { - infoIcon = SwingUtil.createImageIcon("info.png"); - } - return infoIcon; - } - - public static ImageIcon getWarningIcon() { - if (warningIcon == null) { - warningIcon = SwingUtil.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 SwingValidatorMessageListMouseListener) { - 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: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,216 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator.swing; + +import jaxx.runtime.*; +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 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 = SwingUtil.createImageIcon("error.png"); + } + return errorIcon; + } + + public static ImageIcon getInfoIcon() { + if (infoIcon == null) { + infoIcon = SwingUtil.createImageIcon("info.png"); + } + return infoIcon; + } + + public static ImageIcon getWarningIcon() { + if (warningIcon == null) { + warningIcon = SwingUtil.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 SwingValidatorMessageListMouseListener) { + 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 Deleted: trunk/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/AbstractBeanValidatorUI.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,57 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,57 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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); + } + } + +} Deleted: trunk/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/IconValidationUI.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,106 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,106 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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; + } +} Deleted: trunk/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/ImageValidationUI.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,99 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator.swing.ui; - -import jaxx.runtime.SwingUtil; -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(SwingUtil.createImageIcon("error.png")); - } - if (warningIcon == null) { - warningIcon = prepareIcon(SwingUtil.createImageIcon("warning.png")); - } - if (infoIcon == null) { - infoIcon = prepareIcon(SwingUtil.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: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,99 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator.swing.ui; + +import jaxx.runtime.SwingUtil; +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(SwingUtil.createImageIcon("error.png")); + } + if (warningIcon == null) { + warningIcon = prepareIcon(SwingUtil.createImageIcon("warning.png")); + } + if (infoIcon == null) { + infoIcon = prepareIcon(SwingUtil.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 Deleted: trunk/jaxx-runtime/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 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,85 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -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()); - } -} Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java) =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,85 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +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: trunk/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-en_GB.properties =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-en_GB.properties 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-en_GB.properties 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,12 +0,0 @@ -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: trunk/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-en_GB.properties (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-en_GB.properties) =================================================================== --- trunk/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-en_GB.properties (rev 0) +++ trunk/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-en_GB.properties 2009-12-02 13:59:28 UTC (rev 1673) @@ -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 Deleted: trunk/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-fr_FR.properties =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-fr_FR.properties 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-fr_FR.properties 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,12 +0,0 @@ -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: trunk/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-fr_FR.properties (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-fr_FR.properties) =================================================================== --- trunk/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-fr_FR.properties (rev 0) +++ trunk/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-fr_FR.properties 2009-12-02 13:59:28 UTC (rev 1673) @@ -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 Deleted: trunk/jaxx-runtime/src/main/resources/icons/action-delete.png =================================================================== (Binary files differ) Copied: trunk/jaxx-runtime/src/main/resources/icons/action-delete.png (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-delete.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-config-16.png =================================================================== (Binary files differ) Copied: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-config-16.png (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-config-16.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-config.png =================================================================== (Binary files differ) Copied: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-config.png (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-config.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-message-16.png =================================================================== (Binary files differ) Copied: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-message-16.png (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-message-16.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-message.png =================================================================== (Binary files differ) Copied: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-message.png (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-message.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-next-16.png =================================================================== (Binary files differ) Copied: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-next-16.png (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-next-16.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-next.png =================================================================== (Binary files differ) Copied: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-next.png (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-next.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-pause-16.png =================================================================== (Binary files differ) Copied: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-pause-16.png (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-pause-16.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-pause.png =================================================================== (Binary files differ) Copied: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-pause.png (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-pause.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-previous-16.png =================================================================== (Binary files differ) Copied: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-previous-16.png (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-previous-16.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-previous.png =================================================================== (Binary files differ) Copied: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-previous.png (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-previous.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-refresh-16.png =================================================================== (Binary files differ) Copied: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-refresh-16.png (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-refresh-16.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-refresh.png =================================================================== (Binary files differ) Copied: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-refresh.png (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-refresh.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-start-16.png =================================================================== (Binary files differ) Copied: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-start-16.png (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-start-16.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-start.png =================================================================== (Binary files differ) Copied: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-start.png (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-start.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-canceled-16.png =================================================================== (Binary files differ) Copied: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-canceled-16.png (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-canceled-16.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-canceled.png =================================================================== (Binary files differ) Copied: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-canceled.png (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-canceled.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-failed-16.png =================================================================== (Binary files differ) Copied: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-failed-16.png (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-failed-16.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-failed.png =================================================================== (Binary files differ) Copied: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-failed.png (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-failed.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-need_fix-16.png =================================================================== (Binary files differ) Copied: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-need_fix-16.png (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-need_fix-16.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-need_fix.png =================================================================== (Binary files differ) Copied: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-need_fix.png (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-need_fix.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-pending-16.png =================================================================== (Binary files differ) Copied: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-pending-16.png (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-pending-16.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-pending.png =================================================================== (Binary files differ) Copied: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-pending.png (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-pending.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-running-16.png =================================================================== (Binary files differ) Copied: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-running-16.png (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-running-16.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-running.png =================================================================== (Binary files differ) Copied: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-running.png (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-running.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-successed-16.png =================================================================== (Binary files differ) Copied: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-successed-16.png (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-successed-16.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-successed.png =================================================================== (Binary files differ) Copied: trunk/jaxx-runtime/src/main/resources/icons/action-wizard-state-successed.png (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-successed.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-runtime/src/main/resources/icons/error.png =================================================================== (Binary files differ) Copied: trunk/jaxx-runtime/src/main/resources/icons/error.png (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/error.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-runtime/src/main/resources/icons/info.png =================================================================== (Binary files differ) Copied: trunk/jaxx-runtime/src/main/resources/icons/info.png (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/info.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-runtime/src/main/resources/icons/warning.png =================================================================== (Binary files differ) Copied: trunk/jaxx-runtime/src/main/resources/icons/warning.png (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/warning.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-runtime/src/main/resources/validators.xml =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/resources/validators.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/main/resources/validators.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE validators PUBLIC - "-//OpenSymphony Group//XWork Validator Config 1.0//EN" - "http://www.opensymphony.com/xwork/xwork-validator-config-1.0.dtd"> - -<!-- START SNIPPET: validators --> -<validators> - <validator name="requiredFile" class="jaxx.runtime.validator.field.RequiredFileFieldValidator"/> - <validator name="existingFile" class="jaxx.runtime.validator.field.ExistingFileFieldValidator"/> - <validator name="notExistingFile" class="jaxx.runtime.validator.field.NotExistingFileFieldValidator"/> - <validator name="existingDirectory" class="jaxx.runtime.validator.field.ExistingDirectoryFieldValidator"/> - <validator name="notExistingDirectory" class="jaxx.runtime.validator.field.NotExistingDirectoryFieldValidator"/> - <validator name="collectionFieldExpression" - class="jaxx.runtime.validator.field.CollectionFieldExpressionValidator"/> - <validator name="collectionUniqueKey" - class="jaxx.runtime.validator.field.CollectionUniqueKeyValidator"/> -</validators> - <!-- END SNIPPET: validators --> Copied: trunk/jaxx-runtime/src/main/resources/validators.xml (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/main/resources/validators.xml) =================================================================== --- trunk/jaxx-runtime/src/main/resources/validators.xml (rev 0) +++ trunk/jaxx-runtime/src/main/resources/validators.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator Config 1.0//EN" + "http://www.opensymphony.com/xwork/xwork-validator-config-1.0.dtd"> + +<!-- START SNIPPET: validators --> +<validators> + <validator name="requiredFile" class="jaxx.runtime.validator.field.RequiredFileFieldValidator"/> + <validator name="existingFile" class="jaxx.runtime.validator.field.ExistingFileFieldValidator"/> + <validator name="notExistingFile" class="jaxx.runtime.validator.field.NotExistingFileFieldValidator"/> + <validator name="existingDirectory" class="jaxx.runtime.validator.field.ExistingDirectoryFieldValidator"/> + <validator name="notExistingDirectory" class="jaxx.runtime.validator.field.NotExistingDirectoryFieldValidator"/> + <validator name="collectionFieldExpression" + class="jaxx.runtime.validator.field.CollectionFieldExpressionValidator"/> + <validator name="collectionUniqueKey" + class="jaxx.runtime.validator.field.CollectionUniqueKeyValidator"/> +</validators> + <!-- END SNIPPET: validators --> Deleted: trunk/jaxx-runtime/src/site/site.xml =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/site/site.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/site/site.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project name="${project.name}"> - - <bannerLeft> - <name>${project.name}</name> - <src>${site.home.url}/jaxx.png</src> - <href>index.html</href> - </bannerLeft> - - <body> - - <breadcrumbs> - <item name="${project.name}" href="${project.url}" /> - </breadcrumbs> - - <menu ref="parent"/> - - <menu name="Utilisateur" inherited="top"/> - - <menu ref="reports"/> - - <menu ref="modules"/> - - </body> -</project> Copied: trunk/jaxx-runtime/src/site/site.xml (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/site/site.xml) =================================================================== --- trunk/jaxx-runtime/src/site/site.xml (rev 0) +++ trunk/jaxx-runtime/src/site/site.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project name="${project.name}"> + + <bannerLeft> + <name>${project.name}</name> + <src>${site.home.url}/jaxx.png</src> + <href>index.html</href> + </bannerLeft> + + <body> + + <breadcrumbs> + <item name="${project.name}" href="${project.url}" /> + </breadcrumbs> + + <menu ref="parent"/> + + <menu name="Utilisateur" inherited="top"/> + + <menu ref="reports"/> + + <menu ref="modules"/> + + </body> +</project> Deleted: trunk/jaxx-runtime/src/test/java/jaxx/runtime/UtilTest.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/UtilTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/UtilTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,49 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime; - -import org.junit.Assert; -import org.junit.Test; - -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; - -public class UtilTest { - - int count; - - @Test - public void testGetEventListener() { - count = 0; - DocumentListener listener = (DocumentListener) jaxx.runtime.Util.getEventListener(javax.swing.event.DocumentListener.class, this, "incCount"); - listener.insertUpdate(null); - Assert.assertEquals(count, 1); - DocumentListener listener2 = (DocumentListener) jaxx.runtime.Util.getEventListener(javax.swing.event.DocumentListener.class, this, "incCount"); - listener2.removeUpdate(null); - Assert.assertEquals(count, 2); - //assertTrue("Received two different event listeners despite using identical parameters", listener == listener2); - } - - - public void incCount(DocumentEvent e) { - count++; - } -} \ No newline at end of file Copied: trunk/jaxx-runtime/src/test/java/jaxx/runtime/UtilTest.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/UtilTest.java) =================================================================== --- trunk/jaxx-runtime/src/test/java/jaxx/runtime/UtilTest.java (rev 0) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/UtilTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,49 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime; + +import org.junit.Assert; +import org.junit.Test; + +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; + +public class UtilTest { + + int count; + + @Test + public void testGetEventListener() { + count = 0; + DocumentListener listener = (DocumentListener) jaxx.runtime.Util.getEventListener(javax.swing.event.DocumentListener.class, this, "incCount"); + listener.insertUpdate(null); + Assert.assertEquals(count, 1); + DocumentListener listener2 = (DocumentListener) jaxx.runtime.Util.getEventListener(javax.swing.event.DocumentListener.class, this, "incCount"); + listener2.removeUpdate(null); + Assert.assertEquals(count, 2); + //assertTrue("Received two different event listeners despite using identical parameters", listener == listener2); + } + + + public void incCount(DocumentEvent e) { + count++; + } +} \ No newline at end of file Deleted: trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultApplicationContextTest.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultApplicationContextTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultApplicationContextTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,133 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.context; - -import jaxx.runtime.context.DefaultApplicationContext.AutoLoad; -import jaxx.runtime.context.DefaultApplicationContext.MethodAccess; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author tony - */ -public class DefaultApplicationContextTest { - - static int helloCount; - static int helloGetCount; - - @AutoLoad - @MethodAccess(methodName = "hello", target = String.class) - public static class Hello { - - public Hello() { - helloCount++; - } - - public String hello(String name) { - helloGetCount++; - return "hello " + name; - } - } - DefaultApplicationContext context; - - @BeforeClass - public static void setUpClass() throws Exception { - helloCount = 0; - helloGetCount = 0; - } - - @AfterClass - public static void tearDownClass() throws Exception { - } - - @Before - public void setUp() { - context = new DefaultApplicationContext(); - assertEquals(0, helloCount); - assertEquals(0, helloGetCount); - } - - @After - public void tearDown() { - context = null; - helloCount = helloGetCount = 0; - } - - @Test(expected = IllegalArgumentException.class) - public void testAutoLoadNamed() { - context.getContextValue(Hello.class, "fakeName"); - } - - @Test - public void testAutoLoad() { - Hello hello = context.getContextValue(Hello.class); - assertNotNull(hello); - assertEquals(1, helloCount); - - Hello hello2 = context.getContextValue(Hello.class); - assertNotNull(hello2); - assertEquals(1, helloCount); - assertEquals(hello, hello2); - } - - @Test - public void testForward() { - context.getContextValue(Hello.class); - assertEquals(1, helloCount); - String response = context.getContextValue(String.class, "John"); - assertNotNull(response); - assertEquals(1, helloGetCount); - assertEquals(new Hello().hello("John"), response); - } - - @Test - public void testRemove() { - String response; - - context.getContextValue(Hello.class); - assertEquals(1, helloCount); - assertEquals(1, context.forwards.size()); - response = context.getContextValue(String.class, "John"); - assertNotNull(response); - - context.removeContextValue(Hello.class); - assertEquals(0, context.forwards.size()); - response = context.getContextValue(String.class, "John"); - assertEquals(1, helloCount); - assertNull(response); - - // reinstanciate the service - context.getContextValue(Hello.class); - assertEquals(2, helloCount); - assertEquals(1, context.forwards.size()); - - // no effect with a name - context.removeContextValue(Hello.class, "fake"); - assertEquals(1, context.forwards.size()); - context.getContextValue(Hello.class); - assertEquals(2, helloCount); - } -} Copied: trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultApplicationContextTest.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultApplicationContextTest.java) =================================================================== --- trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultApplicationContextTest.java (rev 0) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultApplicationContextTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,133 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.context; + +import jaxx.runtime.context.DefaultApplicationContext.AutoLoad; +import jaxx.runtime.context.DefaultApplicationContext.MethodAccess; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * + * @author tony + */ +public class DefaultApplicationContextTest { + + static int helloCount; + static int helloGetCount; + + @AutoLoad + @MethodAccess(methodName = "hello", target = String.class) + public static class Hello { + + public Hello() { + helloCount++; + } + + public String hello(String name) { + helloGetCount++; + return "hello " + name; + } + } + DefaultApplicationContext context; + + @BeforeClass + public static void setUpClass() throws Exception { + helloCount = 0; + helloGetCount = 0; + } + + @AfterClass + public static void tearDownClass() throws Exception { + } + + @Before + public void setUp() { + context = new DefaultApplicationContext(); + assertEquals(0, helloCount); + assertEquals(0, helloGetCount); + } + + @After + public void tearDown() { + context = null; + helloCount = helloGetCount = 0; + } + + @Test(expected = IllegalArgumentException.class) + public void testAutoLoadNamed() { + context.getContextValue(Hello.class, "fakeName"); + } + + @Test + public void testAutoLoad() { + Hello hello = context.getContextValue(Hello.class); + assertNotNull(hello); + assertEquals(1, helloCount); + + Hello hello2 = context.getContextValue(Hello.class); + assertNotNull(hello2); + assertEquals(1, helloCount); + assertEquals(hello, hello2); + } + + @Test + public void testForward() { + context.getContextValue(Hello.class); + assertEquals(1, helloCount); + String response = context.getContextValue(String.class, "John"); + assertNotNull(response); + assertEquals(1, helloGetCount); + assertEquals(new Hello().hello("John"), response); + } + + @Test + public void testRemove() { + String response; + + context.getContextValue(Hello.class); + assertEquals(1, helloCount); + assertEquals(1, context.forwards.size()); + response = context.getContextValue(String.class, "John"); + assertNotNull(response); + + context.removeContextValue(Hello.class); + assertEquals(0, context.forwards.size()); + response = context.getContextValue(String.class, "John"); + assertEquals(1, helloCount); + assertNull(response); + + // reinstanciate the service + context.getContextValue(Hello.class); + assertEquals(2, helloCount); + assertEquals(1, context.forwards.size()); + + // no effect with a name + context.removeContextValue(Hello.class, "fake"); + assertEquals(1, context.forwards.size()); + context.getContextValue(Hello.class); + assertEquals(2, helloCount); + } +} Deleted: trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,358 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.context; - -import jaxx.runtime.JAXXContext; -import jaxx.runtime.*; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import java.awt.Container; -import java.beans.PropertyChangeListener; -import java.util.Map; - -/** - * @author chemit - */ -public class DefaultJAXXContextTest { - - DefaultJAXXContext ctxt; - - @Before - public void initContext() throws Exception { - - // instanciate a new empty context - ctxt = new DefaultJAXXContext(); - } - -// @Test(expected = IllegalStateException.class) -// public void testParentContainerFail_IllegalStateException() throws Exception { -// ctxt.getParentContainer(Container.class); -// } -// -// @Test(expected = IllegalStateException.class) -// public void testParentContainerFail_IllegalStateException2() throws Exception { -// ctxt.getParentContainer("null", Container.class); -// } - - -// @Test(expected = IllegalArgumentException.class) -// public void testParentContainerFail_IllegalArgumentException() throws Exception { -// -// // attach a fake ui (which is NOT a Container) -// ctxt.setUi(new MyJAXXObject()); -// ctxt.getParentContainer(Container.class); -// } -// -// @Test(expected = IllegalArgumentException.class) -// public void testParentContainerFail_IllegalArgumentException2() throws Exception { -// -// // attach a fake ui (which is NOT a Container) -// ctxt.setUi(new MyJAXXObject()); -// ctxt.getParentContainer(null, Container.class); -// } -// -// @Test(expected = IllegalArgumentException.class) -// public void testParentContainerFail_IllegalArgumentException3() throws Exception { -// -// // attach a fake ui (which is NOT a Container) -// ctxt.setUi(new MyJAXXObject()); -// ctxt.getParentContainer("null", Container.class); -// } - - @Test - public void testGetParentContext() throws Exception { - JAXXContext expected, result; - expected = null; - result = ctxt.getContextValue(JAXXContext.class); - Assert.assertEquals(expected, result); - - DefaultJAXXContext parentContext = new DefaultJAXXContext(); - - ctxt.setContextValue(parentContext); - - expected = parentContext; - result = ctxt.getContextValue(JAXXContext.class); - Assert.assertEquals(expected, result); - } - - @Test - public void testSetGetContextValue() throws Exception { - String expected; - String result; - - result = ctxt.getContextValue(String.class); - Assert.assertNull(result); - - expected = "yo"; - ctxt.setContextValue(expected); - result = ctxt.getContextValue(String.class); - Assert.assertEquals(expected, result); - - expected = "ya"; - ctxt.setContextValue(expected, "second"); - result = ctxt.getContextValue(String.class, "second"); - Assert.assertEquals(expected, result); - - expected = "yi"; - ctxt.setContextValue(expected, "second"); - result = ctxt.getContextValue(String.class, "second"); - Assert.assertEquals(expected, result); - } - - @Test - public void testSetGetContextValueInParentContext() throws Exception { - - // attach parent context - JAXXContext parentContext = new DefaultJAXXContext(); - ctxt.setContextValue(parentContext); - - String expected; - String result; - - result = ctxt.getContextValue(String.class); - Assert.assertNull(result); - - expected = "yo"; - result = ctxt.getContextValue(String.class); - Assert.assertNull(result); - parentContext.setContextValue(expected); - result = ctxt.getContextValue(String.class); - Assert.assertEquals(expected, result); - - expected = "ya"; - result = ctxt.getContextValue(String.class, "second"); - Assert.assertNull(result); - parentContext.setContextValue(expected, "second"); - result = ctxt.getContextValue(String.class, "second"); - Assert.assertEquals(expected, result); - - expected = "yi"; - result = ctxt.getContextValue(String.class, "second"); - parentContext.setContextValue(expected, "second"); - Assert.assertEquals("ya", result); - result = ctxt.getContextValue(String.class, "second"); - Assert.assertEquals(expected, result); - } - - @Test - public void testSetGetContextValue2() throws Exception { - - // attach parent context - JAXXContext parentContext = new DefaultJAXXContext(); - ctxt.setContextValue(parentContext); - - String expected; - String result; - - result = ctxt.getContextValue(String.class); - Assert.assertNull(result); - result = ctxt.getContextValue(String.class, "yo"); - Assert.assertNull(result); - - expected = "yo"; - ctxt.setContextValue(expected, "yo"); - - result = ctxt.getContextValue(String.class); - Assert.assertNull(result); - result = ctxt.getContextValue(String.class, "yo"); - Assert.assertEquals(expected, result); - } - - @Test - public void testSetGetContextValueInParentParentContext() throws Exception { - - // attach parent parent context - JAXXContext parentParentContext = new DefaultJAXXContext(); - JAXXContext parentContext = new DefaultJAXXContext(); - parentContext.setContextValue(parentParentContext); - ctxt.setContextValue(parentContext); - - String expected; - String result; - - result = ctxt.getContextValue(String.class); - Assert.assertNull(result); - - expected = "yo"; - result = ctxt.getContextValue(String.class); - Assert.assertNull(result); - parentParentContext.setContextValue(expected); - result = ctxt.getContextValue(String.class); - Assert.assertEquals(expected, result); - - expected = "ya"; - result = ctxt.getContextValue(String.class, "second"); - Assert.assertNull(result); - parentParentContext.setContextValue(expected, "second"); - result = ctxt.getContextValue(String.class, "second"); - Assert.assertEquals(expected, result); - - expected = "yi"; - result = ctxt.getContextValue(String.class, "second"); - parentParentContext.setContextValue(expected, "second"); - Assert.assertEquals("ya", result); - result = ctxt.getContextValue(String.class, "second"); - Assert.assertEquals(expected, result); - } - - @Test - public void testEntrySet() throws Exception { - Object o = new Object(); - - ctxt.setContextValue(o); - - Assert.assertEquals(1, ctxt.data.size()); - Assert.assertEquals(o, ctxt.getContextValue(Object.class)); - Assert.assertEquals(null, ctxt.getContextValue(Object.class, "named")); - - ctxt.setContextValue(o, "named"); - - Assert.assertEquals(2, ctxt.data.size()); - Assert.assertEquals(o, ctxt.getContextValue(Object.class)); - Assert.assertEquals(o, ctxt.getContextValue(Object.class, "named")); - - ctxt.removeContextValue(Object.class); - Assert.assertEquals(1, ctxt.data.size()); - Assert.assertEquals(null, ctxt.getContextValue(Object.class)); - Assert.assertEquals(o, ctxt.getContextValue(Object.class, "named")); - - ctxt.removeContextValue(Object.class); - Assert.assertEquals(1, ctxt.data.size()); - Assert.assertEquals(null, ctxt.getContextValue(Object.class)); - Assert.assertEquals(o, ctxt.getContextValue(Object.class, "named")); - - ctxt.removeContextValue(Object.class, "named"); - Assert.assertEquals(0, ctxt.data.size()); - Assert.assertEquals(null, ctxt.getContextValue(Object.class)); - Assert.assertEquals(null, ctxt.getContextValue(Object.class, "named")); - - } - - @Test - public void testEntrySetWithParent() throws Exception { - - DefaultJAXXContext parentContext = new DefaultJAXXContext(); - - ctxt.setContextValue(parentContext); - - class Object2 { - - } - Object o = new Object2(); - - parentContext.setContextValue(o); - - Assert.assertEquals(0, ctxt.data.size()); - Assert.assertEquals(1, parentContext.data.size()); - Assert.assertEquals(o, ctxt.getContextValue(Object2.class)); - Assert.assertEquals(null, ctxt.getContextValue(Object2.class, "named")); - - parentContext.setContextValue(o, "named"); - - Assert.assertEquals(0, ctxt.data.size()); - Assert.assertEquals(2, parentContext.data.size()); - Assert.assertEquals(o, ctxt.getContextValue(Object2.class)); - Assert.assertEquals(o, ctxt.getContextValue(Object2.class, "named")); - - parentContext.removeContextValue(Object2.class); - Assert.assertEquals(0, ctxt.data.size()); - Assert.assertEquals(1, parentContext.data.size()); - Assert.assertEquals(null, ctxt.getContextValue(Object2.class)); - Assert.assertEquals(o, ctxt.getContextValue(Object2.class, "named")); - - parentContext.removeContextValue(Object2.class); - Assert.assertEquals(0, ctxt.data.size()); - Assert.assertEquals(1, parentContext.data.size()); - Assert.assertEquals(null, ctxt.getContextValue(Object2.class)); - Assert.assertEquals(o, ctxt.getContextValue(Object2.class, "named")); - - ctxt.removeContextValue(Object2.class, "named"); - Assert.assertEquals(0, ctxt.data.size()); - Assert.assertEquals(0, parentContext.data.size()); - Assert.assertEquals(null, ctxt.getContextValue(Object2.class)); - Assert.assertEquals(null, ctxt.getContextValue(Object2.class, "named")); - - } - - private static class MyJAXXObject extends DefaultJAXXContext implements JAXXObject { - private static final long serialVersionUID = 1L; - - @Override - public Object getObjectById(String id) { - return null; - } - - @Override - public Map<String, Object> get$objectMap() { - return null; - } - - @Override - public void applyDataBinding(String id) { - } - - @Override - public void removeDataBinding(String id) { - } - - @Override - public JAXXContext getDelegateContext() { - return null; - } - - @Override - public void processDataBinding(String dest) { - } - - @Override - public void firePropertyChange(String name, Object oldValue, Object newValue) { - } - - @Override - public void addPropertyChangeListener(PropertyChangeListener listener) { - } - - @Override - public void addPropertyChangeListener(String property, PropertyChangeListener listener) { - } - - @Override - public void removePropertyChangeListener(PropertyChangeListener listener) { - } - - @Override - public void removePropertyChangeListener(String property, PropertyChangeListener listener) { - } - - @Override - public <O extends Container> O getParentContainer(Class<O> clazz) { - return null; - } - - @Override - public <O extends Container> O getParentContainer(Object top, Class<O> clazz) { - return null; - } - - } -} Copied: trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java) =================================================================== --- trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java (rev 0) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,358 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.context; + +import jaxx.runtime.JAXXContext; +import jaxx.runtime.*; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.awt.Container; +import java.beans.PropertyChangeListener; +import java.util.Map; + +/** + * @author chemit + */ +public class DefaultJAXXContextTest { + + DefaultJAXXContext ctxt; + + @Before + public void initContext() throws Exception { + + // instanciate a new empty context + ctxt = new DefaultJAXXContext(); + } + +// @Test(expected = IllegalStateException.class) +// public void testParentContainerFail_IllegalStateException() throws Exception { +// ctxt.getParentContainer(Container.class); +// } +// +// @Test(expected = IllegalStateException.class) +// public void testParentContainerFail_IllegalStateException2() throws Exception { +// ctxt.getParentContainer("null", Container.class); +// } + + +// @Test(expected = IllegalArgumentException.class) +// public void testParentContainerFail_IllegalArgumentException() throws Exception { +// +// // attach a fake ui (which is NOT a Container) +// ctxt.setUi(new MyJAXXObject()); +// ctxt.getParentContainer(Container.class); +// } +// +// @Test(expected = IllegalArgumentException.class) +// public void testParentContainerFail_IllegalArgumentException2() throws Exception { +// +// // attach a fake ui (which is NOT a Container) +// ctxt.setUi(new MyJAXXObject()); +// ctxt.getParentContainer(null, Container.class); +// } +// +// @Test(expected = IllegalArgumentException.class) +// public void testParentContainerFail_IllegalArgumentException3() throws Exception { +// +// // attach a fake ui (which is NOT a Container) +// ctxt.setUi(new MyJAXXObject()); +// ctxt.getParentContainer("null", Container.class); +// } + + @Test + public void testGetParentContext() throws Exception { + JAXXContext expected, result; + expected = null; + result = ctxt.getContextValue(JAXXContext.class); + Assert.assertEquals(expected, result); + + DefaultJAXXContext parentContext = new DefaultJAXXContext(); + + ctxt.setContextValue(parentContext); + + expected = parentContext; + result = ctxt.getContextValue(JAXXContext.class); + Assert.assertEquals(expected, result); + } + + @Test + public void testSetGetContextValue() throws Exception { + String expected; + String result; + + result = ctxt.getContextValue(String.class); + Assert.assertNull(result); + + expected = "yo"; + ctxt.setContextValue(expected); + result = ctxt.getContextValue(String.class); + Assert.assertEquals(expected, result); + + expected = "ya"; + ctxt.setContextValue(expected, "second"); + result = ctxt.getContextValue(String.class, "second"); + Assert.assertEquals(expected, result); + + expected = "yi"; + ctxt.setContextValue(expected, "second"); + result = ctxt.getContextValue(String.class, "second"); + Assert.assertEquals(expected, result); + } + + @Test + public void testSetGetContextValueInParentContext() throws Exception { + + // attach parent context + JAXXContext parentContext = new DefaultJAXXContext(); + ctxt.setContextValue(parentContext); + + String expected; + String result; + + result = ctxt.getContextValue(String.class); + Assert.assertNull(result); + + expected = "yo"; + result = ctxt.getContextValue(String.class); + Assert.assertNull(result); + parentContext.setContextValue(expected); + result = ctxt.getContextValue(String.class); + Assert.assertEquals(expected, result); + + expected = "ya"; + result = ctxt.getContextValue(String.class, "second"); + Assert.assertNull(result); + parentContext.setContextValue(expected, "second"); + result = ctxt.getContextValue(String.class, "second"); + Assert.assertEquals(expected, result); + + expected = "yi"; + result = ctxt.getContextValue(String.class, "second"); + parentContext.setContextValue(expected, "second"); + Assert.assertEquals("ya", result); + result = ctxt.getContextValue(String.class, "second"); + Assert.assertEquals(expected, result); + } + + @Test + public void testSetGetContextValue2() throws Exception { + + // attach parent context + JAXXContext parentContext = new DefaultJAXXContext(); + ctxt.setContextValue(parentContext); + + String expected; + String result; + + result = ctxt.getContextValue(String.class); + Assert.assertNull(result); + result = ctxt.getContextValue(String.class, "yo"); + Assert.assertNull(result); + + expected = "yo"; + ctxt.setContextValue(expected, "yo"); + + result = ctxt.getContextValue(String.class); + Assert.assertNull(result); + result = ctxt.getContextValue(String.class, "yo"); + Assert.assertEquals(expected, result); + } + + @Test + public void testSetGetContextValueInParentParentContext() throws Exception { + + // attach parent parent context + JAXXContext parentParentContext = new DefaultJAXXContext(); + JAXXContext parentContext = new DefaultJAXXContext(); + parentContext.setContextValue(parentParentContext); + ctxt.setContextValue(parentContext); + + String expected; + String result; + + result = ctxt.getContextValue(String.class); + Assert.assertNull(result); + + expected = "yo"; + result = ctxt.getContextValue(String.class); + Assert.assertNull(result); + parentParentContext.setContextValue(expected); + result = ctxt.getContextValue(String.class); + Assert.assertEquals(expected, result); + + expected = "ya"; + result = ctxt.getContextValue(String.class, "second"); + Assert.assertNull(result); + parentParentContext.setContextValue(expected, "second"); + result = ctxt.getContextValue(String.class, "second"); + Assert.assertEquals(expected, result); + + expected = "yi"; + result = ctxt.getContextValue(String.class, "second"); + parentParentContext.setContextValue(expected, "second"); + Assert.assertEquals("ya", result); + result = ctxt.getContextValue(String.class, "second"); + Assert.assertEquals(expected, result); + } + + @Test + public void testEntrySet() throws Exception { + Object o = new Object(); + + ctxt.setContextValue(o); + + Assert.assertEquals(1, ctxt.data.size()); + Assert.assertEquals(o, ctxt.getContextValue(Object.class)); + Assert.assertEquals(null, ctxt.getContextValue(Object.class, "named")); + + ctxt.setContextValue(o, "named"); + + Assert.assertEquals(2, ctxt.data.size()); + Assert.assertEquals(o, ctxt.getContextValue(Object.class)); + Assert.assertEquals(o, ctxt.getContextValue(Object.class, "named")); + + ctxt.removeContextValue(Object.class); + Assert.assertEquals(1, ctxt.data.size()); + Assert.assertEquals(null, ctxt.getContextValue(Object.class)); + Assert.assertEquals(o, ctxt.getContextValue(Object.class, "named")); + + ctxt.removeContextValue(Object.class); + Assert.assertEquals(1, ctxt.data.size()); + Assert.assertEquals(null, ctxt.getContextValue(Object.class)); + Assert.assertEquals(o, ctxt.getContextValue(Object.class, "named")); + + ctxt.removeContextValue(Object.class, "named"); + Assert.assertEquals(0, ctxt.data.size()); + Assert.assertEquals(null, ctxt.getContextValue(Object.class)); + Assert.assertEquals(null, ctxt.getContextValue(Object.class, "named")); + + } + + @Test + public void testEntrySetWithParent() throws Exception { + + DefaultJAXXContext parentContext = new DefaultJAXXContext(); + + ctxt.setContextValue(parentContext); + + class Object2 { + + } + Object o = new Object2(); + + parentContext.setContextValue(o); + + Assert.assertEquals(0, ctxt.data.size()); + Assert.assertEquals(1, parentContext.data.size()); + Assert.assertEquals(o, ctxt.getContextValue(Object2.class)); + Assert.assertEquals(null, ctxt.getContextValue(Object2.class, "named")); + + parentContext.setContextValue(o, "named"); + + Assert.assertEquals(0, ctxt.data.size()); + Assert.assertEquals(2, parentContext.data.size()); + Assert.assertEquals(o, ctxt.getContextValue(Object2.class)); + Assert.assertEquals(o, ctxt.getContextValue(Object2.class, "named")); + + parentContext.removeContextValue(Object2.class); + Assert.assertEquals(0, ctxt.data.size()); + Assert.assertEquals(1, parentContext.data.size()); + Assert.assertEquals(null, ctxt.getContextValue(Object2.class)); + Assert.assertEquals(o, ctxt.getContextValue(Object2.class, "named")); + + parentContext.removeContextValue(Object2.class); + Assert.assertEquals(0, ctxt.data.size()); + Assert.assertEquals(1, parentContext.data.size()); + Assert.assertEquals(null, ctxt.getContextValue(Object2.class)); + Assert.assertEquals(o, ctxt.getContextValue(Object2.class, "named")); + + ctxt.removeContextValue(Object2.class, "named"); + Assert.assertEquals(0, ctxt.data.size()); + Assert.assertEquals(0, parentContext.data.size()); + Assert.assertEquals(null, ctxt.getContextValue(Object2.class)); + Assert.assertEquals(null, ctxt.getContextValue(Object2.class, "named")); + + } + + private static class MyJAXXObject extends DefaultJAXXContext implements JAXXObject { + private static final long serialVersionUID = 1L; + + @Override + public Object getObjectById(String id) { + return null; + } + + @Override + public Map<String, Object> get$objectMap() { + return null; + } + + @Override + public void applyDataBinding(String id) { + } + + @Override + public void removeDataBinding(String id) { + } + + @Override + public JAXXContext getDelegateContext() { + return null; + } + + @Override + public void processDataBinding(String dest) { + } + + @Override + public void firePropertyChange(String name, Object oldValue, Object newValue) { + } + + @Override + public void addPropertyChangeListener(PropertyChangeListener listener) { + } + + @Override + public void addPropertyChangeListener(String property, PropertyChangeListener listener) { + } + + @Override + public void removePropertyChangeListener(PropertyChangeListener listener) { + } + + @Override + public void removePropertyChangeListener(String property, PropertyChangeListener listener) { + } + + @Override + public <O extends Container> O getParentContainer(Class<O> clazz) { + return null; + } + + @Override + public <O extends Container> O getParentContainer(Object top, Class<O> clazz) { + return null; + } + + } +} Deleted: trunk/jaxx-runtime/src/test/java/jaxx/runtime/decorator/Data.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/Data.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/decorator/Data.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,57 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.decorator; - -import java.util.ArrayList; -import java.util.List; - -public 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) { - super(); - 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 + '\'' + '}'; - } -} Copied: trunk/jaxx-runtime/src/test/java/jaxx/runtime/decorator/Data.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/Data.java) =================================================================== --- trunk/jaxx-runtime/src/test/java/jaxx/runtime/decorator/Data.java (rev 0) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/decorator/Data.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,57 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.decorator; + +import java.util.ArrayList; +import java.util.List; + +public 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) { + super(); + 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 + '\'' + '}'; + } +} Deleted: trunk/jaxx-runtime/src/test/java/jaxx/runtime/decorator/DecoratorProviderTest.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/DecoratorProviderTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/decorator/DecoratorProviderTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,153 +0,0 @@ -package jaxx.runtime.decorator; - -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.File; - -/** - * User: chemit - * Date: 28 oct. 2009 - * Time: 21:28:46 - */ -public class DecoratorProviderTest { - private static final String BY_NAME = "name"; - - static class MyDecoratorProvider extends DecoratorProvider { - - @Override - protected void loadDecorators() { - - registerPropertyDecorator(File.class, "name"); - registerPropertyDecorator(File.class, BY_NAME, "parent"); - - - registerJXPathDecorator(Class.class, "${simpleName}$s"); - registerJXPathDecorator(Class.class, BY_NAME, "${name}$s"); - - registerMultiJXPathDecorator(Data.class, "${name}$s", "-", " "); - registerMultiJXPathDecorator(Data.class, BY_NAME, "${pos}$d", "-", " "); - } - } - - static DecoratorProvider provider; - - @BeforeClass - public static void beforeTest() throws Exception { - provider = new MyDecoratorProvider(); - } - - @Test - public void testGetDecoratorByObject() throws Exception { - - File f = new File("myFile"); - Data d = new Data(0, "name"); - Class<?> k = File.class; - - Decorator<File> fileDecorator = provider.getDecorator(f); - Assert.assertNotNull(fileDecorator); - Assert.assertEquals(File.class, fileDecorator.getInternalClass()); - Assert.assertEquals("myFile", fileDecorator.toString(f)); - - Decorator<?> classDecorator = provider.getDecorator(Class.class); - Assert.assertNotNull(classDecorator); - Assert.assertEquals(Class.class, classDecorator.getInternalClass()); - Assert.assertEquals("File", classDecorator.toString(k)); - - Decorator<Data> dataDecorator = provider.getDecorator(d); - Assert.assertNotNull(dataDecorator); - Assert.assertEquals(Data.class, dataDecorator.getInternalClass()); - Assert.assertEquals("name", dataDecorator.toString(d)); - } - - @Test - public void testGetDecoratorByObjectAndName() throws Exception { - - File f = new File("myFile"); - Data d = new Data(0, "name"); - Class<?> k = File.class; - - Decorator<File> fileDecorator = provider.getDecorator(f, BY_NAME); - Assert.assertNotNull(fileDecorator); - Assert.assertEquals(File.class, fileDecorator.getInternalClass()); - Assert.assertEquals("null", fileDecorator.toString(f)); - - Decorator<Class> classDecorator = provider.getDecorator(Class.class, BY_NAME); - Assert.assertNotNull(classDecorator); - Assert.assertEquals(Class.class, classDecorator.getInternalClass()); - Assert.assertEquals("java.io.File", classDecorator.toString(k)); - - - Decorator<Data> dataDecorator = provider.getDecorator(d, BY_NAME); - Assert.assertNotNull(dataDecorator); - Assert.assertEquals(Data.class, dataDecorator.getInternalClass()); - Assert.assertEquals("0", dataDecorator.toString(d)); - } - - @Test - public void testGetDecoratorByType() throws Exception { - - File f = new File("myFile"); - Data d = new Data(0, "name"); - Class<?> k = File.class; - - Decorator<File> fileDecorator = provider.getDecorator(File.class); - Assert.assertNotNull(fileDecorator); - Assert.assertEquals(File.class, fileDecorator.getInternalClass()); - Assert.assertEquals("myFile", fileDecorator.toString(f)); - - Decorator<Class> classDecorator = provider.getDecorator(Class.class); - Assert.assertNotNull(classDecorator); - Assert.assertEquals(Class.class, classDecorator.getInternalClass()); - Assert.assertEquals("File", classDecorator.toString(k)); - - Decorator<Data> dataDecorator = provider.getDecorator(Data.class); - Assert.assertNotNull(dataDecorator); - Assert.assertEquals(Data.class, dataDecorator.getInternalClass()); - Assert.assertEquals("name", dataDecorator.toString(d)); - } - - @Test - public void testGetDecoratorByTypeAndName() throws Exception { - File f = new File("myFile"); - Data d = new Data(0, "name"); - Class<?> k = File.class; - - Decorator<File> fileDecorator = provider.getDecorator(File.class, BY_NAME); - Assert.assertNotNull(fileDecorator); - Assert.assertEquals(File.class, fileDecorator.getInternalClass()); - Assert.assertEquals("null", fileDecorator.toString(f)); - - Decorator<Class> classDecorator = provider.getDecorator(Class.class, BY_NAME); - Assert.assertNotNull(classDecorator); - Assert.assertEquals(Class.class, classDecorator.getInternalClass()); - Assert.assertEquals("java.io.File", classDecorator.toString(k)); - - - Decorator<Data> dataDecorator = provider.getDecorator(Data.class, BY_NAME); - Assert.assertNotNull(dataDecorator); - Assert.assertEquals(Data.class, dataDecorator.getInternalClass()); - Assert.assertEquals("0", dataDecorator.toString(d)); - } - - - @Test - public void testReload() throws Exception { - - int nb = provider.getDecorators().size(); - Assert.assertTrue(nb > 0); - - provider.reload(); - - Assert.assertEquals(nb, provider.getDecorators().size()); - } - - @Test - public void testClear() throws Exception { - provider.clear(); - - Assert.assertTrue(provider.getDecorators().isEmpty()); - } - -} Copied: trunk/jaxx-runtime/src/test/java/jaxx/runtime/decorator/DecoratorProviderTest.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/DecoratorProviderTest.java) =================================================================== --- trunk/jaxx-runtime/src/test/java/jaxx/runtime/decorator/DecoratorProviderTest.java (rev 0) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/decorator/DecoratorProviderTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,153 @@ +package jaxx.runtime.decorator; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.io.File; + +/** + * User: chemit + * Date: 28 oct. 2009 + * Time: 21:28:46 + */ +public class DecoratorProviderTest { + private static final String BY_NAME = "name"; + + static class MyDecoratorProvider extends DecoratorProvider { + + @Override + protected void loadDecorators() { + + registerPropertyDecorator(File.class, "name"); + registerPropertyDecorator(File.class, BY_NAME, "parent"); + + + registerJXPathDecorator(Class.class, "${simpleName}$s"); + registerJXPathDecorator(Class.class, BY_NAME, "${name}$s"); + + registerMultiJXPathDecorator(Data.class, "${name}$s", "-", " "); + registerMultiJXPathDecorator(Data.class, BY_NAME, "${pos}$d", "-", " "); + } + } + + static DecoratorProvider provider; + + @BeforeClass + public static void beforeTest() throws Exception { + provider = new MyDecoratorProvider(); + } + + @Test + public void testGetDecoratorByObject() throws Exception { + + File f = new File("myFile"); + Data d = new Data(0, "name"); + Class<?> k = File.class; + + Decorator<File> fileDecorator = provider.getDecorator(f); + Assert.assertNotNull(fileDecorator); + Assert.assertEquals(File.class, fileDecorator.getInternalClass()); + Assert.assertEquals("myFile", fileDecorator.toString(f)); + + Decorator<?> classDecorator = provider.getDecorator(Class.class); + Assert.assertNotNull(classDecorator); + Assert.assertEquals(Class.class, classDecorator.getInternalClass()); + Assert.assertEquals("File", classDecorator.toString(k)); + + Decorator<Data> dataDecorator = provider.getDecorator(d); + Assert.assertNotNull(dataDecorator); + Assert.assertEquals(Data.class, dataDecorator.getInternalClass()); + Assert.assertEquals("name", dataDecorator.toString(d)); + } + + @Test + public void testGetDecoratorByObjectAndName() throws Exception { + + File f = new File("myFile"); + Data d = new Data(0, "name"); + Class<?> k = File.class; + + Decorator<File> fileDecorator = provider.getDecorator(f, BY_NAME); + Assert.assertNotNull(fileDecorator); + Assert.assertEquals(File.class, fileDecorator.getInternalClass()); + Assert.assertEquals("null", fileDecorator.toString(f)); + + Decorator<Class> classDecorator = provider.getDecorator(Class.class, BY_NAME); + Assert.assertNotNull(classDecorator); + Assert.assertEquals(Class.class, classDecorator.getInternalClass()); + Assert.assertEquals("java.io.File", classDecorator.toString(k)); + + + Decorator<Data> dataDecorator = provider.getDecorator(d, BY_NAME); + Assert.assertNotNull(dataDecorator); + Assert.assertEquals(Data.class, dataDecorator.getInternalClass()); + Assert.assertEquals("0", dataDecorator.toString(d)); + } + + @Test + public void testGetDecoratorByType() throws Exception { + + File f = new File("myFile"); + Data d = new Data(0, "name"); + Class<?> k = File.class; + + Decorator<File> fileDecorator = provider.getDecorator(File.class); + Assert.assertNotNull(fileDecorator); + Assert.assertEquals(File.class, fileDecorator.getInternalClass()); + Assert.assertEquals("myFile", fileDecorator.toString(f)); + + Decorator<Class> classDecorator = provider.getDecorator(Class.class); + Assert.assertNotNull(classDecorator); + Assert.assertEquals(Class.class, classDecorator.getInternalClass()); + Assert.assertEquals("File", classDecorator.toString(k)); + + Decorator<Data> dataDecorator = provider.getDecorator(Data.class); + Assert.assertNotNull(dataDecorator); + Assert.assertEquals(Data.class, dataDecorator.getInternalClass()); + Assert.assertEquals("name", dataDecorator.toString(d)); + } + + @Test + public void testGetDecoratorByTypeAndName() throws Exception { + File f = new File("myFile"); + Data d = new Data(0, "name"); + Class<?> k = File.class; + + Decorator<File> fileDecorator = provider.getDecorator(File.class, BY_NAME); + Assert.assertNotNull(fileDecorator); + Assert.assertEquals(File.class, fileDecorator.getInternalClass()); + Assert.assertEquals("null", fileDecorator.toString(f)); + + Decorator<Class> classDecorator = provider.getDecorator(Class.class, BY_NAME); + Assert.assertNotNull(classDecorator); + Assert.assertEquals(Class.class, classDecorator.getInternalClass()); + Assert.assertEquals("java.io.File", classDecorator.toString(k)); + + + Decorator<Data> dataDecorator = provider.getDecorator(Data.class, BY_NAME); + Assert.assertNotNull(dataDecorator); + Assert.assertEquals(Data.class, dataDecorator.getInternalClass()); + Assert.assertEquals("0", dataDecorator.toString(d)); + } + + + @Test + public void testReload() throws Exception { + + int nb = provider.getDecorators().size(); + Assert.assertTrue(nb > 0); + + provider.reload(); + + Assert.assertEquals(nb, provider.getDecorators().size()); + } + + @Test + public void testClear() throws Exception { + provider.clear(); + + Assert.assertTrue(provider.getDecorators().isEmpty()); + } + +} Deleted: trunk/jaxx-runtime/src/test/java/jaxx/runtime/decorator/JXPathDecoratorTest.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/JXPathDecoratorTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/decorator/JXPathDecoratorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,156 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.decorator; - -import jaxx.runtime.decorator.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 - * @since 1.7.2 (was previously {@code jaxx.runtime.JXPathDecoratorTest}). - */ -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 = DecoratorUtils.newJXPathDecorator(null, "hello"); - } - - @Test(expected = IllegalArgumentException.class) - public void testMissingRightBrace() throws Exception { - decorator = DecoratorUtils.newJXPathDecorator(Object.class, "${haha"); - } - - @Test(expected = IllegalArgumentException.class) - public void testMissingRightBrace2() throws Exception { - decorator = DecoratorUtils.newJXPathDecorator(Object.class, "${haha${hum}"); - } - - @Test - public void testNullBean() throws Exception { - decorator = DecoratorUtils.newJXPathDecorator(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 = DecoratorUtils.newJXPathDecorator(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 = DecoratorUtils.newJXPathDecorator(JXPathDecorator.class, "${expression}$s - ${nbToken}$d"); - assertEquals("%1$s - %2$d", decorator.getExpression()); - assertDecoratorInternal(); - - decorator = DecoratorUtils.newJXPathDecorator(JXPathDecorator.class, "${expression}${nbToken}"); - assertEquals("%1%2", decorator.getExpression()); - assertDecoratorInternal(); - - decorator = DecoratorUtils.newJXPathDecorator(JXPathDecorator.class, "before ${expression}$s - ${nbToken}$d after"); - assertEquals("before %1$s - %2$d after", decorator.getExpression()); - assertDecoratorInternal(); - - decorator = DecoratorUtils.newJXPathDecorator(JXPathDecorator.class, "before${expression}$s-${nbToken}$dafter"); - assertEquals("before%1$s-%2$dafter", decorator.getExpression()); - assertDecoratorInternal(); - } - - @Test - public void testSort() throws Exception { - - List<Data> datas = Data.generate(10); - - JXPathDecorator<Data> d = DecoratorUtils.newJXPathDecorator(Data.class, "${pos}$d ${name}$s"); - - List<Data> sortData = new ArrayList<Data>(datas); - DecoratorUtils.sort(d, 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 = d.context; - context.setComparator(null); - DecoratorUtils.sort(d, 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]); - } - -} Copied: trunk/jaxx-runtime/src/test/java/jaxx/runtime/decorator/JXPathDecoratorTest.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/JXPathDecoratorTest.java) =================================================================== --- trunk/jaxx-runtime/src/test/java/jaxx/runtime/decorator/JXPathDecoratorTest.java (rev 0) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/decorator/JXPathDecoratorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,156 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.decorator; + +import jaxx.runtime.decorator.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 + * @since 1.7.2 (was previously {@code jaxx.runtime.JXPathDecoratorTest}). + */ +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 = DecoratorUtils.newJXPathDecorator(null, "hello"); + } + + @Test(expected = IllegalArgumentException.class) + public void testMissingRightBrace() throws Exception { + decorator = DecoratorUtils.newJXPathDecorator(Object.class, "${haha"); + } + + @Test(expected = IllegalArgumentException.class) + public void testMissingRightBrace2() throws Exception { + decorator = DecoratorUtils.newJXPathDecorator(Object.class, "${haha${hum}"); + } + + @Test + public void testNullBean() throws Exception { + decorator = DecoratorUtils.newJXPathDecorator(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 = DecoratorUtils.newJXPathDecorator(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 = DecoratorUtils.newJXPathDecorator(JXPathDecorator.class, "${expression}$s - ${nbToken}$d"); + assertEquals("%1$s - %2$d", decorator.getExpression()); + assertDecoratorInternal(); + + decorator = DecoratorUtils.newJXPathDecorator(JXPathDecorator.class, "${expression}${nbToken}"); + assertEquals("%1%2", decorator.getExpression()); + assertDecoratorInternal(); + + decorator = DecoratorUtils.newJXPathDecorator(JXPathDecorator.class, "before ${expression}$s - ${nbToken}$d after"); + assertEquals("before %1$s - %2$d after", decorator.getExpression()); + assertDecoratorInternal(); + + decorator = DecoratorUtils.newJXPathDecorator(JXPathDecorator.class, "before${expression}$s-${nbToken}$dafter"); + assertEquals("before%1$s-%2$dafter", decorator.getExpression()); + assertDecoratorInternal(); + } + + @Test + public void testSort() throws Exception { + + List<Data> datas = Data.generate(10); + + JXPathDecorator<Data> d = DecoratorUtils.newJXPathDecorator(Data.class, "${pos}$d ${name}$s"); + + List<Data> sortData = new ArrayList<Data>(datas); + DecoratorUtils.sort(d, 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 = d.context; + context.setComparator(null); + DecoratorUtils.sort(d, 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: trunk/jaxx-runtime/src/test/java/jaxx/runtime/decorator/MultiJXPathDecoratorTest.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/MultiJXPathDecoratorTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/decorator/MultiJXPathDecoratorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,205 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.decorator; - -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 - * @since 1.7.2 (was previously {@code jaxx.runtime.MultiJXPathDecoratorTest}). - */ -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 = DecoratorUtils.newMultiJXPathDecorator(null, "hello", "#"); - } - - @Test(expected = IllegalArgumentException.class) - public void testMissingRightBrace() throws Exception { - decorator = DecoratorUtils.newMultiJXPathDecorator(Object.class, "${haha", "#"); - } - - @Test(expected = IllegalArgumentException.class) - public void testMissingRightBrace2() throws Exception { - decorator = DecoratorUtils.newMultiJXPathDecorator(Object.class, "${haha${hum}", "#"); - } - - @Test - public void testNullBean() throws Exception { - decorator = DecoratorUtils.newMultiJXPathDecorator(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 = DecoratorUtils.newMultiJXPathDecorator(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 = DecoratorUtils.newMultiJXPathDecorator(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 = DecoratorUtils.newMultiJXPathDecorator(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 = DecoratorUtils.newMultiJXPathDecorator(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> d = DecoratorUtils.newMultiJXPathDecorator(Data.class, "${pos}$d-${name}$s", "-"); - - List<Data> sortData = new ArrayList<Data>(datas); - DecoratorUtils.sort(d, 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); - } - }); - d.setContextIndex(1); - DecoratorUtils.sort(d, 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]); - } - } -} Copied: trunk/jaxx-runtime/src/test/java/jaxx/runtime/decorator/MultiJXPathDecoratorTest.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/MultiJXPathDecoratorTest.java) =================================================================== --- trunk/jaxx-runtime/src/test/java/jaxx/runtime/decorator/MultiJXPathDecoratorTest.java (rev 0) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/decorator/MultiJXPathDecoratorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,205 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.decorator; + +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 + * @since 1.7.2 (was previously {@code jaxx.runtime.MultiJXPathDecoratorTest}). + */ +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 = DecoratorUtils.newMultiJXPathDecorator(null, "hello", "#"); + } + + @Test(expected = IllegalArgumentException.class) + public void testMissingRightBrace() throws Exception { + decorator = DecoratorUtils.newMultiJXPathDecorator(Object.class, "${haha", "#"); + } + + @Test(expected = IllegalArgumentException.class) + public void testMissingRightBrace2() throws Exception { + decorator = DecoratorUtils.newMultiJXPathDecorator(Object.class, "${haha${hum}", "#"); + } + + @Test + public void testNullBean() throws Exception { + decorator = DecoratorUtils.newMultiJXPathDecorator(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 = DecoratorUtils.newMultiJXPathDecorator(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 = DecoratorUtils.newMultiJXPathDecorator(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 = DecoratorUtils.newMultiJXPathDecorator(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 = DecoratorUtils.newMultiJXPathDecorator(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> d = DecoratorUtils.newMultiJXPathDecorator(Data.class, "${pos}$d-${name}$s", "-"); + + List<Data> sortData = new ArrayList<Data>(datas); + DecoratorUtils.sort(d, 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); + } + }); + d.setContextIndex(1); + DecoratorUtils.sort(d, 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]); + } + } +} Property changes on: trunk/jaxx-runtime/src/test/java/jaxx/runtime/swing/navigation ___________________________________________________________________ Added: svn:mergeinfo + Deleted: trunk/jaxx-runtime/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,397 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.swing.navigation; - -import jaxx.runtime.context.DefaultJAXXContext; -import jaxx.runtime.JAXXContext; -import org.junit.Assert; -import org.junit.Test; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import jaxx.runtime.Util; - -/** - * 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, new DefaultJAXXContext(), null, null); - - 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 { - - 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())))); - - NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder(separator, context, null, null); - - NavigationTreeNode rootNode = builder.build(null, (String) null, (String) null, ROOT_CONTEXT, null, null); - - NavigationTreeNode sonNode; - NavigationTreeNode sonSonNode; - NavigationTreeNode sonSonSonNode; - - builder.build(rootNode, (String) null, Util.newContextEntryDef("name", String.class), "name", null, null); - builder.build(rootNode, (String) null, Util.newContextEntryDef("name2", String.class), "name2", null, null); - - sonNode = builder.build(rootNode, (String) null, Util.newContextEntryDef(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(); - - Assert.assertNull(model.getBean("$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 testGetBeanFromList() throws Exception { - - 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"); - - - NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder(separator, context, null, null); - - 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, Util.newListContextEntryDef("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(); - - 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.getBean(contextPath); - Assert.assertNotNull("could not find bean for path : " + contextPath, 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.getNodePath()); - Assert.assertEquals(contextPath, node.getFullPath()); - } - - 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 + ">"; - } - } -} Copied: trunk/jaxx-runtime/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java) =================================================================== --- trunk/jaxx-runtime/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java (rev 0) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,397 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.swing.navigation; + +import jaxx.runtime.context.DefaultJAXXContext; +import jaxx.runtime.JAXXContext; +import org.junit.Assert; +import org.junit.Test; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import jaxx.runtime.Util; + +/** + * 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, new DefaultJAXXContext(), null, null); + + 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 { + + 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())))); + + NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder(separator, context, null, null); + + NavigationTreeNode rootNode = builder.build(null, (String) null, (String) null, ROOT_CONTEXT, null, null); + + NavigationTreeNode sonNode; + NavigationTreeNode sonSonNode; + NavigationTreeNode sonSonSonNode; + + builder.build(rootNode, (String) null, Util.newContextEntryDef("name", String.class), "name", null, null); + builder.build(rootNode, (String) null, Util.newContextEntryDef("name2", String.class), "name2", null, null); + + sonNode = builder.build(rootNode, (String) null, Util.newContextEntryDef(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(); + + Assert.assertNull(model.getBean("$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 testGetBeanFromList() throws Exception { + + 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"); + + + NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder(separator, context, null, null); + + 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, Util.newListContextEntryDef("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(); + + 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.getBean(contextPath); + Assert.assertNotNull("could not find bean for path : " + contextPath, 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.getNodePath()); + Assert.assertEquals(contextPath, node.getFullPath()); + } + + 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 + ">"; + } + } +} Deleted: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/AbstractBeanValidatorDetectorTest.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/AbstractBeanValidatorDetectorTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/AbstractBeanValidatorDetectorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,128 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator; - -import java.io.File; -import java.util.Arrays; -import java.util.Collection; -import java.util.SortedSet; -import java.util.regex.Pattern; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * An abstract test to detects validators for a given list of objets types and - * - * a given sourceroot directory where to find validations definitions. - * - * You just have to implements to {@link #assertDetect(SortedSet)} which contains - * the set of validators detected. - * - * See {@link BeanValidatorDetectorTest} for an example. - * - * Note : An implementation of this test should be produced in evry projects which - * defines some validation definitions just to test they are syntax valid. - * - * @author chemit - * @since 1.6.0 - */ -public abstract class AbstractBeanValidatorDetectorTest { - - /** to use log facility, just put in your code: log.info(\"...\"); */ - private static final Log log = LogFactory.getLog(AbstractBeanValidatorDetectorTest.class); - protected static File basedir; - protected BeanValidatorDetector instance; - protected Class<?>[] classes; - protected Class<?> validatorClass; - protected File sourceRoot; - - protected AbstractBeanValidatorDetectorTest(File sourceRoot, Class<?>... classes) { - this(BeanValidator.class, sourceRoot, classes); - } - - protected AbstractBeanValidatorDetectorTest(Class<?> validatorClass, File sourceRoot, Class<?>... classes) { - this.sourceRoot = sourceRoot; - this.classes = classes; - this.validatorClass = validatorClass; - - log.info("sourceRoot " + sourceRoot); - log.info("validatorClass " + validatorClass); - log.info("classes " + Arrays.toString(classes)); - } - - protected AbstractBeanValidatorDetectorTest(File sourceRoot, Collection<Class<?>> classes) { - this(sourceRoot, classes.toArray(new Class<?>[classes.size()])); - } - - public static void setUpClass() throws Exception { - String b = System.getenv("basedir"); - if (b == null) { - b = new File("").getAbsolutePath(); - } - basedir = new File(b); - log.info("basedir " + basedir); - } - - @Before - public void setUp() { - instance = new BeanValidatorDetector(); - } - - @After - public void tearDown() { - instance = null; - } - - /** - * Test of detect method, of class BeanValidatorDetector. - */ - @Test - public void testDetect() { - SortedSet<BeanValidator<?>> result = detect(sourceRoot, classes, null); - log.info(printValidators("testDetect : ", result)); - assertDetect(result); - } - - protected abstract void assertDetect(SortedSet<BeanValidator<?>> validators); - - protected SortedSet<BeanValidator<?>> detect(File sourceRoot, Class<?>[] classes, Pattern contextPattern) { - SortedSet<BeanValidator<?>> result = instance.detect(validatorClass, sourceRoot, contextPattern, classes); - return result; - } - - protected void assertValidator(Class<?> expectedBeanClass, String expectedContextName, BeanValidator<?> validator) { - assertEquals(expectedBeanClass, validator.getBeanClass()); - assertEquals(expectedContextName, validator.getContextName()); - } - - protected String printValidators(String prefix, SortedSet<BeanValidator<?>> result) { - StringBuilder buffer = new StringBuilder(); - buffer.append(prefix).append(result.size()).append("\n"); - for (BeanValidator<?> v : result) { - buffer.append(prefix).append(v).append("\n"); - } - return buffer.toString(); - } -} \ No newline at end of file Copied: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/AbstractBeanValidatorDetectorTest.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/AbstractBeanValidatorDetectorTest.java) =================================================================== --- trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/AbstractBeanValidatorDetectorTest.java (rev 0) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/AbstractBeanValidatorDetectorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,128 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator; + +import java.io.File; +import java.util.Arrays; +import java.util.Collection; +import java.util.SortedSet; +import java.util.regex.Pattern; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * An abstract test to detects validators for a given list of objets types and + * + * a given sourceroot directory where to find validations definitions. + * + * You just have to implements to {@link #assertDetect(SortedSet)} which contains + * the set of validators detected. + * + * See {@link BeanValidatorDetectorTest} for an example. + * + * Note : An implementation of this test should be produced in evry projects which + * defines some validation definitions just to test they are syntax valid. + * + * @author chemit + * @since 1.6.0 + */ +public abstract class AbstractBeanValidatorDetectorTest { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + private static final Log log = LogFactory.getLog(AbstractBeanValidatorDetectorTest.class); + protected static File basedir; + protected BeanValidatorDetector instance; + protected Class<?>[] classes; + protected Class<?> validatorClass; + protected File sourceRoot; + + protected AbstractBeanValidatorDetectorTest(File sourceRoot, Class<?>... classes) { + this(BeanValidator.class, sourceRoot, classes); + } + + protected AbstractBeanValidatorDetectorTest(Class<?> validatorClass, File sourceRoot, Class<?>... classes) { + this.sourceRoot = sourceRoot; + this.classes = classes; + this.validatorClass = validatorClass; + + log.info("sourceRoot " + sourceRoot); + log.info("validatorClass " + validatorClass); + log.info("classes " + Arrays.toString(classes)); + } + + protected AbstractBeanValidatorDetectorTest(File sourceRoot, Collection<Class<?>> classes) { + this(sourceRoot, classes.toArray(new Class<?>[classes.size()])); + } + + public static void setUpClass() throws Exception { + String b = System.getenv("basedir"); + if (b == null) { + b = new File("").getAbsolutePath(); + } + basedir = new File(b); + log.info("basedir " + basedir); + } + + @Before + public void setUp() { + instance = new BeanValidatorDetector(); + } + + @After + public void tearDown() { + instance = null; + } + + /** + * Test of detect method, of class BeanValidatorDetector. + */ + @Test + public void testDetect() { + SortedSet<BeanValidator<?>> result = detect(sourceRoot, classes, null); + log.info(printValidators("testDetect : ", result)); + assertDetect(result); + } + + protected abstract void assertDetect(SortedSet<BeanValidator<?>> validators); + + protected SortedSet<BeanValidator<?>> detect(File sourceRoot, Class<?>[] classes, Pattern contextPattern) { + SortedSet<BeanValidator<?>> result = instance.detect(validatorClass, sourceRoot, contextPattern, classes); + return result; + } + + protected void assertValidator(Class<?> expectedBeanClass, String expectedContextName, BeanValidator<?> validator) { + assertEquals(expectedBeanClass, validator.getBeanClass()); + assertEquals(expectedContextName, validator.getContextName()); + } + + protected String printValidators(String prefix, SortedSet<BeanValidator<?>> result) { + StringBuilder buffer = new StringBuilder(); + buffer.append(prefix).append(result.size()).append("\n"); + for (BeanValidator<?> v : result) { + buffer.append(prefix).append(v).append("\n"); + } + return buffer.toString(); + } +} \ No newline at end of file Deleted: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/BeanValidatorDetectorTest.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/BeanValidatorDetectorTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/BeanValidatorDetectorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,121 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator; - -import java.io.File; -import java.util.SortedSet; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author chemit - */ -public class BeanValidatorDetectorTest extends AbstractBeanValidatorDetectorTest { - - @BeforeClass - public static void setUpClass() throws Exception { - AbstractBeanValidatorDetectorTest.setUpClass(); - - } - - public BeanValidatorDetectorTest() { - super(new File(basedir, "src" + File.separator + "test" + File.separator + "resources"), SimpleBean.class); - } - - /** - * Test of detect method, of class BeanValidatorDetector. - */ - @Test - public void testDetectNothing() { - - SortedSet<BeanValidator<?>> validators = instance.detect(sourceRoot, new Class<?>[]{Object.class}); - assertEquals(0, validators.size()); - } - - @Override - protected void assertDetect(SortedSet<BeanValidator<?>> validators) { - assertEquals(1, validators.size()); - BeanValidator<?> validator = validators.iterator().next(); - assertEquals(classes[0], validator.getBeanClass()); - assertNull(validator.getContextName()); - } - - /** - * Test of getValidator method, of class BeanValidatorDetector. - */ - @Test - public void testGetValidator() { - Class<?>[] types = {SimpleBean.class}; - SortedSet<BeanValidator<?>> result = instance.detect(sourceRoot, types); - assertEquals(1, result.size()); - BeanValidator<?> validator = result.iterator().next(); - assertEquals(types[0], validator.getBeanClass()); - assertNull(validator.getContextName()); - - types = new Class<?>[]{Object.class}; - result = instance.detect(sourceRoot, types); - assertEquals(0, result.size()); - - } - - /** - * Test of getClassDir method, of class BeanValidatorDetector. - */ - @Test - public void testGetClassDir() { - Class<?> clazz = classes[0]; - - File expected = new File(sourceRoot, "jaxx" + File.separator + "runtime" + File.separator + "validator"); - File result = instance.getClassDir(sourceRoot, clazz); - assertEquals(expected, result); - } - - /** - * Test of getContexts method, of class BeanValidatorDetector. - */ - @Test - public void testGetContexts() { - - String[] expResult = {"error", "info", "simple", "warning"}; - Class<?> clazz = classes[0]; - File dir = instance.getClassDir(sourceRoot,clazz); - String[] result = instance.getContexts(clazz, dir); - assertEquals(expResult.length, result.length); - } - - /** - * Test of getContextsWithoutScopes method, of class BeanValidatorDetector. - */ - @Test - public void testGetContextsWithoutScopes() { - System.out.println("getContextsWithoutScopes"); - - Class<?> clazz = SimpleBean.class; - String[] expResult = {""}; - File dir = instance.getClassDir(sourceRoot, clazz); - String[] contexts = instance.getContexts(clazz, dir); - String[] result = instance.getContextsWithoutScopes(contexts); - assertEquals(expResult.length, result.length); - - } -} \ No newline at end of file Copied: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/BeanValidatorDetectorTest.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/BeanValidatorDetectorTest.java) =================================================================== --- trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/BeanValidatorDetectorTest.java (rev 0) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/BeanValidatorDetectorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,121 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator; + +import java.io.File; +import java.util.SortedSet; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * + * @author chemit + */ +public class BeanValidatorDetectorTest extends AbstractBeanValidatorDetectorTest { + + @BeforeClass + public static void setUpClass() throws Exception { + AbstractBeanValidatorDetectorTest.setUpClass(); + + } + + public BeanValidatorDetectorTest() { + super(new File(basedir, "src" + File.separator + "test" + File.separator + "resources"), SimpleBean.class); + } + + /** + * Test of detect method, of class BeanValidatorDetector. + */ + @Test + public void testDetectNothing() { + + SortedSet<BeanValidator<?>> validators = instance.detect(sourceRoot, new Class<?>[]{Object.class}); + assertEquals(0, validators.size()); + } + + @Override + protected void assertDetect(SortedSet<BeanValidator<?>> validators) { + assertEquals(1, validators.size()); + BeanValidator<?> validator = validators.iterator().next(); + assertEquals(classes[0], validator.getBeanClass()); + assertNull(validator.getContextName()); + } + + /** + * Test of getValidator method, of class BeanValidatorDetector. + */ + @Test + public void testGetValidator() { + Class<?>[] types = {SimpleBean.class}; + SortedSet<BeanValidator<?>> result = instance.detect(sourceRoot, types); + assertEquals(1, result.size()); + BeanValidator<?> validator = result.iterator().next(); + assertEquals(types[0], validator.getBeanClass()); + assertNull(validator.getContextName()); + + types = new Class<?>[]{Object.class}; + result = instance.detect(sourceRoot, types); + assertEquals(0, result.size()); + + } + + /** + * Test of getClassDir method, of class BeanValidatorDetector. + */ + @Test + public void testGetClassDir() { + Class<?> clazz = classes[0]; + + File expected = new File(sourceRoot, "jaxx" + File.separator + "runtime" + File.separator + "validator"); + File result = instance.getClassDir(sourceRoot, clazz); + assertEquals(expected, result); + } + + /** + * Test of getContexts method, of class BeanValidatorDetector. + */ + @Test + public void testGetContexts() { + + String[] expResult = {"error", "info", "simple", "warning"}; + Class<?> clazz = classes[0]; + File dir = instance.getClassDir(sourceRoot,clazz); + String[] result = instance.getContexts(clazz, dir); + assertEquals(expResult.length, result.length); + } + + /** + * Test of getContextsWithoutScopes method, of class BeanValidatorDetector. + */ + @Test + public void testGetContextsWithoutScopes() { + System.out.println("getContextsWithoutScopes"); + + Class<?> clazz = SimpleBean.class; + String[] expResult = {""}; + File dir = instance.getClassDir(sourceRoot, clazz); + String[] contexts = instance.getContexts(clazz, dir); + String[] result = instance.getContextsWithoutScopes(contexts); + assertEquals(expResult.length, result.length); + + } +} \ No newline at end of file Deleted: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/BeanValidatorTest.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/BeanValidatorTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/BeanValidatorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,218 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator; - -import java.util.List; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -/** - * - * @author tony - */ -public class BeanValidatorTest { - - /** to use log facility, just put in your code: log.info(\"...\"); */ - static protected final Log log = LogFactory.getLog(BeanValidator.class); - protected BeanValidator<SimpleBean> validator; - protected SimpleBean bean; - BeanValidatorListenerImpl errorListener; - BeanValidatorListenerImpl warningListener; - BeanValidatorListenerImpl infoListener; - - @Before - public void setUp() { - bean = new SimpleBean(); - validator = new BeanValidator<SimpleBean>(SimpleBean.class, null); - validator.addBeanValidatorListener(errorListener = new BeanValidatorListenerImpl(BeanValidatorScope.ERROR)); - validator.addBeanValidatorListener(warningListener = new BeanValidatorListenerImpl(BeanValidatorScope.WARNING)); - validator.addBeanValidatorListener(infoListener = new BeanValidatorListenerImpl(BeanValidatorScope.INFO)); - } - - @After - public void tearDown() { - bean = null; - if (validator != null) { - validator.setBean(null); - validator = null; - } - } - private static final String STRING_VALUE_ERROR = "stringValue.error"; - private static final String STRING_VALUE_WARNING = "stringValue.warning"; - private static final String INT_VALUE_ERROR = "intValue.error"; - private static final String INT_VALUE_INFO = "intValue.info"; - - @Test - public void testValidate() { - - assertMessages(errorListener); - assertMessages(warningListener); - assertMessages(infoListener); - - log.info("-----------------------------------------------"); - validator.setBean(bean); - - assertMessages(errorListener, STRING_VALUE_ERROR, INT_VALUE_ERROR); - assertMessages(warningListener, STRING_VALUE_WARNING); - assertMessages(infoListener, INT_VALUE_INFO); - - log.info("-----------------------------------------------"); - bean.setStringValue("one"); - - assertMessages(errorListener, INT_VALUE_ERROR); - assertMessages(warningListener, STRING_VALUE_WARNING); - assertMessages(infoListener, INT_VALUE_INFO); - - log.info("-----------------------------------------------"); - bean.setStringValue("oneone"); - - assertMessages(errorListener, INT_VALUE_ERROR); - assertMessages(warningListener); - assertMessages(infoListener, INT_VALUE_INFO); - - log.info("-----------------------------------------------"); - bean.setIntValue(1); - - assertMessages(errorListener); - assertMessages(warningListener); - assertMessages(infoListener, INT_VALUE_INFO); - - log.info("-----------------------------------------------"); - bean.setIntValue(10); - - assertMessages(errorListener); - assertMessages(warningListener); - assertMessages(infoListener); - - log.info("-----------------------------------------------"); - - bean.setStringValue(null); - bean.setIntValue(0); - - assertMessages(errorListener, STRING_VALUE_ERROR, INT_VALUE_ERROR); - assertMessages(warningListener, STRING_VALUE_WARNING); - assertMessages(infoListener, INT_VALUE_INFO); - - - log.info("-----------------------------------------------"); - } - - @Test - public void testConvert() { - - - assertMessages(errorListener); - assertMessages(warningListener); - assertMessages(infoListener); - - log.info("-----------------------------------------------"); - - validator.setBean(bean); - - assertMessages(errorListener, STRING_VALUE_ERROR, INT_VALUE_ERROR); - assertMessages(warningListener, STRING_VALUE_WARNING); - assertMessages(infoListener, INT_VALUE_INFO); - - - log.info("-----------------------------------------------"); - - Object value = validator.convert("intValue", "abc", Class.class); - - Assert.assertNull(value); - - assertMessages(errorListener, STRING_VALUE_ERROR, "error.convertor.class"); - assertMessages(warningListener, STRING_VALUE_WARNING); - assertMessages(infoListener, INT_VALUE_INFO); - - log.info("-----------------------------------------------"); - bean.setStringValue("one"); - - assertMessages(errorListener, "error.convertor.class"); - assertMessages(warningListener, STRING_VALUE_WARNING); - assertMessages(infoListener, INT_VALUE_INFO); - - log.info("-----------------------------------------------"); - - value = validator.convert("intValue", "3", Integer.class); - - bean.setIntValue((Integer) value); - - assertMessages(errorListener); - assertMessages(warningListener, STRING_VALUE_WARNING); - assertMessages(infoListener, INT_VALUE_INFO); - - log.info("-----------------------------------------------"); - - bean.setIntValue(-1); - assertMessages(errorListener, INT_VALUE_ERROR); - assertMessages(warningListener, STRING_VALUE_WARNING); - assertMessages(infoListener, INT_VALUE_INFO); - - log.info("-----------------------------------------------"); - } - - void assertMessages(BeanValidatorListenerImpl listener, String... expected) { - List<String> actual = listener.getMessages(); - Assert.assertEquals(" shoudl have " + java.util.Arrays.toString(expected) + " but had " + actual, expected.length, actual.size()); - for (String m : expected) { - Assert.assertEquals("could not find " + m + " in " + actual, true, actual.contains(m)); - } - } - - class BeanValidatorListenerImpl implements BeanValidatorListener { - - final BeanValidatorScope scope; - - public BeanValidatorListenerImpl(BeanValidatorScope scope) { - this.scope = scope; - } - java.util.List<String> messages = new java.util.ArrayList<String>(); - - public List<String> getMessages() { - return messages; - } - - @Override - public void onFieldChanged(BeanValidatorEvent event) { - if (scope != event.getScope()) { - return; - } - String[] messagesToDelete = event.getMessagesToDelete(); - if (messagesToDelete != null && messagesToDelete.length > 0) { - log.info(event.getScope() + " messages to delete : " + java.util.Arrays.toString(messagesToDelete)); - for (String m : messagesToDelete) { - messages.remove(m); - } - } - String[] messagesToAdd = event.getMessagesToAdd(); - if (messagesToAdd != null && messagesToAdd.length > 0) { - log.info(event.getScope() + " messages to add : " + java.util.Arrays.toString(messagesToAdd)); - for (String m : messagesToAdd) { - messages.add(m); - } - } - } - } -} \ No newline at end of file Copied: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/BeanValidatorTest.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/BeanValidatorTest.java) =================================================================== --- trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/BeanValidatorTest.java (rev 0) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/BeanValidatorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,218 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator; + +import java.util.List; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * + * @author tony + */ +public class BeanValidatorTest { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + static protected final Log log = LogFactory.getLog(BeanValidator.class); + protected BeanValidator<SimpleBean> validator; + protected SimpleBean bean; + BeanValidatorListenerImpl errorListener; + BeanValidatorListenerImpl warningListener; + BeanValidatorListenerImpl infoListener; + + @Before + public void setUp() { + bean = new SimpleBean(); + validator = new BeanValidator<SimpleBean>(SimpleBean.class, null); + validator.addBeanValidatorListener(errorListener = new BeanValidatorListenerImpl(BeanValidatorScope.ERROR)); + validator.addBeanValidatorListener(warningListener = new BeanValidatorListenerImpl(BeanValidatorScope.WARNING)); + validator.addBeanValidatorListener(infoListener = new BeanValidatorListenerImpl(BeanValidatorScope.INFO)); + } + + @After + public void tearDown() { + bean = null; + if (validator != null) { + validator.setBean(null); + validator = null; + } + } + private static final String STRING_VALUE_ERROR = "stringValue.error"; + private static final String STRING_VALUE_WARNING = "stringValue.warning"; + private static final String INT_VALUE_ERROR = "intValue.error"; + private static final String INT_VALUE_INFO = "intValue.info"; + + @Test + public void testValidate() { + + assertMessages(errorListener); + assertMessages(warningListener); + assertMessages(infoListener); + + log.info("-----------------------------------------------"); + validator.setBean(bean); + + assertMessages(errorListener, STRING_VALUE_ERROR, INT_VALUE_ERROR); + assertMessages(warningListener, STRING_VALUE_WARNING); + assertMessages(infoListener, INT_VALUE_INFO); + + log.info("-----------------------------------------------"); + bean.setStringValue("one"); + + assertMessages(errorListener, INT_VALUE_ERROR); + assertMessages(warningListener, STRING_VALUE_WARNING); + assertMessages(infoListener, INT_VALUE_INFO); + + log.info("-----------------------------------------------"); + bean.setStringValue("oneone"); + + assertMessages(errorListener, INT_VALUE_ERROR); + assertMessages(warningListener); + assertMessages(infoListener, INT_VALUE_INFO); + + log.info("-----------------------------------------------"); + bean.setIntValue(1); + + assertMessages(errorListener); + assertMessages(warningListener); + assertMessages(infoListener, INT_VALUE_INFO); + + log.info("-----------------------------------------------"); + bean.setIntValue(10); + + assertMessages(errorListener); + assertMessages(warningListener); + assertMessages(infoListener); + + log.info("-----------------------------------------------"); + + bean.setStringValue(null); + bean.setIntValue(0); + + assertMessages(errorListener, STRING_VALUE_ERROR, INT_VALUE_ERROR); + assertMessages(warningListener, STRING_VALUE_WARNING); + assertMessages(infoListener, INT_VALUE_INFO); + + + log.info("-----------------------------------------------"); + } + + @Test + public void testConvert() { + + + assertMessages(errorListener); + assertMessages(warningListener); + assertMessages(infoListener); + + log.info("-----------------------------------------------"); + + validator.setBean(bean); + + assertMessages(errorListener, STRING_VALUE_ERROR, INT_VALUE_ERROR); + assertMessages(warningListener, STRING_VALUE_WARNING); + assertMessages(infoListener, INT_VALUE_INFO); + + + log.info("-----------------------------------------------"); + + Object value = validator.convert("intValue", "abc", Class.class); + + Assert.assertNull(value); + + assertMessages(errorListener, STRING_VALUE_ERROR, "error.convertor.class"); + assertMessages(warningListener, STRING_VALUE_WARNING); + assertMessages(infoListener, INT_VALUE_INFO); + + log.info("-----------------------------------------------"); + bean.setStringValue("one"); + + assertMessages(errorListener, "error.convertor.class"); + assertMessages(warningListener, STRING_VALUE_WARNING); + assertMessages(infoListener, INT_VALUE_INFO); + + log.info("-----------------------------------------------"); + + value = validator.convert("intValue", "3", Integer.class); + + bean.setIntValue((Integer) value); + + assertMessages(errorListener); + assertMessages(warningListener, STRING_VALUE_WARNING); + assertMessages(infoListener, INT_VALUE_INFO); + + log.info("-----------------------------------------------"); + + bean.setIntValue(-1); + assertMessages(errorListener, INT_VALUE_ERROR); + assertMessages(warningListener, STRING_VALUE_WARNING); + assertMessages(infoListener, INT_VALUE_INFO); + + log.info("-----------------------------------------------"); + } + + void assertMessages(BeanValidatorListenerImpl listener, String... expected) { + List<String> actual = listener.getMessages(); + Assert.assertEquals(" shoudl have " + java.util.Arrays.toString(expected) + " but had " + actual, expected.length, actual.size()); + for (String m : expected) { + Assert.assertEquals("could not find " + m + " in " + actual, true, actual.contains(m)); + } + } + + class BeanValidatorListenerImpl implements BeanValidatorListener { + + final BeanValidatorScope scope; + + public BeanValidatorListenerImpl(BeanValidatorScope scope) { + this.scope = scope; + } + java.util.List<String> messages = new java.util.ArrayList<String>(); + + public List<String> getMessages() { + return messages; + } + + @Override + public void onFieldChanged(BeanValidatorEvent event) { + if (scope != event.getScope()) { + return; + } + String[] messagesToDelete = event.getMessagesToDelete(); + if (messagesToDelete != null && messagesToDelete.length > 0) { + log.info(event.getScope() + " messages to delete : " + java.util.Arrays.toString(messagesToDelete)); + for (String m : messagesToDelete) { + messages.remove(m); + } + } + String[] messagesToAdd = event.getMessagesToAdd(); + if (messagesToAdd != null && messagesToAdd.length > 0) { + log.info(event.getScope() + " messages to add : " + java.util.Arrays.toString(messagesToAdd)); + for (String m : messagesToAdd) { + messages.add(m); + } + } + } + } +} \ No newline at end of file Deleted: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/SimpleBean.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/SimpleBean.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/SimpleBean.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,71 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; - -public class SimpleBean { - - protected int intValue; - protected String stringValue; - final PropertyChangeSupport p; - - public SimpleBean() { - p = new PropertyChangeSupport(this); - } - - public int getIntValue() { - return intValue; - } - - public String getStringValue() { - return stringValue; - } - - public void setStringValue(String stringValue) { - String old = this.stringValue; - this.stringValue = stringValue; - p.firePropertyChange("stringValue", old, stringValue); - } - - public void setIntValue(int intValue) { - int old = this.intValue; - this.intValue = intValue; - p.firePropertyChange("intValue", old, intValue); - } - - public void addPropertyChangeListener(PropertyChangeListener listener) { - p.addPropertyChangeListener(listener); - } - - public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { - p.addPropertyChangeListener(propertyName, listener); - } - - public void removePropertyChangeListener(PropertyChangeListener listener) { - p.removePropertyChangeListener(listener); - } - - public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { - p.removePropertyChangeListener(propertyName, listener); - } -} \ No newline at end of file Copied: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/SimpleBean.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/SimpleBean.java) =================================================================== --- trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/SimpleBean.java (rev 0) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/SimpleBean.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,71 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; + +public class SimpleBean { + + protected int intValue; + protected String stringValue; + final PropertyChangeSupport p; + + public SimpleBean() { + p = new PropertyChangeSupport(this); + } + + public int getIntValue() { + return intValue; + } + + public String getStringValue() { + return stringValue; + } + + public void setStringValue(String stringValue) { + String old = this.stringValue; + this.stringValue = stringValue; + p.firePropertyChange("stringValue", old, stringValue); + } + + public void setIntValue(int intValue) { + int old = this.intValue; + this.intValue = intValue; + p.firePropertyChange("intValue", old, intValue); + } + + public void addPropertyChangeListener(PropertyChangeListener listener) { + p.addPropertyChangeListener(listener); + } + + public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { + p.addPropertyChangeListener(propertyName, listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + p.removePropertyChangeListener(listener); + } + + public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { + p.removePropertyChangeListener(propertyName, listener); + } +} \ No newline at end of file Deleted: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/XWorkBeanValidatorTest.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/XWorkBeanValidatorTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/XWorkBeanValidatorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,176 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator; - -import java.util.List; -import java.util.Map; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -/** - * - * @author tony - * @since 1.3 - */ -public class XWorkBeanValidatorTest { - - protected XWorkBeanValidator<SimpleBean> validator; - protected SimpleBean bean; - protected Map<String, List<String>> messages; - - @Before - public void setUp() { - bean = new SimpleBean(); - validator = new XWorkBeanValidator<SimpleBean>(SimpleBean.class, "simple"); - } - - @After - public void tearDown() { - bean = null; - messages = null; - } - - @Test - public void testUnknownField() { - Assert.assertEquals(false, validator.containsField("fake_" + System.nanoTime())); - } - - @Test(expected = NullPointerException.class) - public void testValidateNPE() { - validator.validate(null); - } - - @Test - public void testValidate() { - - - messages = validator.validate(bean); - - assertFieldInError("stringValue", "stringValue.null", true, messages); - assertFieldInError("intValue", "intValue.null", true, messages); - - bean.setStringValue("notnull"); - messages = validator.validate(bean); - - assertFieldInError("stringValue", "stringValue.null", false, messages); - assertFieldInError("intValue", "intValue.null", true, messages); - - bean.setIntValue(1); - messages = validator.validate(bean); - - assertFieldInError("stringValue", "stringValue.null", false, messages); - assertFieldInError("intValue", "intValue.null", false, messages); - - } - - @Test - public void testSetContextName() { - - - String expected = "simple"; - - Assert.assertEquals(expected, validator.getContextName()); - Assert.assertEquals(true, validator.containsField("stringValue")); - Assert.assertEquals(true, validator.containsField("intValue")); - - validator.setContextName(expected = "error"); - - Assert.assertEquals(expected, validator.getContextName()); - Assert.assertEquals(true, validator.containsField("stringValue")); - Assert.assertEquals(true, validator.containsField("intValue")); - - validator.setContextName(expected = "warning"); - - Assert.assertEquals(expected, validator.getContextName()); - Assert.assertEquals(true, validator.containsField("stringValue")); - Assert.assertEquals(false, validator.containsField("intValue")); - - validator.setContextName(expected = "info"); - - Assert.assertEquals(expected, validator.getContextName()); - Assert.assertEquals(false, validator.containsField("stringValue")); - Assert.assertEquals(true, validator.containsField("intValue")); - - validator.setContextName(expected = "fake_" + System.nanoTime()); - - Assert.assertEquals(expected, validator.getContextName()); - Assert.assertEquals(false, validator.containsField("stringValue")); - Assert.assertEquals(false, validator.containsField("intValue")); - - } - - @Test - public void testSetIncludeDefaultContext() { - - validator.setIncludeDefaultContext(false); - - String expected = "simple"; - - Assert.assertEquals(expected, validator.getContextName()); - Assert.assertEquals(true, validator.containsField("stringValue")); - Assert.assertEquals(true, validator.containsField("intValue")); - - validator.setContextName(expected = "error"); - - Assert.assertEquals(expected, validator.getContextName()); - Assert.assertEquals(true, validator.containsField("stringValue")); - Assert.assertEquals(true, validator.containsField("intValue")); - - validator.setContextName(expected = "warning"); - - Assert.assertEquals(expected, validator.getContextName()); - Assert.assertEquals(true, validator.containsField("stringValue")); - Assert.assertEquals(false, validator.containsField("intValue")); - - validator.setContextName(expected = "info"); - - Assert.assertEquals(expected, validator.getContextName()); - Assert.assertEquals(false, validator.containsField("stringValue")); - Assert.assertEquals(true, validator.containsField("intValue")); - - validator.setContextName(expected = "fake_" + System.nanoTime()); - - Assert.assertEquals(expected, validator.getContextName()); - Assert.assertEquals(false, validator.containsField("stringValue")); - Assert.assertEquals(false, validator.containsField("intValue")); - - } - - protected void assertFieldInError(String fieldName, String error, boolean required, Map<String, List<String>> messages) { - - Assert.assertEquals(true, validator.containsField(fieldName)); - List<String> fieldMessages = messages.get(fieldName); - //Assert.assertEquals(true,validator.containsField(fieldName)); - if (fieldMessages != null) { - for (String o : fieldMessages) { - if (o.equals(error)) { - Assert.assertTrue(required); - return; - } - } - } - - // error was not found - Assert.assertFalse(required); - } -} \ No newline at end of file Copied: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/XWorkBeanValidatorTest.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/XWorkBeanValidatorTest.java) =================================================================== --- trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/XWorkBeanValidatorTest.java (rev 0) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/XWorkBeanValidatorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,176 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator; + +import java.util.List; +import java.util.Map; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * + * @author tony + * @since 1.3 + */ +public class XWorkBeanValidatorTest { + + protected XWorkBeanValidator<SimpleBean> validator; + protected SimpleBean bean; + protected Map<String, List<String>> messages; + + @Before + public void setUp() { + bean = new SimpleBean(); + validator = new XWorkBeanValidator<SimpleBean>(SimpleBean.class, "simple"); + } + + @After + public void tearDown() { + bean = null; + messages = null; + } + + @Test + public void testUnknownField() { + Assert.assertEquals(false, validator.containsField("fake_" + System.nanoTime())); + } + + @Test(expected = NullPointerException.class) + public void testValidateNPE() { + validator.validate(null); + } + + @Test + public void testValidate() { + + + messages = validator.validate(bean); + + assertFieldInError("stringValue", "stringValue.null", true, messages); + assertFieldInError("intValue", "intValue.null", true, messages); + + bean.setStringValue("notnull"); + messages = validator.validate(bean); + + assertFieldInError("stringValue", "stringValue.null", false, messages); + assertFieldInError("intValue", "intValue.null", true, messages); + + bean.setIntValue(1); + messages = validator.validate(bean); + + assertFieldInError("stringValue", "stringValue.null", false, messages); + assertFieldInError("intValue", "intValue.null", false, messages); + + } + + @Test + public void testSetContextName() { + + + String expected = "simple"; + + Assert.assertEquals(expected, validator.getContextName()); + Assert.assertEquals(true, validator.containsField("stringValue")); + Assert.assertEquals(true, validator.containsField("intValue")); + + validator.setContextName(expected = "error"); + + Assert.assertEquals(expected, validator.getContextName()); + Assert.assertEquals(true, validator.containsField("stringValue")); + Assert.assertEquals(true, validator.containsField("intValue")); + + validator.setContextName(expected = "warning"); + + Assert.assertEquals(expected, validator.getContextName()); + Assert.assertEquals(true, validator.containsField("stringValue")); + Assert.assertEquals(false, validator.containsField("intValue")); + + validator.setContextName(expected = "info"); + + Assert.assertEquals(expected, validator.getContextName()); + Assert.assertEquals(false, validator.containsField("stringValue")); + Assert.assertEquals(true, validator.containsField("intValue")); + + validator.setContextName(expected = "fake_" + System.nanoTime()); + + Assert.assertEquals(expected, validator.getContextName()); + Assert.assertEquals(false, validator.containsField("stringValue")); + Assert.assertEquals(false, validator.containsField("intValue")); + + } + + @Test + public void testSetIncludeDefaultContext() { + + validator.setIncludeDefaultContext(false); + + String expected = "simple"; + + Assert.assertEquals(expected, validator.getContextName()); + Assert.assertEquals(true, validator.containsField("stringValue")); + Assert.assertEquals(true, validator.containsField("intValue")); + + validator.setContextName(expected = "error"); + + Assert.assertEquals(expected, validator.getContextName()); + Assert.assertEquals(true, validator.containsField("stringValue")); + Assert.assertEquals(true, validator.containsField("intValue")); + + validator.setContextName(expected = "warning"); + + Assert.assertEquals(expected, validator.getContextName()); + Assert.assertEquals(true, validator.containsField("stringValue")); + Assert.assertEquals(false, validator.containsField("intValue")); + + validator.setContextName(expected = "info"); + + Assert.assertEquals(expected, validator.getContextName()); + Assert.assertEquals(false, validator.containsField("stringValue")); + Assert.assertEquals(true, validator.containsField("intValue")); + + validator.setContextName(expected = "fake_" + System.nanoTime()); + + Assert.assertEquals(expected, validator.getContextName()); + Assert.assertEquals(false, validator.containsField("stringValue")); + Assert.assertEquals(false, validator.containsField("intValue")); + + } + + protected void assertFieldInError(String fieldName, String error, boolean required, Map<String, List<String>> messages) { + + Assert.assertEquals(true, validator.containsField(fieldName)); + List<String> fieldMessages = messages.get(fieldName); + //Assert.assertEquals(true,validator.containsField(fieldName)); + if (fieldMessages != null) { + for (String o : fieldMessages) { + if (o.equals(error)) { + Assert.assertTrue(required); + return; + } + } + } + + // error was not found + Assert.assertFalse(required); + } +} \ No newline at end of file Deleted: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/AbstractFieldValidatorTest.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/AbstractFieldValidatorTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/AbstractFieldValidatorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,117 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator.field; - -import java.io.File; -import jaxx.runtime.validator.BeanValidator; -import jaxx.runtime.validator.BeanValidatorField; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; - -/** - * Abstract class to test a specific validator. - * <p/> - * To implements a test on a new validator, just extends this class - * and implements the method {@link #testValidator()}. - * - * @param <B> the type of bean to validate. - * - * @author chemit - */ -public abstract class AbstractFieldValidatorTest<B> extends Assert { - - /** to use log facility, just put in your code: log.info(\"...\"); */ - static private final Log log = LogFactory.getLog(AbstractFieldValidatorTest.class); - protected static BeanValidator<?> cacheValidator; - protected static File basedir; - protected final Class<B> type; - protected BeanValidator<B> validator; - protected B bean; - - public AbstractFieldValidatorTest(Class<B> type) { - this.type = type; - } - - /** - * the method to test the given validator on the given bean. - * - * When coming here a validator and bean were instanciated and the bean was - * setted into validator via setBean method. - * - * @throws Exception if any error ? - */ - public abstract void testValidator() throws Exception; - - @Before - @SuppressWarnings("unchecked") - public void setUp() throws Exception { - log.debug("start test " + getClass().getSimpleName()); - bean = type.newInstance(); - if (cacheValidator == null) { - validator = validator = new BeanValidator<B>(type, null); - cacheValidator = validator; - } else { - validator = (BeanValidator<B>) cacheValidator; - } - validator.setBean(bean); - } - - @After - @SuppressWarnings("unchecked") - public void tearDown() { - validator.setBean(null); - } - - @AfterClass - public static void afterclass() throws Exception { - cacheValidator = null; - } - - @BeforeClass - public static void initValidator() throws Exception { - - String b = System.getenv("basedir"); - if (b == null) { - b = new File("").getAbsolutePath(); - } - basedir = new File(b); - } - - @SuppressWarnings("unchecked") - protected void assertFieldInError(String fieldName, String error, boolean required) { - BeanValidatorField<B> field = validator.getField(fieldName); - if (field != null && field.getErrors() != null) { - for (String o : field.getErrors()) { - if (o.equals(error)) { - assertTrue("error " + error + " should not exist but was found.", required); - return; - } - } - } - // error was not found - assertFalse("error " + error + " should exist but was not found.", required); - } -} \ No newline at end of file Copied: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/AbstractFieldValidatorTest.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/AbstractFieldValidatorTest.java) =================================================================== --- trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/AbstractFieldValidatorTest.java (rev 0) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/AbstractFieldValidatorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,117 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator.field; + +import java.io.File; +import jaxx.runtime.validator.BeanValidator; +import jaxx.runtime.validator.BeanValidatorField; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; + +/** + * Abstract class to test a specific validator. + * <p/> + * To implements a test on a new validator, just extends this class + * and implements the method {@link #testValidator()}. + * + * @param <B> the type of bean to validate. + * + * @author chemit + */ +public abstract class AbstractFieldValidatorTest<B> extends Assert { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private final Log log = LogFactory.getLog(AbstractFieldValidatorTest.class); + protected static BeanValidator<?> cacheValidator; + protected static File basedir; + protected final Class<B> type; + protected BeanValidator<B> validator; + protected B bean; + + public AbstractFieldValidatorTest(Class<B> type) { + this.type = type; + } + + /** + * the method to test the given validator on the given bean. + * + * When coming here a validator and bean were instanciated and the bean was + * setted into validator via setBean method. + * + * @throws Exception if any error ? + */ + public abstract void testValidator() throws Exception; + + @Before + @SuppressWarnings("unchecked") + public void setUp() throws Exception { + log.debug("start test " + getClass().getSimpleName()); + bean = type.newInstance(); + if (cacheValidator == null) { + validator = validator = new BeanValidator<B>(type, null); + cacheValidator = validator; + } else { + validator = (BeanValidator<B>) cacheValidator; + } + validator.setBean(bean); + } + + @After + @SuppressWarnings("unchecked") + public void tearDown() { + validator.setBean(null); + } + + @AfterClass + public static void afterclass() throws Exception { + cacheValidator = null; + } + + @BeforeClass + public static void initValidator() throws Exception { + + String b = System.getenv("basedir"); + if (b == null) { + b = new File("").getAbsolutePath(); + } + basedir = new File(b); + } + + @SuppressWarnings("unchecked") + protected void assertFieldInError(String fieldName, String error, boolean required) { + BeanValidatorField<B> field = validator.getField(fieldName); + if (field != null && field.getErrors() != null) { + for (String o : field.getErrors()) { + if (o.equals(error)) { + assertTrue("error " + error + " should not exist but was found.", required); + return; + } + } + } + // error was not found + assertFalse("error " + error + " should exist but was not found.", required); + } +} \ No newline at end of file Deleted: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/AbstractValidatorBeanFieldValidatorTest.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/AbstractValidatorBeanFieldValidatorTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/AbstractValidatorBeanFieldValidatorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,34 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator.field; - -/** - * Abstract class to test a specific validator for the {@link Validatorbean}. - * - * @author chemit - * @since 1.3 - */ -public abstract class AbstractValidatorBeanFieldValidatorTest extends AbstractFieldValidatorTest<ValidatorBean> { - - public AbstractValidatorBeanFieldValidatorTest() { - super(ValidatorBean.class); - } -} \ No newline at end of file Copied: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/AbstractValidatorBeanFieldValidatorTest.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/AbstractValidatorBeanFieldValidatorTest.java) =================================================================== --- trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/AbstractValidatorBeanFieldValidatorTest.java (rev 0) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/AbstractValidatorBeanFieldValidatorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,34 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator.field; + +/** + * Abstract class to test a specific validator for the {@link Validatorbean}. + * + * @author chemit + * @since 1.3 + */ +public abstract class AbstractValidatorBeanFieldValidatorTest extends AbstractFieldValidatorTest<ValidatorBean> { + + public AbstractValidatorBeanFieldValidatorTest() { + super(ValidatorBean.class); + } +} \ No newline at end of file Deleted: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/CollectionFieldExpressionValidatorTest.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/CollectionFieldExpressionValidatorTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/CollectionFieldExpressionValidatorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,254 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator.field; - -import jaxx.runtime.validator.field.ValidatorBean.ValidatorBeanEntry; - -import java.util.Arrays; - -/** @author chemit */ -public class CollectionFieldExpressionValidatorTest extends AbstractValidatorBeanFieldValidatorTest { - - protected static final String PROPERTY = "entries"; - static protected ValidatorBeanEntry beanEntry0 = new ValidatorBeanEntry(0, "stringValue"); - static protected ValidatorBeanEntry beanEntry0Bis = new ValidatorBeanEntry(0, "fake"); - static protected ValidatorBeanEntry beanEntry1 = new ValidatorBeanEntry(1, "fake"); - static protected ValidatorBeanEntry beanEntry3 = new ValidatorBeanEntry(3, "fake"); - static protected ValidatorBeanEntry beanEntry5 = new ValidatorBeanEntry(5, "fake"); - - @org.junit.Test - @Override - public void testValidator() throws Exception { - assertNull(bean.getEntries()); - - // no entry - assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne", true); - assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne", true); - assertFieldInError(PROPERTY, "collectionFieldExpression.all", false); - assertFieldInError(PROPERTY, "collectionFieldExpression.none", false); - - - // add a matching etry - bean.setEntries(Arrays.asList(beanEntry0)); - - assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne", false); - assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne", false); - assertFieldInError(PROPERTY, "collectionFieldExpression.all", false); - assertFieldInError(PROPERTY, "collectionFieldExpression.none", true); - - // two matching etries - bean.setEntries(Arrays.asList(beanEntry0, beanEntry0)); - - assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne", false); - assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne", true); - assertFieldInError(PROPERTY, "collectionFieldExpression.all", false); - assertFieldInError(PROPERTY, "collectionFieldExpression.none", true); - - // add a none matching etry - bean.setEntries(Arrays.asList(beanEntry0Bis)); - - assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne", true); - assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne", true); - assertFieldInError(PROPERTY, "collectionFieldExpression.all", true); - assertFieldInError(PROPERTY, "collectionFieldExpression.none", false); - - // add a none matching etry and a matching entry - bean.setEntries(Arrays.asList(beanEntry0Bis, beanEntry0)); - - assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne", false); - assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne", false); - assertFieldInError(PROPERTY, "collectionFieldExpression.all", true); - assertFieldInError(PROPERTY, "collectionFieldExpression.none", true); - } - - @org.junit.Test - public void testValidatorWithContext() throws Exception { - assertNull(bean.getEntries()); - - // no entry - assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne.useSensitiveContext", true); - assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne.useSensitiveContext", true); - assertFieldInError(PROPERTY, "collectionFieldExpression.all.useSensitiveContext", false); - assertFieldInError(PROPERTY, "collectionFieldExpression.none.useSensitiveContext", false); - - // add a matching etry - bean.setEntries(Arrays.asList(beanEntry0)); - - assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne.useSensitiveContext", true); - assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne.useSensitiveContext", true); - assertFieldInError(PROPERTY, "collectionFieldExpression.all.useSensitiveContext", true); - assertFieldInError(PROPERTY, "collectionFieldExpression.none.useSensitiveContext", false); - - // add a none matching etry - bean.setEntries(Arrays.asList(beanEntry0Bis)); - - assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne.useSensitiveContext", true); - assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne.useSensitiveContext", true); - assertFieldInError(PROPERTY, "collectionFieldExpression.all.useSensitiveContext", true); - assertFieldInError(PROPERTY, "collectionFieldExpression.none.useSensitiveContext", false); - - // add a none matching etry and a matching entry - bean.setEntries(Arrays.asList(beanEntry0Bis, beanEntry0)); - - assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne.useSensitiveContext", true); - assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne.useSensitiveContext", true); - assertFieldInError(PROPERTY, "collectionFieldExpression.all.useSensitiveContext", true); - assertFieldInError(PROPERTY, "collectionFieldExpression.none.useSensitiveContext", false); - - bean.setEntries(Arrays.asList(beanEntry0, beanEntry1)); - assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne.useSensitiveContext", false); - assertFieldInError(PROPERTY, "collectionFieldExpression.all.useSensitiveContext", false); - assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne.useSensitiveContext", true); - assertFieldInError(PROPERTY, "collectionFieldExpression.none.useSensitiveContext", false); - - bean.setEntries(Arrays.asList(beanEntry1, beanEntry0)); - assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne.useSensitiveContext", true); - assertFieldInError(PROPERTY, "collectionFieldExpression.all.useSensitiveContext", true); - assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne.useSensitiveContext", true); - assertFieldInError(PROPERTY, "collectionFieldExpression.none.useSensitiveContext", false); - - bean.setEntries(Arrays.asList(beanEntry0, beanEntry1, beanEntry3)); - assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne.useSensitiveContext", false); - assertFieldInError(PROPERTY, "collectionFieldExpression.all.useSensitiveContext", false); - assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne.useSensitiveContext", false); - assertFieldInError(PROPERTY, "collectionFieldExpression.none.useSensitiveContext", true); - - bean.setEntries(Arrays.asList(beanEntry0, beanEntry1, beanEntry3, beanEntry5)); - assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne.useSensitiveContext", false); - assertFieldInError(PROPERTY, "collectionFieldExpression.all.useSensitiveContext", false); - assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne.useSensitiveContext", true); - assertFieldInError(PROPERTY, "collectionFieldExpression.none.useSensitiveContext", true); - - bean.setEntries(Arrays.asList(beanEntry0, beanEntry3, beanEntry1)); - assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne.useSensitiveContext", false); - assertFieldInError(PROPERTY, "collectionFieldExpression.all.useSensitiveContext", true); - assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne.useSensitiveContext", false); - assertFieldInError(PROPERTY, "collectionFieldExpression.none.useSensitiveContext", false); - } - - @org.junit.Test - public void testValidatorWithContextAndFirst() throws Exception { - assertNull(bean.getEntries()); - String message = "collectionFieldExpression.all.useFirst"; - - // no entry - assertFieldInError(PROPERTY, message, false); - - bean.setEntries(Arrays.asList(beanEntry0)); - assertFieldInError(PROPERTY, message, false); - - - bean.setEntries(Arrays.asList(beanEntry0Bis)); - assertFieldInError(PROPERTY, message, false); - - bean.setEntries(Arrays.asList(beanEntry1)); - assertFieldInError(PROPERTY, message, true); - - bean.setEntries(Arrays.asList(beanEntry0, beanEntry1)); - assertFieldInError(PROPERTY, message, false); - - bean.setEntries(Arrays.asList(beanEntry1, beanEntry0)); - assertFieldInError(PROPERTY, message, true); - - bean.setEntries(Arrays.asList(beanEntry0, beanEntry1, beanEntry3)); - assertFieldInError(PROPERTY, message, false); - - bean.setEntries(Arrays.asList(beanEntry0, beanEntry1, beanEntry3, beanEntry5)); - assertFieldInError(PROPERTY, message, false); - - bean.setEntries(Arrays.asList(beanEntry0, beanEntry3, beanEntry1)); - assertFieldInError(PROPERTY, message, true); - } - - @org.junit.Test - public void testValidatorWithContextAndLast() throws Exception { - assertNull(bean.getEntries()); - String message = "collectionFieldExpression.all.useLast"; - - // no entry - assertFieldInError(PROPERTY, message, false); - - bean.setEntries(Arrays.asList(beanEntry0)); - assertFieldInError(PROPERTY, message, true); - - - bean.setEntries(Arrays.asList(beanEntry0Bis)); - assertFieldInError(PROPERTY, message, true); - - bean.setEntries(Arrays.asList(beanEntry1)); - assertFieldInError(PROPERTY, message, false); - - bean.setEntries(Arrays.asList(beanEntry0, beanEntry1)); - assertFieldInError(PROPERTY, message, false); - - bean.setEntries(Arrays.asList(beanEntry1, beanEntry0)); - assertFieldInError(PROPERTY, message, true); - - bean.setEntries(Arrays.asList(beanEntry0, beanEntry1, beanEntry3)); - assertFieldInError(PROPERTY, message, false); - - bean.setEntries(Arrays.asList(beanEntry1, beanEntry3)); - assertFieldInError(PROPERTY, message, false); - - bean.setEntries(Arrays.asList(beanEntry0, beanEntry1, beanEntry3, beanEntry5)); - assertFieldInError(PROPERTY, message, false); - - bean.setEntries(Arrays.asList(beanEntry0, beanEntry3, beanEntry1)); - assertFieldInError(PROPERTY, message, true); - } - - @org.junit.Test - public void testValidatorWithContextAndFirstAndLast() throws Exception { - assertNull(bean.getEntries()); - - String message = "collectionFieldExpression.all.useFirstAndLast"; - // no entry - assertFieldInError(PROPERTY, message, false); - - bean.setEntries(Arrays.asList(beanEntry0)); - assertFieldInError(PROPERTY, message, true); - - - bean.setEntries(Arrays.asList(beanEntry0Bis)); - assertFieldInError(PROPERTY, message, true); - - bean.setEntries(Arrays.asList(beanEntry1)); - assertFieldInError(PROPERTY, message, true); - - bean.setEntries(Arrays.asList(beanEntry0, beanEntry1)); - assertFieldInError(PROPERTY, message, false); - - bean.setEntries(Arrays.asList(beanEntry1, beanEntry0)); - assertFieldInError(PROPERTY, message, true); - - bean.setEntries(Arrays.asList(beanEntry0, beanEntry1, beanEntry3)); - assertFieldInError(PROPERTY, message, false); - - bean.setEntries(Arrays.asList(beanEntry1, beanEntry3)); - assertFieldInError(PROPERTY, message, true); - - bean.setEntries(Arrays.asList(beanEntry0, beanEntry1, beanEntry3, beanEntry5)); - assertFieldInError(PROPERTY, message, false); - - bean.setEntries(Arrays.asList(beanEntry0, beanEntry3, beanEntry1)); - assertFieldInError(PROPERTY, message, true); - } -} Copied: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/CollectionFieldExpressionValidatorTest.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/CollectionFieldExpressionValidatorTest.java) =================================================================== --- trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/CollectionFieldExpressionValidatorTest.java (rev 0) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/CollectionFieldExpressionValidatorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,254 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator.field; + +import jaxx.runtime.validator.field.ValidatorBean.ValidatorBeanEntry; + +import java.util.Arrays; + +/** @author chemit */ +public class CollectionFieldExpressionValidatorTest extends AbstractValidatorBeanFieldValidatorTest { + + protected static final String PROPERTY = "entries"; + static protected ValidatorBeanEntry beanEntry0 = new ValidatorBeanEntry(0, "stringValue"); + static protected ValidatorBeanEntry beanEntry0Bis = new ValidatorBeanEntry(0, "fake"); + static protected ValidatorBeanEntry beanEntry1 = new ValidatorBeanEntry(1, "fake"); + static protected ValidatorBeanEntry beanEntry3 = new ValidatorBeanEntry(3, "fake"); + static protected ValidatorBeanEntry beanEntry5 = new ValidatorBeanEntry(5, "fake"); + + @org.junit.Test + @Override + public void testValidator() throws Exception { + assertNull(bean.getEntries()); + + // no entry + assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne", true); + assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne", true); + assertFieldInError(PROPERTY, "collectionFieldExpression.all", false); + assertFieldInError(PROPERTY, "collectionFieldExpression.none", false); + + + // add a matching etry + bean.setEntries(Arrays.asList(beanEntry0)); + + assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne", false); + assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne", false); + assertFieldInError(PROPERTY, "collectionFieldExpression.all", false); + assertFieldInError(PROPERTY, "collectionFieldExpression.none", true); + + // two matching etries + bean.setEntries(Arrays.asList(beanEntry0, beanEntry0)); + + assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne", false); + assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne", true); + assertFieldInError(PROPERTY, "collectionFieldExpression.all", false); + assertFieldInError(PROPERTY, "collectionFieldExpression.none", true); + + // add a none matching etry + bean.setEntries(Arrays.asList(beanEntry0Bis)); + + assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne", true); + assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne", true); + assertFieldInError(PROPERTY, "collectionFieldExpression.all", true); + assertFieldInError(PROPERTY, "collectionFieldExpression.none", false); + + // add a none matching etry and a matching entry + bean.setEntries(Arrays.asList(beanEntry0Bis, beanEntry0)); + + assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne", false); + assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne", false); + assertFieldInError(PROPERTY, "collectionFieldExpression.all", true); + assertFieldInError(PROPERTY, "collectionFieldExpression.none", true); + } + + @org.junit.Test + public void testValidatorWithContext() throws Exception { + assertNull(bean.getEntries()); + + // no entry + assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne.useSensitiveContext", true); + assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne.useSensitiveContext", true); + assertFieldInError(PROPERTY, "collectionFieldExpression.all.useSensitiveContext", false); + assertFieldInError(PROPERTY, "collectionFieldExpression.none.useSensitiveContext", false); + + // add a matching etry + bean.setEntries(Arrays.asList(beanEntry0)); + + assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne.useSensitiveContext", true); + assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne.useSensitiveContext", true); + assertFieldInError(PROPERTY, "collectionFieldExpression.all.useSensitiveContext", true); + assertFieldInError(PROPERTY, "collectionFieldExpression.none.useSensitiveContext", false); + + // add a none matching etry + bean.setEntries(Arrays.asList(beanEntry0Bis)); + + assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne.useSensitiveContext", true); + assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne.useSensitiveContext", true); + assertFieldInError(PROPERTY, "collectionFieldExpression.all.useSensitiveContext", true); + assertFieldInError(PROPERTY, "collectionFieldExpression.none.useSensitiveContext", false); + + // add a none matching etry and a matching entry + bean.setEntries(Arrays.asList(beanEntry0Bis, beanEntry0)); + + assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne.useSensitiveContext", true); + assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne.useSensitiveContext", true); + assertFieldInError(PROPERTY, "collectionFieldExpression.all.useSensitiveContext", true); + assertFieldInError(PROPERTY, "collectionFieldExpression.none.useSensitiveContext", false); + + bean.setEntries(Arrays.asList(beanEntry0, beanEntry1)); + assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne.useSensitiveContext", false); + assertFieldInError(PROPERTY, "collectionFieldExpression.all.useSensitiveContext", false); + assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne.useSensitiveContext", true); + assertFieldInError(PROPERTY, "collectionFieldExpression.none.useSensitiveContext", false); + + bean.setEntries(Arrays.asList(beanEntry1, beanEntry0)); + assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne.useSensitiveContext", true); + assertFieldInError(PROPERTY, "collectionFieldExpression.all.useSensitiveContext", true); + assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne.useSensitiveContext", true); + assertFieldInError(PROPERTY, "collectionFieldExpression.none.useSensitiveContext", false); + + bean.setEntries(Arrays.asList(beanEntry0, beanEntry1, beanEntry3)); + assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne.useSensitiveContext", false); + assertFieldInError(PROPERTY, "collectionFieldExpression.all.useSensitiveContext", false); + assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne.useSensitiveContext", false); + assertFieldInError(PROPERTY, "collectionFieldExpression.none.useSensitiveContext", true); + + bean.setEntries(Arrays.asList(beanEntry0, beanEntry1, beanEntry3, beanEntry5)); + assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne.useSensitiveContext", false); + assertFieldInError(PROPERTY, "collectionFieldExpression.all.useSensitiveContext", false); + assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne.useSensitiveContext", true); + assertFieldInError(PROPERTY, "collectionFieldExpression.none.useSensitiveContext", true); + + bean.setEntries(Arrays.asList(beanEntry0, beanEntry3, beanEntry1)); + assertFieldInError(PROPERTY, "collectionFieldExpression.atLeastOne.useSensitiveContext", false); + assertFieldInError(PROPERTY, "collectionFieldExpression.all.useSensitiveContext", true); + assertFieldInError(PROPERTY, "collectionFieldExpression.exactlyOne.useSensitiveContext", false); + assertFieldInError(PROPERTY, "collectionFieldExpression.none.useSensitiveContext", false); + } + + @org.junit.Test + public void testValidatorWithContextAndFirst() throws Exception { + assertNull(bean.getEntries()); + String message = "collectionFieldExpression.all.useFirst"; + + // no entry + assertFieldInError(PROPERTY, message, false); + + bean.setEntries(Arrays.asList(beanEntry0)); + assertFieldInError(PROPERTY, message, false); + + + bean.setEntries(Arrays.asList(beanEntry0Bis)); + assertFieldInError(PROPERTY, message, false); + + bean.setEntries(Arrays.asList(beanEntry1)); + assertFieldInError(PROPERTY, message, true); + + bean.setEntries(Arrays.asList(beanEntry0, beanEntry1)); + assertFieldInError(PROPERTY, message, false); + + bean.setEntries(Arrays.asList(beanEntry1, beanEntry0)); + assertFieldInError(PROPERTY, message, true); + + bean.setEntries(Arrays.asList(beanEntry0, beanEntry1, beanEntry3)); + assertFieldInError(PROPERTY, message, false); + + bean.setEntries(Arrays.asList(beanEntry0, beanEntry1, beanEntry3, beanEntry5)); + assertFieldInError(PROPERTY, message, false); + + bean.setEntries(Arrays.asList(beanEntry0, beanEntry3, beanEntry1)); + assertFieldInError(PROPERTY, message, true); + } + + @org.junit.Test + public void testValidatorWithContextAndLast() throws Exception { + assertNull(bean.getEntries()); + String message = "collectionFieldExpression.all.useLast"; + + // no entry + assertFieldInError(PROPERTY, message, false); + + bean.setEntries(Arrays.asList(beanEntry0)); + assertFieldInError(PROPERTY, message, true); + + + bean.setEntries(Arrays.asList(beanEntry0Bis)); + assertFieldInError(PROPERTY, message, true); + + bean.setEntries(Arrays.asList(beanEntry1)); + assertFieldInError(PROPERTY, message, false); + + bean.setEntries(Arrays.asList(beanEntry0, beanEntry1)); + assertFieldInError(PROPERTY, message, false); + + bean.setEntries(Arrays.asList(beanEntry1, beanEntry0)); + assertFieldInError(PROPERTY, message, true); + + bean.setEntries(Arrays.asList(beanEntry0, beanEntry1, beanEntry3)); + assertFieldInError(PROPERTY, message, false); + + bean.setEntries(Arrays.asList(beanEntry1, beanEntry3)); + assertFieldInError(PROPERTY, message, false); + + bean.setEntries(Arrays.asList(beanEntry0, beanEntry1, beanEntry3, beanEntry5)); + assertFieldInError(PROPERTY, message, false); + + bean.setEntries(Arrays.asList(beanEntry0, beanEntry3, beanEntry1)); + assertFieldInError(PROPERTY, message, true); + } + + @org.junit.Test + public void testValidatorWithContextAndFirstAndLast() throws Exception { + assertNull(bean.getEntries()); + + String message = "collectionFieldExpression.all.useFirstAndLast"; + // no entry + assertFieldInError(PROPERTY, message, false); + + bean.setEntries(Arrays.asList(beanEntry0)); + assertFieldInError(PROPERTY, message, true); + + + bean.setEntries(Arrays.asList(beanEntry0Bis)); + assertFieldInError(PROPERTY, message, true); + + bean.setEntries(Arrays.asList(beanEntry1)); + assertFieldInError(PROPERTY, message, true); + + bean.setEntries(Arrays.asList(beanEntry0, beanEntry1)); + assertFieldInError(PROPERTY, message, false); + + bean.setEntries(Arrays.asList(beanEntry1, beanEntry0)); + assertFieldInError(PROPERTY, message, true); + + bean.setEntries(Arrays.asList(beanEntry0, beanEntry1, beanEntry3)); + assertFieldInError(PROPERTY, message, false); + + bean.setEntries(Arrays.asList(beanEntry1, beanEntry3)); + assertFieldInError(PROPERTY, message, true); + + bean.setEntries(Arrays.asList(beanEntry0, beanEntry1, beanEntry3, beanEntry5)); + assertFieldInError(PROPERTY, message, false); + + bean.setEntries(Arrays.asList(beanEntry0, beanEntry3, beanEntry1)); + assertFieldInError(PROPERTY, message, true); + } +} Deleted: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidatorTest.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidatorTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidatorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,106 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator.field; - -import jaxx.runtime.validator.field.ValidatorBean.ValidatorBeanEntry; - -import java.util.Arrays; - -/** @author chemit */ -public class CollectionUniqueKeyValidatorTest extends AbstractValidatorBeanFieldValidatorTest { - - static protected ValidatorBeanEntry beanEntry = new ValidatorBeanEntry(0, "stringValue"); - static protected ValidatorBeanEntry beanEntry2 = new ValidatorBeanEntry(0, "fake"); - static protected ValidatorBeanEntry beanEntry3 = new ValidatorBeanEntry(0, "stringValue", "stringValue2"); - - @org.junit.Test - @Override - public void testValidator() throws Exception { - assertNull(bean.getEntries()); - - // no entry - assertFieldInError("entries", "collectionUniqueKey.one.failed", false); - assertFieldInError("entries", "collectionUniqueKey.two.failed", false); - assertFieldInError("entries", "collectionUniqueKey.three.failed", false); - assertFieldInError("entries", "collectionUniqueKey.four.failed", false); - assertFieldInError("entries", "collectionUniqueKey.five.failed", false); - - // add a entry - bean.setEntries(Arrays.asList(beanEntry)); - - assertFieldInError("entries", "collectionUniqueKey.one.failed", false); - assertFieldInError("entries", "collectionUniqueKey.two.failed", false); - assertFieldInError("entries", "collectionUniqueKey.three.failed", false); - assertFieldInError("entries", "collectionUniqueKey.four.failed", false); - assertFieldInError("entries", "collectionUniqueKey.five.failed", false); - - // add violating property - bean.setEntry(beanEntry3); - assertFieldInError("entries", "collectionUniqueKey.one.failed", false); - assertFieldInError("entries", "collectionUniqueKey.two.failed", false); - assertFieldInError("entries", "collectionUniqueKey.three.failed", false); - assertFieldInError("entries", "collectionUniqueKey.four.failed", false); - assertFieldInError("entries", "collectionUniqueKey.five.failed", true); - - - // two entries with same key - bean.setEntries(Arrays.asList(beanEntry, beanEntry)); - - assertFieldInError("entries", "collectionUniqueKey.one.failed", true); - assertFieldInError("entries", "collectionUniqueKey.two.failed", true); - assertFieldInError("entries", "collectionUniqueKey.three.failed", true); - assertFieldInError("entries", "collectionUniqueKey.four.failed", true); - - // add a entry - bean.setEntries(Arrays.asList(beanEntry2)); - - assertFieldInError("entries", "collectionUniqueKey.one.failed", false); - assertFieldInError("entries", "collectionUniqueKey.two.failed", false); - assertFieldInError("entries", "collectionUniqueKey.three.failed", false); - assertFieldInError("entries", "collectionUniqueKey.four.failed", false); - - // add two entries (will violated unique key on intValue) - bean.setEntries(Arrays.asList(beanEntry2, beanEntry)); - - assertFieldInError("entries", "collectionUniqueKey.one.failed", true); - assertFieldInError("entries", "collectionUniqueKey.two.failed", false); - assertFieldInError("entries", "collectionUniqueKey.three.failed", false); - assertFieldInError("entries", "collectionUniqueKey.four.failed", false); - - - // two entries with same key (except validator four) - bean.setEntries(Arrays.asList(beanEntry, beanEntry3)); - assertFieldInError("entries", "collectionUniqueKey.one.failed", true); - assertFieldInError("entries", "collectionUniqueKey.two.failed", true); - assertFieldInError("entries", "collectionUniqueKey.three.failed", true); - assertFieldInError("entries", "collectionUniqueKey.four.failed", false); - - beanEntry.setStringValue2("stringValue2"); - // two entries with same key - bean.setEntries(Arrays.asList(beanEntry, beanEntry3)); - assertFieldInError("entries", "collectionUniqueKey.one.failed", true); - assertFieldInError("entries", "collectionUniqueKey.two.failed", true); - assertFieldInError("entries", "collectionUniqueKey.three.failed", true); - assertFieldInError("entries", "collectionUniqueKey.four.failed", true); - - - } -} \ No newline at end of file Copied: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidatorTest.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidatorTest.java) =================================================================== --- trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidatorTest.java (rev 0) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidatorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,106 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator.field; + +import jaxx.runtime.validator.field.ValidatorBean.ValidatorBeanEntry; + +import java.util.Arrays; + +/** @author chemit */ +public class CollectionUniqueKeyValidatorTest extends AbstractValidatorBeanFieldValidatorTest { + + static protected ValidatorBeanEntry beanEntry = new ValidatorBeanEntry(0, "stringValue"); + static protected ValidatorBeanEntry beanEntry2 = new ValidatorBeanEntry(0, "fake"); + static protected ValidatorBeanEntry beanEntry3 = new ValidatorBeanEntry(0, "stringValue", "stringValue2"); + + @org.junit.Test + @Override + public void testValidator() throws Exception { + assertNull(bean.getEntries()); + + // no entry + assertFieldInError("entries", "collectionUniqueKey.one.failed", false); + assertFieldInError("entries", "collectionUniqueKey.two.failed", false); + assertFieldInError("entries", "collectionUniqueKey.three.failed", false); + assertFieldInError("entries", "collectionUniqueKey.four.failed", false); + assertFieldInError("entries", "collectionUniqueKey.five.failed", false); + + // add a entry + bean.setEntries(Arrays.asList(beanEntry)); + + assertFieldInError("entries", "collectionUniqueKey.one.failed", false); + assertFieldInError("entries", "collectionUniqueKey.two.failed", false); + assertFieldInError("entries", "collectionUniqueKey.three.failed", false); + assertFieldInError("entries", "collectionUniqueKey.four.failed", false); + assertFieldInError("entries", "collectionUniqueKey.five.failed", false); + + // add violating property + bean.setEntry(beanEntry3); + assertFieldInError("entries", "collectionUniqueKey.one.failed", false); + assertFieldInError("entries", "collectionUniqueKey.two.failed", false); + assertFieldInError("entries", "collectionUniqueKey.three.failed", false); + assertFieldInError("entries", "collectionUniqueKey.four.failed", false); + assertFieldInError("entries", "collectionUniqueKey.five.failed", true); + + + // two entries with same key + bean.setEntries(Arrays.asList(beanEntry, beanEntry)); + + assertFieldInError("entries", "collectionUniqueKey.one.failed", true); + assertFieldInError("entries", "collectionUniqueKey.two.failed", true); + assertFieldInError("entries", "collectionUniqueKey.three.failed", true); + assertFieldInError("entries", "collectionUniqueKey.four.failed", true); + + // add a entry + bean.setEntries(Arrays.asList(beanEntry2)); + + assertFieldInError("entries", "collectionUniqueKey.one.failed", false); + assertFieldInError("entries", "collectionUniqueKey.two.failed", false); + assertFieldInError("entries", "collectionUniqueKey.three.failed", false); + assertFieldInError("entries", "collectionUniqueKey.four.failed", false); + + // add two entries (will violated unique key on intValue) + bean.setEntries(Arrays.asList(beanEntry2, beanEntry)); + + assertFieldInError("entries", "collectionUniqueKey.one.failed", true); + assertFieldInError("entries", "collectionUniqueKey.two.failed", false); + assertFieldInError("entries", "collectionUniqueKey.three.failed", false); + assertFieldInError("entries", "collectionUniqueKey.four.failed", false); + + + // two entries with same key (except validator four) + bean.setEntries(Arrays.asList(beanEntry, beanEntry3)); + assertFieldInError("entries", "collectionUniqueKey.one.failed", true); + assertFieldInError("entries", "collectionUniqueKey.two.failed", true); + assertFieldInError("entries", "collectionUniqueKey.three.failed", true); + assertFieldInError("entries", "collectionUniqueKey.four.failed", false); + + beanEntry.setStringValue2("stringValue2"); + // two entries with same key + bean.setEntries(Arrays.asList(beanEntry, beanEntry3)); + assertFieldInError("entries", "collectionUniqueKey.one.failed", true); + assertFieldInError("entries", "collectionUniqueKey.two.failed", true); + assertFieldInError("entries", "collectionUniqueKey.three.failed", true); + assertFieldInError("entries", "collectionUniqueKey.four.failed", true); + + + } +} \ No newline at end of file Deleted: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidatorTest.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidatorTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidatorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,50 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator.field; - -import java.io.File; - -/** @author chemit */ -public class ExistingDirectoryFieldValidatorTest extends AbstractValidatorBeanFieldValidatorTest { - - @org.junit.Test - @Override - public void testValidator() throws Exception { - - assertNull(bean.getExistingDirectory()); - assertFieldInError("existingDirectory", "existingDirectory.required", true); - - bean.setExistingDirectory(new File("")); - assertFieldInError("existingDirectory", "existingDirectory.required", true); - - // existing file - bean.setExistingDirectory(new File(basedir, "pom.xml")); - assertFieldInError("existingDirectory", "existingDirectory.required", false); - assertFieldInError("existingDirectory", "existingDirectory.not.exist", true); - - // existing directory - bean.setExistingDirectory(basedir); - assertFieldInError("existingDirectory", "existingDirectory.required", false); - assertFieldInError("existingDirectory", "existingDirectory.not.exist", false); - - } - -} \ No newline at end of file Copied: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidatorTest.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidatorTest.java) =================================================================== --- trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidatorTest.java (rev 0) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidatorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,50 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator.field; + +import java.io.File; + +/** @author chemit */ +public class ExistingDirectoryFieldValidatorTest extends AbstractValidatorBeanFieldValidatorTest { + + @org.junit.Test + @Override + public void testValidator() throws Exception { + + assertNull(bean.getExistingDirectory()); + assertFieldInError("existingDirectory", "existingDirectory.required", true); + + bean.setExistingDirectory(new File("")); + assertFieldInError("existingDirectory", "existingDirectory.required", true); + + // existing file + bean.setExistingDirectory(new File(basedir, "pom.xml")); + assertFieldInError("existingDirectory", "existingDirectory.required", false); + assertFieldInError("existingDirectory", "existingDirectory.not.exist", true); + + // existing directory + bean.setExistingDirectory(basedir); + assertFieldInError("existingDirectory", "existingDirectory.required", false); + assertFieldInError("existingDirectory", "existingDirectory.not.exist", false); + + } + +} \ No newline at end of file Deleted: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/ExistingFileFieldValidatorTest.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/ExistingFileFieldValidatorTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/ExistingFileFieldValidatorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,50 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator.field; - -import java.io.File; - -/** @author chemit */ -public class ExistingFileFieldValidatorTest extends AbstractValidatorBeanFieldValidatorTest { - - @org.junit.Test - @Override - public void testValidator() throws Exception { - - assertNull(bean.getExistingFile()); - assertFieldInError("existingFile", "existingFile.required", true); - - bean.setExistingFile(new File("")); - assertFieldInError("existingFile", "existingFile.required", true); - - // existing directory - bean.setExistingFile(basedir); - assertFieldInError("existingFile", "existingFile.required", false); - assertFieldInError("existingFile", "existingFile.not.exist", true); - - // existing file - bean.setExistingFile(new File(basedir, "pom.xml")); - assertFieldInError("existingFile", "existingFile.required", false); - assertFieldInError("existingFile", "existingFile.not.exist", false); - - } - -} \ No newline at end of file Copied: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/ExistingFileFieldValidatorTest.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/ExistingFileFieldValidatorTest.java) =================================================================== --- trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/ExistingFileFieldValidatorTest.java (rev 0) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/ExistingFileFieldValidatorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,50 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator.field; + +import java.io.File; + +/** @author chemit */ +public class ExistingFileFieldValidatorTest extends AbstractValidatorBeanFieldValidatorTest { + + @org.junit.Test + @Override + public void testValidator() throws Exception { + + assertNull(bean.getExistingFile()); + assertFieldInError("existingFile", "existingFile.required", true); + + bean.setExistingFile(new File("")); + assertFieldInError("existingFile", "existingFile.required", true); + + // existing directory + bean.setExistingFile(basedir); + assertFieldInError("existingFile", "existingFile.required", false); + assertFieldInError("existingFile", "existingFile.not.exist", true); + + // existing file + bean.setExistingFile(new File(basedir, "pom.xml")); + assertFieldInError("existingFile", "existingFile.required", false); + assertFieldInError("existingFile", "existingFile.not.exist", false); + + } + +} \ No newline at end of file Deleted: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/FieldExpressionBean.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/FieldExpressionBean.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/FieldExpressionBean.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,123 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator.field; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; - -/** - * - * @author tony - */ -public class FieldExpressionBean { - - protected final PropertyChangeSupport p; - protected boolean booleanValue; - protected short shortValue; - protected int intValue; - protected long longValue; - protected double doubleValue; - protected String stringValue; - - public FieldExpressionBean() { - p = new PropertyChangeSupport(this); - } - - public boolean isBooleanValue() { - return booleanValue; - } - - public double getDoubleValue() { - return doubleValue; - } - - public int getIntValue() { - return intValue; - } - - public long getLongValue() { - return longValue; - } - - public short getShortValue() { - return shortValue; - } - - public String getStringValue() { - return stringValue; - } - - public void setBooleanValue(boolean newValue) { - Object oldValue = this.booleanValue; - this.booleanValue = newValue; - firePropertyChange("booleanValue", oldValue, newValue); - } - - public void setDoubleValue(double newValue) { - Object oldValue = this.doubleValue; - this.doubleValue = newValue; - firePropertyChange("doubleValue", oldValue, newValue); - } - - public void setIntValue(int newValue) { - Object oldValue = this.stringValue; - this.intValue = newValue; - firePropertyChange("intValue", oldValue, newValue); - } - - public void setLongValue(long newValue) { - Object oldValue = this.longValue; - this.longValue = newValue; - firePropertyChange("longValue", oldValue, newValue); - } - - public void setShortValue(short newValue) { - Object oldValue = this.shortValue; - this.shortValue = newValue; - firePropertyChange("shortValue", oldValue, newValue); - } - - public void setStringValue(String newValue) { - Object oldValue = this.stringValue; - this.stringValue = newValue; - firePropertyChange("stringValue", oldValue, newValue); - } - - protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { - p.firePropertyChange(propertyName, oldValue, newValue); - } - - public void addPropertyChangeListener(PropertyChangeListener listener) { - p.addPropertyChangeListener(listener); - } - - public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { - p.addPropertyChangeListener(propertyName, listener); - } - - public void removePropertyChangeListener(PropertyChangeListener listener) { - p.removePropertyChangeListener(listener); - } - - public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { - p.removePropertyChangeListener(propertyName, listener); - } -} Copied: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/FieldExpressionBean.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/FieldExpressionBean.java) =================================================================== --- trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/FieldExpressionBean.java (rev 0) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/FieldExpressionBean.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,123 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator.field; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; + +/** + * + * @author tony + */ +public class FieldExpressionBean { + + protected final PropertyChangeSupport p; + protected boolean booleanValue; + protected short shortValue; + protected int intValue; + protected long longValue; + protected double doubleValue; + protected String stringValue; + + public FieldExpressionBean() { + p = new PropertyChangeSupport(this); + } + + public boolean isBooleanValue() { + return booleanValue; + } + + public double getDoubleValue() { + return doubleValue; + } + + public int getIntValue() { + return intValue; + } + + public long getLongValue() { + return longValue; + } + + public short getShortValue() { + return shortValue; + } + + public String getStringValue() { + return stringValue; + } + + public void setBooleanValue(boolean newValue) { + Object oldValue = this.booleanValue; + this.booleanValue = newValue; + firePropertyChange("booleanValue", oldValue, newValue); + } + + public void setDoubleValue(double newValue) { + Object oldValue = this.doubleValue; + this.doubleValue = newValue; + firePropertyChange("doubleValue", oldValue, newValue); + } + + public void setIntValue(int newValue) { + Object oldValue = this.stringValue; + this.intValue = newValue; + firePropertyChange("intValue", oldValue, newValue); + } + + public void setLongValue(long newValue) { + Object oldValue = this.longValue; + this.longValue = newValue; + firePropertyChange("longValue", oldValue, newValue); + } + + public void setShortValue(short newValue) { + Object oldValue = this.shortValue; + this.shortValue = newValue; + firePropertyChange("shortValue", oldValue, newValue); + } + + public void setStringValue(String newValue) { + Object oldValue = this.stringValue; + this.stringValue = newValue; + firePropertyChange("stringValue", oldValue, newValue); + } + + protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { + p.firePropertyChange(propertyName, oldValue, newValue); + } + + public void addPropertyChangeListener(PropertyChangeListener listener) { + p.addPropertyChangeListener(listener); + } + + public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { + p.addPropertyChangeListener(propertyName, listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + p.removePropertyChangeListener(listener); + } + + public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { + p.removePropertyChangeListener(propertyName, listener); + } +} Deleted: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/FieldExpressionWithParamsValidatorTest.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/FieldExpressionWithParamsValidatorTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/FieldExpressionWithParamsValidatorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,136 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator.field; - -/** @author chemit */ -public class FieldExpressionWithParamsValidatorTest extends AbstractFieldValidatorTest<FieldExpressionBean> { - - public static final String MESSAGE = "expression.too.big##100"; - public static final String MESSAGE2 = "expression.too.big##100##2000"; - - public FieldExpressionWithParamsValidatorTest() { - super(FieldExpressionBean.class); - } - - @org.junit.Test - @Override - public void testValidator() throws Exception { - - testBooleanType(); - testShortType(); - testIntType(); - testLongType(); - testDoubleType(); - testStringType(); - - - } - - protected void testBooleanType() { - - assertEquals(false, bean.isBooleanValue()); - assertFieldInError("booleanValue", "expression.boolean.not.equals##true", true); - assertFieldInError("booleanValue", "expression.boolean.not.equals##false", false); - - bean.setBooleanValue(true); - assertFieldInError("booleanValue", "expression.boolean.not.equals##true", false); - assertFieldInError("booleanValue", "expression.boolean.not.equals##false", true); - } - - protected void testShortType() { - assertEquals(0, bean.getShortValue()); - assertFieldInError("shortValue", MESSAGE, false); - assertFieldInError("shortValue", MESSAGE2, false); - bean.setShortValue((short) 10); - assertFieldInError("shortValue", MESSAGE, false); - assertFieldInError("shortValue", MESSAGE2, false); - bean.setShortValue((short) 1000); - assertFieldInError("shortValue", MESSAGE, true); - assertFieldInError("shortValue", MESSAGE2, false); - bean.setShortValue((short) 3000); - assertFieldInError("shortValue", MESSAGE, true); - assertFieldInError("shortValue", MESSAGE2, true); - } - - protected void testIntType() { - assertEquals(0, bean.getIntValue()); - assertFieldInError("intValue", MESSAGE, false); - assertFieldInError("intValue", MESSAGE2, false); - bean.setIntValue(10); - assertFieldInError("intValue", MESSAGE, false); - assertFieldInError("intValue", MESSAGE2, false); - bean.setIntValue(1000); - assertFieldInError("intValue", MESSAGE, true); - assertFieldInError("intValue", MESSAGE2, false); - bean.setIntValue(3000); - assertFieldInError("intValue", MESSAGE, true); - assertFieldInError("intValue", MESSAGE2, true); - } - - protected void testLongType() { - assertEquals(0, bean.getLongValue()); - assertFieldInError("longValue", MESSAGE, false); - assertFieldInError("longValue", MESSAGE2, false); - bean.setLongValue(10); - assertFieldInError("longValue", MESSAGE, false); - assertFieldInError("longValue", MESSAGE2, false); - bean.setLongValue(1000); - assertFieldInError("longValue", MESSAGE, true); - assertFieldInError("longValue", MESSAGE2, false); - bean.setLongValue(3000); - assertFieldInError("longValue", MESSAGE, true); - assertFieldInError("longValue", MESSAGE2, true); - } - - protected void testDoubleType() { - assertEquals(0.0, bean.getDoubleValue(), 0); - assertFieldInError("doubleValue", MESSAGE + ".0", false); - assertFieldInError("doubleValue", "expression.too.big##100.0##2000.0", false); - bean.setDoubleValue(10); - assertFieldInError("doubleValue", MESSAGE + ".0", false); - assertFieldInError("doubleValue", "expression.too.big##100.0##2000.0", false); - bean.setDoubleValue(1000); - assertFieldInError("doubleValue", MESSAGE + ".0", true); - assertFieldInError("doubleValue", "expression.too.big##100.0##2000.0", false); - bean.setDoubleValue(3000); - assertFieldInError("doubleValue", MESSAGE + ".0", true); - assertFieldInError("doubleValue", "expression.too.big##100.0##2000.0", true); - } - - protected void testStringType() { - assertEquals(null, bean.getStringValue()); - - assertFieldInError("stringValue", "expression.stringNotValue##1000", true); - assertFieldInError("stringValue", "expression.stringNotValue##1000##3000", true); - bean.setStringValue("100"); - - assertFieldInError("stringValue", "expression.stringNotValue##1000", true); - assertFieldInError("stringValue", "expression.stringNotValue##1000##3000", true); - - bean.setStringValue("1000"); - assertFieldInError("stringValue", "expression.stringNotValue##1000", false); - assertFieldInError("stringValue", "expression.stringNotValue##1000##3000", false); - - bean.setStringValue("3000"); - assertFieldInError("stringValue", "expression.stringNotValue##1000", true); - assertFieldInError("stringValue", "expression.stringNotValue##1000##3000", false); - } -} \ No newline at end of file Copied: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/FieldExpressionWithParamsValidatorTest.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/FieldExpressionWithParamsValidatorTest.java) =================================================================== --- trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/FieldExpressionWithParamsValidatorTest.java (rev 0) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/FieldExpressionWithParamsValidatorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,136 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator.field; + +/** @author chemit */ +public class FieldExpressionWithParamsValidatorTest extends AbstractFieldValidatorTest<FieldExpressionBean> { + + public static final String MESSAGE = "expression.too.big##100"; + public static final String MESSAGE2 = "expression.too.big##100##2000"; + + public FieldExpressionWithParamsValidatorTest() { + super(FieldExpressionBean.class); + } + + @org.junit.Test + @Override + public void testValidator() throws Exception { + + testBooleanType(); + testShortType(); + testIntType(); + testLongType(); + testDoubleType(); + testStringType(); + + + } + + protected void testBooleanType() { + + assertEquals(false, bean.isBooleanValue()); + assertFieldInError("booleanValue", "expression.boolean.not.equals##true", true); + assertFieldInError("booleanValue", "expression.boolean.not.equals##false", false); + + bean.setBooleanValue(true); + assertFieldInError("booleanValue", "expression.boolean.not.equals##true", false); + assertFieldInError("booleanValue", "expression.boolean.not.equals##false", true); + } + + protected void testShortType() { + assertEquals(0, bean.getShortValue()); + assertFieldInError("shortValue", MESSAGE, false); + assertFieldInError("shortValue", MESSAGE2, false); + bean.setShortValue((short) 10); + assertFieldInError("shortValue", MESSAGE, false); + assertFieldInError("shortValue", MESSAGE2, false); + bean.setShortValue((short) 1000); + assertFieldInError("shortValue", MESSAGE, true); + assertFieldInError("shortValue", MESSAGE2, false); + bean.setShortValue((short) 3000); + assertFieldInError("shortValue", MESSAGE, true); + assertFieldInError("shortValue", MESSAGE2, true); + } + + protected void testIntType() { + assertEquals(0, bean.getIntValue()); + assertFieldInError("intValue", MESSAGE, false); + assertFieldInError("intValue", MESSAGE2, false); + bean.setIntValue(10); + assertFieldInError("intValue", MESSAGE, false); + assertFieldInError("intValue", MESSAGE2, false); + bean.setIntValue(1000); + assertFieldInError("intValue", MESSAGE, true); + assertFieldInError("intValue", MESSAGE2, false); + bean.setIntValue(3000); + assertFieldInError("intValue", MESSAGE, true); + assertFieldInError("intValue", MESSAGE2, true); + } + + protected void testLongType() { + assertEquals(0, bean.getLongValue()); + assertFieldInError("longValue", MESSAGE, false); + assertFieldInError("longValue", MESSAGE2, false); + bean.setLongValue(10); + assertFieldInError("longValue", MESSAGE, false); + assertFieldInError("longValue", MESSAGE2, false); + bean.setLongValue(1000); + assertFieldInError("longValue", MESSAGE, true); + assertFieldInError("longValue", MESSAGE2, false); + bean.setLongValue(3000); + assertFieldInError("longValue", MESSAGE, true); + assertFieldInError("longValue", MESSAGE2, true); + } + + protected void testDoubleType() { + assertEquals(0.0, bean.getDoubleValue(), 0); + assertFieldInError("doubleValue", MESSAGE + ".0", false); + assertFieldInError("doubleValue", "expression.too.big##100.0##2000.0", false); + bean.setDoubleValue(10); + assertFieldInError("doubleValue", MESSAGE + ".0", false); + assertFieldInError("doubleValue", "expression.too.big##100.0##2000.0", false); + bean.setDoubleValue(1000); + assertFieldInError("doubleValue", MESSAGE + ".0", true); + assertFieldInError("doubleValue", "expression.too.big##100.0##2000.0", false); + bean.setDoubleValue(3000); + assertFieldInError("doubleValue", MESSAGE + ".0", true); + assertFieldInError("doubleValue", "expression.too.big##100.0##2000.0", true); + } + + protected void testStringType() { + assertEquals(null, bean.getStringValue()); + + assertFieldInError("stringValue", "expression.stringNotValue##1000", true); + assertFieldInError("stringValue", "expression.stringNotValue##1000##3000", true); + bean.setStringValue("100"); + + assertFieldInError("stringValue", "expression.stringNotValue##1000", true); + assertFieldInError("stringValue", "expression.stringNotValue##1000##3000", true); + + bean.setStringValue("1000"); + assertFieldInError("stringValue", "expression.stringNotValue##1000", false); + assertFieldInError("stringValue", "expression.stringNotValue##1000##3000", false); + + bean.setStringValue("3000"); + assertFieldInError("stringValue", "expression.stringNotValue##1000", true); + assertFieldInError("stringValue", "expression.stringNotValue##1000##3000", false); + } +} \ No newline at end of file Deleted: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/NotExistingDirectoryFieldValidatorTest.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/NotExistingDirectoryFieldValidatorTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/NotExistingDirectoryFieldValidatorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,53 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator.field; - -import java.io.File; - -/** @author chemit */ -public class NotExistingDirectoryFieldValidatorTest extends AbstractValidatorBeanFieldValidatorTest { - - @org.junit.Test - @Override - public void testValidator() throws Exception { - assertNull(bean.getNotExistingDirectory()); - assertFieldInError("notExistingDirectory", "notExistingDirectory.required", true); - - bean.setNotExistingDirectory(new File("")); - assertFieldInError("notExistingDirectory", "notExistingDirectory.required", true); - - // existing directory - bean.setNotExistingDirectory(basedir); - assertFieldInError("notExistingDirectory", "notExistingDirectory.required", false); - assertFieldInError("notExistingDirectory", "notExistingDirectory.exist", true); - - // existing file - bean.setNotExistingDirectory(new File(basedir, "pom.xml")); - assertFieldInError("notExistingDirectory", "notExistingDirectory.required", false); - assertFieldInError("notExistingDirectory", "notExistingDirectory.exist", true); - - // none existing directory - bean.setNotExistingDirectory(new File(basedir, "pom.xml-" + System.currentTimeMillis())); - assertFieldInError("notExistingDirectory", "notEexistingFile.required", false); - assertFieldInError("notExistingDirectory", "notExistingDirectory.exist", false); - } - -} \ No newline at end of file Copied: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/NotExistingDirectoryFieldValidatorTest.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/NotExistingDirectoryFieldValidatorTest.java) =================================================================== --- trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/NotExistingDirectoryFieldValidatorTest.java (rev 0) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/NotExistingDirectoryFieldValidatorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,53 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator.field; + +import java.io.File; + +/** @author chemit */ +public class NotExistingDirectoryFieldValidatorTest extends AbstractValidatorBeanFieldValidatorTest { + + @org.junit.Test + @Override + public void testValidator() throws Exception { + assertNull(bean.getNotExistingDirectory()); + assertFieldInError("notExistingDirectory", "notExistingDirectory.required", true); + + bean.setNotExistingDirectory(new File("")); + assertFieldInError("notExistingDirectory", "notExistingDirectory.required", true); + + // existing directory + bean.setNotExistingDirectory(basedir); + assertFieldInError("notExistingDirectory", "notExistingDirectory.required", false); + assertFieldInError("notExistingDirectory", "notExistingDirectory.exist", true); + + // existing file + bean.setNotExistingDirectory(new File(basedir, "pom.xml")); + assertFieldInError("notExistingDirectory", "notExistingDirectory.required", false); + assertFieldInError("notExistingDirectory", "notExistingDirectory.exist", true); + + // none existing directory + bean.setNotExistingDirectory(new File(basedir, "pom.xml-" + System.currentTimeMillis())); + assertFieldInError("notExistingDirectory", "notEexistingFile.required", false); + assertFieldInError("notExistingDirectory", "notExistingDirectory.exist", false); + } + +} \ No newline at end of file Deleted: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/NotExistingFileFieldValidatorTest.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/NotExistingFileFieldValidatorTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/NotExistingFileFieldValidatorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,57 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator.field; - -import java.io.File; - -/** @author chemit */ -public class NotExistingFileFieldValidatorTest extends AbstractValidatorBeanFieldValidatorTest { - - - @org.junit.Test - @Override - public void testValidator() throws Exception { - - assertNull(bean.getNotExistingFile()); - assertFieldInError("notExistingFile", "notExistingFile.required", true); - - bean.setNotExistingFile(new File("")); - assertFieldInError("notExistingFile", "notExistingFile.required", true); - - // existing directory - bean.setNotExistingFile(basedir); - assertFieldInError("notExistingFile", "notExistingFile.required", false); - assertFieldInError("notExistingFile", "notExistingFile.exist", true); - - // existing file - bean.setNotExistingFile(new File(basedir, "pom.xml")); - assertFieldInError("notExistingFile", "notExistingFile.required", false); - assertFieldInError("notExistingFile", "notExistingFile.exist", true); - - // none existing file - bean.setNotExistingFile(new File(basedir, "pom.xml-" + System.currentTimeMillis())); - assertFieldInError("notExistingFile", "notEexistingFile.required", false); - assertFieldInError("notExistingFile", "notExistingFile.exist", false); - - - } - -} \ No newline at end of file Copied: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/NotExistingFileFieldValidatorTest.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/NotExistingFileFieldValidatorTest.java) =================================================================== --- trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/NotExistingFileFieldValidatorTest.java (rev 0) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/NotExistingFileFieldValidatorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,57 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator.field; + +import java.io.File; + +/** @author chemit */ +public class NotExistingFileFieldValidatorTest extends AbstractValidatorBeanFieldValidatorTest { + + + @org.junit.Test + @Override + public void testValidator() throws Exception { + + assertNull(bean.getNotExistingFile()); + assertFieldInError("notExistingFile", "notExistingFile.required", true); + + bean.setNotExistingFile(new File("")); + assertFieldInError("notExistingFile", "notExistingFile.required", true); + + // existing directory + bean.setNotExistingFile(basedir); + assertFieldInError("notExistingFile", "notExistingFile.required", false); + assertFieldInError("notExistingFile", "notExistingFile.exist", true); + + // existing file + bean.setNotExistingFile(new File(basedir, "pom.xml")); + assertFieldInError("notExistingFile", "notExistingFile.required", false); + assertFieldInError("notExistingFile", "notExistingFile.exist", true); + + // none existing file + bean.setNotExistingFile(new File(basedir, "pom.xml-" + System.currentTimeMillis())); + assertFieldInError("notExistingFile", "notEexistingFile.required", false); + assertFieldInError("notExistingFile", "notExistingFile.exist", false); + + + } + +} \ No newline at end of file Deleted: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/RequiredFileFieldValidatorTest.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/RequiredFileFieldValidatorTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/RequiredFileFieldValidatorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,49 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator.field; - -import java.io.File; - -/** @author chemit */ -public class RequiredFileFieldValidatorTest extends AbstractValidatorBeanFieldValidatorTest { - - @org.junit.Test - @Override - public void testValidator() throws Exception { - - assertNull(bean.getExistingFile()); - assertFieldInError("existingFile", "existingFile.required", true); - - bean.setExistingFile(new File("")); - assertFieldInError("existingFile", "existingFile.required", true); - - bean.setExistingFile(basedir); - assertFieldInError("existingFile", "existingFile.required", false); - - assertFieldInError("existingFile", "existingFile.not.exist", true); - - bean.setExistingFile(new File(basedir, "pom.xml")); - assertFieldInError("existingFile", "existingFile.required", false); - assertFieldInError("existingFile", "existingFile.not.exist", false); - - } - -} \ No newline at end of file Copied: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/RequiredFileFieldValidatorTest.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/RequiredFileFieldValidatorTest.java) =================================================================== --- trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/RequiredFileFieldValidatorTest.java (rev 0) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/RequiredFileFieldValidatorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,49 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator.field; + +import java.io.File; + +/** @author chemit */ +public class RequiredFileFieldValidatorTest extends AbstractValidatorBeanFieldValidatorTest { + + @org.junit.Test + @Override + public void testValidator() throws Exception { + + assertNull(bean.getExistingFile()); + assertFieldInError("existingFile", "existingFile.required", true); + + bean.setExistingFile(new File("")); + assertFieldInError("existingFile", "existingFile.required", true); + + bean.setExistingFile(basedir); + assertFieldInError("existingFile", "existingFile.required", false); + + assertFieldInError("existingFile", "existingFile.not.exist", true); + + bean.setExistingFile(new File(basedir, "pom.xml")); + assertFieldInError("existingFile", "existingFile.required", false); + assertFieldInError("existingFile", "existingFile.not.exist", false); + + } + +} \ No newline at end of file Deleted: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/ValidatorBean.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/ValidatorBean.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/ValidatorBean.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,169 +0,0 @@ -/* - * *##% - * JAXX Runtime - * 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>. - * ##%* - */ -package jaxx.runtime.validator.field; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.io.File; -import java.util.Collection; - -public class ValidatorBean { - - public static class ValidatorBeanEntry { - - protected int intValue; - protected String stringValue; - protected String stringValue2; - - public ValidatorBeanEntry(int intValue, String stringValue) { - this.intValue = intValue; - this.stringValue = stringValue; - } - - public ValidatorBeanEntry(int intValue, String stringValue, String stringValue2) { - this.intValue = intValue; - this.stringValue = stringValue; - this.stringValue2 = stringValue2; - } - - public int getIntValue() { - return intValue; - } - - public void setIntValue(int intValue) { - this.intValue = intValue; - } - - public String getStringValue() { - return stringValue; - } - - public void setStringValue(String stringValue) { - this.stringValue = stringValue; - } - - public String getStringValue2() { - return stringValue2; - } - - public void setStringValue2(String stringValue2) { - this.stringValue2 = stringValue2; - } - } - protected File existingFile; - protected File notExistingFile; - protected File existingDirectory; - protected File notExistingDirectory; - protected Collection<ValidatorBeanEntry> entries; - protected String stringValue; - protected ValidatorBeanEntry entry; - PropertyChangeSupport p; - - public ValidatorBean() { - p = new PropertyChangeSupport(this); - } - - public void addPropertyChangeListener(PropertyChangeListener listener) { - p.addPropertyChangeListener(listener); - } - - public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { - p.addPropertyChangeListener(propertyName, listener); - } - - public void removePropertyChangeListener(PropertyChangeListener listener) { - p.removePropertyChangeListener(listener); - } - - public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { - p.removePropertyChangeListener(propertyName, listener); - } - - public String getStringValue() { - return stringValue; - } - - public File getExistingFile() { - return existingFile; - } - - public File getNotExistingFile() { - return notExistingFile; - } - - public File getExistingDirectory() { - return existingDirectory; - } - - public File getNotExistingDirectory() { - return notExistingDirectory; - } - - public ValidatorBeanEntry getEntry() { - return entry; - } - - public Collection<ValidatorBeanEntry> getEntries() { - return entries; - } - - public void setStringValue(String stringValue) { - String old = this.stringValue; - this.stringValue = stringValue; - p.firePropertyChange("stringValue", old, existingFile); - } - - public void setExistingFile(File existingFile) { - File old = this.existingFile; - this.existingFile = existingFile; - p.firePropertyChange("existingFile", old, existingFile); - } - - public void setNotExistingFile(File notExistingFile) { - File old = this.notExistingFile; - this.notExistingFile = notExistingFile; - p.firePropertyChange("notExistingFile", old, notExistingFile); - } - - public void setExistingDirectory(File existingDirectory) { - File old = this.existingDirectory; - this.existingDirectory = existingDirectory; - p.firePropertyChange("existingDirectory", old, existingDirectory); - } - - public void setNotExistingDirectory(File notExistingDirectory) { - File old = this.notExistingDirectory; - this.notExistingDirectory = notExistingDirectory; - p.firePropertyChange("notExistingDirectory", old, notExistingDirectory); - } - - public void setEntries(Collection<ValidatorBeanEntry> entries) { - this.entries = entries; - // set null oldValue to always fire event - // otherwise it could been not sent... - p.firePropertyChange("entries", null, entries); - } - - public void setEntry(ValidatorBeanEntry entry) { - this.entry = entry; - p.firePropertyChange("entry", null, entry); - } -} \ No newline at end of file Copied: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/ValidatorBean.java (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/ValidatorBean.java) =================================================================== --- trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/ValidatorBean.java (rev 0) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/ValidatorBean.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,169 @@ +/* + * *##% + * JAXX Runtime + * 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>. + * ##%* + */ +package jaxx.runtime.validator.field; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.io.File; +import java.util.Collection; + +public class ValidatorBean { + + public static class ValidatorBeanEntry { + + protected int intValue; + protected String stringValue; + protected String stringValue2; + + public ValidatorBeanEntry(int intValue, String stringValue) { + this.intValue = intValue; + this.stringValue = stringValue; + } + + public ValidatorBeanEntry(int intValue, String stringValue, String stringValue2) { + this.intValue = intValue; + this.stringValue = stringValue; + this.stringValue2 = stringValue2; + } + + public int getIntValue() { + return intValue; + } + + public void setIntValue(int intValue) { + this.intValue = intValue; + } + + public String getStringValue() { + return stringValue; + } + + public void setStringValue(String stringValue) { + this.stringValue = stringValue; + } + + public String getStringValue2() { + return stringValue2; + } + + public void setStringValue2(String stringValue2) { + this.stringValue2 = stringValue2; + } + } + protected File existingFile; + protected File notExistingFile; + protected File existingDirectory; + protected File notExistingDirectory; + protected Collection<ValidatorBeanEntry> entries; + protected String stringValue; + protected ValidatorBeanEntry entry; + PropertyChangeSupport p; + + public ValidatorBean() { + p = new PropertyChangeSupport(this); + } + + public void addPropertyChangeListener(PropertyChangeListener listener) { + p.addPropertyChangeListener(listener); + } + + public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { + p.addPropertyChangeListener(propertyName, listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + p.removePropertyChangeListener(listener); + } + + public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { + p.removePropertyChangeListener(propertyName, listener); + } + + public String getStringValue() { + return stringValue; + } + + public File getExistingFile() { + return existingFile; + } + + public File getNotExistingFile() { + return notExistingFile; + } + + public File getExistingDirectory() { + return existingDirectory; + } + + public File getNotExistingDirectory() { + return notExistingDirectory; + } + + public ValidatorBeanEntry getEntry() { + return entry; + } + + public Collection<ValidatorBeanEntry> getEntries() { + return entries; + } + + public void setStringValue(String stringValue) { + String old = this.stringValue; + this.stringValue = stringValue; + p.firePropertyChange("stringValue", old, existingFile); + } + + public void setExistingFile(File existingFile) { + File old = this.existingFile; + this.existingFile = existingFile; + p.firePropertyChange("existingFile", old, existingFile); + } + + public void setNotExistingFile(File notExistingFile) { + File old = this.notExistingFile; + this.notExistingFile = notExistingFile; + p.firePropertyChange("notExistingFile", old, notExistingFile); + } + + public void setExistingDirectory(File existingDirectory) { + File old = this.existingDirectory; + this.existingDirectory = existingDirectory; + p.firePropertyChange("existingDirectory", old, existingDirectory); + } + + public void setNotExistingDirectory(File notExistingDirectory) { + File old = this.notExistingDirectory; + this.notExistingDirectory = notExistingDirectory; + p.firePropertyChange("notExistingDirectory", old, notExistingDirectory); + } + + public void setEntries(Collection<ValidatorBeanEntry> entries) { + this.entries = entries; + // set null oldValue to always fire event + // otherwise it could been not sent... + p.firePropertyChange("entries", null, entries); + } + + public void setEntry(ValidatorBeanEntry entry) { + this.entry = entry; + p.firePropertyChange("entry", null, entry); + } +} \ No newline at end of file Deleted: trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-error-validation.xml =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-error-validation.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-error-validation.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,19 +0,0 @@ -<!DOCTYPE validators PUBLIC - "-//OpenSymphony Group//XWork Validator 1.0.2//EN" - "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> -<validators> - - <field name="stringValue"> - <field-validator type="requiredstring"> - <message>stringValue.error</message> - </field-validator> - </field> - - <field name="intValue"> - <field-validator type="int"> - <param name="min">1</param> - <message>intValue.error</message> - </field-validator> - </field> - -</validators> \ No newline at end of file Copied: trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-error-validation.xml (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-error-validation.xml) =================================================================== --- trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-error-validation.xml (rev 0) +++ trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-error-validation.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,19 @@ +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator 1.0.2//EN" + "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> +<validators> + + <field name="stringValue"> + <field-validator type="requiredstring"> + <message>stringValue.error</message> + </field-validator> + </field> + + <field name="intValue"> + <field-validator type="int"> + <param name="min">1</param> + <message>intValue.error</message> + </field-validator> + </field> + +</validators> \ No newline at end of file Deleted: trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-info-validation.xml =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-info-validation.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-info-validation.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,13 +0,0 @@ -<!DOCTYPE validators PUBLIC - "-//OpenSymphony Group//XWork Validator 1.0.2//EN" - "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> -<validators> - - <field name="intValue"> - <field-validator type="int"> - <param name="min">10</param> - <message>intValue.info</message> - </field-validator> - </field> - -</validators> \ No newline at end of file Copied: trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-info-validation.xml (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-info-validation.xml) =================================================================== --- trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-info-validation.xml (rev 0) +++ trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-info-validation.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,13 @@ +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator 1.0.2//EN" + "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> +<validators> + + <field name="intValue"> + <field-validator type="int"> + <param name="min">10</param> + <message>intValue.info</message> + </field-validator> + </field> + +</validators> \ No newline at end of file Deleted: trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-simple-validation.xml =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-simple-validation.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-simple-validation.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,19 +0,0 @@ -<!DOCTYPE validators PUBLIC - "-//OpenSymphony Group//XWork Validator 1.0.2//EN" - "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> -<validators> - - <field name="stringValue"> - <field-validator type="requiredstring"> - <message>stringValue.null</message> - </field-validator> - </field> - - <field name="intValue"> - <field-validator type="int"> - <param name="min">1</param> - <message>intValue.null</message> - </field-validator> - </field> - -</validators> \ No newline at end of file Copied: trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-simple-validation.xml (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-simple-validation.xml) =================================================================== --- trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-simple-validation.xml (rev 0) +++ trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-simple-validation.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,19 @@ +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator 1.0.2//EN" + "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> +<validators> + + <field name="stringValue"> + <field-validator type="requiredstring"> + <message>stringValue.null</message> + </field-validator> + </field> + + <field name="intValue"> + <field-validator type="int"> + <param name="min">1</param> + <message>intValue.null</message> + </field-validator> + </field> + +</validators> \ No newline at end of file Deleted: trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-warning-validation.xml =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-warning-validation.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-warning-validation.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,13 +0,0 @@ -<!DOCTYPE validators PUBLIC - "-//OpenSymphony Group//XWork Validator 1.0.2//EN" - "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> -<validators> - - <field name="stringValue"> - <field-validator type="fieldexpression"> - <param name="expression"><![CDATA[ stringValue != null && stringValue.length() > 5]]></param> - <message>stringValue.warning</message> - </field-validator> - </field> - -</validators> \ No newline at end of file Copied: trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-warning-validation.xml (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-warning-validation.xml) =================================================================== --- trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-warning-validation.xml (rev 0) +++ trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/SimpleBean-warning-validation.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,13 @@ +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator 1.0.2//EN" + "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> +<validators> + + <field name="stringValue"> + <field-validator type="fieldexpression"> + <param name="expression"><![CDATA[ stringValue != null && stringValue.length() > 5]]></param> + <message>stringValue.warning</message> + </field-validator> + </field> + +</validators> \ No newline at end of file Deleted: trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/field/FieldExpressionBean-error-validation.xml =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/resources/jaxx/runtime/validator/field/FieldExpressionBean-error-validation.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/field/FieldExpressionBean-error-validation.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,99 +0,0 @@ -<!DOCTYPE validators PUBLIC - "-//OpenSymphony Group//XWork Validator 1.0.2//EN" - "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> -<validators> - -<field name="booleanValue"> - <field-validator type="fieldexpressionwithparams"> - <param name="booleanParams">boolean:true</param> - <param name="expression"><![CDATA[ booleanValue == booleans.boolean]]> - </param> - <message>expression.boolean.not.equals##${booleans.boolean}</message> - </field-validator> - <field-validator type="fieldexpressionwithparams"> - <param name="booleanParams">boolean:false</param> - <param name="expression"><![CDATA[ booleanValue == booleans.boolean]]> - </param> - <message>expression.boolean.not.equals##${booleans.boolean}</message> - </field-validator> - </field> - - <field name="shortValue"> - <field-validator type="fieldexpressionwithparams"> - <param name="shortParams">short:100</param> - <param name="expression"><![CDATA[ shortValue < shorts.short]]> - </param> - <message>expression.too.big##${shorts.short}</message> - </field-validator> - <field-validator type="fieldexpressionwithparams"> - <param name="shortParams">short:100|short2:2000</param> - <param name="expression"><![CDATA[ shortValue < shorts.short || shortValue < shorts.short2]]> - </param> - <message>expression.too.big##${shorts.short}##${shorts.short2}</message> - </field-validator> - </field> - - <field name="intValue"> - <field-validator type="fieldexpressionwithparams"> - <param name="intParams">int:100</param> - <param name="expression"><![CDATA[ intValue < ints.int]]> - </param> - <message>expression.too.big##${ints.int}</message> - </field-validator> - <field-validator type="fieldexpressionwithparams"> - <param name="intParams">int:100|int2:2000</param> - <param name="expression"><![CDATA[ intValue < ints.int || intValue < ints.int2]]> - </param> - <message>expression.too.big##${ints.int}##${ints.int2}</message> - </field-validator> - </field> - - <field name="longValue"> - <field-validator type="fieldexpressionwithparams"> - <param name="longParams">long:100</param> - <param name="expression"><![CDATA[ longValue < longs.long]]> - </param> - <message>expression.too.big##${longs.long}</message> - </field-validator> - <field-validator type="fieldexpressionwithparams"> - <param name="longParams">long:100|long2:2000</param> - <param name="expression"><![CDATA[ longValue < longs.long || longValue < longs.long2]]> - </param> - <message>expression.too.big##${longs.long}##${longs.long2}</message> - </field-validator> - </field> - - <field name="doubleValue"> - <field-validator type="fieldexpressionwithparams"> - <param name="doubleParams">double:100.0</param> - <param name="expression"><![CDATA[ doubleValue < doubles.double]]> - </param> - <message>expression.too.big##${doubles.double}</message> - </field-validator> - <field-validator type="fieldexpressionwithparams"> - <param name="doubleParams">double:100.0|double2:2000.0</param> - <param name="expression"><![CDATA[ doubleValue < doubles.double || doubleValue < doubles.double2]]> - </param> - <message>expression.too.big##${doubles.double}##${doubles.double2}</message> - </field-validator> - </field> - - <field name="stringValue"> - <field-validator type="fieldexpressionwithparams"> - <param name="stringParams">string:1000</param> - <param name="expression"><![CDATA[ stringValue.equals(strings.string)]]> - </param> - <message>expression.stringNotValue##${strings.string}</message> - </field-validator> - <field-validator type="fieldexpressionwithparams"> - <param name="stringParams">string:1000|string2:3000</param> - <param name="expression"><![CDATA[ stringValue.equals(strings.string) || stringValue.equals(strings.string2)]]> - </param> - <message>expression.stringNotValue##${strings.string}##${strings.string2}</message> - </field-validator> - </field> - - - - -</validators> \ No newline at end of file Copied: trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/field/FieldExpressionBean-error-validation.xml (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/resources/jaxx/runtime/validator/field/FieldExpressionBean-error-validation.xml) =================================================================== --- trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/field/FieldExpressionBean-error-validation.xml (rev 0) +++ trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/field/FieldExpressionBean-error-validation.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,99 @@ +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator 1.0.2//EN" + "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> +<validators> + +<field name="booleanValue"> + <field-validator type="fieldexpressionwithparams"> + <param name="booleanParams">boolean:true</param> + <param name="expression"><![CDATA[ booleanValue == booleans.boolean]]> + </param> + <message>expression.boolean.not.equals##${booleans.boolean}</message> + </field-validator> + <field-validator type="fieldexpressionwithparams"> + <param name="booleanParams">boolean:false</param> + <param name="expression"><![CDATA[ booleanValue == booleans.boolean]]> + </param> + <message>expression.boolean.not.equals##${booleans.boolean}</message> + </field-validator> + </field> + + <field name="shortValue"> + <field-validator type="fieldexpressionwithparams"> + <param name="shortParams">short:100</param> + <param name="expression"><![CDATA[ shortValue < shorts.short]]> + </param> + <message>expression.too.big##${shorts.short}</message> + </field-validator> + <field-validator type="fieldexpressionwithparams"> + <param name="shortParams">short:100|short2:2000</param> + <param name="expression"><![CDATA[ shortValue < shorts.short || shortValue < shorts.short2]]> + </param> + <message>expression.too.big##${shorts.short}##${shorts.short2}</message> + </field-validator> + </field> + + <field name="intValue"> + <field-validator type="fieldexpressionwithparams"> + <param name="intParams">int:100</param> + <param name="expression"><![CDATA[ intValue < ints.int]]> + </param> + <message>expression.too.big##${ints.int}</message> + </field-validator> + <field-validator type="fieldexpressionwithparams"> + <param name="intParams">int:100|int2:2000</param> + <param name="expression"><![CDATA[ intValue < ints.int || intValue < ints.int2]]> + </param> + <message>expression.too.big##${ints.int}##${ints.int2}</message> + </field-validator> + </field> + + <field name="longValue"> + <field-validator type="fieldexpressionwithparams"> + <param name="longParams">long:100</param> + <param name="expression"><![CDATA[ longValue < longs.long]]> + </param> + <message>expression.too.big##${longs.long}</message> + </field-validator> + <field-validator type="fieldexpressionwithparams"> + <param name="longParams">long:100|long2:2000</param> + <param name="expression"><![CDATA[ longValue < longs.long || longValue < longs.long2]]> + </param> + <message>expression.too.big##${longs.long}##${longs.long2}</message> + </field-validator> + </field> + + <field name="doubleValue"> + <field-validator type="fieldexpressionwithparams"> + <param name="doubleParams">double:100.0</param> + <param name="expression"><![CDATA[ doubleValue < doubles.double]]> + </param> + <message>expression.too.big##${doubles.double}</message> + </field-validator> + <field-validator type="fieldexpressionwithparams"> + <param name="doubleParams">double:100.0|double2:2000.0</param> + <param name="expression"><![CDATA[ doubleValue < doubles.double || doubleValue < doubles.double2]]> + </param> + <message>expression.too.big##${doubles.double}##${doubles.double2}</message> + </field-validator> + </field> + + <field name="stringValue"> + <field-validator type="fieldexpressionwithparams"> + <param name="stringParams">string:1000</param> + <param name="expression"><![CDATA[ stringValue.equals(strings.string)]]> + </param> + <message>expression.stringNotValue##${strings.string}</message> + </field-validator> + <field-validator type="fieldexpressionwithparams"> + <param name="stringParams">string:1000|string2:3000</param> + <param name="expression"><![CDATA[ stringValue.equals(strings.string) || stringValue.equals(strings.string2)]]> + </param> + <message>expression.stringNotValue##${strings.string}##${strings.string2}</message> + </field-validator> + </field> + + + + +</validators> \ No newline at end of file Deleted: trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/field/ValidatorBean-error-validation.xml =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/resources/jaxx/runtime/validator/field/ValidatorBean-error-validation.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/field/ValidatorBean-error-validation.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,155 +0,0 @@ -<!DOCTYPE validators PUBLIC - "-//OpenSymphony Group//XWork Validator 1.0.2//EN" - "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> -<validators> - - <field name="stringValue"> - <field-validator type="requiredstring" short-circuit="true"> - <message>stringValue.required</message> - </field-validator> - </field> - - <field name="existingFile"> - <field-validator type="requiredFile" short-circuit="true"> - <message>existingFile.required</message> - </field-validator> - <field-validator type="existingFile" short-circuit="true"> - <message>existingFile.not.exist</message> - </field-validator> - </field> - - <field name="notExistingFile"> - <field-validator type="requiredFile" short-circuit="true"> - <message>notExistingFile.required</message> - </field-validator> - <field-validator type="notExistingFile" short-circuit="true"> - <message>notExistingFile.exist</message> - </field-validator> - </field> - - <field name="existingDirectory"> - <field-validator type="requiredFile" short-circuit="true"> - <message>existingDirectory.required</message> - </field-validator> - - <field-validator type="existingDirectory" short-circuit="true"> - <message>existingDirectory.not.exist</message> - </field-validator> - </field> - - <field name="notExistingDirectory"> - <field-validator type="requiredFile" short-circuit="true"> - <message>notExistingDirectory.required</message> - </field-validator> - - <field-validator type="notExistingDirectory" short-circuit="true"> - <message>notExistingDirectory.exist</message> - </field-validator> - </field> - - <field name="entries"> - - <field-validator type="collectionUniqueKey"> - <param name="keys">intValue</param> - <message>collectionUniqueKey.one.failed</message> - </field-validator> - <field-validator type="collectionUniqueKey"> - <param name="keys">stringValue</param> - <message>collectionUniqueKey.two.failed</message> - </field-validator> - <field-validator type="collectionUniqueKey"> - <param name="keys">intValue,stringValue</param> - <message>collectionUniqueKey.three.failed</message> - </field-validator> - <field-validator type="collectionUniqueKey"> - <param name="keys">intValue,stringValue,stringValue2</param> - <message>collectionUniqueKey.four.failed</message> - </field-validator> - <field-validator type="collectionUniqueKey"> - <param name="keys">stringValue</param> - <param name="againstProperty">entry</param> - <message>collectionUniqueKey.five.failed</message> - </field-validator> - - <field-validator type="collectionFieldExpression"> - <param name="mode">AT_LEAST_ONE</param> - <param name="expression"><![CDATA[ intValue == 0 && stringValue == "stringValue" ]]> - </param> - <message>collectionFieldExpression.atLeastOne</message> - </field-validator> - <field-validator type="collectionFieldExpression"> - <param name="mode">EXACTLY_ONE</param> - <param name="expression"><![CDATA[ intValue == 0 && stringValue == "stringValue" ]]> - </param> - <message>collectionFieldExpression.exactlyOne</message> - </field-validator> - <field-validator type="collectionFieldExpression"> - <param name="mode">ALL</param> - <param name="expression"><![CDATA[ intValue == 0 && stringValue == "stringValue" ]]> - </param> - <message>collectionFieldExpression.all</message> - </field-validator> - <field-validator type="collectionFieldExpression"> - <param name="mode">NONE</param> - <param name="expression"><![CDATA[ intValue == 0 && stringValue == "stringValue" ]]> - </param> - <message>collectionFieldExpression.none</message> - </field-validator> - - <!-- useContext --> - <field-validator type="collectionFieldExpression"> - <param name="mode">AT_LEAST_ONE</param> - <param name="useSensitiveContext">true</param> - <param name="expression"><![CDATA[ size > 1 && previous != null && previous.intValue < current.intValue]]></param> - <message>collectionFieldExpression.atLeastOne.useSensitiveContext</message> - </field-validator> - <field-validator type="collectionFieldExpression"> - <param name="mode">EXACTLY_ONE</param> - <param name="useSensitiveContext">true</param> - <param name="expression"><![CDATA[ size > 1 && previous != null && ( previous.intValue == 2 + current.intValue || current.intValue == 2 + previous.intValue) ]]></param> - <message>collectionFieldExpression.exactlyOne.useSensitiveContext</message> - </field-validator> - <field-validator type="collectionFieldExpression"> - <param name="mode">ALL</param> - <param name="useSensitiveContext">true</param> - <param name="expression"><![CDATA[ size > 1 && (previous == null || previous.intValue < current.intValue)]]></param> - <message>collectionFieldExpression.all.useSensitiveContext</message> - </field-validator> - <field-validator type="collectionFieldExpression"> - <param name="mode">NONE</param> - <param name="useSensitiveContext">true</param> - <param name="expression"><![CDATA[ size > 1 && previous != null && ( current.intValue == 2 + previous.intValue)]]></param> - <message>collectionFieldExpression.none.useSensitiveContext</message> - </field-validator> - - <!-- useFirst --> - <field-validator type="collectionFieldExpression"> - <param name="mode">ALL</param> - <param name="useSensitiveContext">true</param> - <param name="expressionForFirst"><![CDATA[ current.intValue == 0]]></param> - <param name="expression"><![CDATA[ previous == null || previous.intValue < current.intValue]]></param> - <message>collectionFieldExpression.all.useFirst</message> - </field-validator> - - <!-- useLast --> - <field-validator type="collectionFieldExpression"> - <param name="mode">ALL</param> - <param name="useSensitiveContext">true</param> - <param name="expressionForLast"><![CDATA[ current.intValue > 0]]></param> - <param name="expression"><![CDATA[ previous == null || previous.intValue < current.intValue]]></param> - <message>collectionFieldExpression.all.useLast</message> - </field-validator> - - <!-- useFirstAndLast --> - <field-validator type="collectionFieldExpression"> - <param name="mode">ALL</param> - <param name="useSensitiveContext">true</param> - <param name="expressionForFirst"><![CDATA[ current.intValue == 0]]></param> - <param name="expressionForLast"><![CDATA[ current.intValue > 0]]></param> - <param name="expression"><![CDATA[ previous == null || previous.intValue < current.intValue]]></param> - <message>collectionFieldExpression.all.useFirstAndLast</message> - </field-validator> - - </field> - -</validators> \ No newline at end of file Copied: trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/field/ValidatorBean-error-validation.xml (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/resources/jaxx/runtime/validator/field/ValidatorBean-error-validation.xml) =================================================================== --- trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/field/ValidatorBean-error-validation.xml (rev 0) +++ trunk/jaxx-runtime/src/test/resources/jaxx/runtime/validator/field/ValidatorBean-error-validation.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,155 @@ +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator 1.0.2//EN" + "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> +<validators> + + <field name="stringValue"> + <field-validator type="requiredstring" short-circuit="true"> + <message>stringValue.required</message> + </field-validator> + </field> + + <field name="existingFile"> + <field-validator type="requiredFile" short-circuit="true"> + <message>existingFile.required</message> + </field-validator> + <field-validator type="existingFile" short-circuit="true"> + <message>existingFile.not.exist</message> + </field-validator> + </field> + + <field name="notExistingFile"> + <field-validator type="requiredFile" short-circuit="true"> + <message>notExistingFile.required</message> + </field-validator> + <field-validator type="notExistingFile" short-circuit="true"> + <message>notExistingFile.exist</message> + </field-validator> + </field> + + <field name="existingDirectory"> + <field-validator type="requiredFile" short-circuit="true"> + <message>existingDirectory.required</message> + </field-validator> + + <field-validator type="existingDirectory" short-circuit="true"> + <message>existingDirectory.not.exist</message> + </field-validator> + </field> + + <field name="notExistingDirectory"> + <field-validator type="requiredFile" short-circuit="true"> + <message>notExistingDirectory.required</message> + </field-validator> + + <field-validator type="notExistingDirectory" short-circuit="true"> + <message>notExistingDirectory.exist</message> + </field-validator> + </field> + + <field name="entries"> + + <field-validator type="collectionUniqueKey"> + <param name="keys">intValue</param> + <message>collectionUniqueKey.one.failed</message> + </field-validator> + <field-validator type="collectionUniqueKey"> + <param name="keys">stringValue</param> + <message>collectionUniqueKey.two.failed</message> + </field-validator> + <field-validator type="collectionUniqueKey"> + <param name="keys">intValue,stringValue</param> + <message>collectionUniqueKey.three.failed</message> + </field-validator> + <field-validator type="collectionUniqueKey"> + <param name="keys">intValue,stringValue,stringValue2</param> + <message>collectionUniqueKey.four.failed</message> + </field-validator> + <field-validator type="collectionUniqueKey"> + <param name="keys">stringValue</param> + <param name="againstProperty">entry</param> + <message>collectionUniqueKey.five.failed</message> + </field-validator> + + <field-validator type="collectionFieldExpression"> + <param name="mode">AT_LEAST_ONE</param> + <param name="expression"><![CDATA[ intValue == 0 && stringValue == "stringValue" ]]> + </param> + <message>collectionFieldExpression.atLeastOne</message> + </field-validator> + <field-validator type="collectionFieldExpression"> + <param name="mode">EXACTLY_ONE</param> + <param name="expression"><![CDATA[ intValue == 0 && stringValue == "stringValue" ]]> + </param> + <message>collectionFieldExpression.exactlyOne</message> + </field-validator> + <field-validator type="collectionFieldExpression"> + <param name="mode">ALL</param> + <param name="expression"><![CDATA[ intValue == 0 && stringValue == "stringValue" ]]> + </param> + <message>collectionFieldExpression.all</message> + </field-validator> + <field-validator type="collectionFieldExpression"> + <param name="mode">NONE</param> + <param name="expression"><![CDATA[ intValue == 0 && stringValue == "stringValue" ]]> + </param> + <message>collectionFieldExpression.none</message> + </field-validator> + + <!-- useContext --> + <field-validator type="collectionFieldExpression"> + <param name="mode">AT_LEAST_ONE</param> + <param name="useSensitiveContext">true</param> + <param name="expression"><![CDATA[ size > 1 && previous != null && previous.intValue < current.intValue]]></param> + <message>collectionFieldExpression.atLeastOne.useSensitiveContext</message> + </field-validator> + <field-validator type="collectionFieldExpression"> + <param name="mode">EXACTLY_ONE</param> + <param name="useSensitiveContext">true</param> + <param name="expression"><![CDATA[ size > 1 && previous != null && ( previous.intValue == 2 + current.intValue || current.intValue == 2 + previous.intValue) ]]></param> + <message>collectionFieldExpression.exactlyOne.useSensitiveContext</message> + </field-validator> + <field-validator type="collectionFieldExpression"> + <param name="mode">ALL</param> + <param name="useSensitiveContext">true</param> + <param name="expression"><![CDATA[ size > 1 && (previous == null || previous.intValue < current.intValue)]]></param> + <message>collectionFieldExpression.all.useSensitiveContext</message> + </field-validator> + <field-validator type="collectionFieldExpression"> + <param name="mode">NONE</param> + <param name="useSensitiveContext">true</param> + <param name="expression"><![CDATA[ size > 1 && previous != null && ( current.intValue == 2 + previous.intValue)]]></param> + <message>collectionFieldExpression.none.useSensitiveContext</message> + </field-validator> + + <!-- useFirst --> + <field-validator type="collectionFieldExpression"> + <param name="mode">ALL</param> + <param name="useSensitiveContext">true</param> + <param name="expressionForFirst"><![CDATA[ current.intValue == 0]]></param> + <param name="expression"><![CDATA[ previous == null || previous.intValue < current.intValue]]></param> + <message>collectionFieldExpression.all.useFirst</message> + </field-validator> + + <!-- useLast --> + <field-validator type="collectionFieldExpression"> + <param name="mode">ALL</param> + <param name="useSensitiveContext">true</param> + <param name="expressionForLast"><![CDATA[ current.intValue > 0]]></param> + <param name="expression"><![CDATA[ previous == null || previous.intValue < current.intValue]]></param> + <message>collectionFieldExpression.all.useLast</message> + </field-validator> + + <!-- useFirstAndLast --> + <field-validator type="collectionFieldExpression"> + <param name="mode">ALL</param> + <param name="useSensitiveContext">true</param> + <param name="expressionForFirst"><![CDATA[ current.intValue == 0]]></param> + <param name="expressionForLast"><![CDATA[ current.intValue > 0]]></param> + <param name="expression"><![CDATA[ previous == null || previous.intValue < current.intValue]]></param> + <message>collectionFieldExpression.all.useFirstAndLast</message> + </field-validator> + + </field> + +</validators> \ No newline at end of file Deleted: trunk/jaxx-runtime/src/test/resources/log4j.properties =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/resources/log4j.properties 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/resources/log4j.properties 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,8 +0,0 @@ -# Global logging configuration -log4j.rootLogger=ERROR, stdout -# Console output... -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n - -log4j.logger.jaxx=INFO Copied: trunk/jaxx-runtime/src/test/resources/log4j.properties (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/resources/log4j.properties) =================================================================== --- trunk/jaxx-runtime/src/test/resources/log4j.properties (rev 0) +++ trunk/jaxx-runtime/src/test/resources/log4j.properties 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,8 @@ +# Global logging configuration +log4j.rootLogger=ERROR, stdout +# Console output... +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n + +log4j.logger.jaxx=INFO Deleted: trunk/jaxx-runtime/src/test/resources/validators.xml =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/resources/validators.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-runtime/src/test/resources/validators.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,36 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE validators PUBLIC - "-//OpenSymphony Group//XWork Validator Config 1.0//EN" - "http://www.opensymphony.com/xwork/xwork-validator-config-1.0.dtd"> -<validators> - <!-- default validators from XWork framework --> - <validator name="required" class="com.opensymphony.xwork2.validator.validators.RequiredFieldValidator"/> - <validator name="requiredstring" class="com.opensymphony.xwork2.validator.validators.RequiredStringValidator"/> - <validator name="int" class="com.opensymphony.xwork2.validator.validators.IntRangeFieldValidator"/> - <validator name="long" class="com.opensymphony.xwork2.validator.validators.LongRangeFieldValidator"/> - <validator name="short" class="com.opensymphony.xwork2.validator.validators.ShortRangeFieldValidator"/> - <validator name="double" class="com.opensymphony.xwork2.validator.validators.DoubleRangeFieldValidator"/> - <validator name="date" class="com.opensymphony.xwork2.validator.validators.DateRangeFieldValidator"/> - <validator name="expression" class="com.opensymphony.xwork2.validator.validators.ExpressionValidator"/> - <validator name="fieldexpression" class="com.opensymphony.xwork2.validator.validators.FieldExpressionValidator"/> - <validator name="email" class="com.opensymphony.xwork2.validator.validators.EmailValidator"/> - <validator name="url" class="com.opensymphony.xwork2.validator.validators.URLValidator"/> - <validator name="visitor" class="com.opensymphony.xwork2.validator.validators.VisitorFieldValidator"/> - <validator name="conversion" class="com.opensymphony.xwork2.validator.validators.ConversionErrorFieldValidator"/> - <validator name="stringlength" class="com.opensymphony.xwork2.validator.validators.StringLengthFieldValidator"/> - <validator name="regex" class="com.opensymphony.xwork2.validator.validators.RegexFieldValidator"/> - <validator name="conditionalvisitor" - class="com.opensymphony.xwork2.validator.validators.ConditionalVisitorFieldValidator"/> - - <!-- jaxx validators --> - <validator name="collectionFieldExpression" - class="jaxx.runtime.validator.field.CollectionFieldExpressionValidator"/> - <validator name="collectionUniqueKey" class="jaxx.runtime.validator.field.CollectionUniqueKeyValidator"/> - <validator name="requiredFile" class="jaxx.runtime.validator.field.RequiredFileFieldValidator"/> - <validator name="existingFile" class="jaxx.runtime.validator.field.ExistingFileFieldValidator"/> - <validator name="notExistingFile" class="jaxx.runtime.validator.field.NotExistingFileFieldValidator"/> - <validator name="existingDirectory" class="jaxx.runtime.validator.field.ExistingDirectoryFieldValidator"/> - <validator name="notExistingDirectory" class="jaxx.runtime.validator.field.NotExistingDirectoryFieldValidator"/> - <validator name="fieldexpressionwithparams" class="jaxx.runtime.validator.field.FieldExpressionWithParamsValidator"/> - -</validators> \ No newline at end of file Copied: trunk/jaxx-runtime/src/test/resources/validators.xml (from rev 1672, branches/jaxx-2.X/jaxx-runtime/src/test/resources/validators.xml) =================================================================== --- trunk/jaxx-runtime/src/test/resources/validators.xml (rev 0) +++ trunk/jaxx-runtime/src/test/resources/validators.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator Config 1.0//EN" + "http://www.opensymphony.com/xwork/xwork-validator-config-1.0.dtd"> +<validators> + <!-- default validators from XWork framework --> + <validator name="required" class="com.opensymphony.xwork2.validator.validators.RequiredFieldValidator"/> + <validator name="requiredstring" class="com.opensymphony.xwork2.validator.validators.RequiredStringValidator"/> + <validator name="int" class="com.opensymphony.xwork2.validator.validators.IntRangeFieldValidator"/> + <validator name="long" class="com.opensymphony.xwork2.validator.validators.LongRangeFieldValidator"/> + <validator name="short" class="com.opensymphony.xwork2.validator.validators.ShortRangeFieldValidator"/> + <validator name="double" class="com.opensymphony.xwork2.validator.validators.DoubleRangeFieldValidator"/> + <validator name="date" class="com.opensymphony.xwork2.validator.validators.DateRangeFieldValidator"/> + <validator name="expression" class="com.opensymphony.xwork2.validator.validators.ExpressionValidator"/> + <validator name="fieldexpression" class="com.opensymphony.xwork2.validator.validators.FieldExpressionValidator"/> + <validator name="email" class="com.opensymphony.xwork2.validator.validators.EmailValidator"/> + <validator name="url" class="com.opensymphony.xwork2.validator.validators.URLValidator"/> + <validator name="visitor" class="com.opensymphony.xwork2.validator.validators.VisitorFieldValidator"/> + <validator name="conversion" class="com.opensymphony.xwork2.validator.validators.ConversionErrorFieldValidator"/> + <validator name="stringlength" class="com.opensymphony.xwork2.validator.validators.StringLengthFieldValidator"/> + <validator name="regex" class="com.opensymphony.xwork2.validator.validators.RegexFieldValidator"/> + <validator name="conditionalvisitor" + class="com.opensymphony.xwork2.validator.validators.ConditionalVisitorFieldValidator"/> + + <!-- jaxx validators --> + <validator name="collectionFieldExpression" + class="jaxx.runtime.validator.field.CollectionFieldExpressionValidator"/> + <validator name="collectionUniqueKey" class="jaxx.runtime.validator.field.CollectionUniqueKeyValidator"/> + <validator name="requiredFile" class="jaxx.runtime.validator.field.RequiredFileFieldValidator"/> + <validator name="existingFile" class="jaxx.runtime.validator.field.ExistingFileFieldValidator"/> + <validator name="notExistingFile" class="jaxx.runtime.validator.field.NotExistingFileFieldValidator"/> + <validator name="existingDirectory" class="jaxx.runtime.validator.field.ExistingDirectoryFieldValidator"/> + <validator name="notExistingDirectory" class="jaxx.runtime.validator.field.NotExistingDirectoryFieldValidator"/> + <validator name="fieldexpressionwithparams" class="jaxx.runtime.validator.field.FieldExpressionWithParamsValidator"/> + +</validators> \ No newline at end of file Property changes on: trunk/jaxx-swing-action ___________________________________________________________________ Modified: svn:ignore - target + target *.iml *.ipr *.iws Modified: trunk/jaxx-swing-action/pom.xml =================================================================== --- trunk/jaxx-swing-action/pom.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/pom.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -11,7 +11,7 @@ <parent> <groupId>org.nuiton</groupId> <artifactId>jaxx</artifactId> - <version>1.7.2-SNAPSHOT</version> + <version>2.0.0-beta-3-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 :: Swing-Action</name> + <description>JAXX Action framework</description> <!-- ************************************************************* --> <!-- *** Build Settings ****************************************** --> Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/AbstractActionConfigurationResolver.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/AbstractActionConfigurationResolver.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/AbstractActionConfigurationResolver.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /** * ##% Copyright (C) 2008 Code Lutin, Tony Chemit * This program is free software; you Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionAnnotationProcessing.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionAnnotationProcessing.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionAnnotationProcessing.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /** * ##% Copyright (C) 2008 Code Lutin, Tony Chemit * This program is free software; you Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionConfig.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionConfig.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionConfig.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /* * ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin, * Tony Chemit, Gabriel Landais Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionConfigConfigurationResolver.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionConfigConfigurationResolver.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionConfigConfigurationResolver.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /** * ##% Copyright (C) 2008 Code Lutin, Tony Chemit * This program is free software; you Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionConfigurationResolver.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionConfigurationResolver.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionConfigurationResolver.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /** * ##% Copyright (C) 2008 Code Lutin, Tony Chemit * This program is free software; you Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionFactory.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionFactory.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionFactory.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /** * ##% Copyright (C) 2008 Code Lutin, Tony Chemit * This program is free software; you Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionFactoryFromProvider.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionFactoryFromProvider.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionFactoryFromProvider.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /* * ##% Copyright (C) 2007, 2008 Code Lutin, Tony Chemit * Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionNameProvider.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionNameProvider.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionNameProvider.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /** * ##% Copyright (C) 2008 Code Lutin, Tony Chemit * This program is free software; you Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionProvider.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionProvider.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionProvider.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /** * ##% Copyright (C) 2008 Code Lutin, Tony Chemit * This program is free software; you Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionProviderAnnotation.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionProviderAnnotation.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionProviderAnnotation.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /** * ##% Copyright (C) 2008 Code Lutin, Tony Chemit * This program is free software; you Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionProviderFromProperties.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionProviderFromProperties.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ActionProviderFromProperties.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /** * ##% Copyright (C) 2008 Code Lutin, Tony Chemit * This program is free software; you Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/MyAbstractAction.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/MyAbstractAction.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/MyAbstractAction.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /** * ##% Copyright (C) 2008 Code Lutin, Tony Chemit * This program is free software; you Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/SelectActionConfig.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/SelectActionConfig.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/SelectActionConfig.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /* * ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin, * Tony Chemit, Gabriel Landais Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/SelectActionConfigConfigurationResolver.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/SelectActionConfigConfigurationResolver.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/SelectActionConfigConfigurationResolver.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /** * ##% Copyright (C) 2008 Code Lutin, Tony Chemit * This program is free software; you Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ToggleActionConfig.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ToggleActionConfig.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ToggleActionConfig.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /* * ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin, * Tony Chemit, Gabriel Landais Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ToggleActionConfigConfigurationResolver.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ToggleActionConfigConfigurationResolver.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/action/ToggleActionConfigConfigurationResolver.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /** * ##% Copyright (C) 2008 Code Lutin, Tony Chemit * This program is free software; you Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/tab/TabContentConfig.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/tab/TabContentConfig.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/tab/TabContentConfig.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /* * ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin, * Tony Chemit, Gabriel Landais Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/tab/TabFactory.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/tab/TabFactory.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/tab/TabFactory.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /* * \#\#% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin, * Tony Chemit Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/tab/TabModel.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/tab/TabModel.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/tab/TabModel.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /* * ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin, * Tony Chemit Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/AbstractUIAction.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/AbstractUIAction.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/AbstractUIAction.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /** * ##% Copyright (C) 2008 Code Lutin, Tony Chemit * This program is free software; you Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/DialogUI.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/DialogUI.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/DialogUI.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /** * ##% Copyright (C) 2008 Code Lutin, Tony Chemit * This program is free software; you Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/DialogUIDef.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/DialogUIDef.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/DialogUIDef.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /** * ##% Copyright (C) 2008 Code Lutin, Tony Chemit * This program is free software; you Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/DialogUIHandler.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/DialogUIHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/DialogUIHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /** * ##% Copyright (C) 2008 Code Lutin, Tony Chemit * This program is free software; you Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/DialogUIModel.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/DialogUIModel.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/DialogUIModel.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /** * ##% Copyright (C) 2008 Code Lutin, Tony Chemit * This program is free software; you Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/FactoryWindowListener.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/FactoryWindowListener.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/FactoryWindowListener.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /** * ##% Copyright (C) 2008 Code Lutin, Tony Chemit * This program is free software; you Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/FormElement.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/FormElement.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/FormElement.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /** * ##% Copyright (C) 2008 Code Lutin, Tony Chemit * This program is free software; you Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/ShowUIAction.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/ShowUIAction.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/ShowUIAction.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /** * ##% Copyright (C) 2008 Code Lutin, Tony Chemit * This program is free software; you Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/UIFactory.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/UIFactory.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/UIFactory.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /** /** * ##% Copyright (C) 2008 Code Lutin, Tony Chemit Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/UIHelper.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/UIHelper.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/UIHelper.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /* * ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin, * Tony Chemit Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/UIProvider.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/UIProvider.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/UIProvider.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /** * ##% Copyright (C) 2008 Code Lutin, Tony Chemit * This program is free software; you Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/config/CancelAction.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/config/CancelAction.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/config/CancelAction.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /** * ##% Copyright (C) 2008 Code Lutin, Tony Chemit * This program is free software; you Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/config/DialogConfigUI.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/config/DialogConfigUI.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/config/DialogConfigUI.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /** * ##% Copyright (C) 2008 Code Lutin, Tony Chemit * This program is free software; you Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/config/DialogConfigUIHandler.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/config/DialogConfigUIHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/config/DialogConfigUIHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /** * ##% Copyright (C) 2008 Code Lutin, Tony Chemit * This program is free software; you Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/config/DialogConfigUIModel.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/config/DialogConfigUIModel.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/config/DialogConfigUIModel.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /** * ##% Copyright (C) 2008 Code Lutin, Tony Chemit * This program is free software; you Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/config/ResetAction.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/config/ResetAction.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/config/ResetAction.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /** * ##% Copyright (C) 2008 Code Lutin, Tony Chemit * This program is free software; you Modified: trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/config/SaveAction.java =================================================================== --- trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/config/SaveAction.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-swing-action/src/main/java/org/nuiton/jaxx/util/config/SaveAction.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Action + * 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>. + * ##%* + */ /** * ##% Copyright (C) 2008 Code Lutin, Tony Chemit * This program is free software; you Property changes on: trunk/jaxx-widgets ___________________________________________________________________ Added: svn:ignore + velocity.log target nbactions.xml nbproject *.iml *.ipr *.iws Added: svn:mergeinfo + Deleted: trunk/jaxx-widgets/LICENSE.txt =================================================================== --- branches/jaxx-2.X/jaxx-widgets/LICENSE.txt 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/LICENSE.txt 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,166 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. - Copied: trunk/jaxx-widgets/LICENSE.txt (from rev 1672, branches/jaxx-2.X/jaxx-widgets/LICENSE.txt) =================================================================== --- trunk/jaxx-widgets/LICENSE.txt (rev 0) +++ trunk/jaxx-widgets/LICENSE.txt 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,166 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. + Deleted: trunk/jaxx-widgets/README.txt =================================================================== --- branches/jaxx-2.X/jaxx-widgets/README.txt 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/README.txt 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,2 +0,0 @@ -To deploy new version of pom: mvn deploy -To install localy: mvn install Copied: trunk/jaxx-widgets/README.txt (from rev 1672, branches/jaxx-2.X/jaxx-widgets/README.txt) =================================================================== --- trunk/jaxx-widgets/README.txt (rev 0) +++ trunk/jaxx-widgets/README.txt 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,2 @@ +To deploy new version of pom: mvn deploy +To install localy: mvn install Deleted: trunk/jaxx-widgets/changelog.txt =================================================================== --- branches/jaxx-2.X/jaxx-widgets/changelog.txt 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/changelog.txt 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,5 +0,0 @@ -1.6.0 - * introduce StatusMessageBar and AboutPanel (fork from nuiton-widgets but in JAXX :)) - -1.5 - * 20090404 [chemit] - initial version Copied: trunk/jaxx-widgets/changelog.txt (from rev 1672, branches/jaxx-2.X/jaxx-widgets/changelog.txt) =================================================================== --- trunk/jaxx-widgets/changelog.txt (rev 0) +++ trunk/jaxx-widgets/changelog.txt 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,5 @@ +1.6.0 + * introduce StatusMessageBar and AboutPanel (fork from nuiton-widgets but in JAXX :)) + +1.5 + * 20090404 [chemit] - initial version Deleted: trunk/jaxx-widgets/pom.xml =================================================================== --- branches/jaxx-2.X/jaxx-widgets/pom.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/pom.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,120 +0,0 @@ - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - - <modelVersion>4.0.0</modelVersion> - - <!-- ************************************************************* --> - <!-- *** POM Relationships *************************************** --> - <!-- ************************************************************* --> - - <parent> - <groupId>org.nuiton</groupId> - <artifactId>jaxx</artifactId> - <version>2.0.0-beta-3-SNAPSHOT</version> - </parent> - - <groupId>org.nuiton.jaxx</groupId> - <artifactId>jaxx-widgets</artifactId> - - <dependencies> - - <!-- sibiling dependencies --> - - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>jaxx-runtime</artifactId> - <version>${project.version}</version> - </dependency> - - <dependency> - <groupId>org.swinglabs</groupId> - <artifactId>swingx</artifactId> - </dependency> - - <dependency> - <groupId>org.swinglabs</groupId> - <artifactId>swing-worker</artifactId> - </dependency> - - <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - </dependency> - - </dependencies> - - <!-- ************************************************************* --> - <!-- *** Project Information ************************************* --> - <!-- ************************************************************* --> - - <name>JAXX :: Widgets</name> - <description>Collection of swing widgets wrote with JAXX</description> - - <!-- ************************************************************* --> - <!-- *** Build Settings ****************************************** --> - <!-- ************************************************************* --> - - <packaging>jar</packaging> - - <properties> - <jaxx.addSourcesToClassPath>true</jaxx.addSourcesToClassPath> - <!--jaxx.useUIManagerForIcon>true</jaxx.useUIManagerForIcon--> - </properties> - - <build> - - <resources> - <!-- TC20091016 do not expose jaxx files --> - <!--resource> - <directory>src/main/java</directory> - <includes> - <include>**/*.jaxx</include> - </includes> - </resource--> - <resource> - <directory>src/main/resources</directory> - <includes> - <include>**/*</include> - </includes> - </resource> - </resources> - - <plugins> - - <plugin> - <groupId>${project.groupId}</groupId> - <artifactId>maven-jaxx-plugin</artifactId> - <version>${project.version}</version> - <executions> - <execution> - <goals> - <goal>generate</goal> - </goals> - </execution> - </executions> - </plugin> - - <plugin> - <groupId>org.nuiton.i18n</groupId> - <artifactId>maven-i18n-plugin</artifactId> - <configuration> - <entries> - <entry> - <basedir>${maven.gen.dir}/java</basedir> - </entry> - </entries> - </configuration> - <executions> - <execution> - <goals> - <goal>parserJava</goal> - <goal>gen</goal> - </goals> - </execution> - </executions> - </plugin> - - </plugins> - </build> - -</project> \ No newline at end of file Copied: trunk/jaxx-widgets/pom.xml (from rev 1672, branches/jaxx-2.X/jaxx-widgets/pom.xml) =================================================================== --- trunk/jaxx-widgets/pom.xml (rev 0) +++ trunk/jaxx-widgets/pom.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,120 @@ + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <!-- ************************************************************* --> + <!-- *** POM Relationships *************************************** --> + <!-- ************************************************************* --> + + <parent> + <groupId>org.nuiton</groupId> + <artifactId>jaxx</artifactId> + <version>2.0.0-beta-3-SNAPSHOT</version> + </parent> + + <groupId>org.nuiton.jaxx</groupId> + <artifactId>jaxx-widgets</artifactId> + + <dependencies> + + <!-- sibiling dependencies --> + + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>jaxx-runtime</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.swinglabs</groupId> + <artifactId>swingx</artifactId> + </dependency> + + <dependency> + <groupId>org.swinglabs</groupId> + <artifactId>swing-worker</artifactId> + </dependency> + + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </dependency> + + </dependencies> + + <!-- ************************************************************* --> + <!-- *** Project Information ************************************* --> + <!-- ************************************************************* --> + + <name>JAXX :: Widgets</name> + <description>Collection of swing widgets wrote with JAXX</description> + + <!-- ************************************************************* --> + <!-- *** Build Settings ****************************************** --> + <!-- ************************************************************* --> + + <packaging>jar</packaging> + + <properties> + <jaxx.addSourcesToClassPath>true</jaxx.addSourcesToClassPath> + <!--jaxx.useUIManagerForIcon>true</jaxx.useUIManagerForIcon--> + </properties> + + <build> + + <resources> + <!-- TC20091016 do not expose jaxx files --> + <!--resource> + <directory>src/main/java</directory> + <includes> + <include>**/*.jaxx</include> + </includes> + </resource--> + <resource> + <directory>src/main/resources</directory> + <includes> + <include>**/*</include> + </includes> + </resource> + </resources> + + <plugins> + + <plugin> + <groupId>${project.groupId}</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <version>${project.version}</version> + <executions> + <execution> + <goals> + <goal>generate</goal> + </goals> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.nuiton.i18n</groupId> + <artifactId>maven-i18n-plugin</artifactId> + <configuration> + <entries> + <entry> + <basedir>${maven.gen.dir}/java</basedir> + </entry> + </entries> + </configuration> + <executions> + <execution> + <goals> + <goal>parserJava</goal> + <goal>gen</goal> + </goals> + </execution> + </executions> + </plugin> + + </plugins> + </build> + +</project> \ No newline at end of file Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/AboutPanel.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/AboutPanel.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/AboutPanel.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,223 +0,0 @@ -<!-- - -/** - * *##% jaxx-runtime-swing-widget - * 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>. ##%* - */ - ---> -<Table insets='1' - background='{getBackgroundColor()}' - border='{BorderFactory.createLineBorder(Color.BLACK, 1)}'> - -<String id='title' javaBean='null'/> - -<String id='iconPath' javaBean='null'/> - -<String id='aboutText' javaBean='null'/> - -<String id='bottomText' javaBean='null'/> - -<String id='licenseText' javaBean='null'/> - -<String id='thirdpartyText' javaBean='null'/> - -<Color id='backgroundColor' javaBean='null'/> - - <script><![CDATA[ -import org.nuiton.util.Resource; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; -import org.apache.commons.io.IOUtils; - -final Action closeAction = new AbstractAction("close") { - private static final long serialVersionUID = 1L; - - @Override - public void actionPerformed(ActionEvent e) { - JDialog container = getParentContainer(JDialog.class); - if (container != null) { - container.dispose(); - } else { - setVisible(false); - } - } -}; - -public void setLicenseFile(String filename) { - String load = load(filename); - setLicenseText(load); -} - -public void setThirdpartyFile(String filename) { - String load = load(filename); - setThirdpartyText(load); -} - -public void buildTopPanel() { - // image - JLabel labelIcon; - if (iconPath != null) { - Icon logoIcon = Resource.getIcon(iconPath); - labelIcon = new JLabel(logoIcon); - } else { - labelIcon = new JLabel(); - } - topPanel.add(labelIcon); -} - -public void init() { - if (getAboutText() == null) { - tabs.remove(aboutContent); - } - if (getLicenseText() == null) { - tabs.remove(licenseContent); - } else { - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - licenseTextArea.setCaretPosition(0); - } - }); - - } - if (getThirdpartyText() == null) { - tabs.remove(thirdpartyContent); - } else { - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - thirdpartyTextArea.setCaretPosition(0); - } - }); - } -} - -public void showInDialog(Frame ui, boolean undecorated) { - JDialog f = new JDialog(ui, true); - f.add(this); - if (iconPath != null) { - f.setIconImage(SwingUtil.createIcon(iconPath).getImage()); - } - f.setResizable(false); - f.setSize(550, 450); - f.setUndecorated(undecorated); - JRootPane rootPane = f.getRootPane(); - rootPane.setDefaultButton(close); - rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close"); - rootPane.getActionMap().put("close", closeAction); - SwingUtil.center(ui, f); - f.setVisible(true); -} - -protected String load(String filename) { - InputStream licenseStream = getClass().getResourceAsStream("/" + filename); - String result = null; - try { - if (licenseStream != null) { - result = IOUtils.toString(licenseStream); - } - } catch (IOException ex) { - // ignore it - } finally { - if (licenseStream != null) { - try { - licenseStream.close(); - } catch (IOException ex) { - log.error("could not close file " + filename); - } - } - } - if (result == null) { - result = "resource " + filename + " not found"; - } - return result; -} - -void $afterCompleteSetup() { - buildTopPanel(); - close.setText(_("aboutframe.ok")); -} - -]]> - </script> - <row> - <cell weightx='1' fill='both'> - <JPanel background='{Color.WHITE}' layout='{new BorderLayout()}'> - <JLabel text='{SwingUtil.getStringValue(getTitle())}' - visible='{getTitle() != null}' - font-size='12' - constraints='BorderLayout.CENTER'/> - </JPanel> - </cell> - </row> - <row> - <cell weightx='1' fill='both'> - <JPanel id='topPanel'/> - </cell> - </row> - <row> - <cell weighty='1' fill='both'> - <JTabbedPane id='tabs'> - <tab title="aboutframe.about"> - <JScrollPane id='aboutContent' border='{null}'> - <JEditorPane contentType='text/html' - editable='false' - border='{null}' - text='{SwingUtil.getStringValue(getAboutText())}' - onHyperlinkUpdate='SwingUtil.openLink(event)'/> - </JScrollPane> - </tab> - <tab title="aboutframe.license"> - <JScrollPane id='licenseContent' border='{null}'> - <JTextArea id='licenseTextArea' - editable='false' - font-size='11' - border='{null}' - text='{SwingUtil.getStringValue(getLicenseText())}'/> - </JScrollPane> - </tab> - <tab title="aboutframe.thirdparty"> - <JScrollPane id='thirdpartyContent' border='{null}'> - <JTextArea id='thirdpartyTextArea' - editable='false' - font-size='11' - border='{null}' - text='{SwingUtil.getStringValue(getThirdpartyText())}'/> - </JScrollPane> - </tab> - </JTabbedPane> - </cell> - </row> - <row> - <cell fill='both'> - <JPanel layout='{new BorderLayout()}'> - <JLabel id='bottomLabel' - constraints='BorderLayout.CENTER' - horizontalAlignment='{SwingConstants.CENTER}' - text='{SwingUtil.getStringValue(getBottomText())}' - visible='{getBottomText() != null}'/> - <JButton id='close' action='{closeAction}' constraints='BorderLayout.EAST'/> - </JPanel> - </cell> - </row> - -</Table> Copied: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/AboutPanel.jaxx (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/AboutPanel.jaxx) =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/AboutPanel.jaxx (rev 0) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/AboutPanel.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,223 @@ +<!-- + +/** + * *##% jaxx-runtime-swing-widget + * 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>. ##%* + */ + +--> +<Table insets='1' + background='{getBackgroundColor()}' + border='{BorderFactory.createLineBorder(Color.BLACK, 1)}'> + +<String id='title' javaBean='null'/> + +<String id='iconPath' javaBean='null'/> + +<String id='aboutText' javaBean='null'/> + +<String id='bottomText' javaBean='null'/> + +<String id='licenseText' javaBean='null'/> + +<String id='thirdpartyText' javaBean='null'/> + +<Color id='backgroundColor' javaBean='null'/> + + <script><![CDATA[ +import org.nuiton.util.Resource; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import org.apache.commons.io.IOUtils; + +final Action closeAction = new AbstractAction("close") { + private static final long serialVersionUID = 1L; + + @Override + public void actionPerformed(ActionEvent e) { + JDialog container = getParentContainer(JDialog.class); + if (container != null) { + container.dispose(); + } else { + setVisible(false); + } + } +}; + +public void setLicenseFile(String filename) { + String load = load(filename); + setLicenseText(load); +} + +public void setThirdpartyFile(String filename) { + String load = load(filename); + setThirdpartyText(load); +} + +public void buildTopPanel() { + // image + JLabel labelIcon; + if (iconPath != null) { + Icon logoIcon = Resource.getIcon(iconPath); + labelIcon = new JLabel(logoIcon); + } else { + labelIcon = new JLabel(); + } + topPanel.add(labelIcon); +} + +public void init() { + if (getAboutText() == null) { + tabs.remove(aboutContent); + } + if (getLicenseText() == null) { + tabs.remove(licenseContent); + } else { + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + licenseTextArea.setCaretPosition(0); + } + }); + + } + if (getThirdpartyText() == null) { + tabs.remove(thirdpartyContent); + } else { + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + thirdpartyTextArea.setCaretPosition(0); + } + }); + } +} + +public void showInDialog(Frame ui, boolean undecorated) { + JDialog f = new JDialog(ui, true); + f.add(this); + if (iconPath != null) { + f.setIconImage(SwingUtil.createIcon(iconPath).getImage()); + } + f.setResizable(false); + f.setSize(550, 450); + f.setUndecorated(undecorated); + JRootPane rootPane = f.getRootPane(); + rootPane.setDefaultButton(close); + rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close"); + rootPane.getActionMap().put("close", closeAction); + SwingUtil.center(ui, f); + f.setVisible(true); +} + +protected String load(String filename) { + InputStream licenseStream = getClass().getResourceAsStream("/" + filename); + String result = null; + try { + if (licenseStream != null) { + result = IOUtils.toString(licenseStream); + } + } catch (IOException ex) { + // ignore it + } finally { + if (licenseStream != null) { + try { + licenseStream.close(); + } catch (IOException ex) { + log.error("could not close file " + filename); + } + } + } + if (result == null) { + result = "resource " + filename + " not found"; + } + return result; +} + +void $afterCompleteSetup() { + buildTopPanel(); + close.setText(_("aboutframe.ok")); +} + +]]> + </script> + <row> + <cell weightx='1' fill='both'> + <JPanel background='{Color.WHITE}' layout='{new BorderLayout()}'> + <JLabel text='{SwingUtil.getStringValue(getTitle())}' + visible='{getTitle() != null}' + font-size='12' + constraints='BorderLayout.CENTER'/> + </JPanel> + </cell> + </row> + <row> + <cell weightx='1' fill='both'> + <JPanel id='topPanel'/> + </cell> + </row> + <row> + <cell weighty='1' fill='both'> + <JTabbedPane id='tabs'> + <tab title="aboutframe.about"> + <JScrollPane id='aboutContent' border='{null}'> + <JEditorPane contentType='text/html' + editable='false' + border='{null}' + text='{SwingUtil.getStringValue(getAboutText())}' + onHyperlinkUpdate='SwingUtil.openLink(event)'/> + </JScrollPane> + </tab> + <tab title="aboutframe.license"> + <JScrollPane id='licenseContent' border='{null}'> + <JTextArea id='licenseTextArea' + editable='false' + font-size='11' + border='{null}' + text='{SwingUtil.getStringValue(getLicenseText())}'/> + </JScrollPane> + </tab> + <tab title="aboutframe.thirdparty"> + <JScrollPane id='thirdpartyContent' border='{null}'> + <JTextArea id='thirdpartyTextArea' + editable='false' + font-size='11' + border='{null}' + text='{SwingUtil.getStringValue(getThirdpartyText())}'/> + </JScrollPane> + </tab> + </JTabbedPane> + </cell> + </row> + <row> + <cell fill='both'> + <JPanel layout='{new BorderLayout()}'> + <JLabel id='bottomLabel' + constraints='BorderLayout.CENTER' + horizontalAlignment='{SwingConstants.CENTER}' + text='{SwingUtil.getStringValue(getBottomText())}' + visible='{getBottomText() != null}'/> + <JButton id='close' action='{closeAction}' constraints='BorderLayout.EAST'/> + </JPanel> + </cell> + </row> + +</Table> Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ClockWidget.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/ClockWidget.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ClockWidget.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,55 +0,0 @@ -<!-- - -/** - * *##% jaxx-runtime-swing-widget - * 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>. ##%* - */ - ---> -<JLabel implements='ActionListener' - foreground='{Color.BLACK}' - background='{Color.WHITE}'> - -<javax.swing.Timer id='timer' constructorParams='60000,this' /> - - <script><![CDATA[ - -@Override -public void actionPerformed(ActionEvent evt) { - update(); -} - -/** Adds a feature to the Notify attribute of the Clock object */ -@Override -public void addNotify() { - super.addNotify(); - update(); - timer.start(); -} - -@Override -public void removeNotify() { - timer.stop(); - super.removeNotify(); -} - -protected void update() { - setText(java.text.DateFormat.getTimeInstance(3).format(new Date())); -} -]]> - </script> -</JLabel> Copied: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ClockWidget.jaxx (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/ClockWidget.jaxx) =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ClockWidget.jaxx (rev 0) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ClockWidget.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,55 @@ +<!-- + +/** + * *##% jaxx-runtime-swing-widget + * 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>. ##%* + */ + +--> +<JLabel implements='ActionListener' + foreground='{Color.BLACK}' + background='{Color.WHITE}'> + +<javax.swing.Timer id='timer' constructorParams='60000,this' /> + + <script><![CDATA[ + +@Override +public void actionPerformed(ActionEvent evt) { + update(); +} + +/** Adds a feature to the Notify attribute of the Clock object */ +@Override +public void addNotify() { + super.addNotify(); + update(); + timer.start(); +} + +@Override +public void removeNotify() { + timer.stop(); + super.removeNotify(); +} + +protected void update() { + setText(java.text.DateFormat.getTimeInstance(3).format(new Date())); +} +]]> + </script> +</JLabel> Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,133 +0,0 @@ -<!-- - -/** - * *##% jaxx-runtime-swing-widget - * 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>. ##%* - */ - ---> -<Table fill='both' insets='0' genericType='O' - onFocusGained='combobox.requestFocus()' - onFocusLost='hidePopup()'> - - <!-- auto complete property --> - <Boolean id='autoComplete' javaBean='false'/> - - <!-- show reset property --> - <Boolean id='showReset' javaBean='false'/> - - <!-- show decorator property --> - <Boolean id='showDecorator' javaBean='true'/> - - <!-- editable combo property --> - <Boolean id='editable' javaBean='true'/> - - <!-- bean property linked state --> - <String id='property' javaBean='""'/> - - <!-- bean property --> - <Object id='bean' javaBean='null'/> - - <!-- selectedItem property --> - <Object id='selectedItem' javaBean='null'/> - - <!-- sort index property --> - <Integer id='index' javaBean='0'/> - - <!-- datas of the combo-box --> - <java.util.List id='data' genericType='O' javaBean='null'/> - - <!-- model of sorted property --> - <ButtonGroup id='indexes' useToolTipText='true' - onStateChanged='setIndex((Integer)indexes.getSelectedValue())'/> - - <!-- ui handler --> - <EntityComboBoxHandler id='handler' genericType='O' constructorParams='this'/> - - <String id='selectedToolTipText' javaBean='null'/> - - <String id='notSelectedToolTipText' javaBean='null'/> - - <String id='popupTitleText' javaBean='null'/> - - <String id='i18nPrefix' javaBean='"entitycombobox.common."'/> - - <!-- popup to change sorted property--> - <JPopupMenu id='popup' - border='{new TitledBorder(_("entitycombobox.popup.title"))}' - onPopupMenuWillBecomeInvisible='getChangeDecorator().setSelected(false)' - onPopupMenuCanceled='getChangeDecorator().setSelected(false)'> - <JLabel id='popupLabel'/> - <JSeparator/> - </JPopupMenu> - - <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"); - -public static final String DEFAULT_SELECTED_TOOLTIP = n_("entitycombobox.sort.on"); - -public static final String DEFAULT_NOT_SELECTED_TOOLTIP = n_("entitycombobox.sort.off"); - -public void init(JXPathDecorator<O> decorator, java.util.List<O> data) { - handler.init(decorator, data); -} - -protected void hidePopup() { - if (popup.isVisible()) { - popup.setVisible(false); - } -} -]]> - </script> - <row> - <cell anchor='west'> - <!-- le boutton pour reinitialiser la valeur sélectionnée --> - <JToolBar floatable='false' borderPainted='false' visible='{isShowReset()}'> - <JButton actionIcon='combobox-reset' - toolTipText='entitycombobox.action.reset.tip' - focusable='false' - focusPainted='false' - enabled='{isEnabled()}' - onActionPerformed='setSelectedItem(null)'/> - </JToolBar> - - </cell> - <cell weightx='1'> - <!-- la liste déroulante --> - <JComboBox id='combobox' - selectedItem='{getSelectedItem()}' - enabled='{isEnabled()}' - editable='{isEditable()}' - onFocusGained='hidePopup()' - onItemStateChanged='setSelectedItem(combobox.getSelectedItem())'/> - </cell> - <cell anchor='east' fill='both' insets='0'> - <!-- le boutton pour changer le tri --> - <JToolBar floatable='false' borderPainted='false' visible='{isShowDecorator()}'> - <JToggleButton id='changeDecorator' - actionIcon='combobox-sort' - toolTipText='entitycombobox.action.sort.tip' - focusable='false' - focusPainted='false' - onActionPerformed='getHandler().togglePopup()'/> - </JToolBar> - </cell> - </row> -</Table> Copied: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx) =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx (rev 0) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,133 @@ +<!-- + +/** + * *##% jaxx-runtime-swing-widget + * 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>. ##%* + */ + +--> +<Table fill='both' insets='0' genericType='O' + onFocusGained='combobox.requestFocus()' + onFocusLost='hidePopup()'> + + <!-- auto complete property --> + <Boolean id='autoComplete' javaBean='false'/> + + <!-- show reset property --> + <Boolean id='showReset' javaBean='false'/> + + <!-- show decorator property --> + <Boolean id='showDecorator' javaBean='true'/> + + <!-- editable combo property --> + <Boolean id='editable' javaBean='true'/> + + <!-- bean property linked state --> + <String id='property' javaBean='""'/> + + <!-- bean property --> + <Object id='bean' javaBean='null'/> + + <!-- selectedItem property --> + <Object id='selectedItem' javaBean='null'/> + + <!-- sort index property --> + <Integer id='index' javaBean='0'/> + + <!-- datas of the combo-box --> + <java.util.List id='data' genericType='O' javaBean='null'/> + + <!-- model of sorted property --> + <ButtonGroup id='indexes' useToolTipText='true' + onStateChanged='setIndex((Integer)indexes.getSelectedValue())'/> + + <!-- ui handler --> + <EntityComboBoxHandler id='handler' genericType='O' constructorParams='this'/> + + <String id='selectedToolTipText' javaBean='null'/> + + <String id='notSelectedToolTipText' javaBean='null'/> + + <String id='popupTitleText' javaBean='null'/> + + <String id='i18nPrefix' javaBean='"entitycombobox.common."'/> + + <!-- popup to change sorted property--> + <JPopupMenu id='popup' + border='{new TitledBorder(_("entitycombobox.popup.title"))}' + onPopupMenuWillBecomeInvisible='getChangeDecorator().setSelected(false)' + onPopupMenuCanceled='getChangeDecorator().setSelected(false)'> + <JLabel id='popupLabel'/> + <JSeparator/> + </JPopupMenu> + + <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"); + +public static final String DEFAULT_SELECTED_TOOLTIP = n_("entitycombobox.sort.on"); + +public static final String DEFAULT_NOT_SELECTED_TOOLTIP = n_("entitycombobox.sort.off"); + +public void init(JXPathDecorator<O> decorator, java.util.List<O> data) { + handler.init(decorator, data); +} + +protected void hidePopup() { + if (popup.isVisible()) { + popup.setVisible(false); + } +} +]]> + </script> + <row> + <cell anchor='west'> + <!-- le boutton pour reinitialiser la valeur sélectionnée --> + <JToolBar floatable='false' borderPainted='false' visible='{isShowReset()}'> + <JButton actionIcon='combobox-reset' + toolTipText='entitycombobox.action.reset.tip' + focusable='false' + focusPainted='false' + enabled='{isEnabled()}' + onActionPerformed='setSelectedItem(null)'/> + </JToolBar> + + </cell> + <cell weightx='1'> + <!-- la liste déroulante --> + <JComboBox id='combobox' + selectedItem='{getSelectedItem()}' + enabled='{isEnabled()}' + editable='{isEditable()}' + onFocusGained='hidePopup()' + onItemStateChanged='setSelectedItem(combobox.getSelectedItem())'/> + </cell> + <cell anchor='east' fill='both' insets='0'> + <!-- le boutton pour changer le tri --> + <JToolBar floatable='false' borderPainted='false' visible='{isShowDecorator()}'> + <JToggleButton id='changeDecorator' + actionIcon='combobox-sort' + toolTipText='entitycombobox.action.sort.tip' + focusable='false' + focusPainted='false' + onActionPerformed='getHandler().togglePopup()'/> + </JToolBar> + </cell> + </row> +</Table> Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,473 +0,0 @@ -/** - * *##% - * JAXX Widgets - * 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>. - * ##%* - */ -package jaxx.runtime.swing; - -import java.awt.Component; -import jaxx.runtime.SwingUtil; -import org.apache.commons.beanutils.PropertyUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import static org.nuiton.i18n.I18n._; -import static org.nuiton.i18n.I18n.n_; -import org.jdesktop.swingx.autocomplete.ObjectToStringConverter; - -import javax.swing.JPopupMenu; -import javax.swing.JRadioButtonMenuItem; -import javax.swing.JToggleButton; -import javax.swing.SwingUtilities; -import javax.swing.text.Document; -import javax.swing.text.JTextComponent; -import java.awt.Dimension; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.beans.Introspector; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.beans.PropertyDescriptor; -import java.lang.reflect.Method; -import java.util.List; -import javax.swing.JComboBox; -import jaxx.runtime.decorator.Decorator; -import jaxx.runtime.decorator.JXPathDecorator; -import jaxx.runtime.decorator.MultiJXPathDecorator; -import jaxx.runtime.swing.renderer.DecoratorListCellRenderer; -import jaxx.runtime.decorator.DecoratorUtils; -import org.jdesktop.swingx.autocomplete.AutoCompletePropertyChangeListener; - -/** - * Le handler d'un {@link EntityComboBox}. - * <p/> - * Note: ce handler n'est pas staeless et n'est donc pas partageable entre plusieurs ui. - * - * @param <O> le type des objet contenus dans le modèle du composant. - * - * @author chemit - * @see EntityComboBox - */ -public class EntityComboBoxHandler<O> implements PropertyChangeListener { - - public static final Log log = LogFactory.getLog(EntityComboBoxHandler.class); - public static final String SELECTED_ITEM_PROPERTY = "selectedItem"; - public static final String INDEX_PROPERTY = "index"; - public static final String AUTO_COMPLETE_PROPERTY = "autoComplete"; - public static final String DATA_PROPERTY = "data"; - /** ui if the handler */ - protected EntityComboBox<O> ui; - /** the mutator method on the property of boxed bean in the ui */ - protected Method mutator; - /** the original document of the combbo box editor (keep it to make possible undecorate) */ - protected Document originalDocument; - /** the convertor used to auto-complete */ - protected ObjectToStringConverter convertor; - /** the decorator of data */ - protected MultiJXPathDecorator<O> decorator; - protected boolean init; - - public EntityComboBoxHandler(EntityComboBox<O> ui) { - this.ui = ui; - } - protected final FocusListener EDITOR_TEXT_COMP0NENT_FOCUSLISTENER = new FocusListener() { - - @Override - public void focusGained(FocusEvent e) { - if (log.isDebugEnabled()) { - log.debug("close popup from " + e); - } - ui.getPopup().setVisible(false); - } - - @Override - public void focusLost(FocusEvent e) { - } - }; - - /** - * Initialise le handler de l'ui - * - * @param decorator le decorateur a utiliser - * @param data la liste des données a gérer - */ - public void init(JXPathDecorator<O> decorator, List<O> data) { - - if (init) { - throw new IllegalStateException("can not init the handler twice"); - } - init = true; - if (decorator == null) { - throw new NullPointerException("can not have a null decorator as parameter"); - } - - JAXXButtonGroup indexes = ui.getIndexes(); - - MultiJXPathDecorator<O> d; - if (decorator instanceof MultiJXPathDecorator<?>) { - // should clone decorator ? - d = (MultiJXPathDecorator<O>) decorator; - } else { - d = DecoratorUtils.newMultiJXPathDecorator(decorator.getInternalClass(), decorator.getInitialExpression(), " - "); - } - this.decorator = d; - - // init combobox renderer base on given decorator - ui.getCombobox().setRenderer(new DecoratorListCellRenderer(d)); - - this.convertor = newDecoratedObjectToStringConverter(d); - - // keep a trace of original document (to make possible reverse autom-complete) - JTextComponent editorComponent = (JTextComponent) ui.getCombobox().getEditor().getEditorComponent(); - this.originalDocument = editorComponent.getDocument(); - - // build popup - preparePopup(d); - - ui.autoComplete = true; - - ui.addPropertyChangeListener(this); - - // set datas - ui.setData(data); - - // select sort button - indexes.setSelectedButton(ui.getIndex()); - } - - /** Toggle the popup visible state. */ - public void togglePopup() { - boolean newValue = !ui.getPopup().isVisible(); - - if (log.isTraceEnabled()) { - log.trace(newValue); - } - - if (!newValue) { - if (ui.getPopup() != null) { - ui.getPopup().setVisible(false); - } - return; - } - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - ui.getPopup().pack(); - Dimension dim = ui.getPopup().getPreferredSize(); - JToggleButton invoker = ui.getChangeDecorator(); - ui.getPopup().show(invoker, (int) (invoker.getPreferredSize().getWidth() - dim.getWidth()), invoker.getHeight()); - } - }); - } - - /** - * Modifie l'état autoComplete de l'ui. - * - * @param oldValue l'ancienne valeur - * @param newValue la nouvelle valeur - */ - protected void setAutoComplete(Boolean oldValue, Boolean newValue) { - oldValue = oldValue != null && oldValue; - newValue = newValue != null && newValue; - if (oldValue == newValue) { - return; - } - if (log.isDebugEnabled()) { - log.debug("autocomplete state : <" + oldValue + " to " + newValue + ">"); - } - if (!newValue) { - JTextComponent editorComponent = (JTextComponent) ui.getCombobox().getEditor().getEditorComponent(); - editorComponent.removeFocusListener(EDITOR_TEXT_COMP0NENT_FOCUSLISTENER); - undecorate(ui.getCombobox(), originalDocument); - } else { - decorate(ui.getCombobox(), convertor); - JTextComponent editorComponent = (JTextComponent) ui.getCombobox().getEditor().getEditorComponent(); - editorComponent.addFocusListener(EDITOR_TEXT_COMP0NENT_FOCUSLISTENER); - } - } - - /** - * Modifie l'index du décorateur - * - * @param oldValue l'ancienne valeur - * @param newValue la nouvelle valeur - */ - @SuppressWarnings({"unchecked"}) - protected void setIndex(Integer oldValue, Integer newValue) { - if (newValue.equals(oldValue)) { - return; - } - if (log.isDebugEnabled()) { - log.debug("check state : <" + oldValue + " to " + newValue + ">"); - } - - // change decorator context - decorator.setContextIndex(newValue); - - // keep selected item - Object previousSelectedItem = ui.getSelectedItem(); - Boolean wasAutoComplete = ui.isAutoComplete(); - - if (wasAutoComplete) { - ui.setAutoComplete(false); - } - - // remove autocomplete - if (previousSelectedItem != null) { - ui.getCombobox().setSelectedItem(null); - ui.selectedItem = null; - } - - - try { - // Sort data with the decorator jxpath tokens. - DecoratorUtils.sort(decorator, ui.getData(), newValue); - } catch (Exception e) { - log.warn(e.getMessage(), e); - //System.out.println("newValue :: "+decorator+" : "+newValue); - //System.out.println("datas :: "+ui.getData()); - } - - // reload the model - SwingUtil.fillComboBox(ui.getCombobox(), ui.getData(), null); - - if (wasAutoComplete) { - ui.setAutoComplete(true); - } - - if (previousSelectedItem != null) { - ui.setSelectedItem(previousSelectedItem); - } - - ui.getCombobox().requestFocus(); - } - - /** - * Modifie la valeur sélectionnée dans la liste déroulante. - * - * @param oldValue l'ancienne valeur - * @param newValue la nouvelle valeur - */ - protected void setSelectedItem(Object oldValue, Object newValue) { - if (ui.getBean() == null) { - return; - } - - if (newValue == null) { - if (ui.getCombobox().getSelectedItem() == null) { - return; - } - ui.getCombobox().setSelectedItem(null); - - if (ui.isAutoComplete()) { - ui.setAutoComplete(false); - ui.setAutoComplete(true); - } - - if (oldValue == null) { - return; - } - } - if (log.isDebugEnabled()) { - log.debug(ui.getProperty() + " on " + ui.getBean().getClass() + " :: " + oldValue + " to " + newValue); - } - - try { - Method mut = getMutator(); - if (mut != null) { - mut.invoke(ui.getBean(), newValue); - } - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - /** @return le document de l'éditeur avant complétion. */ - public Document getOriginalDocument() { - return originalDocument; - } - - public MultiJXPathDecorator<O> getDecorator() { - return decorator; - } - - /** - * Creation de l'ui pour modifier le décorateur. - * - * @param decorator le decorateur a utiliser - */ - protected void preparePopup(MultiJXPathDecorator<?> decorator) { - String selectedTip = ui.getSelectedToolTipText(); - if (selectedTip == null) { - // use default selected tip text - selectedTip = EntityComboBox.DEFAULT_SELECTED_TOOLTIP; - } - String notSelectedTip = ui.getNotSelectedToolTipText(); - if (notSelectedTip == null) { - // use default selected tip text - notSelectedTip = EntityComboBox.DEFAULT_NOT_SELECTED_TOOLTIP; - } - JPopupMenu popup = ui.getPopup(); - - //Container container = ui.getIndexesContainer(); - for (int i = 0, max = decorator.getNbContext(); i < max; i++) { - String property = ui.getI18nPrefix() + decorator.getProperty(i); - String propertyI18n = _(property); - JRadioButtonMenuItem button = new JRadioButtonMenuItem(propertyI18n); - button.putClientProperty(JAXXButtonGroup.BUTTON8GROUP_CLIENT_PROPERTY, ui.getIndexes()); - button.putClientProperty(JAXXButtonGroup.VALUE_CLIENT_PROPERTY, i); - popup.add(button); - if (selectedTip != null) { - button.putClientProperty(JAXXButtonGroup.SELECTED_TIP_CLIENT_PROPERTY, _(selectedTip, propertyI18n)); - } - if (notSelectedTip != null) { - button.putClientProperty(JAXXButtonGroup.NOT_SELECTED_TIP_CLIENT_PROPERTY, _(notSelectedTip, propertyI18n)); - } - button.setSelected(false); - ui.getIndexes().add(button); - } - String title = ui.getPopupTitleText(); - if (title == null) { - // use default popup title - title = EntityComboBox.DEFAULT_POPUP_LABEL; - - Class<?> internalClass = decorator.getInternalClass(); - String beanI18nKey; - if (internalClass == null) { - beanI18nKey = n_("entitycombobox.unknown.type"); - } else { - beanI18nKey = ui.getI18nPrefix() + Introspector.decapitalize(internalClass.getSimpleName()); - } - String beanI18n = _(beanI18nKey); - title = _(title, beanI18n); - } else { - title = _(title); - } - ui.getPopupLabel().setText(title); - ui.getPopup().setLabel(title); - ui.getPopup().invalidate(); - } - - public Class<?> getTargetClass() { - Method m = getMutator(); - return m == null ? null : m.getParameterTypes()[0]; - } - - /** @return le mutateur a utiliser pour modifier le bean associé. */ - protected Method getMutator() { - if (mutator == null) { - Object bean = ui.getBean(); - if (bean == null) { - throw new NullPointerException("could not find bean in " + ui); - } - String property = ui.getProperty(); - if (property == null) { - throw new NullPointerException("could not find property in " + ui); - } - - try { - PropertyDescriptor descriptor = PropertyUtils.getPropertyDescriptor(bean, property); - if (descriptor != null) { - mutator = descriptor.getWriteMethod(); - } - } catch (Exception e) { - throw new RuntimeException(e); - } - } - return mutator; - } - - /** - * Encapsule un {@link Decorator} dans un {@link ObjectToStringConverter}. - * - * @param decorator le decorateur a encapsuler. - * @return le converter encapsule dans un {@link ObjectToStringConverter} - */ - public static ObjectToStringConverter newDecoratedObjectToStringConverter(final Decorator<?> decorator) { - - return new ObjectToStringConverter() { - - @Override - public String getPreferredStringForItem(Object item) { - return item instanceof String ? (String) item : (item == null ? "" : decorator.toString(item)); - } - }; - } - - /** - * Ajout l'auto-complétion sur une liste déroulante, en utilisant le - * converteur donné pour afficher les données. - * - * @param combo la combo à décorer - * @param convertor le converter utilisé pour afficher les données. - */ - public static void decorate(JComboBox combo, ObjectToStringConverter convertor) { - - org.jdesktop.swingx.autocomplete.AutoCompleteDecorator.decorate(combo, convertor); - } - - /** - * Désactive l'aut-complétion sur une liste déroulante, en y repositionnant - * le modèle du document d'édition d'avant auto-complétion. - * - * @param combo la liste déroulante à décorer - * @param originalDocument le document original de l'édtieur de la - * liste déroulante. - */ - public static void undecorate(JComboBox combo, Document originalDocument) { - - // has not to be editable - combo.setEditable(false); - - // configure the text component=editor component - Component c = combo.getEditor().getEditorComponent(); - JTextComponent editorComponent = (JTextComponent) c; - editorComponent.setDocument(originalDocument); - editorComponent.setText(null); - //remove old property change listener - for (PropertyChangeListener l : c.getPropertyChangeListeners("editor")) { - if (l instanceof AutoCompletePropertyChangeListener) { - c.removePropertyChangeListener("editor", l); - } - } - } - - @Override - public void propertyChange(PropertyChangeEvent evt) { - String propertyName = evt.getPropertyName(); - - if (SELECTED_ITEM_PROPERTY.equals(propertyName)) { - setSelectedItem(evt.getOldValue(), evt.getNewValue()); - return; - } - - if (INDEX_PROPERTY.equals(propertyName)) { - setIndex((Integer) evt.getOldValue(), (Integer) evt.getNewValue()); - return; - } - if (AUTO_COMPLETE_PROPERTY.equals(propertyName)) { - setAutoComplete((Boolean) evt.getOldValue(), (Boolean) evt.getNewValue()); - return; - } - if (DATA_PROPERTY.equals(propertyName)) { - // list has changed, force reload of index - setIndex(-1, ui.getIndex()); - } - - } -} Copied: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java) =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java (rev 0) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,473 @@ +/** + * *##% + * JAXX Widgets + * 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>. + * ##%* + */ +package jaxx.runtime.swing; + +import java.awt.Component; +import jaxx.runtime.SwingUtil; +import org.apache.commons.beanutils.PropertyUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import static org.nuiton.i18n.I18n._; +import static org.nuiton.i18n.I18n.n_; +import org.jdesktop.swingx.autocomplete.ObjectToStringConverter; + +import javax.swing.JPopupMenu; +import javax.swing.JRadioButtonMenuItem; +import javax.swing.JToggleButton; +import javax.swing.SwingUtilities; +import javax.swing.text.Document; +import javax.swing.text.JTextComponent; +import java.awt.Dimension; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.beans.Introspector; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.beans.PropertyDescriptor; +import java.lang.reflect.Method; +import java.util.List; +import javax.swing.JComboBox; +import jaxx.runtime.decorator.Decorator; +import jaxx.runtime.decorator.JXPathDecorator; +import jaxx.runtime.decorator.MultiJXPathDecorator; +import jaxx.runtime.swing.renderer.DecoratorListCellRenderer; +import jaxx.runtime.decorator.DecoratorUtils; +import org.jdesktop.swingx.autocomplete.AutoCompletePropertyChangeListener; + +/** + * Le handler d'un {@link EntityComboBox}. + * <p/> + * Note: ce handler n'est pas staeless et n'est donc pas partageable entre plusieurs ui. + * + * @param <O> le type des objet contenus dans le modèle du composant. + * + * @author chemit + * @see EntityComboBox + */ +public class EntityComboBoxHandler<O> implements PropertyChangeListener { + + public static final Log log = LogFactory.getLog(EntityComboBoxHandler.class); + public static final String SELECTED_ITEM_PROPERTY = "selectedItem"; + public static final String INDEX_PROPERTY = "index"; + public static final String AUTO_COMPLETE_PROPERTY = "autoComplete"; + public static final String DATA_PROPERTY = "data"; + /** ui if the handler */ + protected EntityComboBox<O> ui; + /** the mutator method on the property of boxed bean in the ui */ + protected Method mutator; + /** the original document of the combbo box editor (keep it to make possible undecorate) */ + protected Document originalDocument; + /** the convertor used to auto-complete */ + protected ObjectToStringConverter convertor; + /** the decorator of data */ + protected MultiJXPathDecorator<O> decorator; + protected boolean init; + + public EntityComboBoxHandler(EntityComboBox<O> ui) { + this.ui = ui; + } + protected final FocusListener EDITOR_TEXT_COMP0NENT_FOCUSLISTENER = new FocusListener() { + + @Override + public void focusGained(FocusEvent e) { + if (log.isDebugEnabled()) { + log.debug("close popup from " + e); + } + ui.getPopup().setVisible(false); + } + + @Override + public void focusLost(FocusEvent e) { + } + }; + + /** + * Initialise le handler de l'ui + * + * @param decorator le decorateur a utiliser + * @param data la liste des données a gérer + */ + public void init(JXPathDecorator<O> decorator, List<O> data) { + + if (init) { + throw new IllegalStateException("can not init the handler twice"); + } + init = true; + if (decorator == null) { + throw new NullPointerException("can not have a null decorator as parameter"); + } + + JAXXButtonGroup indexes = ui.getIndexes(); + + MultiJXPathDecorator<O> d; + if (decorator instanceof MultiJXPathDecorator<?>) { + // should clone decorator ? + d = (MultiJXPathDecorator<O>) decorator; + } else { + d = DecoratorUtils.newMultiJXPathDecorator(decorator.getInternalClass(), decorator.getInitialExpression(), " - "); + } + this.decorator = d; + + // init combobox renderer base on given decorator + ui.getCombobox().setRenderer(new DecoratorListCellRenderer(d)); + + this.convertor = newDecoratedObjectToStringConverter(d); + + // keep a trace of original document (to make possible reverse autom-complete) + JTextComponent editorComponent = (JTextComponent) ui.getCombobox().getEditor().getEditorComponent(); + this.originalDocument = editorComponent.getDocument(); + + // build popup + preparePopup(d); + + ui.autoComplete = true; + + ui.addPropertyChangeListener(this); + + // set datas + ui.setData(data); + + // select sort button + indexes.setSelectedButton(ui.getIndex()); + } + + /** Toggle the popup visible state. */ + public void togglePopup() { + boolean newValue = !ui.getPopup().isVisible(); + + if (log.isTraceEnabled()) { + log.trace(newValue); + } + + if (!newValue) { + if (ui.getPopup() != null) { + ui.getPopup().setVisible(false); + } + return; + } + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + ui.getPopup().pack(); + Dimension dim = ui.getPopup().getPreferredSize(); + JToggleButton invoker = ui.getChangeDecorator(); + ui.getPopup().show(invoker, (int) (invoker.getPreferredSize().getWidth() - dim.getWidth()), invoker.getHeight()); + } + }); + } + + /** + * Modifie l'état autoComplete de l'ui. + * + * @param oldValue l'ancienne valeur + * @param newValue la nouvelle valeur + */ + protected void setAutoComplete(Boolean oldValue, Boolean newValue) { + oldValue = oldValue != null && oldValue; + newValue = newValue != null && newValue; + if (oldValue == newValue) { + return; + } + if (log.isDebugEnabled()) { + log.debug("autocomplete state : <" + oldValue + " to " + newValue + ">"); + } + if (!newValue) { + JTextComponent editorComponent = (JTextComponent) ui.getCombobox().getEditor().getEditorComponent(); + editorComponent.removeFocusListener(EDITOR_TEXT_COMP0NENT_FOCUSLISTENER); + undecorate(ui.getCombobox(), originalDocument); + } else { + decorate(ui.getCombobox(), convertor); + JTextComponent editorComponent = (JTextComponent) ui.getCombobox().getEditor().getEditorComponent(); + editorComponent.addFocusListener(EDITOR_TEXT_COMP0NENT_FOCUSLISTENER); + } + } + + /** + * Modifie l'index du décorateur + * + * @param oldValue l'ancienne valeur + * @param newValue la nouvelle valeur + */ + @SuppressWarnings({"unchecked"}) + protected void setIndex(Integer oldValue, Integer newValue) { + if (newValue.equals(oldValue)) { + return; + } + if (log.isDebugEnabled()) { + log.debug("check state : <" + oldValue + " to " + newValue + ">"); + } + + // change decorator context + decorator.setContextIndex(newValue); + + // keep selected item + Object previousSelectedItem = ui.getSelectedItem(); + Boolean wasAutoComplete = ui.isAutoComplete(); + + if (wasAutoComplete) { + ui.setAutoComplete(false); + } + + // remove autocomplete + if (previousSelectedItem != null) { + ui.getCombobox().setSelectedItem(null); + ui.selectedItem = null; + } + + + try { + // Sort data with the decorator jxpath tokens. + DecoratorUtils.sort(decorator, ui.getData(), newValue); + } catch (Exception e) { + log.warn(e.getMessage(), e); + //System.out.println("newValue :: "+decorator+" : "+newValue); + //System.out.println("datas :: "+ui.getData()); + } + + // reload the model + SwingUtil.fillComboBox(ui.getCombobox(), ui.getData(), null); + + if (wasAutoComplete) { + ui.setAutoComplete(true); + } + + if (previousSelectedItem != null) { + ui.setSelectedItem(previousSelectedItem); + } + + ui.getCombobox().requestFocus(); + } + + /** + * Modifie la valeur sélectionnée dans la liste déroulante. + * + * @param oldValue l'ancienne valeur + * @param newValue la nouvelle valeur + */ + protected void setSelectedItem(Object oldValue, Object newValue) { + if (ui.getBean() == null) { + return; + } + + if (newValue == null) { + if (ui.getCombobox().getSelectedItem() == null) { + return; + } + ui.getCombobox().setSelectedItem(null); + + if (ui.isAutoComplete()) { + ui.setAutoComplete(false); + ui.setAutoComplete(true); + } + + if (oldValue == null) { + return; + } + } + if (log.isDebugEnabled()) { + log.debug(ui.getProperty() + " on " + ui.getBean().getClass() + " :: " + oldValue + " to " + newValue); + } + + try { + Method mut = getMutator(); + if (mut != null) { + mut.invoke(ui.getBean(), newValue); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** @return le document de l'éditeur avant complétion. */ + public Document getOriginalDocument() { + return originalDocument; + } + + public MultiJXPathDecorator<O> getDecorator() { + return decorator; + } + + /** + * Creation de l'ui pour modifier le décorateur. + * + * @param decorator le decorateur a utiliser + */ + protected void preparePopup(MultiJXPathDecorator<?> decorator) { + String selectedTip = ui.getSelectedToolTipText(); + if (selectedTip == null) { + // use default selected tip text + selectedTip = EntityComboBox.DEFAULT_SELECTED_TOOLTIP; + } + String notSelectedTip = ui.getNotSelectedToolTipText(); + if (notSelectedTip == null) { + // use default selected tip text + notSelectedTip = EntityComboBox.DEFAULT_NOT_SELECTED_TOOLTIP; + } + JPopupMenu popup = ui.getPopup(); + + //Container container = ui.getIndexesContainer(); + for (int i = 0, max = decorator.getNbContext(); i < max; i++) { + String property = ui.getI18nPrefix() + decorator.getProperty(i); + String propertyI18n = _(property); + JRadioButtonMenuItem button = new JRadioButtonMenuItem(propertyI18n); + button.putClientProperty(JAXXButtonGroup.BUTTON8GROUP_CLIENT_PROPERTY, ui.getIndexes()); + button.putClientProperty(JAXXButtonGroup.VALUE_CLIENT_PROPERTY, i); + popup.add(button); + if (selectedTip != null) { + button.putClientProperty(JAXXButtonGroup.SELECTED_TIP_CLIENT_PROPERTY, _(selectedTip, propertyI18n)); + } + if (notSelectedTip != null) { + button.putClientProperty(JAXXButtonGroup.NOT_SELECTED_TIP_CLIENT_PROPERTY, _(notSelectedTip, propertyI18n)); + } + button.setSelected(false); + ui.getIndexes().add(button); + } + String title = ui.getPopupTitleText(); + if (title == null) { + // use default popup title + title = EntityComboBox.DEFAULT_POPUP_LABEL; + + Class<?> internalClass = decorator.getInternalClass(); + String beanI18nKey; + if (internalClass == null) { + beanI18nKey = n_("entitycombobox.unknown.type"); + } else { + beanI18nKey = ui.getI18nPrefix() + Introspector.decapitalize(internalClass.getSimpleName()); + } + String beanI18n = _(beanI18nKey); + title = _(title, beanI18n); + } else { + title = _(title); + } + ui.getPopupLabel().setText(title); + ui.getPopup().setLabel(title); + ui.getPopup().invalidate(); + } + + public Class<?> getTargetClass() { + Method m = getMutator(); + return m == null ? null : m.getParameterTypes()[0]; + } + + /** @return le mutateur a utiliser pour modifier le bean associé. */ + protected Method getMutator() { + if (mutator == null) { + Object bean = ui.getBean(); + if (bean == null) { + throw new NullPointerException("could not find bean in " + ui); + } + String property = ui.getProperty(); + if (property == null) { + throw new NullPointerException("could not find property in " + ui); + } + + try { + PropertyDescriptor descriptor = PropertyUtils.getPropertyDescriptor(bean, property); + if (descriptor != null) { + mutator = descriptor.getWriteMethod(); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + return mutator; + } + + /** + * Encapsule un {@link Decorator} dans un {@link ObjectToStringConverter}. + * + * @param decorator le decorateur a encapsuler. + * @return le converter encapsule dans un {@link ObjectToStringConverter} + */ + public static ObjectToStringConverter newDecoratedObjectToStringConverter(final Decorator<?> decorator) { + + return new ObjectToStringConverter() { + + @Override + public String getPreferredStringForItem(Object item) { + return item instanceof String ? (String) item : (item == null ? "" : decorator.toString(item)); + } + }; + } + + /** + * Ajout l'auto-complétion sur une liste déroulante, en utilisant le + * converteur donné pour afficher les données. + * + * @param combo la combo à décorer + * @param convertor le converter utilisé pour afficher les données. + */ + public static void decorate(JComboBox combo, ObjectToStringConverter convertor) { + + org.jdesktop.swingx.autocomplete.AutoCompleteDecorator.decorate(combo, convertor); + } + + /** + * Désactive l'aut-complétion sur une liste déroulante, en y repositionnant + * le modèle du document d'édition d'avant auto-complétion. + * + * @param combo la liste déroulante à décorer + * @param originalDocument le document original de l'édtieur de la + * liste déroulante. + */ + public static void undecorate(JComboBox combo, Document originalDocument) { + + // has not to be editable + combo.setEditable(false); + + // configure the text component=editor component + Component c = combo.getEditor().getEditorComponent(); + JTextComponent editorComponent = (JTextComponent) c; + editorComponent.setDocument(originalDocument); + editorComponent.setText(null); + //remove old property change listener + for (PropertyChangeListener l : c.getPropertyChangeListeners("editor")) { + if (l instanceof AutoCompletePropertyChangeListener) { + c.removePropertyChangeListener("editor", l); + } + } + } + + @Override + public void propertyChange(PropertyChangeEvent evt) { + String propertyName = evt.getPropertyName(); + + if (SELECTED_ITEM_PROPERTY.equals(propertyName)) { + setSelectedItem(evt.getOldValue(), evt.getNewValue()); + return; + } + + if (INDEX_PROPERTY.equals(propertyName)) { + setIndex((Integer) evt.getOldValue(), (Integer) evt.getNewValue()); + return; + } + if (AUTO_COMPLETE_PROPERTY.equals(propertyName)) { + setAutoComplete((Boolean) evt.getOldValue(), (Boolean) evt.getNewValue()); + return; + } + if (DATA_PROPERTY.equals(propertyName)) { + // list has changed, force reload of index + setIndex(-1, ui.getIndex()); + } + + } +} Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ErrorDialogUI.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/ErrorDialogUI.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ErrorDialogUI.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,88 +0,0 @@ -<!-- - -/** - * *##% jaxx-runtime-swing-widget - * 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>. ##%* - */ - ---> -<JDialog title='errorUI.title' modal='true'> - <script><![CDATA[ -protected static ErrorDialogUI instance; -public static void init(Frame frame) { - disposeUI(); - instance = new ErrorDialogUI(frame); - instance.setModalityType(ModalityType.TOOLKIT_MODAL); -} -public static void showError(Exception e) { - if (instance == null) { - instance = new ErrorDialogUI(); - } - instance.getErrorMessage().setText(e.getMessage()); - StringWriter w = new StringWriter(); - e.printStackTrace(new PrintWriter(w)); - instance.getErrorStack().setText(w.toString()); - instance.getErrorStack().setCaretPosition(0); - instance.pack(); - jaxx.runtime.SwingUtil.center(instance.getContextValue(JFrame.class,"parent"), instance); - instance.setVisible(true); -} -public static void disposeUI() { - instance=null; -} - -public ErrorDialogUI(Frame frame) { - super(frame); - if (frame!=null) { - setContextValue(frame); - setContextValue(frame,"parent"); - } - -} - -JRootPane rootPane = getRootPane(); -rootPane.setDefaultButton(close); -rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close"); -rootPane.getActionMap().put("close", close.getAction()); - ]]></script> - <Table> - <row fill='both'> - <cell> - <JPanel> - <JLabel text='errorUI.message'/> - </JPanel> - </cell> - </row> - <row fill='both'> - <cell> - <JLabel id='errorMessage'/> - </cell> - </row> - <row fill='both' weightx='1' weighty='1'> - <cell> - <JScrollPane width='600' height='200'> - <JTextArea id='errorStack' editable='false' font-size='9'/> - </JScrollPane> - </cell> - </row> - <row fill='horizontal'> - <cell> - <JButton id='close' text='errorUI.action.close' onActionPerformed='dispose()'/> - </cell> - </row> - </Table> -</JDialog> Copied: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ErrorDialogUI.jaxx (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/ErrorDialogUI.jaxx) =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ErrorDialogUI.jaxx (rev 0) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ErrorDialogUI.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,88 @@ +<!-- + +/** + * *##% jaxx-runtime-swing-widget + * 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>. ##%* + */ + +--> +<JDialog title='errorUI.title' modal='true'> + <script><![CDATA[ +protected static ErrorDialogUI instance; +public static void init(Frame frame) { + disposeUI(); + instance = new ErrorDialogUI(frame); + instance.setModalityType(ModalityType.TOOLKIT_MODAL); +} +public static void showError(Exception e) { + if (instance == null) { + instance = new ErrorDialogUI(); + } + instance.getErrorMessage().setText(e.getMessage()); + StringWriter w = new StringWriter(); + e.printStackTrace(new PrintWriter(w)); + instance.getErrorStack().setText(w.toString()); + instance.getErrorStack().setCaretPosition(0); + instance.pack(); + jaxx.runtime.SwingUtil.center(instance.getContextValue(JFrame.class,"parent"), instance); + instance.setVisible(true); +} +public static void disposeUI() { + instance=null; +} + +public ErrorDialogUI(Frame frame) { + super(frame); + if (frame!=null) { + setContextValue(frame); + setContextValue(frame,"parent"); + } + +} + +JRootPane rootPane = getRootPane(); +rootPane.setDefaultButton(close); +rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close"); +rootPane.getActionMap().put("close", close.getAction()); + ]]></script> + <Table> + <row fill='both'> + <cell> + <JPanel> + <JLabel text='errorUI.message'/> + </JPanel> + </cell> + </row> + <row fill='both'> + <cell> + <JLabel id='errorMessage'/> + </cell> + </row> + <row fill='both' weightx='1' weighty='1'> + <cell> + <JScrollPane width='600' height='200'> + <JTextArea id='errorStack' editable='false' font-size='9'/> + </JScrollPane> + </cell> + </row> + <row fill='horizontal'> + <cell> + <JButton id='close' text='errorUI.action.close' onActionPerformed='dispose()'/> + </cell> + </row> + </Table> +</JDialog> Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/HidorButton.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/HidorButton.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/HidorButton.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,57 +0,0 @@ -<JToggleButton id='hidor' - toolTipText='{updateToolTipText(isTargetVisible())}' - icon='{SwingUtil.createActionIcon("collapse")}' - pressedIcon='{SwingUtil.createActionIcon("expand")}' - onActionPerformed='setTargetVisible(!targetVisible)'> - - <Boolean id='targetVisible' javaBean='null'/> - - <String id='collapseTip' javaBean='_("hidor.collapseTip")'/> - - <String id='expandTip' javaBean='_("hidor.expandTip")'/> - - <script><![CDATA[ -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - -addPropertyChangeListener("targetVisible", new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - if (log.isDebugEnabled()) { - log.debug("target visible changed <" + evt.getOldValue() + ":" + evt.getNewValue() + ">"); - } - boolean newValue = (Boolean) evt.getNewValue(); - if (target != null) { - target.setVisible(newValue); - } - } -}); - -protected JComponent target; - -public JComponent getTarget() { - return target; -} - -public void setTarget(JComponent target) { - JComponent oldValue = this.target; - this.target = target; - firePropertyChange("target", oldValue, target); -} - -public void setExpandIcon(Icon icon) { - setSelectedIcon(icon); -} - -public void setCollapseIcon(Icon icon) { - setIcon(icon); -} - -protected String updateToolTipText(boolean c) { - String i = c ? collapseTip : expandTip; - return i; -} -]]> - </script> -</JToggleButton> Copied: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/HidorButton.jaxx (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/HidorButton.jaxx) =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/HidorButton.jaxx (rev 0) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/HidorButton.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,57 @@ +<JToggleButton id='hidor' + toolTipText='{updateToolTipText(isTargetVisible())}' + icon='{SwingUtil.createActionIcon("collapse")}' + pressedIcon='{SwingUtil.createActionIcon("expand")}' + onActionPerformed='setTargetVisible(!targetVisible)'> + + <Boolean id='targetVisible' javaBean='null'/> + + <String id='collapseTip' javaBean='_("hidor.collapseTip")'/> + + <String id='expandTip' javaBean='_("hidor.expandTip")'/> + + <script><![CDATA[ +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +addPropertyChangeListener("targetVisible", new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent evt) { + if (log.isDebugEnabled()) { + log.debug("target visible changed <" + evt.getOldValue() + ":" + evt.getNewValue() + ">"); + } + boolean newValue = (Boolean) evt.getNewValue(); + if (target != null) { + target.setVisible(newValue); + } + } +}); + +protected JComponent target; + +public JComponent getTarget() { + return target; +} + +public void setTarget(JComponent target) { + JComponent oldValue = this.target; + this.target = target; + firePropertyChange("target", oldValue, target); +} + +public void setExpandIcon(Icon icon) { + setSelectedIcon(icon); +} + +public void setCollapseIcon(Icon icon) { + setIcon(icon); +} + +protected String updateToolTipText(boolean c) { + String i = c ? collapseTip : expandTip; + return i; +} +]]> + </script> +</JToggleButton> Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ListSelectorUI.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/ListSelectorUI.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ListSelectorUI.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,192 +0,0 @@ -<JPanel layout='{new BorderLayout()}' genericType='B'> - - <!-- show hidor property --> - <Boolean id='showHidor' javaBean='false'/> - - <Boolean id='modified' javaBean='false'/> - - <String id='addToListTip' javaBean='"+"'/> - - <String id='addToComboTip' javaBean='"-"'/> - - <ListCellRenderer id='renderer' javaBean='null'/> - - <script><![CDATA[ -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeEvent; - -hidor.addPropertyChangeListener("targetVisible", new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - if (log.isDebugEnabled()) { - log.debug("target visible changed <" + evt.getOldValue() + ":" + evt.getNewValue() + ">"); - } - if (!showHidor || !isEnabled()) { - return; - } - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - log.info("invalidate " + getParent().getName()); - listPane.invalidate(); - } - }); - } -}); - -/** - * @return the datas from the combo box. - */ -public java.util.List<B> getComboDatas() { - java.util.List<B> datas = new java.util.ArrayList<B>(); - ComboBoxModel comboModel = combo.getModel(); - for (int i = 0, j = comboModel.getSize(); i < j; i++) { - B g = (B) comboModel.getElementAt(i); - datas.add(g); - } - return datas; -} - -/** - * @return the data for the list. - */ -public java.util.List<B> getListDatas() { - java.util.List<B> datas = new java.util.ArrayList<B>(); - ListModel listModel = list.getModel(); - for (int i = 0, j = listModel.getSize(); i < j; i++) { - B g = (B) listModel.getElementAt(i); - datas.add(g); - } - return datas; -} - -/** - * Initialize the component. - * - * @param toCombo datas to set in combo - * @param toList datas to set in list - */ -public void init(java.util.List<B> toCombo, java.util.List<B> toList) { - setComboDatas(toCombo); - setListDatas(toList); - // after init, always unmodified editor - // TODO should avoid to fire a changed ? - setModified(false); -} - -/** - * Transfert the {@code b} data from combo box to list. - * - * @param b the data to transfert - */ -protected void transfertToList(B b) { - ((DefaultListModel) list.getModel()).addElement(b); - ((DefaultComboBoxModel) combo.getModel()).removeElement(b); - setModified(true); -} - -/** - * Transfert the {@code b} data from list to combo box. - * - * @param bs the data to transfert - */ -protected void transfertToCombo(B[] bs) { - for (B b : bs) { - ((DefaultListModel) list.getModel()).removeElement(b); - ((DefaultComboBoxModel) combo.getModel()).addElement(b); - } - setModified(true); -} - -/** - * @param enabled databinding - * @return {@code true} if add button should be enabled - */ -protected boolean updateAddEnabled(boolean enabled) { - return enabled && combo.getModel().getSize() > 0; -} - -/** - * @param enabled databinding - * @return {@code true} if remove button should be enabled - */ -protected boolean updateRemoveEnabled(boolean enabled) { - return enabled && list.getModel().getSize() > 0; -} - -/** - * Set the data in combo box model. - * - * @param toCombo datas to set in combo box model - */ -protected void setComboDatas(java.util.List<B> toCombo) { - SwingUtil.fillComboBox(combo, toCombo, null); - //Note : there is a case when combo was selected, then come here with an empty - // combo model : no propertyChanged is fired, so add button stays enabled... - processDataBinding("add.enabled"); -} - -/** - * Set the data in the list model. - * - * @param toList datas to set in list model - */ -protected void setListDatas(java.util.List<B> toList) { - SwingUtil.fillList(list, toList, null); -} - -]]> - </script> - - <JScrollPane id='listPane' constraints='BorderLayout.CENTER' - columnHeaderView='{header}'> - <!--minimumSize='{SwingUtil.newMinDimension()}'>--> - <!--verticalScrollBarPolicy='vertical_scrollbar_always'--> - <JPanel layout="{new BorderLayout()}" minimumSize='{getMinimumSize()}'> - <JList id='list' - constraints='BorderLayout.CENTER' - enabled='{isEnabled()}' - model='{new DefaultListModel()}' - font-size='11' - onMouseClicked='if (event.getClickCount()==2) { transfertToCombo((B[]) list.getSelectedValues()); }' - cellRenderer='{getRenderer()}'/> - </JPanel> - - </JScrollPane> - - <Table id="header" insets='0' constraints='BorderLayout.SOUTH'> - <row> - <cell fill='horizontal' weightx='1' anchor="west"> - <JComboBox id='combo' enabled='{isEnabled()}' - model='{new DefaultComboBoxModel()}' - renderer='{getRenderer()}'/> - </cell> - <cell anchor='east'> - <JToolBar id='actions' floatable='false'> - <JButton id="add" - toolTipText='{getAddToListTip()}' - actionIcon='add' - enabled='{updateAddEnabled(combo.isEnabled() && combo.getSelectedIndex() > -1)}' - onActionPerformed='transfertToList((B) combo.getSelectedItem());'/> - - <JButton id="remove" - toolTipText='{getAddToComboTip()}' - actionIcon='remove' - enabled='{updateRemoveEnabled(list.isEnabled() && list.getSelectedIndex() > -1)}' - onActionPerformed='transfertToCombo((B[]) list.getSelectedValues())'/> - - <HidorButton id="hidor" - target='{list}' - visible='{isShowHidor()}' - enabled='{isEnabled()}' - collapseTip='{_("listSelector.hideList")}' - expandTip='{_("listSelector.showList")}' - targetVisible='{true}'/> - </JToolBar> - </cell> - </row> - </Table> - -</JPanel> \ No newline at end of file Copied: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ListSelectorUI.jaxx (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/ListSelectorUI.jaxx) =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ListSelectorUI.jaxx (rev 0) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ListSelectorUI.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,192 @@ +<JPanel layout='{new BorderLayout()}' genericType='B'> + + <!-- show hidor property --> + <Boolean id='showHidor' javaBean='false'/> + + <Boolean id='modified' javaBean='false'/> + + <String id='addToListTip' javaBean='"+"'/> + + <String id='addToComboTip' javaBean='"-"'/> + + <ListCellRenderer id='renderer' javaBean='null'/> + + <script><![CDATA[ +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeEvent; + +hidor.addPropertyChangeListener("targetVisible", new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent evt) { + if (log.isDebugEnabled()) { + log.debug("target visible changed <" + evt.getOldValue() + ":" + evt.getNewValue() + ">"); + } + if (!showHidor || !isEnabled()) { + return; + } + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + log.info("invalidate " + getParent().getName()); + listPane.invalidate(); + } + }); + } +}); + +/** + * @return the datas from the combo box. + */ +public java.util.List<B> getComboDatas() { + java.util.List<B> datas = new java.util.ArrayList<B>(); + ComboBoxModel comboModel = combo.getModel(); + for (int i = 0, j = comboModel.getSize(); i < j; i++) { + B g = (B) comboModel.getElementAt(i); + datas.add(g); + } + return datas; +} + +/** + * @return the data for the list. + */ +public java.util.List<B> getListDatas() { + java.util.List<B> datas = new java.util.ArrayList<B>(); + ListModel listModel = list.getModel(); + for (int i = 0, j = listModel.getSize(); i < j; i++) { + B g = (B) listModel.getElementAt(i); + datas.add(g); + } + return datas; +} + +/** + * Initialize the component. + * + * @param toCombo datas to set in combo + * @param toList datas to set in list + */ +public void init(java.util.List<B> toCombo, java.util.List<B> toList) { + setComboDatas(toCombo); + setListDatas(toList); + // after init, always unmodified editor + // TODO should avoid to fire a changed ? + setModified(false); +} + +/** + * Transfert the {@code b} data from combo box to list. + * + * @param b the data to transfert + */ +protected void transfertToList(B b) { + ((DefaultListModel) list.getModel()).addElement(b); + ((DefaultComboBoxModel) combo.getModel()).removeElement(b); + setModified(true); +} + +/** + * Transfert the {@code b} data from list to combo box. + * + * @param bs the data to transfert + */ +protected void transfertToCombo(B[] bs) { + for (B b : bs) { + ((DefaultListModel) list.getModel()).removeElement(b); + ((DefaultComboBoxModel) combo.getModel()).addElement(b); + } + setModified(true); +} + +/** + * @param enabled databinding + * @return {@code true} if add button should be enabled + */ +protected boolean updateAddEnabled(boolean enabled) { + return enabled && combo.getModel().getSize() > 0; +} + +/** + * @param enabled databinding + * @return {@code true} if remove button should be enabled + */ +protected boolean updateRemoveEnabled(boolean enabled) { + return enabled && list.getModel().getSize() > 0; +} + +/** + * Set the data in combo box model. + * + * @param toCombo datas to set in combo box model + */ +protected void setComboDatas(java.util.List<B> toCombo) { + SwingUtil.fillComboBox(combo, toCombo, null); + //Note : there is a case when combo was selected, then come here with an empty + // combo model : no propertyChanged is fired, so add button stays enabled... + processDataBinding("add.enabled"); +} + +/** + * Set the data in the list model. + * + * @param toList datas to set in list model + */ +protected void setListDatas(java.util.List<B> toList) { + SwingUtil.fillList(list, toList, null); +} + +]]> + </script> + + <JScrollPane id='listPane' constraints='BorderLayout.CENTER' + columnHeaderView='{header}'> + <!--minimumSize='{SwingUtil.newMinDimension()}'>--> + <!--verticalScrollBarPolicy='vertical_scrollbar_always'--> + <JPanel layout="{new BorderLayout()}" minimumSize='{getMinimumSize()}'> + <JList id='list' + constraints='BorderLayout.CENTER' + enabled='{isEnabled()}' + model='{new DefaultListModel()}' + font-size='11' + onMouseClicked='if (event.getClickCount()==2) { transfertToCombo((B[]) list.getSelectedValues()); }' + cellRenderer='{getRenderer()}'/> + </JPanel> + + </JScrollPane> + + <Table id="header" insets='0' constraints='BorderLayout.SOUTH'> + <row> + <cell fill='horizontal' weightx='1' anchor="west"> + <JComboBox id='combo' enabled='{isEnabled()}' + model='{new DefaultComboBoxModel()}' + renderer='{getRenderer()}'/> + </cell> + <cell anchor='east'> + <JToolBar id='actions' floatable='false'> + <JButton id="add" + toolTipText='{getAddToListTip()}' + actionIcon='add' + enabled='{updateAddEnabled(combo.isEnabled() && combo.getSelectedIndex() > -1)}' + onActionPerformed='transfertToList((B) combo.getSelectedItem());'/> + + <JButton id="remove" + toolTipText='{getAddToComboTip()}' + actionIcon='remove' + enabled='{updateRemoveEnabled(list.isEnabled() && list.getSelectedIndex() > -1)}' + onActionPerformed='transfertToCombo((B[]) list.getSelectedValues())'/> + + <HidorButton id="hidor" + target='{list}' + visible='{isShowHidor()}' + enabled='{isEnabled()}' + collapseTip='{_("listSelector.hideList")}' + expandTip='{_("listSelector.showList")}' + targetVisible='{true}'/> + </JToolBar> + </cell> + </row> + </Table> + +</JPanel> \ No newline at end of file Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/MemoryStatusWidget.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/MemoryStatusWidget.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/MemoryStatusWidget.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,113 +0,0 @@ -<!-- - -/** - * *##% jaxx-runtime-swing-widget - * 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>. ##%* - */ - ---> - -<JComponent implements='ActionListener' - foreground='{Color.BLACK}' - background='{Color.WHITE}' - font='{new JLabel().getFont()}'> - - <javax.swing.Timer id='timer' javaBean='null'/> - - <Color id='progressBackground' javaBean='Color.decode("#666699a")'/> - <Color id='progressForeground' javaBean='Color.decode("#cccccc")'/> - - <script><![CDATA[ -import java.awt.font.FontRenderContext; -import java.awt.font.LineMetrics; -import java.awt.geom.Rectangle2D; - -private final static String memoryTestStr = "99999/99999Mb"; - -private FontRenderContext frc = new FontRenderContext(null, false, false); - -private LineMetrics lm = new JLabel().getFont().getLineMetrics(memoryTestStr, frc); - -@Override -public void actionPerformed(ActionEvent evt) { - repaint(); -} - -/** Adds a feature to the Notify attribute of the MemoryStatus object */ -@Override -public void addNotify() { - super.addNotify(); - setTimer(new javax.swing.Timer(2000, this)); - timer.start(); -} - -@Override -public void removeNotify() { - if (timer != null) { - timer.stop(); - timer = null; - } - super.removeNotify(); -} - -@Override -public void paintComponent(Graphics g) { - Insets insets = new Insets(0, 0, 0, 0); - Runtime runtime = Runtime.getRuntime(); - int freeMemory = (int) (runtime.freeMemory() / 1024L); - int totalMemory = (int) (runtime.totalMemory() / 1024L); - int usedMemory = totalMemory - freeMemory; - int width = getWidth() - insets.left - insets.right; - int height = getHeight() - insets.top - insets.bottom - 1; - float fraction = (float) usedMemory / (float) totalMemory; - g.setColor(progressBackground); - g.fillRect(insets.left, insets.top, (int) ((float) width * fraction), height); - // No i18n string was : - // String str = usedMemory / 1024 + "/" + totalMemory / 1024 + "Mb"; - String str = _("memorywidget.memory", usedMemory / 1024, totalMemory / 1024); - //FontRenderContext frc = new FontRenderContext(null, false, false); - Rectangle2D bounds = g.getFont().getStringBounds(str, frc); - Graphics g2 = g.create(); - g2.setClip(insets.left, insets.top, - (int) ((float) width * fraction), height); - g2.setColor(progressForeground); - g2.drawString(str, insets.left - + (int) ((double) width - bounds.getWidth()) / 2, - (int) ((float) insets.top + lm.getAscent())); - g2.dispose(); - g2 = g.create(); - g2.setClip(insets.left + (int) ((float) width * fraction), - insets.top, getWidth() - insets.left - - (int) ((float) width * fraction), height); - g2.setColor(getForeground()); - g2.drawString(str, insets.left - + (int) ((double) width - bounds.getWidth()) / 2, - (int) ((float) insets.top + lm.getAscent())); - g2.dispose(); -} - - -void $afterCompleteSetup() { - //FontRenderContext frc = new FontRenderContext(null, false, false); - Rectangle2D bounds = getFont().getStringBounds(memoryTestStr, frc); - Dimension dim = new Dimension((int) bounds.getWidth(), (int) bounds .getHeight()); - setPreferredSize(dim); - setMaximumSize(dim); -} -]]> - </script> -</JComponent> Copied: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/MemoryStatusWidget.jaxx (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/MemoryStatusWidget.jaxx) =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/MemoryStatusWidget.jaxx (rev 0) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/MemoryStatusWidget.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,113 @@ +<!-- + +/** + * *##% jaxx-runtime-swing-widget + * 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>. ##%* + */ + +--> + +<JComponent implements='ActionListener' + foreground='{Color.BLACK}' + background='{Color.WHITE}' + font='{new JLabel().getFont()}'> + + <javax.swing.Timer id='timer' javaBean='null'/> + + <Color id='progressBackground' javaBean='Color.decode("#666699a")'/> + <Color id='progressForeground' javaBean='Color.decode("#cccccc")'/> + + <script><![CDATA[ +import java.awt.font.FontRenderContext; +import java.awt.font.LineMetrics; +import java.awt.geom.Rectangle2D; + +private final static String memoryTestStr = "99999/99999Mb"; + +private FontRenderContext frc = new FontRenderContext(null, false, false); + +private LineMetrics lm = new JLabel().getFont().getLineMetrics(memoryTestStr, frc); + +@Override +public void actionPerformed(ActionEvent evt) { + repaint(); +} + +/** Adds a feature to the Notify attribute of the MemoryStatus object */ +@Override +public void addNotify() { + super.addNotify(); + setTimer(new javax.swing.Timer(2000, this)); + timer.start(); +} + +@Override +public void removeNotify() { + if (timer != null) { + timer.stop(); + timer = null; + } + super.removeNotify(); +} + +@Override +public void paintComponent(Graphics g) { + Insets insets = new Insets(0, 0, 0, 0); + Runtime runtime = Runtime.getRuntime(); + int freeMemory = (int) (runtime.freeMemory() / 1024L); + int totalMemory = (int) (runtime.totalMemory() / 1024L); + int usedMemory = totalMemory - freeMemory; + int width = getWidth() - insets.left - insets.right; + int height = getHeight() - insets.top - insets.bottom - 1; + float fraction = (float) usedMemory / (float) totalMemory; + g.setColor(progressBackground); + g.fillRect(insets.left, insets.top, (int) ((float) width * fraction), height); + // No i18n string was : + // String str = usedMemory / 1024 + "/" + totalMemory / 1024 + "Mb"; + String str = _("memorywidget.memory", usedMemory / 1024, totalMemory / 1024); + //FontRenderContext frc = new FontRenderContext(null, false, false); + Rectangle2D bounds = g.getFont().getStringBounds(str, frc); + Graphics g2 = g.create(); + g2.setClip(insets.left, insets.top, + (int) ((float) width * fraction), height); + g2.setColor(progressForeground); + g2.drawString(str, insets.left + + (int) ((double) width - bounds.getWidth()) / 2, + (int) ((float) insets.top + lm.getAscent())); + g2.dispose(); + g2 = g.create(); + g2.setClip(insets.left + (int) ((float) width * fraction), + insets.top, getWidth() - insets.left + - (int) ((float) width * fraction), height); + g2.setColor(getForeground()); + g2.drawString(str, insets.left + + (int) ((double) width - bounds.getWidth()) / 2, + (int) ((float) insets.top + lm.getAscent())); + g2.dispose(); +} + + +void $afterCompleteSetup() { + //FontRenderContext frc = new FontRenderContext(null, false, false); + Rectangle2D bounds = getFont().getStringBounds(memoryTestStr, frc); + Dimension dim = new Dimension((int) bounds.getWidth(), (int) bounds .getHeight()); + setPreferredSize(dim); + setMaximumSize(dim); +} +]]> + </script> +</JComponent> Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/StatusMessagePanel.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/StatusMessagePanel.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/StatusMessagePanel.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,84 +0,0 @@ -<!-- - -/** - * *##% jaxx-runtime-swing-widget - * 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>. ##%* - */ - ---> - -<Table border='{BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED)}' - insets='0' - implements='ActionListener'> - - <Boolean id='showMemoryStatus' javaBean='Boolean.TRUE'/> - <Boolean id='showClock' javaBean='Boolean.TRUE'/> - <Boolean id='showI18n' javaBean='Boolean.FALSE'/> - - <StatusMessagePanelHandler id='handler' /> - - <script><![CDATA[ - -// To ensure status bar constant height, no matter what font are in use... -protected final static String EMPTY_STATUS = " "; - -public void clearStatus() { - handler.stopStatusFader(this); - getStatusLabel().setText(EMPTY_STATUS); -} - -public void setStatus(String status) { - handler.stopStatusFader(this); - getStatusLabel().setText(status); - handler.startStatusFader(this); -} - -@Override -public void actionPerformed(ActionEvent evt) { - handler.fadeStatus(this); -} - -public <U extends Component> U getWidget(Class<U> clazz) { - for (Component component : box.getComponents()) { - if (clazz == component.getClass()) { - return (U) component; - } - } - return null; -} - -public void addWidget(Component w) { - box.add(w); -} - -public void addWidget(Component w, int index) { - box.add(w, index); -} -]]> - </script> - <row> - <cell anchor='west' weightx='1' insets='2'> - <JLabel id='statusLabel'/> - </cell> - <cell anchor='east'> - <Box id='box' constructorParams='0'> - <MemoryStatusWidget/> - <ClockWidget/> - </Box> - </cell> - </row> -</Table> Copied: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/StatusMessagePanel.jaxx (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/StatusMessagePanel.jaxx) =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/StatusMessagePanel.jaxx (rev 0) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/StatusMessagePanel.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,84 @@ +<!-- + +/** + * *##% jaxx-runtime-swing-widget + * 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>. ##%* + */ + +--> + +<Table border='{BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED)}' + insets='0' + implements='ActionListener'> + + <Boolean id='showMemoryStatus' javaBean='Boolean.TRUE'/> + <Boolean id='showClock' javaBean='Boolean.TRUE'/> + <Boolean id='showI18n' javaBean='Boolean.FALSE'/> + + <StatusMessagePanelHandler id='handler' /> + + <script><![CDATA[ + +// To ensure status bar constant height, no matter what font are in use... +protected final static String EMPTY_STATUS = " "; + +public void clearStatus() { + handler.stopStatusFader(this); + getStatusLabel().setText(EMPTY_STATUS); +} + +public void setStatus(String status) { + handler.stopStatusFader(this); + getStatusLabel().setText(status); + handler.startStatusFader(this); +} + +@Override +public void actionPerformed(ActionEvent evt) { + handler.fadeStatus(this); +} + +public <U extends Component> U getWidget(Class<U> clazz) { + for (Component component : box.getComponents()) { + if (clazz == component.getClass()) { + return (U) component; + } + } + return null; +} + +public void addWidget(Component w) { + box.add(w); +} + +public void addWidget(Component w, int index) { + box.add(w, index); +} +]]> + </script> + <row> + <cell anchor='west' weightx='1' insets='2'> + <JLabel id='statusLabel'/> + </cell> + <cell anchor='east'> + <Box id='box' constructorParams='0'> + <MemoryStatusWidget/> + <ClockWidget/> + </Box> + </cell> + </row> +</Table> Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/StatusMessagePanelHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/StatusMessagePanelHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/StatusMessagePanelHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,77 +0,0 @@ -/** - * *##% - * JAXX Widgets - * 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>. - * ##%* - */ -package jaxx.runtime.swing; - -import java.awt.Color; -import java.awt.event.ActionListener; -import javax.swing.Timer; - -/** - * - * @author chemit - * @since 1.6.0 - */ -public class StatusMessagePanelHandler { - - protected Color statusForeground = null; - protected String statusReferenceContent = null; - protected javax.swing.Timer timer = null; - - protected void fadeStatus(StatusMessagePanel ui) { - for (int i = 0; i < 8; i++) { - // synchronized (this) { - if (!statusReferenceContent.equals(ui.getStatusLabel().getText())) { - return; - } - Color currentForeground = ui.getStatusLabel().getForeground(); - Color newColor = new Color(currentForeground.getRed(), - currentForeground.getGreen(), currentForeground.getBlue(), - currentForeground.getAlpha() - 25); - ui.getStatusLabel().setForeground(newColor); - ui.getStatusLabel().repaint(); - // } - // TC-2000311 je comprends pas a quoi ca sert, a part frizzer les ui ? - // si on utilise un Timer, pourquoi utiliser ça ? - /*try { - Thread.sleep(200); - } catch (InterruptedException eee) { - eee.printStackTrace(); - }*/ - } - } - - protected void startStatusFader(StatusMessagePanel ui) { - statusReferenceContent = ui.getStatusLabel().getText(); - - int millisecondsPerMinute = 5000; - timer = new Timer(millisecondsPerMinute, (ActionListener) ui); - timer.setRepeats(false); - timer.setInitialDelay((int) ((long) millisecondsPerMinute - System.currentTimeMillis() % (long) millisecondsPerMinute) + 500); - timer.start(); - } - - protected void stopStatusFader(StatusMessagePanel ui) { - if (timer != null) { - timer.stop(); - ui.getStatusLabel().setForeground(statusForeground); - } - } -} Copied: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/StatusMessagePanelHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/StatusMessagePanelHandler.java) =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/StatusMessagePanelHandler.java (rev 0) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/StatusMessagePanelHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,77 @@ +/** + * *##% + * JAXX Widgets + * 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>. + * ##%* + */ +package jaxx.runtime.swing; + +import java.awt.Color; +import java.awt.event.ActionListener; +import javax.swing.Timer; + +/** + * + * @author chemit + * @since 1.6.0 + */ +public class StatusMessagePanelHandler { + + protected Color statusForeground = null; + protected String statusReferenceContent = null; + protected javax.swing.Timer timer = null; + + protected void fadeStatus(StatusMessagePanel ui) { + for (int i = 0; i < 8; i++) { + // synchronized (this) { + if (!statusReferenceContent.equals(ui.getStatusLabel().getText())) { + return; + } + Color currentForeground = ui.getStatusLabel().getForeground(); + Color newColor = new Color(currentForeground.getRed(), + currentForeground.getGreen(), currentForeground.getBlue(), + currentForeground.getAlpha() - 25); + ui.getStatusLabel().setForeground(newColor); + ui.getStatusLabel().repaint(); + // } + // TC-2000311 je comprends pas a quoi ca sert, a part frizzer les ui ? + // si on utilise un Timer, pourquoi utiliser ça ? + /*try { + Thread.sleep(200); + } catch (InterruptedException eee) { + eee.printStackTrace(); + }*/ + } + } + + protected void startStatusFader(StatusMessagePanel ui) { + statusReferenceContent = ui.getStatusLabel().getText(); + + int millisecondsPerMinute = 5000; + timer = new Timer(millisecondsPerMinute, (ActionListener) ui); + timer.setRepeats(false); + timer.setInitialDelay((int) ((long) millisecondsPerMinute - System.currentTimeMillis() % (long) millisecondsPerMinute) + 500); + timer.start(); + } + + protected void stopStatusFader(StatusMessagePanel ui) { + if (timer != null) { + timer.stop(); + ui.getStatusLabel().setForeground(statusForeground); + } + } +} Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/ColumnSelector.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/ColumnSelector.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/ColumnSelector.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,155 +0,0 @@ -<!-- - -/** - * *##% jaxx-runtime-swing-widget - * 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>. ##%* - */ - ---> -<JPanel implements='PropertyChangeListener, ActionListener' - layout='{new BorderLayout()}' - onFocusGained='button.requestFocus()' - onFocusLost='setPopupVisible(false)'> - - <!-- table to works with --> - <Object id='myTable' javaBean='null'/> - - <!-- internal state --> - <Boolean id='popupVisible' javaBean='false'/> - - <!-- ui handler --> - <!--ColumnSelectorHandler id='handler' constructorParams='this'/--> - - <JPopupMenu id='popup' - border='{new TitledBorder(_("i18neditor.popup.title"))}' - onPopupMenuWillBecomeInvisible='button.setSelected(false)' - onPopupMenuCanceled='button.setSelected(false)'> - <JLabel id='popupLabel' enabled='false' text='i18neditor.empty.locales'/> - </JPopupMenu> - - <script><![CDATA[ -import javax.swing.table.TableColumn; -import javax.swing.table.TableCellRenderer; -import jaxx.runtime.swing.renderer.I18nTableCellRenderer; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeEvent; - -public static final String TABLE_PROPERTY = "myTable"; -public static final String POPUP_VISIBLE_PROPERTY = "popupVisible"; - -@Override -public void propertyChange(PropertyChangeEvent evt) { - String name = evt.getPropertyName(); - if (log.isDebugEnabled()) { - log.debug(name+" <old:"+evt.getOldValue()+" - new:"+evt.getNewValue()+">"); - } - //log.info(name+" <old:"+evt.getOldValue()+" - new:"+evt.getNewValue()+">"); - if (TABLE_PROPERTY.equals(name)) { - // table has changed, rebuild the popup - try { - - popup.removeAll(); - JTable t = (JTable) evt.getNewValue(); - if (t != null) { - log.info("table has changed ! " + t.getName()); - for (int i = 0, columnCount = t.getColumnCount(); i < columnCount; i++) { - TableColumn column = t.getColumnModel().getColumn(i); - TableCellRenderer defaultRenderer = t.getTableHeader().getDefaultRenderer(); - String columnName = column.getHeaderValue() + ""; - if (defaultRenderer instanceof I18nTableCellRenderer) { - I18nTableCellRenderer renderer = (I18nTableCellRenderer) defaultRenderer; - columnName = _(renderer.getKeys()[i]); - } - JRadioButtonMenuItem b = new JRadioButtonMenuItem(columnName, null, true); - popup.add(b); - b.addActionListener(this); - b.putClientProperty("columnIndex", i); - b.putClientProperty("columnName", columnName); - b.putClientProperty("column", column); - } - } - } finally { - popup.invalidate(); - } - return; - } - if (POPUP_VISIBLE_PROPERTY.equals(name)) { - Boolean newValue = (Boolean) evt.getNewValue(); - if (newValue == null || !newValue) { - if (getPopup() != null && getPopup().isVisible()) { - getPopup().setVisible(false); - } - return; - } - if (!getPopup().isVisible()) { - SwingUtilities.invokeLater(showPopupRunnable); - } - return; - } - -} - -@Override -public void actionPerformed(ActionEvent event) { - JRadioButtonMenuItem source = (JRadioButtonMenuItem) event.getSource(); - boolean selected = source.isSelected(); - TableColumn column = (TableColumn) source.getClientProperty("column"); - Integer columnIndex = (Integer) source.getClientProperty("columnIndex"); - String columnName = (String) source.getClientProperty("columnName"); - log.info(columnName + ", selected : " + selected); - JTable t = (JTable) myTable; - if (selected) { - // reinject the column in table - t.getColumnModel().addColumn(column); - } else { - // remove column from table - t.getColumnModel().removeColumn(column); - } -} - -protected Runnable showPopupRunnable = new Runnable() { - @Override - public void run() { - getPopup().pack(); - Dimension dim = getPopup().getPreferredSize(); - JToggleButton invoker = getButton(); - getPopup().show(invoker, (int) (invoker.getPreferredSize().getWidth() - dim.getWidth()), invoker.getHeight()); - } -}; - - -addPropertyChangeListener(TABLE_PROPERTY,this); -addPropertyChangeListener(POPUP_VISIBLE_PROPERTY,this); -]]> - </script> - <JToolBar floatable='false' - opaque='false' - borderPainted='false'> - <JToggleButton - id='button' - toolTipText='columnselector.action.tip' - actionIcon='numbereditor-calculator' - constraints='BorderLayout.CENTER' - selected='{popup.isVisible()}' - focusable='true' - focusPainted='false' - borderPainted='false' - rolloverEnabled='false' - onItemStateChanged='if (event.getStateChange() == ItemEvent.SELECTED) { setPopupVisible(true); } else { popupVisible = false; }'/> - </JToolBar> -</JPanel> \ No newline at end of file Copied: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/ColumnSelector.jaxx (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/ColumnSelector.jaxx) =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/ColumnSelector.jaxx (rev 0) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/ColumnSelector.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,155 @@ +<!-- + +/** + * *##% jaxx-runtime-swing-widget + * 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>. ##%* + */ + +--> +<JPanel implements='PropertyChangeListener, ActionListener' + layout='{new BorderLayout()}' + onFocusGained='button.requestFocus()' + onFocusLost='setPopupVisible(false)'> + + <!-- table to works with --> + <Object id='myTable' javaBean='null'/> + + <!-- internal state --> + <Boolean id='popupVisible' javaBean='false'/> + + <!-- ui handler --> + <!--ColumnSelectorHandler id='handler' constructorParams='this'/--> + + <JPopupMenu id='popup' + border='{new TitledBorder(_("i18neditor.popup.title"))}' + onPopupMenuWillBecomeInvisible='button.setSelected(false)' + onPopupMenuCanceled='button.setSelected(false)'> + <JLabel id='popupLabel' enabled='false' text='i18neditor.empty.locales'/> + </JPopupMenu> + + <script><![CDATA[ +import javax.swing.table.TableColumn; +import javax.swing.table.TableCellRenderer; +import jaxx.runtime.swing.renderer.I18nTableCellRenderer; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeEvent; + +public static final String TABLE_PROPERTY = "myTable"; +public static final String POPUP_VISIBLE_PROPERTY = "popupVisible"; + +@Override +public void propertyChange(PropertyChangeEvent evt) { + String name = evt.getPropertyName(); + if (log.isDebugEnabled()) { + log.debug(name+" <old:"+evt.getOldValue()+" - new:"+evt.getNewValue()+">"); + } + //log.info(name+" <old:"+evt.getOldValue()+" - new:"+evt.getNewValue()+">"); + if (TABLE_PROPERTY.equals(name)) { + // table has changed, rebuild the popup + try { + + popup.removeAll(); + JTable t = (JTable) evt.getNewValue(); + if (t != null) { + log.info("table has changed ! " + t.getName()); + for (int i = 0, columnCount = t.getColumnCount(); i < columnCount; i++) { + TableColumn column = t.getColumnModel().getColumn(i); + TableCellRenderer defaultRenderer = t.getTableHeader().getDefaultRenderer(); + String columnName = column.getHeaderValue() + ""; + if (defaultRenderer instanceof I18nTableCellRenderer) { + I18nTableCellRenderer renderer = (I18nTableCellRenderer) defaultRenderer; + columnName = _(renderer.getKeys()[i]); + } + JRadioButtonMenuItem b = new JRadioButtonMenuItem(columnName, null, true); + popup.add(b); + b.addActionListener(this); + b.putClientProperty("columnIndex", i); + b.putClientProperty("columnName", columnName); + b.putClientProperty("column", column); + } + } + } finally { + popup.invalidate(); + } + return; + } + if (POPUP_VISIBLE_PROPERTY.equals(name)) { + Boolean newValue = (Boolean) evt.getNewValue(); + if (newValue == null || !newValue) { + if (getPopup() != null && getPopup().isVisible()) { + getPopup().setVisible(false); + } + return; + } + if (!getPopup().isVisible()) { + SwingUtilities.invokeLater(showPopupRunnable); + } + return; + } + +} + +@Override +public void actionPerformed(ActionEvent event) { + JRadioButtonMenuItem source = (JRadioButtonMenuItem) event.getSource(); + boolean selected = source.isSelected(); + TableColumn column = (TableColumn) source.getClientProperty("column"); + Integer columnIndex = (Integer) source.getClientProperty("columnIndex"); + String columnName = (String) source.getClientProperty("columnName"); + log.info(columnName + ", selected : " + selected); + JTable t = (JTable) myTable; + if (selected) { + // reinject the column in table + t.getColumnModel().addColumn(column); + } else { + // remove column from table + t.getColumnModel().removeColumn(column); + } +} + +protected Runnable showPopupRunnable = new Runnable() { + @Override + public void run() { + getPopup().pack(); + Dimension dim = getPopup().getPreferredSize(); + JToggleButton invoker = getButton(); + getPopup().show(invoker, (int) (invoker.getPreferredSize().getWidth() - dim.getWidth()), invoker.getHeight()); + } +}; + + +addPropertyChangeListener(TABLE_PROPERTY,this); +addPropertyChangeListener(POPUP_VISIBLE_PROPERTY,this); +]]> + </script> + <JToolBar floatable='false' + opaque='false' + borderPainted='false'> + <JToggleButton + id='button' + toolTipText='columnselector.action.tip' + actionIcon='numbereditor-calculator' + constraints='BorderLayout.CENTER' + selected='{popup.isVisible()}' + focusable='true' + focusPainted='false' + borderPainted='false' + rolloverEnabled='false' + onItemStateChanged='if (event.getStateChange() == ItemEvent.SELECTED) { setPopupVisible(true); } else { popupVisible = false; }'/> + </JToolBar> +</JPanel> \ No newline at end of file Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/I18nEditor.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/I18nEditor.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/I18nEditor.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,254 +0,0 @@ -<!-- - -/** - * *##% jaxx-runtime-swing-widget - * 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>. ##%* - */ - ---> - -<JPanel implements='PropertyChangeListener, ActionListener' - id='content' - layout='{new BorderLayout()}' - onFocusGained='button.requestFocus()' - onFocusLost='setPopupVisible(false)'> - - <String id='selectedToolTipText' javaBean='null'/> - <String id='notSelectedToolTipText' javaBean='null'/> - - <Border id='popupBorder' javaBean='new TitledBorder(_("i18neditor.popup.title"))'/> - - <Boolean id='showText' javaBean='Boolean.TRUE'/> - <Boolean id='showIcon' javaBean='Boolean.TRUE'/> - <Boolean id='showPopupText' javaBean='Boolean.TRUE'/> - <Boolean id='showPopupIcon' javaBean='Boolean.TRUE'/> - <Boolean id='popupVisible' javaBean='Boolean.FALSE'/> - - <java.util.List id='locales' javaBean='null' genericType='Locale'/> - - <Locale id='selectedLocale' javaBean='Locale.getDefault()'/> - - <jaxx.runtime.swing.renderer.LocaleListCellRenderer id='renderer' - showIcon='{isShowIcon()}' - showText='{isShowText()}' - javaBean='new LocaleListCellRenderer(showIcon , showText)'/> - - <!-- popup to change sorted property--> - <JPopupMenu id='popup' - border='{getPopupBorder()}' - onPopupMenuWillBecomeInvisible='button.setSelected(false)' - onPopupMenuCanceled='button.setSelected(false)'> - <JLabel id='popupLabel' enabled='false' text='i18neditor.empty.locales'/> - </JPopupMenu> - - <JToggleButton - id='button' - text='{SwingUtil.getStringValue(renderer.getText(getSelectedLocale()))}' - toolTipText='{getTip(getSelectedLocale())}' - icon='{renderer.getIcon(getSelectedLocale())}' - constraints='BorderLayout.CENTER' - selected='{popup.isVisible()}' - focusable='true' - focusPainted='false' - onItemStateChanged='if (event.getStateChange() == ItemEvent.SELECTED) { setPopupVisible(true); } else { popupVisible = false; }'/> - - <ButtonGroup id='indexes' onStateChanged='log.info(indexes.getSelectedValue())'/> - - <script><![CDATA[ -import java.util.Locale; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import jaxx.runtime.swing.renderer.LocaleListCellRenderer; -import static org.nuiton.i18n.I18n.n_; - -public static final String DEFAULT_SELECTED_TOOLTIP = n_("i18neditor.selected"); -public static final String DEFAULT_NOT_SELECTED_TOOLTIP = n_("i18neditor.unselected"); - -public static final String LOCALES_PROPERTY = "locales"; -public static final String SELECTED_LOCALE_PROPERTY = "selectedLocale"; -public static final String SHOW_ICON_PROPERTY = "showIcon"; -public static final String SHOW_TEXT_PROPERTY = "showText"; -public static final String SHOW_POPUP_ICON_PROPERTY = "showPopupIcon"; -public static final String SHOW_POPUP_TEXT_PROPERTY = "showPopupText"; -public static final String POPUP_BORDER_PROPERTY = "popupBorder"; -public static final String POPUP_VISIBLE_PROPERTY = "popupVisible"; - -@Override -public void propertyChange(PropertyChangeEvent evt) { - String name = evt.getPropertyName(); - if (log.isDebugEnabled()) { - log.debug(name+" <old:"+evt.getOldValue()+" - new:"+evt.getNewValue()+">"); - } - log.info(name + " <old:"+evt.getOldValue()+" - new:"+evt.getNewValue()+">"); - if (LOCALES_PROPERTY.equals(name)) { - java.util.Collection<?> newLocales = (java.util.Collection<?>) evt.getNewValue(); - // mise a jour de la popup - boolean oldShowText = renderer.isShowText(); - try { - renderer.setShowText(true); - popup.removeAll(); - for (Object o : newLocales) { - Locale l = (Locale) o; - boolean selected = l.equals(selectedLocale); - String text = isShowPopupText() ? renderer.getText(l) : null; - Icon icon = isShowPopupIcon() ? renderer.getIcon(l) : null; - JRadioButtonMenuItem b = new JRadioButtonMenuItem(text, icon, selected); - popup.add(b); - b.addActionListener(this); - b.putClientProperty("locale", l); - b.setToolTipText(getTip(l)); - b.putClientProperty(JAXXButtonGroup.BUTTON8GROUP_CLIENT_PROPERTY, getIndexes()); - b.putClientProperty(JAXXButtonGroup.VALUE_CLIENT_PROPERTY, l); - } - } finally { - renderer.setShowText(oldShowText); - popup.invalidate(); - } - return; - } - if (SHOW_ICON_PROPERTY.equals(name)) { - renderer.setShowIcon((Boolean) evt.getNewValue()); - processDataBinding("button.icon"); - return; - } - if (SHOW_TEXT_PROPERTY.equals(name)) { - renderer.setShowText((Boolean) evt.getNewValue()); - processDataBinding("button.text"); - return; - } - if (SHOW_POPUP_ICON_PROPERTY.equals(name)) { - rebuildPopup(); - return; - } - if (SHOW_POPUP_TEXT_PROPERTY.equals(name)) { - rebuildPopup(); - return; - } - if (POPUP_BORDER_PROPERTY.equals(name)) { - popup.setBorder((Border)evt.getNewValue()); - return; - } - if (POPUP_VISIBLE_PROPERTY.equals(name)) { - Boolean newValue = (Boolean) evt.getNewValue(); - if (newValue == null || !newValue) { - if (getPopup() != null && getPopup().isVisible()) { - getPopup().setVisible(false); - } - return; - } - if (!getPopup().isVisible()) { - SwingUtilities.invokeLater(showPopupRunnable); - } - return; - } - if (SELECTED_LOCALE_PROPERTY.equals(name)) { - Locale newLocale = (Locale) evt.getNewValue(); - // mise a jour de la popup - try { - for (Component c : popup.getComponents()) { - if (c instanceof JRadioButtonMenuItem) { - JRadioButtonMenuItem b = (JRadioButtonMenuItem) c; - Locale l = (Locale) b.getClientProperty("locale"); - b.setSelected(newLocale.equals(l)); - } - } - } finally { - popup.invalidate(); - } - return; - } -} - -@Override -public void actionPerformed(ActionEvent event) { - Locale value = (Locale) ((JComponent)event.getSource()).getClientProperty("locale"); - if (log.isDebugEnabled()) { - log.debug("new locale : " + value); - } - setSelectedLocale(value); -} - -public void loadI18nBundles() { - Locale[] locales = org.nuiton.i18n.I18n.getLoader().getLocales(); - setLocales(java.util.Arrays.asList(org.nuiton.i18n.I18n.getLoader().getLocales())); -} - -protected void rebuildPopup() { - log.debug("start rebuild"); - try { - for (Component c : popup.getComponents()) { - if (c instanceof JRadioButtonMenuItem) { - JRadioButtonMenuItem b = (JRadioButtonMenuItem) c; - Locale l = (Locale) b.getClientProperty("locale"); - String text = isShowPopupText() ? renderer.getSafeText(l) : null; - Icon icon = isShowPopupIcon() ? renderer.getSafeIcon(l) : null; - b.setIcon(icon); - b.setText(text); - log.debug("text=" + text); - log.debug("icon=" + icon); - } - } - } finally { - popup.invalidate(); - } -} - -protected String getTip(Locale l) { - boolean selected = l.equals(selectedLocale); - String tip = selected ? getSelectedTip(l):getNotSelectedTip(l); - return tip; -} - -protected String getSelectedTip(Locale l) { - String selectedTip = getSelectedToolTipText(); - if (selectedTip == null) { - // use default selected tip text - selectedTip = DEFAULT_SELECTED_TOOLTIP; - } - String tip = renderer.getToolTipText(l); - tip = _(selectedTip, tip); - return tip; -} - -protected String getNotSelectedTip(Locale l) { - String selectedTip = getNotSelectedToolTipText(); - if (selectedTip == null) { - // use default not selected tip text - selectedTip = DEFAULT_NOT_SELECTED_TOOLTIP; - } - String tip = renderer.getToolTipText(l); - tip = _(selectedTip, tip); - return tip; -} - -protected Runnable showPopupRunnable = new Runnable() { - @Override - public void run() { - getPopup().pack(); - JToggleButton invoker = getButton(); - Dimension dim = getPopup().getPreferredSize(); - Dimension invokerDim = invoker.getSize(); - getPopup().show(invoker, (int) (invokerDim.getWidth() - dim.getWidth()), invoker.getHeight()); -// getPopup().setVisible(true); - } -}; - -addPropertyChangeListener(this); - -]]> - </script> -</JPanel> Copied: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/I18nEditor.jaxx (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/I18nEditor.jaxx) =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/I18nEditor.jaxx (rev 0) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/I18nEditor.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,254 @@ +<!-- + +/** + * *##% jaxx-runtime-swing-widget + * 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>. ##%* + */ + +--> + +<JPanel implements='PropertyChangeListener, ActionListener' + id='content' + layout='{new BorderLayout()}' + onFocusGained='button.requestFocus()' + onFocusLost='setPopupVisible(false)'> + + <String id='selectedToolTipText' javaBean='null'/> + <String id='notSelectedToolTipText' javaBean='null'/> + + <Border id='popupBorder' javaBean='new TitledBorder(_("i18neditor.popup.title"))'/> + + <Boolean id='showText' javaBean='Boolean.TRUE'/> + <Boolean id='showIcon' javaBean='Boolean.TRUE'/> + <Boolean id='showPopupText' javaBean='Boolean.TRUE'/> + <Boolean id='showPopupIcon' javaBean='Boolean.TRUE'/> + <Boolean id='popupVisible' javaBean='Boolean.FALSE'/> + + <java.util.List id='locales' javaBean='null' genericType='Locale'/> + + <Locale id='selectedLocale' javaBean='Locale.getDefault()'/> + + <jaxx.runtime.swing.renderer.LocaleListCellRenderer id='renderer' + showIcon='{isShowIcon()}' + showText='{isShowText()}' + javaBean='new LocaleListCellRenderer(showIcon , showText)'/> + + <!-- popup to change sorted property--> + <JPopupMenu id='popup' + border='{getPopupBorder()}' + onPopupMenuWillBecomeInvisible='button.setSelected(false)' + onPopupMenuCanceled='button.setSelected(false)'> + <JLabel id='popupLabel' enabled='false' text='i18neditor.empty.locales'/> + </JPopupMenu> + + <JToggleButton + id='button' + text='{SwingUtil.getStringValue(renderer.getText(getSelectedLocale()))}' + toolTipText='{getTip(getSelectedLocale())}' + icon='{renderer.getIcon(getSelectedLocale())}' + constraints='BorderLayout.CENTER' + selected='{popup.isVisible()}' + focusable='true' + focusPainted='false' + onItemStateChanged='if (event.getStateChange() == ItemEvent.SELECTED) { setPopupVisible(true); } else { popupVisible = false; }'/> + + <ButtonGroup id='indexes' onStateChanged='log.info(indexes.getSelectedValue())'/> + + <script><![CDATA[ +import java.util.Locale; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import jaxx.runtime.swing.renderer.LocaleListCellRenderer; +import static org.nuiton.i18n.I18n.n_; + +public static final String DEFAULT_SELECTED_TOOLTIP = n_("i18neditor.selected"); +public static final String DEFAULT_NOT_SELECTED_TOOLTIP = n_("i18neditor.unselected"); + +public static final String LOCALES_PROPERTY = "locales"; +public static final String SELECTED_LOCALE_PROPERTY = "selectedLocale"; +public static final String SHOW_ICON_PROPERTY = "showIcon"; +public static final String SHOW_TEXT_PROPERTY = "showText"; +public static final String SHOW_POPUP_ICON_PROPERTY = "showPopupIcon"; +public static final String SHOW_POPUP_TEXT_PROPERTY = "showPopupText"; +public static final String POPUP_BORDER_PROPERTY = "popupBorder"; +public static final String POPUP_VISIBLE_PROPERTY = "popupVisible"; + +@Override +public void propertyChange(PropertyChangeEvent evt) { + String name = evt.getPropertyName(); + if (log.isDebugEnabled()) { + log.debug(name+" <old:"+evt.getOldValue()+" - new:"+evt.getNewValue()+">"); + } + log.info(name + " <old:"+evt.getOldValue()+" - new:"+evt.getNewValue()+">"); + if (LOCALES_PROPERTY.equals(name)) { + java.util.Collection<?> newLocales = (java.util.Collection<?>) evt.getNewValue(); + // mise a jour de la popup + boolean oldShowText = renderer.isShowText(); + try { + renderer.setShowText(true); + popup.removeAll(); + for (Object o : newLocales) { + Locale l = (Locale) o; + boolean selected = l.equals(selectedLocale); + String text = isShowPopupText() ? renderer.getText(l) : null; + Icon icon = isShowPopupIcon() ? renderer.getIcon(l) : null; + JRadioButtonMenuItem b = new JRadioButtonMenuItem(text, icon, selected); + popup.add(b); + b.addActionListener(this); + b.putClientProperty("locale", l); + b.setToolTipText(getTip(l)); + b.putClientProperty(JAXXButtonGroup.BUTTON8GROUP_CLIENT_PROPERTY, getIndexes()); + b.putClientProperty(JAXXButtonGroup.VALUE_CLIENT_PROPERTY, l); + } + } finally { + renderer.setShowText(oldShowText); + popup.invalidate(); + } + return; + } + if (SHOW_ICON_PROPERTY.equals(name)) { + renderer.setShowIcon((Boolean) evt.getNewValue()); + processDataBinding("button.icon"); + return; + } + if (SHOW_TEXT_PROPERTY.equals(name)) { + renderer.setShowText((Boolean) evt.getNewValue()); + processDataBinding("button.text"); + return; + } + if (SHOW_POPUP_ICON_PROPERTY.equals(name)) { + rebuildPopup(); + return; + } + if (SHOW_POPUP_TEXT_PROPERTY.equals(name)) { + rebuildPopup(); + return; + } + if (POPUP_BORDER_PROPERTY.equals(name)) { + popup.setBorder((Border)evt.getNewValue()); + return; + } + if (POPUP_VISIBLE_PROPERTY.equals(name)) { + Boolean newValue = (Boolean) evt.getNewValue(); + if (newValue == null || !newValue) { + if (getPopup() != null && getPopup().isVisible()) { + getPopup().setVisible(false); + } + return; + } + if (!getPopup().isVisible()) { + SwingUtilities.invokeLater(showPopupRunnable); + } + return; + } + if (SELECTED_LOCALE_PROPERTY.equals(name)) { + Locale newLocale = (Locale) evt.getNewValue(); + // mise a jour de la popup + try { + for (Component c : popup.getComponents()) { + if (c instanceof JRadioButtonMenuItem) { + JRadioButtonMenuItem b = (JRadioButtonMenuItem) c; + Locale l = (Locale) b.getClientProperty("locale"); + b.setSelected(newLocale.equals(l)); + } + } + } finally { + popup.invalidate(); + } + return; + } +} + +@Override +public void actionPerformed(ActionEvent event) { + Locale value = (Locale) ((JComponent)event.getSource()).getClientProperty("locale"); + if (log.isDebugEnabled()) { + log.debug("new locale : " + value); + } + setSelectedLocale(value); +} + +public void loadI18nBundles() { + Locale[] locales = org.nuiton.i18n.I18n.getLoader().getLocales(); + setLocales(java.util.Arrays.asList(org.nuiton.i18n.I18n.getLoader().getLocales())); +} + +protected void rebuildPopup() { + log.debug("start rebuild"); + try { + for (Component c : popup.getComponents()) { + if (c instanceof JRadioButtonMenuItem) { + JRadioButtonMenuItem b = (JRadioButtonMenuItem) c; + Locale l = (Locale) b.getClientProperty("locale"); + String text = isShowPopupText() ? renderer.getSafeText(l) : null; + Icon icon = isShowPopupIcon() ? renderer.getSafeIcon(l) : null; + b.setIcon(icon); + b.setText(text); + log.debug("text=" + text); + log.debug("icon=" + icon); + } + } + } finally { + popup.invalidate(); + } +} + +protected String getTip(Locale l) { + boolean selected = l.equals(selectedLocale); + String tip = selected ? getSelectedTip(l):getNotSelectedTip(l); + return tip; +} + +protected String getSelectedTip(Locale l) { + String selectedTip = getSelectedToolTipText(); + if (selectedTip == null) { + // use default selected tip text + selectedTip = DEFAULT_SELECTED_TOOLTIP; + } + String tip = renderer.getToolTipText(l); + tip = _(selectedTip, tip); + return tip; +} + +protected String getNotSelectedTip(Locale l) { + String selectedTip = getNotSelectedToolTipText(); + if (selectedTip == null) { + // use default not selected tip text + selectedTip = DEFAULT_NOT_SELECTED_TOOLTIP; + } + String tip = renderer.getToolTipText(l); + tip = _(selectedTip, tip); + return tip; +} + +protected Runnable showPopupRunnable = new Runnable() { + @Override + public void run() { + getPopup().pack(); + JToggleButton invoker = getButton(); + Dimension dim = getPopup().getPreferredSize(); + Dimension invokerDim = invoker.getSize(); + getPopup().show(invoker, (int) (invokerDim.getWidth() - dim.getWidth()), invoker.getHeight()); +// getPopup().setVisible(true); + } +}; + +addPropertyChangeListener(this); + +]]> + </script> +</JPanel> Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditor.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditor.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditor.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,170 +0,0 @@ -<!-- - -/** - * *##% jaxx-runtime-swing-widget - * 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>. ##%* - */ - ---> - -<JPanel layout='{new BorderLayout()}' - onFocusGained='textField.requestFocus()' - onFocusLost='setPopupVisible(false);popup.setVisible(false);' - onMouseExited='setPopupVisible(false);popup.setVisible(false);'> - - <!-- onFocusGained='if (autoPopup) setPopupVisible(true); textField.requestFocus();'--> - - <!-- bean property associated with the editing value --> - <String id='property' javaBean='""'/> - - <!-- bean property --> - <Object id='bean' javaBean='null'/> - - <!-- editor model --> - <Number id="model" javaBean='null'/> - - <!-- editor model type (specify it when you want to use a special type other than Integer or Float)--> - <Class id="modelType" javaBean='null'/> - - <!-- useFloat property --> - <Boolean id='useFloat' javaBean='false'/> - - <!-- useSign property --> - <Boolean id='useSign' javaBean='false'/> - - <!-- autoPopup property --> - <Boolean id='autoPopup' javaBean='false'/> - - <!-- showPopupButton property --> - <Boolean id='showPopupButton' javaBean='false'/> - - <!-- show reset property --> - <Boolean id='showReset' javaBean='false'/> - - <!-- internal editor model as text --> - <String id="modelText" javaBean='""'/> - - <!-- internal state --> - <Boolean id='popupVisible' javaBean='false'/> - - <!-- ui handler --> - <NumberEditorHandler id='handler' constructorParams='this'/> - - <!-- popup digital number editor --> - <JPopupMenu id='popup' - onPopupMenuWillBecomeVisible='button.setSelected(true)' - onPopupMenuWillBecomeInvisible='button.setSelected(false)' - onPopupMenuCanceled='button.setSelected(false)'> - <style source='NumberEditorPopup.css'/> - <JPanel layout='{new GridLayout(4,4)}' - border='{BorderFactory.createEmptyBorder(4, 4, 4, 4)}' - background='{Color.WHITE}'> - <JButton text='numbereditor.7' onActionPerformed='addChar(event)' styleClass='digit'/> - <JButton text='numbereditor.8' onActionPerformed='addChar(event)' styleClass='digit'/> - <JButton text='numbereditor.9' onActionPerformed='addChar(event)' styleClass='digit'/> - <JButton text='numbereditor.clearAll' onActionPerformed='setModel(null)' styleClass='clear' - enabled='{!getModelText().isEmpty()}'/> - - - <JButton text='numbereditor.4' onActionPerformed='addChar(event)' styleClass='digit'/> - <JButton text='numbereditor.5' onActionPerformed='addChar(event)' styleClass='digit'/> - <JButton text='numbereditor.6' onActionPerformed='addChar(event)' styleClass='digit'/> - <JButton text='numbereditor.clearOne' onActionPerformed='getHandler().removeChar()' styleClass='clear' - enabled='{!(getModelText().isEmpty() || textField.getCaretPosition() ==0 )}'/> - - <JButton text='numbereditor.1' onActionPerformed='addChar(event)' styleClass='digit'/> - <JButton text='numbereditor.2' onActionPerformed='addChar(event)' styleClass='digit'/> - <JButton text='numbereditor.3' onActionPerformed='addChar(event)' styleClass='digit'/> - - <JButton enabled="false"/> - - <JButton text='numbereditor.0' onActionPerformed='addChar(event)' styleClass='digit' - enabled='{!getEditor().getModelText().equals("0")}'/> - - <JButton id='toggleSign' text='numbereditor.toggleSign' styleClass='operator' - onActionPerformed='getHandler().toggleSign()' - enabled='{isUseSign() && !getEditor().getModelText().isEmpty()}'/> - - <JButton id='dot' text='numbereditor..' styleClass='operator' - onActionPerformed='addChar(event)' - enabled='{isUseFloat() && getEditor().getModelText().indexOf(".") == -1 }'/> - - <JButton actionIcon='numbereditor-validate' onActionPerformed="getHandler().validate()"/> - </JPanel> - </JPopupMenu> - <script><![CDATA[ -public void init() { - handler.init(); -} - -public NumberEditor getEditor() { - return this; -} - -public void addChar(ActionEvent event) { - getHandler().addChar(((JButton)event.getSource()).getText()); -} - -void showPopup() { - if ( popupVisible || autoPopup ) { - if (!popupVisible) { - setPopupVisible(true); - } else if (!getPopup().isVisible()) { - getHandler().setPopupVisible(true); - } - } -} - -]]> - </script> - - <JToolBar floatable='false' - borderPainted='false' - visible='{isShowReset()}' - constraints='BorderLayout.WEST'> - <JButton id='resetButton' - actionIcon='numbereditor-reset' - toolTipText='numbereditor.action.reset.tip' - focusable='false' - focusPainted='false' - enabled='{isEnabled()}' - onActionPerformed='setModel(null)'/> - </JToolBar> - - <JTextField id='textField' - constraints='BorderLayout.CENTER' - text='{getModelText()}' - enabled='{isEnabled()}' - onKeyReleased='getHandler().setModel(textField.getText())' - onFocusGained='showPopup()'/> - - <JToolBar constraints='BorderLayout.EAST' - floatable='false' - opaque='false' - borderPainted='false' - visible='{isShowPopupButton()}' - maximumSize='{new Dimension(24,24)}'> - <JToggleButton id='button' - focusable='false' - focusPainted='false' - actionIcon='numbereditor-calculator' - toolTipText='numbereditor.action.show.tip' - enabled='{isEnabled()}' - onActionPerformed='getHandler().setPopupVisible(!popup.isVisible())'/> - </JToolBar> - -</JPanel> Copied: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditor.jaxx (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditor.jaxx) =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditor.jaxx (rev 0) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditor.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,170 @@ +<!-- + +/** + * *##% jaxx-runtime-swing-widget + * 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>. ##%* + */ + +--> + +<JPanel layout='{new BorderLayout()}' + onFocusGained='textField.requestFocus()' + onFocusLost='setPopupVisible(false);popup.setVisible(false);' + onMouseExited='setPopupVisible(false);popup.setVisible(false);'> + + <!-- onFocusGained='if (autoPopup) setPopupVisible(true); textField.requestFocus();'--> + + <!-- bean property associated with the editing value --> + <String id='property' javaBean='""'/> + + <!-- bean property --> + <Object id='bean' javaBean='null'/> + + <!-- editor model --> + <Number id="model" javaBean='null'/> + + <!-- editor model type (specify it when you want to use a special type other than Integer or Float)--> + <Class id="modelType" javaBean='null'/> + + <!-- useFloat property --> + <Boolean id='useFloat' javaBean='false'/> + + <!-- useSign property --> + <Boolean id='useSign' javaBean='false'/> + + <!-- autoPopup property --> + <Boolean id='autoPopup' javaBean='false'/> + + <!-- showPopupButton property --> + <Boolean id='showPopupButton' javaBean='false'/> + + <!-- show reset property --> + <Boolean id='showReset' javaBean='false'/> + + <!-- internal editor model as text --> + <String id="modelText" javaBean='""'/> + + <!-- internal state --> + <Boolean id='popupVisible' javaBean='false'/> + + <!-- ui handler --> + <NumberEditorHandler id='handler' constructorParams='this'/> + + <!-- popup digital number editor --> + <JPopupMenu id='popup' + onPopupMenuWillBecomeVisible='button.setSelected(true)' + onPopupMenuWillBecomeInvisible='button.setSelected(false)' + onPopupMenuCanceled='button.setSelected(false)'> + <style source='NumberEditorPopup.css'/> + <JPanel layout='{new GridLayout(4,4)}' + border='{BorderFactory.createEmptyBorder(4, 4, 4, 4)}' + background='{Color.WHITE}'> + <JButton text='numbereditor.7' onActionPerformed='addChar(event)' styleClass='digit'/> + <JButton text='numbereditor.8' onActionPerformed='addChar(event)' styleClass='digit'/> + <JButton text='numbereditor.9' onActionPerformed='addChar(event)' styleClass='digit'/> + <JButton text='numbereditor.clearAll' onActionPerformed='setModel(null)' styleClass='clear' + enabled='{!getModelText().isEmpty()}'/> + + + <JButton text='numbereditor.4' onActionPerformed='addChar(event)' styleClass='digit'/> + <JButton text='numbereditor.5' onActionPerformed='addChar(event)' styleClass='digit'/> + <JButton text='numbereditor.6' onActionPerformed='addChar(event)' styleClass='digit'/> + <JButton text='numbereditor.clearOne' onActionPerformed='getHandler().removeChar()' styleClass='clear' + enabled='{!(getModelText().isEmpty() || textField.getCaretPosition() ==0 )}'/> + + <JButton text='numbereditor.1' onActionPerformed='addChar(event)' styleClass='digit'/> + <JButton text='numbereditor.2' onActionPerformed='addChar(event)' styleClass='digit'/> + <JButton text='numbereditor.3' onActionPerformed='addChar(event)' styleClass='digit'/> + + <JButton enabled="false"/> + + <JButton text='numbereditor.0' onActionPerformed='addChar(event)' styleClass='digit' + enabled='{!getEditor().getModelText().equals("0")}'/> + + <JButton id='toggleSign' text='numbereditor.toggleSign' styleClass='operator' + onActionPerformed='getHandler().toggleSign()' + enabled='{isUseSign() && !getEditor().getModelText().isEmpty()}'/> + + <JButton id='dot' text='numbereditor..' styleClass='operator' + onActionPerformed='addChar(event)' + enabled='{isUseFloat() && getEditor().getModelText().indexOf(".") == -1 }'/> + + <JButton actionIcon='numbereditor-validate' onActionPerformed="getHandler().validate()"/> + </JPanel> + </JPopupMenu> + <script><![CDATA[ +public void init() { + handler.init(); +} + +public NumberEditor getEditor() { + return this; +} + +public void addChar(ActionEvent event) { + getHandler().addChar(((JButton)event.getSource()).getText()); +} + +void showPopup() { + if ( popupVisible || autoPopup ) { + if (!popupVisible) { + setPopupVisible(true); + } else if (!getPopup().isVisible()) { + getHandler().setPopupVisible(true); + } + } +} + +]]> + </script> + + <JToolBar floatable='false' + borderPainted='false' + visible='{isShowReset()}' + constraints='BorderLayout.WEST'> + <JButton id='resetButton' + actionIcon='numbereditor-reset' + toolTipText='numbereditor.action.reset.tip' + focusable='false' + focusPainted='false' + enabled='{isEnabled()}' + onActionPerformed='setModel(null)'/> + </JToolBar> + + <JTextField id='textField' + constraints='BorderLayout.CENTER' + text='{getModelText()}' + enabled='{isEnabled()}' + onKeyReleased='getHandler().setModel(textField.getText())' + onFocusGained='showPopup()'/> + + <JToolBar constraints='BorderLayout.EAST' + floatable='false' + opaque='false' + borderPainted='false' + visible='{isShowPopupButton()}' + maximumSize='{new Dimension(24,24)}'> + <JToggleButton id='button' + focusable='false' + focusPainted='false' + actionIcon='numbereditor-calculator' + toolTipText='numbereditor.action.show.tip' + enabled='{isEnabled()}' + onActionPerformed='getHandler().setPopupVisible(!popup.isVisible())'/> + </JToolBar> + +</JPanel> Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,547 +0,0 @@ -/** - * *##% - * JAXX Widgets - * 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>. - * ##%* - */ -package jaxx.runtime.swing.editor; - -import static jaxx.runtime.swing.editor.NumberEditor.PROPERTY_MODEL; -import static jaxx.runtime.swing.editor.NumberEditor.PROPERTY_POPUP_VISIBLE; -import org.apache.commons.beanutils.PropertyUtils; -import org.apache.commons.lang.math.NumberUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.swing.*; -import javax.swing.text.BadLocationException; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.beans.PropertyDescriptor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.math.BigDecimal; -import java.math.BigInteger; - -/** - * Le handler de l'éditeur graphique de nombres. - * <p/> - * Note: Ce handler n'est pas staless, et chaque ui possède le sien. - * - * @author chemit - * @see NumberEditor - */ -public class NumberEditorHandler { - /** - * Logger - */ - public static final Log log = LogFactory.getLog(NumberEditorHandler.class); - public static final String VALIDATE_PROPERTY = "validate"; - /** - * editor ui - */ - protected NumberEditor editor; - /** - * the mutator method on the property of boxed bean in the editor - */ - protected Method mutator; - /** - * the getter method on the property - */ - protected Method getter; - /** - * a flag to known if mutator accept null value - */ - protected Boolean acceptNull; - - protected Class<?> modelType; - - public NumberEditorHandler(NumberEditor ui) { - this.editor = ui; - } - - /** - * initialise l'ui et les listeners d'évènements. - */ - public void init() { - try { - if (editor.getBean() == null) { - throw new NullPointerException("can not have a null bean in ui " + editor); - } - editor.addPropertyChangeListener(PROPERTY_MODEL, new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - if (log.isDebugEnabled()) { - log.debug("set new model " + evt.getNewValue() + " for " + editor.getProperty()); - } - setModel((Number) evt.getOldValue(), (Number) evt.getNewValue()); - } - }); - editor.addPropertyChangeListener(PROPERTY_POPUP_VISIBLE, new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - setPopupVisible((Boolean) evt.getNewValue()); - } - }); - editor.getTextField().addMouseListener(new PopupListener()); - - // Determine si c'est un float - Class<?> type = getGetter().getReturnType(); - if (editor.getModelType() != null) { - type = editor.getModelType(); - } - modelType = type; - if (log.isDebugEnabled()) { - log.debug("model type to use = " + modelType); - } - //FIXME le test n'est pas assez fort (on peut avoir un long, short,...) - editor.setUseFloat(!type.equals(Integer.class) && !type.equals(int.class)); - - // Initialise le model - if (editor.getModel() == null) { - Number num = (Number) getGetter().invoke(editor.getBean()); - editor.setModel(num); - } - - /*if (editor.getResetButton().getIcon() == null) { - editor.getResetButton().setIcon(SwingUtil.createActionIcon("numbereditor-reset")); - } - if (editor.getButton().getIcon() == null) { - editor.getButton().setIcon(SwingUtil.createActionIcon("numbereditor-calculator")); - }*/ - } catch (IllegalAccessException ex) { - log.error(ex); - } catch (IllegalArgumentException ex) { - log.error(ex); - } catch (InvocationTargetException ex) { - log.error(ex); - } - } - - /** - * Affiche ou cache la popup. - * - * @param newValue la nouvelle valeur de visibilité de la popup. - */ - public void setPopupVisible(Boolean newValue) { - - if (log.isTraceEnabled()) { - log.trace(newValue); - } - - if (newValue == null || !newValue) { - editor.getPopup().setVisible(false); - return; - } - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - JToggleButton invoker = editor.getButton(); - Dimension dim = editor.getPopup().getPreferredSize(); - editor.getPopup().show(invoker, (int) (invoker.getPreferredSize().getWidth() - dim.getWidth()), invoker.getHeight()); - editor.getTextField().requestFocus(); - } - }); - } - - /** - * Modifie le modèle de la donnée à éditer à partir d'un evenement clavier - * <p/> - * TODO utiliser une filtre sur les donnes en entrees pour ne pas a avoir - * faire les tests ici. - * - * @param s la nouvelle valeur du modèle - */ - public void setModel(String s) { - - String text = editor.getModelText(); - if (text.equals(s)) { - // le modeèle n'a pas changé, rien a faire sur le modèle - if (log.isDebugEnabled()) { - log.debug("modelText is the same, skip !"); - } - return; - } - - boolean canApply = false; - - boolean endWithDot = false; - - boolean isLess = false; - - Number newValue = null; - - if (s.trim().isEmpty()) { - // le champ est vide donc c'est la valeur null a reaffecter - s = null; - canApply = true; - } else if (s.endsWith(".")) { - s += "0"; - endWithDot = true; - } else if (editor.isUseSign() && s.length() == 1 && s.startsWith("-")) { - s = "0"; - isLess = true; - } - - if (s != null && NumberUtils.isNumber(s)) { - - // on a un nombre valide - - try { - Float f = Float.parseFloat(s); - if (!editor.isUseSign() && (s.startsWith("-"))) { - if (log.isDebugEnabled()) { - log.debug("will skip since can not allow sign on this editor but was " + f); - } - } else { - - if (!editor.isUseFloat() && s.contains(".")) { - if (log.isDebugEnabled()) { - log.debug("will skip since can not allow float on this editor but was " + f); - } - } else { - // ok on peut utilise ce modele - newValue = getRealValue(f); -// if (editor.isUseFloat()) { -// if (getMutator().getParameterTypes()[0] == BigDecimal.class) { -// newValue = BigDecimal.valueOf(f); -// } else { -// newValue = f; -// } -// } else { -// newValue = f.intValue(); -// } - canApply = true; - } - } - - } catch (NumberFormatException e) { - // rien a faire - log.debug(e); - } - } - JTextField field = editor.getTextField(); - - int oldPosition = field.getCaretPosition(); - - if (canApply) { - if (log.isDebugEnabled()) { - log.debug("can apply new model value : " + newValue); - } - if (isLess) { - editor.setModelText("-"); - return; - } - // on peut mettre a jour le model - editor.setModel(newValue); - if (endWithDot) { - editor.setModelText(s.substring(0, s.length() - 1)); - field.setCaretPosition(oldPosition); - } - return; - } - - // on ne peut pas appliquer, on repositionne l'ancien texte - // dans l'éditeur - - if (log.isDebugEnabled()) { - log.debug("invalid text " + s + " reput old text " + text); - } - - if (oldPosition > 0) { - oldPosition--; - } - field.setText(text); - try { - field.setCaretPosition(oldPosition); - } - catch (IllegalArgumentException ex) { - log.debug("CaretPosition is invalid for position : " + oldPosition, ex); - } - } - - private Number getRealValue(Float f) { - if (modelType == Integer.class) { - return f.intValue(); - } - if (modelType == Float.class) { - return f; - } - if (modelType == Double.class) { - return f.doubleValue(); - } - if (modelType == Long.class) { - return f.longValue(); - } - if (modelType == BigInteger.class) { - return BigInteger.valueOf(f.longValue()); - } - if (modelType == BigDecimal.class) { - return BigDecimal.valueOf(f.doubleValue()); - } - if (editor.isUseFloat()) { - // use default float value - return f; - } - return f.intValue(); - } - - /** - * Ajoute le caractère donné à l'endroit où est le curseur dans la zone de - * saisie et met à jour le modèle. - * - * @param s le caractère à ajouter. - */ - public void addChar(String s) { - char c = s.charAt(0); - try { - editor.getTextField().getDocument().insertString(editor.getTextField().getCaretPosition(), c + "", null); - setModel(editor.getTextField().getText()); - //setModel(editor.getModelText() + c); - - } catch (BadLocationException e) { - log.warn(e); - } - } - - /** - * Supprime le caractère juste avant le curseur du modèle (textuel) et - * met à jour la zone de saisie. - */ - public void removeChar() { - String s = editor.getModelText(); - int position = editor.getTextField().getCaretPosition(); - if (position < 1 || s.isEmpty()) { - if (log.isDebugEnabled()) { - log.debug("cannot remove when caret on first position or text empty"); - } - // on est au debut du doc, donc rien a faire - return; - } - try { - editor.getTextField().getDocument().remove(position - 1, 1); - } catch (BadLocationException ex) { - // ne devrait jamais arrive vu qu'on a fait le controle... - log.debug(ex); - return; - } - String newText = editor.getTextField().getText(); - if (log.isDebugEnabled()) { - log.debug("text updated : " + newText); - } - position--; - editor.getTextField().setCaretPosition(position); - setModel(newText); - } - - /** - * Permute le signe dans la zone de saisie et - * dans le modèle. - */ - public void toggleSign() { - String newValue = editor.getModelText(); - - if (newValue.startsWith("-")) { - setModel(newValue.substring(1)); - } else { - setModel("-" + newValue); - } - } - - /** - * @return l'éditeur au quel est rattaché le handler. - */ - public NumberEditor getEditor() { - return editor; - } - - protected void setModel(Number oldValue, Number newValue) { - if (editor.getBean() == null) { - return; - } - - if (log.isDebugEnabled()) { - log.debug(editor.getProperty() + " on " + editor.getBean().getClass() + " :: " + oldValue + " to " + newValue); - } - - try { - Method mutator = getMutator(); - if (newValue == null && !getAcceptNull()) { - // valeur nulle sur une propriete primitive - // on ne peut pas utiliser la valeur null, mais 0 à la place - newValue = getRealValue(0.0f); -// if (editor.isUseFloat()) { -// if (log.isInfoEnabled()) { -// log.info("use float, check mutator default type = " + mutator.getParameterTypes()[0]); -// } -// if (mutator.getParameterTypes()[0] == BigDecimal.class) { -// newValue = BigDecimal.valueOf(0); -// } else { -// newValue = 0.0f; -//// mutator.invoke(editor.getBean(), 0.0f); -// } -// } else { -// newValue = 0; -//// mutator.invoke(editor.getBean(), 0); -// } - - } //else { -// mutator.invoke(editor.getBean(), newValue); -// } - mutator.invoke(editor.getBean(), newValue); - String strValue; - if (newValue == null) { - strValue = ""; - } else { - strValue = newValue + ""; - if (editor.isUseFloat()) { - Float n = Float.parseFloat(strValue); - if (((float) n.intValue()) == n) { - strValue = n.intValue() + ""; - } - } - } - - editor.setModelText(strValue); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - protected void validate() { - - setPopupVisible(false); - // fire validate property (to be able to notify listeners) - editor.firePropertyChange(VALIDATE_PROPERTY, null, true); - } - - protected class PopupListener extends MouseAdapter { - - @Override - public void mousePressed(MouseEvent e) { - maybeShowPopup(e); - } - - @Override - public void mouseReleased(MouseEvent e) { - maybeShowPopup(e); - } - - protected void maybeShowPopup(MouseEvent e) { - if (!e.isPopupTrigger()) { - return; - } - if (editor.isAutoPopup()) { - if (editor.isPopupVisible()) { - if (!editor.getPopup().isVisible()) { - setPopupVisible(true); - } - // popup already visible - - } else { - // set popup auto - editor.setPopupVisible(true); - - } - } else { - if (editor.isPopupVisible()) { - setPopupVisible(true); - } - } - } - } - - protected Method getMutator() { - if (mutator == null) { - Object bean = editor.getBean(); - if (bean == null) { - throw new NullPointerException("could not find bean in " + editor); - } - String property = editor.getProperty(); - if (property == null) { - throw new NullPointerException("could not find property in " + editor); - } - if (log.isDebugEnabled()) { - log.debug("searching mutator for property " + property + " on bean of type " + bean.getClass()); - } - if (log.isTraceEnabled()) { - PropertyDescriptor[] descriptors = PropertyUtils.getPropertyDescriptors(bean); - for (PropertyDescriptor p : descriptors) { - log.trace("property discover " + p.getName() + " writer = " + p.getWriteMethod()); - } - } - try { - PropertyDescriptor descriptor = PropertyUtils.getPropertyDescriptor(bean, property); - mutator = descriptor.getWriteMethod(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - return mutator; - } - - protected Method getGetter() { - if (getter == null) { - Object bean = editor.getBean(); - if (bean == null) { - throw new NullPointerException("could not find bean in " + editor); - } - String property = editor.getProperty(); - if (property == null) { - throw new NullPointerException("could not find property in " + editor); - } - if (log.isDebugEnabled()) { - log.debug("searching accessor for property " + property + " on bean of type " + bean.getClass()); - } - if (log.isTraceEnabled()) { - PropertyDescriptor[] descriptors = PropertyUtils.getPropertyDescriptors(bean); - for (PropertyDescriptor p : descriptors) { - log.trace("property discover " + p.getName() + " reader = " + p.getWriteMethod()); - } - } - try { - PropertyDescriptor descriptor = PropertyUtils.getPropertyDescriptor(bean, property); - getter = descriptor.getReadMethod(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - return getter; - } - - public Boolean getAcceptNull() { - if (acceptNull == null) { - Method m = getMutator(); - if (m == null) { - // should never happens - throw new IllegalStateException("could not find the mutator"); - } - Class<?> returnType = m.getParameterTypes()[0]; - acceptNull = !returnType.isPrimitive(); - if (log.isDebugEnabled()) { - log.debug(acceptNull + " for mutator " + m.getName() + " type : " + returnType); - } - } - return acceptNull; - } -} Copied: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java) =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java (rev 0) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,547 @@ +/** + * *##% + * JAXX Widgets + * 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>. + * ##%* + */ +package jaxx.runtime.swing.editor; + +import static jaxx.runtime.swing.editor.NumberEditor.PROPERTY_MODEL; +import static jaxx.runtime.swing.editor.NumberEditor.PROPERTY_POPUP_VISIBLE; +import org.apache.commons.beanutils.PropertyUtils; +import org.apache.commons.lang.math.NumberUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.swing.*; +import javax.swing.text.BadLocationException; +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.beans.PropertyDescriptor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.math.BigDecimal; +import java.math.BigInteger; + +/** + * Le handler de l'éditeur graphique de nombres. + * <p/> + * Note: Ce handler n'est pas staless, et chaque ui possède le sien. + * + * @author chemit + * @see NumberEditor + */ +public class NumberEditorHandler { + /** + * Logger + */ + public static final Log log = LogFactory.getLog(NumberEditorHandler.class); + public static final String VALIDATE_PROPERTY = "validate"; + /** + * editor ui + */ + protected NumberEditor editor; + /** + * the mutator method on the property of boxed bean in the editor + */ + protected Method mutator; + /** + * the getter method on the property + */ + protected Method getter; + /** + * a flag to known if mutator accept null value + */ + protected Boolean acceptNull; + + protected Class<?> modelType; + + public NumberEditorHandler(NumberEditor ui) { + this.editor = ui; + } + + /** + * initialise l'ui et les listeners d'évènements. + */ + public void init() { + try { + if (editor.getBean() == null) { + throw new NullPointerException("can not have a null bean in ui " + editor); + } + editor.addPropertyChangeListener(PROPERTY_MODEL, new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent evt) { + if (log.isDebugEnabled()) { + log.debug("set new model " + evt.getNewValue() + " for " + editor.getProperty()); + } + setModel((Number) evt.getOldValue(), (Number) evt.getNewValue()); + } + }); + editor.addPropertyChangeListener(PROPERTY_POPUP_VISIBLE, new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent evt) { + setPopupVisible((Boolean) evt.getNewValue()); + } + }); + editor.getTextField().addMouseListener(new PopupListener()); + + // Determine si c'est un float + Class<?> type = getGetter().getReturnType(); + if (editor.getModelType() != null) { + type = editor.getModelType(); + } + modelType = type; + if (log.isDebugEnabled()) { + log.debug("model type to use = " + modelType); + } + //FIXME le test n'est pas assez fort (on peut avoir un long, short,...) + editor.setUseFloat(!type.equals(Integer.class) && !type.equals(int.class)); + + // Initialise le model + if (editor.getModel() == null) { + Number num = (Number) getGetter().invoke(editor.getBean()); + editor.setModel(num); + } + + /*if (editor.getResetButton().getIcon() == null) { + editor.getResetButton().setIcon(SwingUtil.createActionIcon("numbereditor-reset")); + } + if (editor.getButton().getIcon() == null) { + editor.getButton().setIcon(SwingUtil.createActionIcon("numbereditor-calculator")); + }*/ + } catch (IllegalAccessException ex) { + log.error(ex); + } catch (IllegalArgumentException ex) { + log.error(ex); + } catch (InvocationTargetException ex) { + log.error(ex); + } + } + + /** + * Affiche ou cache la popup. + * + * @param newValue la nouvelle valeur de visibilité de la popup. + */ + public void setPopupVisible(Boolean newValue) { + + if (log.isTraceEnabled()) { + log.trace(newValue); + } + + if (newValue == null || !newValue) { + editor.getPopup().setVisible(false); + return; + } + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + JToggleButton invoker = editor.getButton(); + Dimension dim = editor.getPopup().getPreferredSize(); + editor.getPopup().show(invoker, (int) (invoker.getPreferredSize().getWidth() - dim.getWidth()), invoker.getHeight()); + editor.getTextField().requestFocus(); + } + }); + } + + /** + * Modifie le modèle de la donnée à éditer à partir d'un evenement clavier + * <p/> + * TODO utiliser une filtre sur les donnes en entrees pour ne pas a avoir + * faire les tests ici. + * + * @param s la nouvelle valeur du modèle + */ + public void setModel(String s) { + + String text = editor.getModelText(); + if (text.equals(s)) { + // le modeèle n'a pas changé, rien a faire sur le modèle + if (log.isDebugEnabled()) { + log.debug("modelText is the same, skip !"); + } + return; + } + + boolean canApply = false; + + boolean endWithDot = false; + + boolean isLess = false; + + Number newValue = null; + + if (s.trim().isEmpty()) { + // le champ est vide donc c'est la valeur null a reaffecter + s = null; + canApply = true; + } else if (s.endsWith(".")) { + s += "0"; + endWithDot = true; + } else if (editor.isUseSign() && s.length() == 1 && s.startsWith("-")) { + s = "0"; + isLess = true; + } + + if (s != null && NumberUtils.isNumber(s)) { + + // on a un nombre valide + + try { + Float f = Float.parseFloat(s); + if (!editor.isUseSign() && (s.startsWith("-"))) { + if (log.isDebugEnabled()) { + log.debug("will skip since can not allow sign on this editor but was " + f); + } + } else { + + if (!editor.isUseFloat() && s.contains(".")) { + if (log.isDebugEnabled()) { + log.debug("will skip since can not allow float on this editor but was " + f); + } + } else { + // ok on peut utilise ce modele + newValue = getRealValue(f); +// if (editor.isUseFloat()) { +// if (getMutator().getParameterTypes()[0] == BigDecimal.class) { +// newValue = BigDecimal.valueOf(f); +// } else { +// newValue = f; +// } +// } else { +// newValue = f.intValue(); +// } + canApply = true; + } + } + + } catch (NumberFormatException e) { + // rien a faire + log.debug(e); + } + } + JTextField field = editor.getTextField(); + + int oldPosition = field.getCaretPosition(); + + if (canApply) { + if (log.isDebugEnabled()) { + log.debug("can apply new model value : " + newValue); + } + if (isLess) { + editor.setModelText("-"); + return; + } + // on peut mettre a jour le model + editor.setModel(newValue); + if (endWithDot) { + editor.setModelText(s.substring(0, s.length() - 1)); + field.setCaretPosition(oldPosition); + } + return; + } + + // on ne peut pas appliquer, on repositionne l'ancien texte + // dans l'éditeur + + if (log.isDebugEnabled()) { + log.debug("invalid text " + s + " reput old text " + text); + } + + if (oldPosition > 0) { + oldPosition--; + } + field.setText(text); + try { + field.setCaretPosition(oldPosition); + } + catch (IllegalArgumentException ex) { + log.debug("CaretPosition is invalid for position : " + oldPosition, ex); + } + } + + private Number getRealValue(Float f) { + if (modelType == Integer.class) { + return f.intValue(); + } + if (modelType == Float.class) { + return f; + } + if (modelType == Double.class) { + return f.doubleValue(); + } + if (modelType == Long.class) { + return f.longValue(); + } + if (modelType == BigInteger.class) { + return BigInteger.valueOf(f.longValue()); + } + if (modelType == BigDecimal.class) { + return BigDecimal.valueOf(f.doubleValue()); + } + if (editor.isUseFloat()) { + // use default float value + return f; + } + return f.intValue(); + } + + /** + * Ajoute le caractère donné à l'endroit où est le curseur dans la zone de + * saisie et met à jour le modèle. + * + * @param s le caractère à ajouter. + */ + public void addChar(String s) { + char c = s.charAt(0); + try { + editor.getTextField().getDocument().insertString(editor.getTextField().getCaretPosition(), c + "", null); + setModel(editor.getTextField().getText()); + //setModel(editor.getModelText() + c); + + } catch (BadLocationException e) { + log.warn(e); + } + } + + /** + * Supprime le caractère juste avant le curseur du modèle (textuel) et + * met à jour la zone de saisie. + */ + public void removeChar() { + String s = editor.getModelText(); + int position = editor.getTextField().getCaretPosition(); + if (position < 1 || s.isEmpty()) { + if (log.isDebugEnabled()) { + log.debug("cannot remove when caret on first position or text empty"); + } + // on est au debut du doc, donc rien a faire + return; + } + try { + editor.getTextField().getDocument().remove(position - 1, 1); + } catch (BadLocationException ex) { + // ne devrait jamais arrive vu qu'on a fait le controle... + log.debug(ex); + return; + } + String newText = editor.getTextField().getText(); + if (log.isDebugEnabled()) { + log.debug("text updated : " + newText); + } + position--; + editor.getTextField().setCaretPosition(position); + setModel(newText); + } + + /** + * Permute le signe dans la zone de saisie et + * dans le modèle. + */ + public void toggleSign() { + String newValue = editor.getModelText(); + + if (newValue.startsWith("-")) { + setModel(newValue.substring(1)); + } else { + setModel("-" + newValue); + } + } + + /** + * @return l'éditeur au quel est rattaché le handler. + */ + public NumberEditor getEditor() { + return editor; + } + + protected void setModel(Number oldValue, Number newValue) { + if (editor.getBean() == null) { + return; + } + + if (log.isDebugEnabled()) { + log.debug(editor.getProperty() + " on " + editor.getBean().getClass() + " :: " + oldValue + " to " + newValue); + } + + try { + Method mutator = getMutator(); + if (newValue == null && !getAcceptNull()) { + // valeur nulle sur une propriete primitive + // on ne peut pas utiliser la valeur null, mais 0 à la place + newValue = getRealValue(0.0f); +// if (editor.isUseFloat()) { +// if (log.isInfoEnabled()) { +// log.info("use float, check mutator default type = " + mutator.getParameterTypes()[0]); +// } +// if (mutator.getParameterTypes()[0] == BigDecimal.class) { +// newValue = BigDecimal.valueOf(0); +// } else { +// newValue = 0.0f; +//// mutator.invoke(editor.getBean(), 0.0f); +// } +// } else { +// newValue = 0; +//// mutator.invoke(editor.getBean(), 0); +// } + + } //else { +// mutator.invoke(editor.getBean(), newValue); +// } + mutator.invoke(editor.getBean(), newValue); + String strValue; + if (newValue == null) { + strValue = ""; + } else { + strValue = newValue + ""; + if (editor.isUseFloat()) { + Float n = Float.parseFloat(strValue); + if (((float) n.intValue()) == n) { + strValue = n.intValue() + ""; + } + } + } + + editor.setModelText(strValue); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + protected void validate() { + + setPopupVisible(false); + // fire validate property (to be able to notify listeners) + editor.firePropertyChange(VALIDATE_PROPERTY, null, true); + } + + protected class PopupListener extends MouseAdapter { + + @Override + public void mousePressed(MouseEvent e) { + maybeShowPopup(e); + } + + @Override + public void mouseReleased(MouseEvent e) { + maybeShowPopup(e); + } + + protected void maybeShowPopup(MouseEvent e) { + if (!e.isPopupTrigger()) { + return; + } + if (editor.isAutoPopup()) { + if (editor.isPopupVisible()) { + if (!editor.getPopup().isVisible()) { + setPopupVisible(true); + } + // popup already visible + + } else { + // set popup auto + editor.setPopupVisible(true); + + } + } else { + if (editor.isPopupVisible()) { + setPopupVisible(true); + } + } + } + } + + protected Method getMutator() { + if (mutator == null) { + Object bean = editor.getBean(); + if (bean == null) { + throw new NullPointerException("could not find bean in " + editor); + } + String property = editor.getProperty(); + if (property == null) { + throw new NullPointerException("could not find property in " + editor); + } + if (log.isDebugEnabled()) { + log.debug("searching mutator for property " + property + " on bean of type " + bean.getClass()); + } + if (log.isTraceEnabled()) { + PropertyDescriptor[] descriptors = PropertyUtils.getPropertyDescriptors(bean); + for (PropertyDescriptor p : descriptors) { + log.trace("property discover " + p.getName() + " writer = " + p.getWriteMethod()); + } + } + try { + PropertyDescriptor descriptor = PropertyUtils.getPropertyDescriptor(bean, property); + mutator = descriptor.getWriteMethod(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + return mutator; + } + + protected Method getGetter() { + if (getter == null) { + Object bean = editor.getBean(); + if (bean == null) { + throw new NullPointerException("could not find bean in " + editor); + } + String property = editor.getProperty(); + if (property == null) { + throw new NullPointerException("could not find property in " + editor); + } + if (log.isDebugEnabled()) { + log.debug("searching accessor for property " + property + " on bean of type " + bean.getClass()); + } + if (log.isTraceEnabled()) { + PropertyDescriptor[] descriptors = PropertyUtils.getPropertyDescriptors(bean); + for (PropertyDescriptor p : descriptors) { + log.trace("property discover " + p.getName() + " reader = " + p.getWriteMethod()); + } + } + try { + PropertyDescriptor descriptor = PropertyUtils.getPropertyDescriptor(bean, property); + getter = descriptor.getReadMethod(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + return getter; + } + + public Boolean getAcceptNull() { + if (acceptNull == null) { + Method m = getMutator(); + if (m == null) { + // should never happens + throw new IllegalStateException("could not find the mutator"); + } + Class<?> returnType = m.getParameterTypes()[0]; + acceptNull = !returnType.isPrimitive(); + if (log.isDebugEnabled()) { + log.debug(acceptNull + " for mutator " + m.getName() + " type : " + returnType); + } + } + return acceptNull; + } +} Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorPopup.css =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorPopup.css 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorPopup.css 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,43 +0,0 @@ -/** - * *##% jaxx-runtime-swing-widget - * 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>. ##%* - */ -JButton { - font-size: 14; - focusPainted: false; - focusable: false; -} - -JButton.digit { - foreground: blue; -} - -JButton.operator { - foreground: #009900; -} - -JButton.clear { - foreground: red; -} - -JButton:mouseover { - font-weight: bold; -} - -JButton.operator:mouseover { - font-weight: normal; -} Copied: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorPopup.css (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorPopup.css) =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorPopup.css (rev 0) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorPopup.css 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,43 @@ +/** + * *##% jaxx-runtime-swing-widget + * 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>. ##%* + */ +JButton { + font-size: 14; + focusPainted: false; + focusable: false; +} + +JButton.digit { + foreground: blue; +} + +JButton.operator { + foreground: #009900; +} + +JButton.clear { + foreground: red; +} + +JButton:mouseover { + font-weight: bold; +} + +JButton.operator:mouseover { + font-weight: normal; +} Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/TimeEditor.css =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/TimeEditor.css 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/TimeEditor.css 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,49 +0,0 @@ -/** - * *##% jaxx-runtime-swing-widget - * 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>. ##%* - */ -#title{ - text:{getLabel()}; - horizontalAlignment:center; -} - -#hour{ - value:{getTimeModel()/60}; - enabled:{isEnabled()}; - model:{new SpinnerNumberModel(0,0,23,1)}; -} - -#labelH { - text:"timeeditor.H"; - horizontalAlignment:center; -} -#minute{ - value:{getTimeModel()%60}; - enabled:{isEnabled()}; - model:{new SpinnerNumberModel(0,0,59,1)}; -} - -#slider{ - font-size: 11; - paintTicks:true; - paintLabels:true; - majorTickSpacing:60; - minorTickSpacing:30; - value:{getTimeModel()}; - enabled:{isEnabled()}; - model:{new DefaultBoundedRangeModel(0,1,0,60*24)}; -} Copied: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/TimeEditor.css (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/TimeEditor.css) =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/TimeEditor.css (rev 0) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/TimeEditor.css 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,49 @@ +/** + * *##% jaxx-runtime-swing-widget + * 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>. ##%* + */ +#title{ + text:{getLabel()}; + horizontalAlignment:center; +} + +#hour{ + value:{getTimeModel()/60}; + enabled:{isEnabled()}; + model:{new SpinnerNumberModel(0,0,23,1)}; +} + +#labelH { + text:"timeeditor.H"; + horizontalAlignment:center; +} +#minute{ + value:{getTimeModel()%60}; + enabled:{isEnabled()}; + model:{new SpinnerNumberModel(0,0,59,1)}; +} + +#slider{ + font-size: 11; + paintTicks:true; + paintLabels:true; + majorTickSpacing:60; + minorTickSpacing:30; + value:{getTimeModel()}; + enabled:{isEnabled()}; + model:{new DefaultBoundedRangeModel(0,1,0,60*24)}; +} Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/TimeEditor.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/TimeEditor.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/TimeEditor.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,78 +0,0 @@ -<!-- - -/** - * *##% jaxx-runtime-swing-widget - * 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>. ##%* - */ - ---> - -<JPanel layout='{new BorderLayout()}'> - - <style source='TimeEditor.css'/> - - <!-- bean property --> - <String id='property' javaBean='""'/> - - <!-- title --> - <String id='label' javaBean='""'/> - - <!-- bean --> - <Object id='bean' javaBean='null'/> - - <!-- time model --> - <Integer id="timeModel" javaBean='0'/> - - <!-- the real date --> - <java.util.Date id="date" javaBean='null'/> - - <!-- ui handler --> - <TimeEditorHandler id='handler' constructorParams='this'/> - - <script><![CDATA[ -public void init() { - handler.init(); -} -]]> - </script> - - <Table constraints='BorderLayout.NORTH' fill='horizontal' insets='0'> - <row> - <cell> - <JLabel id='title'/> - </cell> - <cell weightx='1'> - <JLabel/> - </cell> - <cell> - <JSpinner id='hour' - onStateChanged='setTimeModel((Integer)hour.getValue()* 60 + timeModel % 60)'/> - </cell> - <cell> - <JLabel id='labelH'/> - </cell> - <cell> - <JSpinner id='minute' - onStateChanged='setTimeModel((timeModel / 60) * 60 + (Integer) minute.getValue())'/> - </cell> - </row> - </Table> - - <JSlider id='slider' constraints='BorderLayout.SOUTH' - onStateChanged='if (!slider.getValueIsAdjusting()) setTimeModel(slider.getValue());'/> - -</JPanel> Copied: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/TimeEditor.jaxx (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/TimeEditor.jaxx) =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/TimeEditor.jaxx (rev 0) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/TimeEditor.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,78 @@ +<!-- + +/** + * *##% jaxx-runtime-swing-widget + * 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>. ##%* + */ + +--> + +<JPanel layout='{new BorderLayout()}'> + + <style source='TimeEditor.css'/> + + <!-- bean property --> + <String id='property' javaBean='""'/> + + <!-- title --> + <String id='label' javaBean='""'/> + + <!-- bean --> + <Object id='bean' javaBean='null'/> + + <!-- time model --> + <Integer id="timeModel" javaBean='0'/> + + <!-- the real date --> + <java.util.Date id="date" javaBean='null'/> + + <!-- ui handler --> + <TimeEditorHandler id='handler' constructorParams='this'/> + + <script><![CDATA[ +public void init() { + handler.init(); +} +]]> + </script> + + <Table constraints='BorderLayout.NORTH' fill='horizontal' insets='0'> + <row> + <cell> + <JLabel id='title'/> + </cell> + <cell weightx='1'> + <JLabel/> + </cell> + <cell> + <JSpinner id='hour' + onStateChanged='setTimeModel((Integer)hour.getValue()* 60 + timeModel % 60)'/> + </cell> + <cell> + <JLabel id='labelH'/> + </cell> + <cell> + <JSpinner id='minute' + onStateChanged='setTimeModel((timeModel / 60) * 60 + (Integer) minute.getValue())'/> + </cell> + </row> + </Table> + + <JSlider id='slider' constraints='BorderLayout.SOUTH' + onStateChanged='if (!slider.getValueIsAdjusting()) setTimeModel(slider.getValue());'/> + +</JPanel> Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/TimeEditorHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/TimeEditorHandler.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/TimeEditorHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,224 +0,0 @@ -/** - * *##% - * JAXX Widgets - * 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>. - * ##%* - */ -package jaxx.runtime.swing.editor; - -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import org.apache.commons.beanutils.PropertyUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.swing.JLabel; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.beans.PropertyDescriptor; -import java.lang.reflect.Method; -import java.util.Calendar; -import java.util.Date; -import java.util.Dictionary; -import java.util.Hashtable; -import java.util.Map; -import javax.swing.JSlider; -import javax.swing.plaf.basic.BasicSliderUI; - -/** @author chemit */ -public class TimeEditorHandler { - - public static final Log log = LogFactory.getLog(TimeEditorHandler.class); - public static final String BEAN_PROPERTY = "bean"; - public static final String PROPERTY_PROPERTY = "property"; - public static final String DATE_PROPERTY = "date"; - public static final String TIME_MODEL_PROPERTY = "timeModel"; - /** editor ui */ - protected TimeEditor editor; - /** the mutator method on the property of boxed bean in the editor */ - protected Method mutator; - protected Calendar calendar; - - public TimeEditorHandler(TimeEditor ui) { - this.editor = ui; - this.calendar = Calendar.getInstance(); - } - - public void init() { - - if (editor.getBean() == null) { - throw new NullPointerException("can not have a null bean in ui " + editor); - } - - // create slider labels - Map<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>(); - for (int i = 0; i < 25; i += 2) { - labelTable.put(i * 60, new JLabel(i + "")); - } - JSlider slider = editor.getSlider(); - slider.setLabelTable((Dictionary<?,?>) labelTable); - - MouseAdapter m = new MouseAdapter() { - - @Override - public void mouseClicked(MouseEvent e) { - // set the value - int value = getSliderValue(e); - JSlider slider = (JSlider) e.getComponent(); - slider.setValueIsAdjusting(true); - slider.setValue(value); - slider.setValueIsAdjusting(false); - showToolTip(e); - e.consume(); - } - - @Override - public void mouseDragged(MouseEvent e) { - showToolTip(e); - } - - @Override - public void mouseEntered(MouseEvent e) { - showToolTip(e); - } - - @Override - public void mouseMoved(MouseEvent e) { - showToolTip(e); - } - - @Override - public void mouseReleased(MouseEvent e) { - showToolTip(e); - } - - int getSliderValue(MouseEvent e) { - JSlider slider = (JSlider) e.getSource(); - int value = -1; - if (slider.getUI() instanceof BasicSliderUI) { - BasicSliderUI ui = (BasicSliderUI) slider.getUI(); - value = slider.getOrientation() == JSlider.HORIZONTAL - ? ui.valueForXPosition(e.getX()) - : ui.valueForYPosition(e.getY()); - } - return value; - } - - void showToolTip(MouseEvent e) { - - int value = getSliderValue(e); - if (value == -1) { - return; - } - int h = value / 60; - int m = value % 60; - - String text = ""; - if (h < 10) { - text = "0"; - } - text += h + " : "; - if (m < 10) { - text += "0"; - } - text += m; - - JSlider slider = (JSlider) e.getSource(); - slider.setToolTipText(text); - - } - }; - slider.addMouseListener(m); - slider.addMouseMotionListener(m); - - // listen when date changes (should come from outside) - editor.addPropertyChangeListener(DATE_PROPERTY, new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - Date date = (Date) evt.getNewValue(); - - if (date == null) { - return; - } - calendar.setTime(date); - int hours = calendar.get(Calendar.HOUR_OF_DAY); - int minutes = calendar.get(Calendar.MINUTE); - if (log.isDebugEnabled()) { - log.debug("date changed : new value " + hours + ":" + minutes); - } - getEditor().setTimeModel((hours * 60) + minutes); - } - }); - - // listen when time model changes (should come from editor) - editor.addPropertyChangeListener(TIME_MODEL_PROPERTY, new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - Integer time = (Integer) evt.getNewValue(); - int hours = time / 60; - int minutes = time % 60; - calendar.set(Calendar.HOUR_OF_DAY, hours); - calendar.set(Calendar.MINUTE, minutes); - setDate(null, calendar.getTime()); - } - }); - } - - public TimeEditor getEditor() { - return editor; - } - - protected void setDate(Date oldValue, Date newValue) { - if (editor.getBean() == null) { - return; - } - - if (log.isDebugEnabled()) { - log.debug(editor.getProperty() + " on " + editor.getBean().getClass() + " :: " + oldValue + " to " + newValue); - } - - try { - getMutator().invoke(editor.getBean(), newValue); - - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - protected Method getMutator() { - if (mutator == null) { - Object bean = editor.getBean(); - if (bean == null) { - throw new NullPointerException("could not find bean in " + editor); - } - String property = editor.getProperty(); - if (property == null) { - throw new NullPointerException("could not find property in " + editor); - } - - try { - PropertyDescriptor descriptor = PropertyUtils.getPropertyDescriptor(bean, property); - mutator = descriptor.getWriteMethod(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - return mutator; - } -} Copied: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/TimeEditorHandler.java (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/TimeEditorHandler.java) =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/TimeEditorHandler.java (rev 0) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/TimeEditorHandler.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,224 @@ +/** + * *##% + * JAXX Widgets + * 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>. + * ##%* + */ +package jaxx.runtime.swing.editor; + +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import org.apache.commons.beanutils.PropertyUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.swing.JLabel; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.beans.PropertyDescriptor; +import java.lang.reflect.Method; +import java.util.Calendar; +import java.util.Date; +import java.util.Dictionary; +import java.util.Hashtable; +import java.util.Map; +import javax.swing.JSlider; +import javax.swing.plaf.basic.BasicSliderUI; + +/** @author chemit */ +public class TimeEditorHandler { + + public static final Log log = LogFactory.getLog(TimeEditorHandler.class); + public static final String BEAN_PROPERTY = "bean"; + public static final String PROPERTY_PROPERTY = "property"; + public static final String DATE_PROPERTY = "date"; + public static final String TIME_MODEL_PROPERTY = "timeModel"; + /** editor ui */ + protected TimeEditor editor; + /** the mutator method on the property of boxed bean in the editor */ + protected Method mutator; + protected Calendar calendar; + + public TimeEditorHandler(TimeEditor ui) { + this.editor = ui; + this.calendar = Calendar.getInstance(); + } + + public void init() { + + if (editor.getBean() == null) { + throw new NullPointerException("can not have a null bean in ui " + editor); + } + + // create slider labels + Map<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>(); + for (int i = 0; i < 25; i += 2) { + labelTable.put(i * 60, new JLabel(i + "")); + } + JSlider slider = editor.getSlider(); + slider.setLabelTable((Dictionary<?,?>) labelTable); + + MouseAdapter m = new MouseAdapter() { + + @Override + public void mouseClicked(MouseEvent e) { + // set the value + int value = getSliderValue(e); + JSlider slider = (JSlider) e.getComponent(); + slider.setValueIsAdjusting(true); + slider.setValue(value); + slider.setValueIsAdjusting(false); + showToolTip(e); + e.consume(); + } + + @Override + public void mouseDragged(MouseEvent e) { + showToolTip(e); + } + + @Override + public void mouseEntered(MouseEvent e) { + showToolTip(e); + } + + @Override + public void mouseMoved(MouseEvent e) { + showToolTip(e); + } + + @Override + public void mouseReleased(MouseEvent e) { + showToolTip(e); + } + + int getSliderValue(MouseEvent e) { + JSlider slider = (JSlider) e.getSource(); + int value = -1; + if (slider.getUI() instanceof BasicSliderUI) { + BasicSliderUI ui = (BasicSliderUI) slider.getUI(); + value = slider.getOrientation() == JSlider.HORIZONTAL + ? ui.valueForXPosition(e.getX()) + : ui.valueForYPosition(e.getY()); + } + return value; + } + + void showToolTip(MouseEvent e) { + + int value = getSliderValue(e); + if (value == -1) { + return; + } + int h = value / 60; + int m = value % 60; + + String text = ""; + if (h < 10) { + text = "0"; + } + text += h + " : "; + if (m < 10) { + text += "0"; + } + text += m; + + JSlider slider = (JSlider) e.getSource(); + slider.setToolTipText(text); + + } + }; + slider.addMouseListener(m); + slider.addMouseMotionListener(m); + + // listen when date changes (should come from outside) + editor.addPropertyChangeListener(DATE_PROPERTY, new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent evt) { + Date date = (Date) evt.getNewValue(); + + if (date == null) { + return; + } + calendar.setTime(date); + int hours = calendar.get(Calendar.HOUR_OF_DAY); + int minutes = calendar.get(Calendar.MINUTE); + if (log.isDebugEnabled()) { + log.debug("date changed : new value " + hours + ":" + minutes); + } + getEditor().setTimeModel((hours * 60) + minutes); + } + }); + + // listen when time model changes (should come from editor) + editor.addPropertyChangeListener(TIME_MODEL_PROPERTY, new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent evt) { + Integer time = (Integer) evt.getNewValue(); + int hours = time / 60; + int minutes = time % 60; + calendar.set(Calendar.HOUR_OF_DAY, hours); + calendar.set(Calendar.MINUTE, minutes); + setDate(null, calendar.getTime()); + } + }); + } + + public TimeEditor getEditor() { + return editor; + } + + protected void setDate(Date oldValue, Date newValue) { + if (editor.getBean() == null) { + return; + } + + if (log.isDebugEnabled()) { + log.debug(editor.getProperty() + " on " + editor.getBean().getClass() + " :: " + oldValue + " to " + newValue); + } + + try { + getMutator().invoke(editor.getBean(), newValue); + + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + protected Method getMutator() { + if (mutator == null) { + Object bean = editor.getBean(); + if (bean == null) { + throw new NullPointerException("could not find bean in " + editor); + } + String property = editor.getProperty(); + if (property == null) { + throw new NullPointerException("could not find property in " + editor); + } + + try { + PropertyDescriptor descriptor = PropertyUtils.getPropertyDescriptor(bean, property); + mutator = descriptor.getWriteMethod(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + return mutator; + } +} Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.css =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.css 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.css 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,60 +0,0 @@ -/** - * *##% jaxx-runtime-swing-widget - * 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>. ##%* -*/ - -#categoryLabelPanel { - background:{Color.WHITE}; -} - -#descriptionPane { - columnHeaderView:{new JLabel(_("config.descrition"), SwingUtil.getUIManagerActionIcon("information"), 10)}; -} - -#description { - rows:3; - editable:false; - focusable:false; - font-size:10; - text:{_("config.no.option.selected")}; -} - -#tablePane { - columnHeaderView:{table.getTableHeader()}; - verticalScrollBarPolicy:{ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS}; - horizontalScrollBarPolicy:{ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER}; -} - -#table { - rowSelectionAllowed:false; - autoCreateRowSorter:true; - autoResizeMode:{JTable.AUTO_RESIZE_ALL_COLUMNS}; -} - -#reset{ - text:"config.action.reset"; - toolTipText:"config.action.reset.tip"; - actionIcon:"config-reset"; - enabled:{getCategoryModel().isModified()}; -} - -#save{ - text:"config.action.save"; - toolTipText:"config.action.save.tip"; - actionIcon:"config-save"; - enabled:{getCategoryModel().isModified() && getCategoryModel().isValid()}; -} Copied: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.css (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.css) =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.css (rev 0) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.css 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,60 @@ +/** + * *##% jaxx-runtime-swing-widget + * 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>. ##%* +*/ + +#categoryLabelPanel { + background:{Color.WHITE}; +} + +#descriptionPane { + columnHeaderView:{new JLabel(_("config.descrition"), SwingUtil.getUIManagerActionIcon("information"), 10)}; +} + +#description { + rows:3; + editable:false; + focusable:false; + font-size:10; + text:{_("config.no.option.selected")}; +} + +#tablePane { + columnHeaderView:{table.getTableHeader()}; + verticalScrollBarPolicy:{ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS}; + horizontalScrollBarPolicy:{ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER}; +} + +#table { + rowSelectionAllowed:false; + autoCreateRowSorter:true; + autoResizeMode:{JTable.AUTO_RESIZE_ALL_COLUMNS}; +} + +#reset{ + text:"config.action.reset"; + toolTipText:"config.action.reset.tip"; + actionIcon:"config-reset"; + enabled:{getCategoryModel().isModified()}; +} + +#save{ + text:"config.action.save"; + toolTipText:"config.action.save.tip"; + actionIcon:"config-save"; + enabled:{getCategoryModel().isModified() && getCategoryModel().isValid()}; +} Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,119 +0,0 @@ -<!-- - -/** - * *##% jaxx-runtime-swing-widget - * 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>. ##%* - */ - ---> - -<JPanel layout='{new BorderLayout()}'> - - <style source='ConfigCategoryUI.css'/> - - <script><![CDATA[ -import jaxx.runtime.swing.editor.config.model.*; -import jaxx.runtime.swing.editor.ColumnSelector; -import static org.nuiton.i18n.I18n.n_; - -void $afterCompleteSetup() { - // prepare table - SwingUtil.setI18nTableHeaderRenderer(table, - n_("config.key"), - n_("config.key.tip"), - n_("config.value"), - n_("config.value.tip"), - n_("config.defaultValue"), - n_("config.defaultValue.tip")); - - ConfigTableRenderer renderer = new ConfigTableRenderer(); - SwingUtil.setTableColumnRenderer(table, 0, renderer); - SwingUtil.setTableColumnRenderer(table, 1, renderer); - SwingUtil.setTableColumnRenderer(table, 2, renderer); - Font f = table.getFont().deriveFont(Font.ITALIC | Font.BOLD); - int width = SwingUtil.computeTableColumnWidth(table, f, 0, "___*"); - SwingUtil.fixTableColumnWidth(table, 0, width); - SwingUtil.setTableColumnEditor(table, 1, new ConfigTableEditor((ConfigTableModel) table.getModel())); - //TODO to be continued... - //columnSelector.setMyTable(table); - //tablePane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, columnSelector); -} - -protected void updateDescriptionText() { - OptionModel option; - if (selectionModel.isSelectionEmpty()) { - option = null; - } else { - int row = selectionModel.getAnchorSelectionIndex(); - ConfigTableModel m = (ConfigTableModel) table.getModel(); - option = m.getEntry(row); - if (log.isDebugEnabled()) { - log.debug(row + " : " + option); - } - } - StringBuilder buffer = new StringBuilder(); - if (option == null) { - buffer.append(_("config.no.option.selected")); - } else { - buffer.append(_("config.option.label", option.getKey(), _(option.getDescription()))).append('\n'); - if (option.isModified()) { - buffer.append(_("config.option.modified", option.getOriginalValue(), option.getValue())).append('\n'); - } - if (option.isFinal()) { - buffer.append(_("config.option.final")).append('\n'); - } - } - description.setText(buffer.toString()); -} -]]> - </script> - - <CategoryModel id='categoryModel' javaBean='getContextValue(CategoryModel.class)'/> - - <ConfigTableModel id='tableModel' constructorParams='categoryModel' - onTableChanged='updateDescriptionText()'/> - - <ListSelectionModel id='selectionModel' javaBean='new DefaultListSelectionModel()' - onValueChanged='if (!event.getValueIsAdjusting()) { updateDescriptionText(); }'/> - - <!--<ColumnSelector id='columnSelector' />--> - - <!-- categorie label --> - <JPanel id="categoryLabelPanel" constraints='BorderLayout.NORTH'> - <JLabel id='categoryLabel'/> - </JPanel> - - <!-- table of options --> - <JScrollPane id='tablePane' constraints='BorderLayout.CENTER'> - <JTable id="table" constructorParams='tableModel' - selectionModel='{selectionModel}'/> - </JScrollPane> - - <JPanel layout='{new BorderLayout()}' constraints='BorderLayout.SOUTH'> - - <!-- description of selected option in table --> - <JScrollPane id="descriptionPane" constraints='BorderLayout.CENTER'> - <JTextArea id='description'/> - </JScrollPane> - - <!-- actions of the category --> - <JPanel layout='{new GridLayout(1,0)}' constraints='BorderLayout.SOUTH'> - <JButton id='reset' onActionPerformed='getContextValue(ConfigUIModel.class).reset()'/> - <JButton id='save' onActionPerformed='getContextValue(ConfigUIModel.class).saveModified()'/> - </JPanel> - </JPanel> -</JPanel> Copied: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.jaxx (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.jaxx) =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.jaxx (rev 0) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,119 @@ +<!-- + +/** + * *##% jaxx-runtime-swing-widget + * 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>. ##%* + */ + +--> + +<JPanel layout='{new BorderLayout()}'> + + <style source='ConfigCategoryUI.css'/> + + <script><![CDATA[ +import jaxx.runtime.swing.editor.config.model.*; +import jaxx.runtime.swing.editor.ColumnSelector; +import static org.nuiton.i18n.I18n.n_; + +void $afterCompleteSetup() { + // prepare table + SwingUtil.setI18nTableHeaderRenderer(table, + n_("config.key"), + n_("config.key.tip"), + n_("config.value"), + n_("config.value.tip"), + n_("config.defaultValue"), + n_("config.defaultValue.tip")); + + ConfigTableRenderer renderer = new ConfigTableRenderer(); + SwingUtil.setTableColumnRenderer(table, 0, renderer); + SwingUtil.setTableColumnRenderer(table, 1, renderer); + SwingUtil.setTableColumnRenderer(table, 2, renderer); + Font f = table.getFont().deriveFont(Font.ITALIC | Font.BOLD); + int width = SwingUtil.computeTableColumnWidth(table, f, 0, "___*"); + SwingUtil.fixTableColumnWidth(table, 0, width); + SwingUtil.setTableColumnEditor(table, 1, new ConfigTableEditor((ConfigTableModel) table.getModel())); + //TODO to be continued... + //columnSelector.setMyTable(table); + //tablePane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, columnSelector); +} + +protected void updateDescriptionText() { + OptionModel option; + if (selectionModel.isSelectionEmpty()) { + option = null; + } else { + int row = selectionModel.getAnchorSelectionIndex(); + ConfigTableModel m = (ConfigTableModel) table.getModel(); + option = m.getEntry(row); + if (log.isDebugEnabled()) { + log.debug(row + " : " + option); + } + } + StringBuilder buffer = new StringBuilder(); + if (option == null) { + buffer.append(_("config.no.option.selected")); + } else { + buffer.append(_("config.option.label", option.getKey(), _(option.getDescription()))).append('\n'); + if (option.isModified()) { + buffer.append(_("config.option.modified", option.getOriginalValue(), option.getValue())).append('\n'); + } + if (option.isFinal()) { + buffer.append(_("config.option.final")).append('\n'); + } + } + description.setText(buffer.toString()); +} +]]> + </script> + + <CategoryModel id='categoryModel' javaBean='getContextValue(CategoryModel.class)'/> + + <ConfigTableModel id='tableModel' constructorParams='categoryModel' + onTableChanged='updateDescriptionText()'/> + + <ListSelectionModel id='selectionModel' javaBean='new DefaultListSelectionModel()' + onValueChanged='if (!event.getValueIsAdjusting()) { updateDescriptionText(); }'/> + + <!--<ColumnSelector id='columnSelector' />--> + + <!-- categorie label --> + <JPanel id="categoryLabelPanel" constraints='BorderLayout.NORTH'> + <JLabel id='categoryLabel'/> + </JPanel> + + <!-- table of options --> + <JScrollPane id='tablePane' constraints='BorderLayout.CENTER'> + <JTable id="table" constructorParams='tableModel' + selectionModel='{selectionModel}'/> + </JScrollPane> + + <JPanel layout='{new BorderLayout()}' constraints='BorderLayout.SOUTH'> + + <!-- description of selected option in table --> + <JScrollPane id="descriptionPane" constraints='BorderLayout.CENTER'> + <JTextArea id='description'/> + </JScrollPane> + + <!-- actions of the category --> + <JPanel layout='{new GridLayout(1,0)}' constraints='BorderLayout.SOUTH'> + <JButton id='reset' onActionPerformed='getContextValue(ConfigUIModel.class).reset()'/> + <JButton id='save' onActionPerformed='getContextValue(ConfigUIModel.class).saveModified()'/> + </JPanel> + </JPanel> +</JPanel> Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableEditor.java =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableEditor.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableEditor.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,127 +0,0 @@ -/* -* *##% - * JAXX Widgets - * 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>. - * ##%* */ -package jaxx.runtime.swing.editor.config; - -import jaxx.runtime.swing.editor.config.model.ConfigTableModel; -import javax.swing.DefaultCellEditor; -import javax.swing.JTable; -import javax.swing.event.CellEditorListener; -import javax.swing.table.TableCellEditor; -import java.awt.Component; -import java.util.EventObject; -import java.util.Locale; -import jaxx.runtime.swing.editor.ClassCellEditor; -import jaxx.runtime.swing.editor.EnumEditor; -import jaxx.runtime.swing.editor.LocaleEditor; - -/** - * L'éditeur des valeurs des propriétés d'une configuration - * - * @author chemit - */ -public class ConfigTableEditor implements TableCellEditor { - - protected TableCellEditor delegate; - protected ConfigTableModel model; - - public ConfigTableEditor(ConfigTableModel model) { - this.model = model; - } - - @Override - public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { - delegate = findDelegate(table, model.getEntry(row).getType()); - return delegate.getTableCellEditorComponent(table, value, isSelected, row, column); - } - - @Override - public Object getCellEditorValue() { - return !hasDelegate() ? null : delegate.getCellEditorValue(); - } - - @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 findDelegate(JTable table, Class<?> type) { - TableCellEditor editor = table.getDefaultEditor(type); - TableCellEditor defaultEditor = table.getDefaultEditor(Object.class); - if (editor == defaultEditor) { - // find not a specialized editor for the type - if (type.isEnum()) { - // add a EnumEditor to table - editor = new DefaultCellEditor(EnumEditor.newEditor((Class<Enum>) type)); - table.setDefaultEditor(type, editor); - } else if (type == Class.class) { - editor = new ClassCellEditor(); - table.setDefaultEditor(type, editor); - } //else if (type == File.class){ - // TODO a FileEditor - // table.setDefaultEditor(type, delegate); - //} - else if (type.equals(Locale.class)) { - editor = new DefaultCellEditor(LocaleEditor.newEditor()); - table.setDefaultEditor(Locale.class, editor); - } else { - editor = table.getDefaultEditor(String.class); - } - } - if (editor == null) { - throw new IllegalStateException("could not find a editor for type +" + type); - } - return editor; - } - - protected boolean hasDelegate() { - return delegate != null; - } -} Copied: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableEditor.java (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableEditor.java) =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableEditor.java (rev 0) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableEditor.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,127 @@ +/* +* *##% + * JAXX Widgets + * 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>. + * ##%* */ +package jaxx.runtime.swing.editor.config; + +import jaxx.runtime.swing.editor.config.model.ConfigTableModel; +import javax.swing.DefaultCellEditor; +import javax.swing.JTable; +import javax.swing.event.CellEditorListener; +import javax.swing.table.TableCellEditor; +import java.awt.Component; +import java.util.EventObject; +import java.util.Locale; +import jaxx.runtime.swing.editor.ClassCellEditor; +import jaxx.runtime.swing.editor.EnumEditor; +import jaxx.runtime.swing.editor.LocaleEditor; + +/** + * L'éditeur des valeurs des propriétés d'une configuration + * + * @author chemit + */ +public class ConfigTableEditor implements TableCellEditor { + + protected TableCellEditor delegate; + protected ConfigTableModel model; + + public ConfigTableEditor(ConfigTableModel model) { + this.model = model; + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + delegate = findDelegate(table, model.getEntry(row).getType()); + return delegate.getTableCellEditorComponent(table, value, isSelected, row, column); + } + + @Override + public Object getCellEditorValue() { + return !hasDelegate() ? null : delegate.getCellEditorValue(); + } + + @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 findDelegate(JTable table, Class<?> type) { + TableCellEditor editor = table.getDefaultEditor(type); + TableCellEditor defaultEditor = table.getDefaultEditor(Object.class); + if (editor == defaultEditor) { + // find not a specialized editor for the type + if (type.isEnum()) { + // add a EnumEditor to table + editor = new DefaultCellEditor(EnumEditor.newEditor((Class<Enum>) type)); + table.setDefaultEditor(type, editor); + } else if (type == Class.class) { + editor = new ClassCellEditor(); + table.setDefaultEditor(type, editor); + } //else if (type == File.class){ + // TODO a FileEditor + // table.setDefaultEditor(type, delegate); + //} + else if (type.equals(Locale.class)) { + editor = new DefaultCellEditor(LocaleEditor.newEditor()); + table.setDefaultEditor(Locale.class, editor); + } else { + editor = table.getDefaultEditor(String.class); + } + } + if (editor == null) { + throw new IllegalStateException("could not find a editor for type +" + type); + } + return editor; + } + + protected boolean hasDelegate() { + return delegate != null; + } +} Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableRenderer.java =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableRenderer.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableRenderer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,114 +0,0 @@ -/* - * *##% - * JAXX Widgets - * 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>. - * ##%* */ -package jaxx.runtime.swing.editor.config; - -import static org.nuiton.i18n.I18n._; - -import javax.swing.JComponent; -import javax.swing.JTable; -import javax.swing.table.DefaultTableCellRenderer; -import javax.swing.table.TableCellRenderer; -import java.awt.Color; -import java.awt.Component; -import java.awt.Font; -import jaxx.runtime.swing.editor.config.model.ConfigTableModel; -import jaxx.runtime.swing.editor.config.model.OptionModel; - -/** - * Pour le rendu du tableau des options d'une categorie - * - * @author chemit - * @see ConfigTableModel - */ -public class ConfigTableRenderer extends DefaultTableCellRenderer { - - private static final long serialVersionUID = 1L; - protected static Color col; - protected static Font font; - protected static Font font2; - - public ConfigTableRenderer() { - col = getForeground(); - } - - @Override - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - int modelRow = table.convertRowIndexToModel(row); - int modelColumn = table.convertColumnIndexToModel(column); - ConfigTableModel model = (ConfigTableModel) table.getModel(); - OptionModel key = model.getEntry(modelRow); - boolean isModified = key.isModified(); - - boolean isValid = key.isValid(); - - if (font == null) { - font = getFont(); - font2 = font.deriveFont(Font.ITALIC | Font.BOLD); - } - Component cellRenderer = null; - switch (modelColumn) { - case 0: - cellRenderer = getKeyCellRenderer(table, value, isSelected, hasFocus, modelRow, modelColumn, key, isValid, isModified); - break; - case 1: - cellRenderer = getValueCellRenderer(table, value, isSelected, hasFocus, modelRow, modelColumn, key, isValid, isModified); - break; - case 2: - cellRenderer = getValueCellRenderer(table, value, isSelected, hasFocus, modelRow, modelColumn, key, isValid, isModified); - break; - default: - throw new IllegalStateException("no renderer find for column " + modelColumn); - } - return cellRenderer; - } - - protected Component getKeyCellRenderer(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column, OptionModel key, boolean isValid, boolean isModified) { - String tooltip = _(key.getDescription()); - Object originalValue = key.getOriginalValue(); - boolean isFinal = key.isFinal(); - if (isFinal) { - tooltip += " [" + _("config.unmodifiable") + ']'; - } - if (isModified) { - String s = _("config.modified", originalValue); - value = value + " *"; - tooltip += " [" + s + ']'; - } - if (!isValid) { - String s2 = _("config.unvalid", originalValue, key.getType()); - tooltip += " (" + s2 + ")"; - value = value + " !"; - } - JComponent result = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - result.setToolTipText(tooltip); - result.setForeground(isValid ? col : Color.RED); - result.setFont(isModified || !isValid ? font2 : font); - result.setEnabled(!isFinal); - return result; - } - - protected Component getValueCellRenderer(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column, OptionModel key, boolean isValid, boolean isModified) { - TableCellRenderer defaultRenderer = table.getDefaultRenderer(key.getType()); - - Component result; - result = defaultRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - return result; - } -} Copied: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableRenderer.java (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableRenderer.java) =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableRenderer.java (rev 0) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableRenderer.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,114 @@ +/* + * *##% + * JAXX Widgets + * 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>. + * ##%* */ +package jaxx.runtime.swing.editor.config; + +import static org.nuiton.i18n.I18n._; + +import javax.swing.JComponent; +import javax.swing.JTable; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableCellRenderer; +import java.awt.Color; +import java.awt.Component; +import java.awt.Font; +import jaxx.runtime.swing.editor.config.model.ConfigTableModel; +import jaxx.runtime.swing.editor.config.model.OptionModel; + +/** + * Pour le rendu du tableau des options d'une categorie + * + * @author chemit + * @see ConfigTableModel + */ +public class ConfigTableRenderer extends DefaultTableCellRenderer { + + private static final long serialVersionUID = 1L; + protected static Color col; + protected static Font font; + protected static Font font2; + + public ConfigTableRenderer() { + col = getForeground(); + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + int modelRow = table.convertRowIndexToModel(row); + int modelColumn = table.convertColumnIndexToModel(column); + ConfigTableModel model = (ConfigTableModel) table.getModel(); + OptionModel key = model.getEntry(modelRow); + boolean isModified = key.isModified(); + + boolean isValid = key.isValid(); + + if (font == null) { + font = getFont(); + font2 = font.deriveFont(Font.ITALIC | Font.BOLD); + } + Component cellRenderer = null; + switch (modelColumn) { + case 0: + cellRenderer = getKeyCellRenderer(table, value, isSelected, hasFocus, modelRow, modelColumn, key, isValid, isModified); + break; + case 1: + cellRenderer = getValueCellRenderer(table, value, isSelected, hasFocus, modelRow, modelColumn, key, isValid, isModified); + break; + case 2: + cellRenderer = getValueCellRenderer(table, value, isSelected, hasFocus, modelRow, modelColumn, key, isValid, isModified); + break; + default: + throw new IllegalStateException("no renderer find for column " + modelColumn); + } + return cellRenderer; + } + + protected Component getKeyCellRenderer(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column, OptionModel key, boolean isValid, boolean isModified) { + String tooltip = _(key.getDescription()); + Object originalValue = key.getOriginalValue(); + boolean isFinal = key.isFinal(); + if (isFinal) { + tooltip += " [" + _("config.unmodifiable") + ']'; + } + if (isModified) { + String s = _("config.modified", originalValue); + value = value + " *"; + tooltip += " [" + s + ']'; + } + if (!isValid) { + String s2 = _("config.unvalid", originalValue, key.getType()); + tooltip += " (" + s2 + ")"; + value = value + " !"; + } + JComponent result = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + result.setToolTipText(tooltip); + result.setForeground(isValid ? col : Color.RED); + result.setFont(isModified || !isValid ? font2 : font); + result.setEnabled(!isFinal); + return result; + } + + protected Component getValueCellRenderer(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column, OptionModel key, boolean isValid, boolean isModified) { + TableCellRenderer defaultRenderer = table.getDefaultRenderer(key.getType()); + + Component result; + result = defaultRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + return result; + } +} Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.css =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.css 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.css 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,27 +0,0 @@ -/** - * *##% jaxx-runtime-swing-widget - * 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>. ##%* -*/ -#quit{ - text:"config.action.quit"; - toolTipText:"config.action.quit.tip"; - actionIcon:"config-quit"; -} - -#categories{ - tabPlacement:{JTabbedPane.LEFT}; -} Copied: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.css (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.css) =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.css (rev 0) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.css 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,27 @@ +/** + * *##% jaxx-runtime-swing-widget + * 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>. ##%* +*/ +#quit{ + text:"config.action.quit"; + toolTipText:"config.action.quit.tip"; + actionIcon:"config-quit"; +} + +#categories{ + tabPlacement:{JTabbedPane.LEFT}; +} Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,72 +0,0 @@ -<!-- - -/** - * *##% jaxx-runtime-swing-widget - * 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>. ##%* - */ - ---> - -<JPanel layout='{new BorderLayout()}'> - - <style source='ConfigUI.css'/> - - <script><![CDATA[ - import jaxx.runtime.swing.editor.config.model.ConfigUIModel; - - categories.setModel(new DefaultSingleSelectionModel() { - - private static final long serialVersionUID = 1L; - - @Override - public void setSelectedIndex(int index) { - // check if catgeory can be quit - boolean canContinue = !isSelected() || ConfigUIBuilder.canQuitCategory(ConfigUI.this); - if (canContinue) { - if (log.isDebugEnabled()) { - log.debug("new index : " + index); - } - // was authorized to continue - super.setSelectedIndex(index); - } - } - }); - - protected void changeCategory(ChangeEvent e) { - JPanel p = (JPanel) getCategories().getSelectedComponent(); - if (p == null) { - // pas de selection - return; - } - getModel().setCategory(p.getName()); - getCategories().invalidate(); - } - ]]> - </script> - - <!-- le modele de l'ui --> - <ConfigUIModel id='model' javaBean='getContextValue(ConfigUIModel.class)'/> - - <!-- les differentes categories de la configuration --> - <JTabbedPane id='categories' constraints='BorderLayout.CENTER' - onStateChanged='changeCategory(event)' /> - - <!-- pour quitter l'ui --> - <JPanel layout='{new GridLayout(1,0)}' constraints='BorderLayout.SOUTH'> - <JButton id='quit'/> - </JPanel> -</JPanel> Copied: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.jaxx (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.jaxx) =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.jaxx (rev 0) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,72 @@ +<!-- + +/** + * *##% jaxx-runtime-swing-widget + * 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>. ##%* + */ + +--> + +<JPanel layout='{new BorderLayout()}'> + + <style source='ConfigUI.css'/> + + <script><![CDATA[ + import jaxx.runtime.swing.editor.config.model.ConfigUIModel; + + categories.setModel(new DefaultSingleSelectionModel() { + + private static final long serialVersionUID = 1L; + + @Override + public void setSelectedIndex(int index) { + // check if catgeory can be quit + boolean canContinue = !isSelected() || ConfigUIBuilder.canQuitCategory(ConfigUI.this); + if (canContinue) { + if (log.isDebugEnabled()) { + log.debug("new index : " + index); + } + // was authorized to continue + super.setSelectedIndex(index); + } + } + }); + + protected void changeCategory(ChangeEvent e) { + JPanel p = (JPanel) getCategories().getSelectedComponent(); + if (p == null) { + // pas de selection + return; + } + getModel().setCategory(p.getName()); + getCategories().invalidate(); + } + ]]> + </script> + + <!-- le modele de l'ui --> + <ConfigUIModel id='model' javaBean='getContextValue(ConfigUIModel.class)'/> + + <!-- les differentes categories de la configuration --> + <JTabbedPane id='categories' constraints='BorderLayout.CENTER' + onStateChanged='changeCategory(event)' /> + + <!-- pour quitter l'ui --> + <JPanel layout='{new GridLayout(1,0)}' constraints='BorderLayout.SOUTH'> + <JButton id='quit'/> + </JPanel> +</JPanel> Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,248 +0,0 @@ -/** - * *##% - * JAXX Widgets - * 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>. - * ##%* - */ -package jaxx.runtime.swing.editor.config; - -import java.awt.Frame; -import java.awt.Window; -import java.awt.event.ActionEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.util.List; -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.JButton; -import javax.swing.JComponent; -import javax.swing.JDialog; -import javax.swing.JOptionPane; -import javax.swing.JRootPane; -import javax.swing.KeyStroke; -import jaxx.runtime.JAXXContext; -import jaxx.runtime.context.JAXXInitialContext; -import jaxx.runtime.SwingUtil; - -import jaxx.runtime.swing.editor.config.model.CategoryModel; -import jaxx.runtime.swing.editor.config.model.ConfigUIModel; -import jaxx.runtime.swing.editor.config.model.OptionModel; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import static org.nuiton.i18n.I18n._; - -/** - * La classe pour construire l'ui - * @author chemit - */ -public class ConfigUIBuilder { - - public static final Log log = LogFactory.getLog(ConfigUIBuilder.class); - - /** - * Construire l'ui de configuration (sous forme de panel) - * - * @param parentContext le context applicatif - * @param model le modele de l'ui de configuration - * @param defaultCategory la categorie a selectionner - * @return l'ui instanciate - */ - public static ConfigUI newConfigUI(jaxx.runtime.JAXXContext parentContext, final ConfigUIModel model, String defaultCategory) { - JAXXContext tx = new JAXXInitialContext().add(parentContext).add(model); - - final ConfigUI ui = new ConfigUI(tx); - JButton quitButton = ui.getQuit(); - - // prepare quit action - Action quitAction = new AbstractAction(quitButton.getText(), quitButton.getIcon()) { - - private static final long serialVersionUID = 1L; - - @Override - public void actionPerformed(ActionEvent e) { - if (!canQuitCategory(ui)) { - return; - } - - if (model.isSaved() && !model.isStandalone()) { - StringBuilder buffer = new StringBuilder(); - // on doit verifier si des options sauvees necessite - // un redemarrage de l'application - for (CategoryModel cat : model) { - List<OptionModel> savedOptions = cat.getSavedOptions(); - if (!savedOptions.isEmpty()) { - buffer.append("\n").append(_("config.category.saved", _(cat.getCategory()))).append("\n"); - for (OptionModel option : savedOptions) { - buffer.append("\n- ").append(option.getKey()); - } - } - - } -// askUser(ui, -// _("config.title.will.reload.application"), buffer.toString(), -// JOptionPane.INFORMATION_MESSAGE, -// new Object[]{ -// _("config.choice.ok")}, -// 0); - } - ui.getParentContainer(Window.class).dispose(); - } - }; - String tip = quitButton.getToolTipText(); - quitButton.setAction(quitAction); - quitButton.setToolTipText(tip); - - // build categories tabs - for (CategoryModel categoryModel : model) { - String category = categoryModel.getCategory(); - String categoryLabel = _(categoryModel.getCategoryLabel()); - ConfigCategoryUI p = new ConfigCategoryUI(new JAXXInitialContext().add(ui).add(categoryModel)); - p.getCategoryLabel().setText(categoryLabel); - p.setName(category); - ui.getCategories().addTab(_(category), null, p, categoryLabel); - } - - model.setCategory(defaultCategory); - int categoryIndex = model.getCategoryIndex(defaultCategory); - if (log.isDebugEnabled()) { - log.debug("index of default category (" + defaultCategory + ") : " + categoryIndex); - } - ui.getCategories().setSelectedIndex(categoryIndex); - return ui; - } - - /** - * Affiche l'ui de configuration dans un boite de dialogue. - * - * @param configUI l'ui de configuration - * @param ui l'ui parent de la boite de dialogue a afficher (peut etre nulle) - * @param undecorated un drapeau pour savoir si on affiche les decorations de fenetre - */ - public static void showConfigUI(final ConfigUI configUI, Frame ui, boolean undecorated) { - JDialog f = new JDialog(ui, true); - f.setTitle(_("config.title")); - f.add(configUI); - if (ui != null) { - f.setIconImage(ui.getIconImage()); - } - // pour savoir si l'ui est autonome - configUI.getModel().setStandalone(ui == null); - - f.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); - f.addWindowListener(new WindowAdapter() { - - @Override - public void windowClosing(WindowEvent e) { - ActionEvent myEvent = new ActionEvent(e.getSource(), 1, "quit"); - configUI.getQuit().getAction().actionPerformed(myEvent); -// if (canQuitCategory(configUI)) { -// e.getWindow().dispose(); -// } - } - }); - f.setUndecorated(undecorated); - JRootPane rootPane = f.getRootPane(); - rootPane.setDefaultButton(configUI.getQuit()); - rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "quit"); - rootPane.getActionMap().put("quit", configUI.getQuit().getAction()); - f.pack(); - SwingUtil.center(ui, f); - f.setVisible(true); - } - - protected static boolean canQuitCategory(ConfigUI ui) { - boolean canContinue = true; - ConfigUIModel model = ui.getModel(); - CategoryModel categoryModel = model.getCategoryModel(); - String categoryName = _(categoryModel.getCategory()); - if (!categoryModel.isValid()) { - - // the category is not valid - // get all the invalid options - - StringBuilder buffer = new StringBuilder(); - buffer.append(_("config.message.quit.invalid.category", categoryName)).append('\n'); - for (OptionModel m : categoryModel.getInvalidOptions()) { - buffer.append("\n- ").append(m.getKey()); - } - buffer.append('\n'); - int reponse = askUser(ui, - _("config.title.need.confirm"), - buffer.toString(), - JOptionPane.ERROR_MESSAGE, - new Object[]{ - _("config.choice.continue"), - _("config.choice.cancel")}, - 0); - - switch (reponse) { - case JOptionPane.CLOSED_OPTION: - case 1: - canContinue = false; - break; - case 0: - if (categoryModel.isModified()) { - // wil reset category - model.reset(); - } - break; - } - } else if (categoryModel.isModified()) { - - // category was modified, ask user if wants to save - - StringBuilder buffer = new StringBuilder(); - buffer.append(_("config.message.quit.valid.and.modified.category", categoryName)).append('\n'); - for (OptionModel m : categoryModel.getModifiedOptions()) { - buffer.append("\n- ").append(m.getKey()); - } - buffer.append('\n'); - - int reponse = askUser(ui, - _("config.title.need.confirm"), buffer.toString(), - JOptionPane.WARNING_MESSAGE, - new Object[]{ - _("config.choice.save"), - _("config.choice.doNotSave"), - _("config.choice.cancel")}, - 0); - - switch (reponse) { - case JOptionPane.CLOSED_OPTION: - case 2: - canContinue = false; - break; - case 0: - // will save ui - model.saveModified(); - break; - case 1: - // wil reset ui - model.reset(); - break; - } - - } - return canContinue; - } - - public static int askUser(ConfigUI parent, String title, String message, int typeMessage, Object[] options, int defaultOption) { - - int response = JOptionPane.showOptionDialog(parent, message, title, JOptionPane.DEFAULT_OPTION, typeMessage, null, options, options[defaultOption]); - return response; - } -} Copied: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java) =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java (rev 0) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,248 @@ +/** + * *##% + * JAXX Widgets + * 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>. + * ##%* + */ +package jaxx.runtime.swing.editor.config; + +import java.awt.Frame; +import java.awt.Window; +import java.awt.event.ActionEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.List; +import javax.swing.AbstractAction; +import javax.swing.Action; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JDialog; +import javax.swing.JOptionPane; +import javax.swing.JRootPane; +import javax.swing.KeyStroke; +import jaxx.runtime.JAXXContext; +import jaxx.runtime.context.JAXXInitialContext; +import jaxx.runtime.SwingUtil; + +import jaxx.runtime.swing.editor.config.model.CategoryModel; +import jaxx.runtime.swing.editor.config.model.ConfigUIModel; +import jaxx.runtime.swing.editor.config.model.OptionModel; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import static org.nuiton.i18n.I18n._; + +/** + * La classe pour construire l'ui + * @author chemit + */ +public class ConfigUIBuilder { + + public static final Log log = LogFactory.getLog(ConfigUIBuilder.class); + + /** + * Construire l'ui de configuration (sous forme de panel) + * + * @param parentContext le context applicatif + * @param model le modele de l'ui de configuration + * @param defaultCategory la categorie a selectionner + * @return l'ui instanciate + */ + public static ConfigUI newConfigUI(jaxx.runtime.JAXXContext parentContext, final ConfigUIModel model, String defaultCategory) { + JAXXContext tx = new JAXXInitialContext().add(parentContext).add(model); + + final ConfigUI ui = new ConfigUI(tx); + JButton quitButton = ui.getQuit(); + + // prepare quit action + Action quitAction = new AbstractAction(quitButton.getText(), quitButton.getIcon()) { + + private static final long serialVersionUID = 1L; + + @Override + public void actionPerformed(ActionEvent e) { + if (!canQuitCategory(ui)) { + return; + } + + if (model.isSaved() && !model.isStandalone()) { + StringBuilder buffer = new StringBuilder(); + // on doit verifier si des options sauvees necessite + // un redemarrage de l'application + for (CategoryModel cat : model) { + List<OptionModel> savedOptions = cat.getSavedOptions(); + if (!savedOptions.isEmpty()) { + buffer.append("\n").append(_("config.category.saved", _(cat.getCategory()))).append("\n"); + for (OptionModel option : savedOptions) { + buffer.append("\n- ").append(option.getKey()); + } + } + + } +// askUser(ui, +// _("config.title.will.reload.application"), buffer.toString(), +// JOptionPane.INFORMATION_MESSAGE, +// new Object[]{ +// _("config.choice.ok")}, +// 0); + } + ui.getParentContainer(Window.class).dispose(); + } + }; + String tip = quitButton.getToolTipText(); + quitButton.setAction(quitAction); + quitButton.setToolTipText(tip); + + // build categories tabs + for (CategoryModel categoryModel : model) { + String category = categoryModel.getCategory(); + String categoryLabel = _(categoryModel.getCategoryLabel()); + ConfigCategoryUI p = new ConfigCategoryUI(new JAXXInitialContext().add(ui).add(categoryModel)); + p.getCategoryLabel().setText(categoryLabel); + p.setName(category); + ui.getCategories().addTab(_(category), null, p, categoryLabel); + } + + model.setCategory(defaultCategory); + int categoryIndex = model.getCategoryIndex(defaultCategory); + if (log.isDebugEnabled()) { + log.debug("index of default category (" + defaultCategory + ") : " + categoryIndex); + } + ui.getCategories().setSelectedIndex(categoryIndex); + return ui; + } + + /** + * Affiche l'ui de configuration dans un boite de dialogue. + * + * @param configUI l'ui de configuration + * @param ui l'ui parent de la boite de dialogue a afficher (peut etre nulle) + * @param undecorated un drapeau pour savoir si on affiche les decorations de fenetre + */ + public static void showConfigUI(final ConfigUI configUI, Frame ui, boolean undecorated) { + JDialog f = new JDialog(ui, true); + f.setTitle(_("config.title")); + f.add(configUI); + if (ui != null) { + f.setIconImage(ui.getIconImage()); + } + // pour savoir si l'ui est autonome + configUI.getModel().setStandalone(ui == null); + + f.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); + f.addWindowListener(new WindowAdapter() { + + @Override + public void windowClosing(WindowEvent e) { + ActionEvent myEvent = new ActionEvent(e.getSource(), 1, "quit"); + configUI.getQuit().getAction().actionPerformed(myEvent); +// if (canQuitCategory(configUI)) { +// e.getWindow().dispose(); +// } + } + }); + f.setUndecorated(undecorated); + JRootPane rootPane = f.getRootPane(); + rootPane.setDefaultButton(configUI.getQuit()); + rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "quit"); + rootPane.getActionMap().put("quit", configUI.getQuit().getAction()); + f.pack(); + SwingUtil.center(ui, f); + f.setVisible(true); + } + + protected static boolean canQuitCategory(ConfigUI ui) { + boolean canContinue = true; + ConfigUIModel model = ui.getModel(); + CategoryModel categoryModel = model.getCategoryModel(); + String categoryName = _(categoryModel.getCategory()); + if (!categoryModel.isValid()) { + + // the category is not valid + // get all the invalid options + + StringBuilder buffer = new StringBuilder(); + buffer.append(_("config.message.quit.invalid.category", categoryName)).append('\n'); + for (OptionModel m : categoryModel.getInvalidOptions()) { + buffer.append("\n- ").append(m.getKey()); + } + buffer.append('\n'); + int reponse = askUser(ui, + _("config.title.need.confirm"), + buffer.toString(), + JOptionPane.ERROR_MESSAGE, + new Object[]{ + _("config.choice.continue"), + _("config.choice.cancel")}, + 0); + + switch (reponse) { + case JOptionPane.CLOSED_OPTION: + case 1: + canContinue = false; + break; + case 0: + if (categoryModel.isModified()) { + // wil reset category + model.reset(); + } + break; + } + } else if (categoryModel.isModified()) { + + // category was modified, ask user if wants to save + + StringBuilder buffer = new StringBuilder(); + buffer.append(_("config.message.quit.valid.and.modified.category", categoryName)).append('\n'); + for (OptionModel m : categoryModel.getModifiedOptions()) { + buffer.append("\n- ").append(m.getKey()); + } + buffer.append('\n'); + + int reponse = askUser(ui, + _("config.title.need.confirm"), buffer.toString(), + JOptionPane.WARNING_MESSAGE, + new Object[]{ + _("config.choice.save"), + _("config.choice.doNotSave"), + _("config.choice.cancel")}, + 0); + + switch (reponse) { + case JOptionPane.CLOSED_OPTION: + case 2: + canContinue = false; + break; + case 0: + // will save ui + model.saveModified(); + break; + case 1: + // wil reset ui + model.reset(); + break; + } + + } + return canContinue; + } + + public static int askUser(ConfigUI parent, String title, String message, int typeMessage, Object[] options, int defaultOption) { + + int response = JOptionPane.showOptionDialog(parent, message, title, JOptionPane.DEFAULT_OPTION, typeMessage, null, options, options[defaultOption]); + return response; + } +} Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,177 +0,0 @@ -/** - * *##% - * JAXX Widgets - * 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>. - * ##%* - */ -package jaxx.runtime.swing.editor.config.model; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -/** - * le modele d'une categorie d'options. - * - * Une categorie est un ensemble d'options. - * - * @author tchemit - */ -public class CategoryModel implements Iterable<OptionModel> { - - public static final String RELOAD_PROPERTY_NAME = "reload"; - public static final String MODIFIED_PROPERTY_NAME = "modified"; - public static final String VALID_PROPERTY_NAME = "valid"; - /** category short name (i18n key) */ - protected String category; - /** category long name (i18n key) */ - protected String categoryLabel; - /** options of the category */ - protected List<OptionModel> entries; - /** suport of modification */ - protected PropertyChangeSupport pcs = new PropertyChangeSupport(this); - - public CategoryModel(String category, String categoryLabel, OptionModel[] entries) { - super(); - this.category = category; - this.categoryLabel = categoryLabel; - this.entries = Collections.unmodifiableList(Arrays.asList(entries)); - } - - public String getCategory() { - return category; - } - - public String getCategoryLabel() { - return categoryLabel; - } - - public List<OptionModel> getEntries() { - return entries; - } - - public boolean isModified() { - boolean modified = false; - for (OptionModel m : this) { - if (m.isModified()) { - modified = true; - break; - } - } - return modified; - } - - public boolean isValid() { - boolean valid = true; - for (OptionModel m : this) { - if (!m.isValid()) { - valid = false; - break; - } - } - return valid; - } - - public void setValue(OptionModel key, Object val) { - boolean wasModified = isModified(); - boolean wasValid = isValid(); - key.setValue(val); - boolean modified = isModified(); - boolean valid = isValid(); - if (wasModified != modified) { - // change modified state - firePropertyChange(MODIFIED_PROPERTY_NAME, wasModified, modified); - } - if (wasValid != valid) { - // change valid state - firePropertyChange(VALID_PROPERTY_NAME, wasValid, valid); - } - } - - @Override - public Iterator<OptionModel> iterator() { - return entries.iterator(); - } - - public List<OptionModel> getInvalidOptions() { - - List<OptionModel> result = new ArrayList<OptionModel>(); - for (OptionModel m : this) { - if (!m.isValid()) { - result.add(m); - } - } - return result; - } - - public List<OptionModel> getModifiedOptions() { - - List<OptionModel> result = new ArrayList<OptionModel>(); - for (OptionModel m : this) { - if (m.isModified()) { - result.add(m); - } - } - return result; - } - - public List<OptionModel> getSavedOptions() { - List<OptionModel> result = new ArrayList<OptionModel>(); - for (OptionModel option : this) { - if (option.isSaved()) { - result.add(option); - } - } - return result; - } - - public void firePropertyChange(String propertyName, Object oldValue, Object newValue) { - pcs.firePropertyChange(propertyName, oldValue, newValue); - } - - 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 synchronized boolean hasListeners(String propertyName) { - return pcs.hasListeners(propertyName); - } - - public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) { - return pcs.getPropertyChangeListeners(propertyName); - } - - public synchronized PropertyChangeListener[] getPropertyChangeListeners() { - return pcs.getPropertyChangeListeners(); - } -} Copied: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java) =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java (rev 0) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,177 @@ +/** + * *##% + * JAXX Widgets + * 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>. + * ##%* + */ +package jaxx.runtime.swing.editor.config.model; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +/** + * le modele d'une categorie d'options. + * + * Une categorie est un ensemble d'options. + * + * @author tchemit + */ +public class CategoryModel implements Iterable<OptionModel> { + + public static final String RELOAD_PROPERTY_NAME = "reload"; + public static final String MODIFIED_PROPERTY_NAME = "modified"; + public static final String VALID_PROPERTY_NAME = "valid"; + /** category short name (i18n key) */ + protected String category; + /** category long name (i18n key) */ + protected String categoryLabel; + /** options of the category */ + protected List<OptionModel> entries; + /** suport of modification */ + protected PropertyChangeSupport pcs = new PropertyChangeSupport(this); + + public CategoryModel(String category, String categoryLabel, OptionModel[] entries) { + super(); + this.category = category; + this.categoryLabel = categoryLabel; + this.entries = Collections.unmodifiableList(Arrays.asList(entries)); + } + + public String getCategory() { + return category; + } + + public String getCategoryLabel() { + return categoryLabel; + } + + public List<OptionModel> getEntries() { + return entries; + } + + public boolean isModified() { + boolean modified = false; + for (OptionModel m : this) { + if (m.isModified()) { + modified = true; + break; + } + } + return modified; + } + + public boolean isValid() { + boolean valid = true; + for (OptionModel m : this) { + if (!m.isValid()) { + valid = false; + break; + } + } + return valid; + } + + public void setValue(OptionModel key, Object val) { + boolean wasModified = isModified(); + boolean wasValid = isValid(); + key.setValue(val); + boolean modified = isModified(); + boolean valid = isValid(); + if (wasModified != modified) { + // change modified state + firePropertyChange(MODIFIED_PROPERTY_NAME, wasModified, modified); + } + if (wasValid != valid) { + // change valid state + firePropertyChange(VALID_PROPERTY_NAME, wasValid, valid); + } + } + + @Override + public Iterator<OptionModel> iterator() { + return entries.iterator(); + } + + public List<OptionModel> getInvalidOptions() { + + List<OptionModel> result = new ArrayList<OptionModel>(); + for (OptionModel m : this) { + if (!m.isValid()) { + result.add(m); + } + } + return result; + } + + public List<OptionModel> getModifiedOptions() { + + List<OptionModel> result = new ArrayList<OptionModel>(); + for (OptionModel m : this) { + if (m.isModified()) { + result.add(m); + } + } + return result; + } + + public List<OptionModel> getSavedOptions() { + List<OptionModel> result = new ArrayList<OptionModel>(); + for (OptionModel option : this) { + if (option.isSaved()) { + result.add(option); + } + } + return result; + } + + public void firePropertyChange(String propertyName, Object oldValue, Object newValue) { + pcs.firePropertyChange(propertyName, oldValue, newValue); + } + + 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 synchronized boolean hasListeners(String propertyName) { + return pcs.hasListeners(propertyName); + } + + public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) { + return pcs.getPropertyChangeListeners(propertyName); + } + + public synchronized PropertyChangeListener[] getPropertyChangeListeners() { + return pcs.getPropertyChangeListeners(); + } +} Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigTableModel.java =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigTableModel.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigTableModel.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,136 +0,0 @@ -/** - * *##% - * JAXX Widgets - * 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>. - * ##%* - */ -package jaxx.runtime.swing.editor.config.model; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import javax.swing.table.AbstractTableModel; -import org.nuiton.util.ConverterUtil; - -/** - * le modele du tableau d'options pour une categorie donnee. - * - * Le modele se base sur le modele d'une categorie d'option. - * - * @author tchemit - * - * @see CategoryModel - */ -public class ConfigTableModel extends AbstractTableModel { - - private static final long serialVersionUID = 1L; - private static final Class<?>[] columnClass = {String.class, Object.class, String.class}; - /** le modele d'une categorie */ - protected final CategoryModel categoryModel; - - public ConfigTableModel(CategoryModel categoryModel) { - this.categoryModel = categoryModel; - // listen of property reload of the category model - // to known when to refresh table - this.categoryModel.addPropertyChangeListener(CategoryModel.RELOAD_PROPERTY_NAME, new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - fireTableDataChanged(); - } - }); - } - - public CategoryModel getCategoryModel() { - return categoryModel; - } - - public OptionModel getEntry(int rowIndex) { - return categoryModel.getEntries().get(rowIndex); - } - - @Override - public int getRowCount() { - return categoryModel.getEntries().size(); - } - - @Override - public int getColumnCount() { - return columnClass.length; - } - - @Override - public Class<?> getColumnClass(int columnIndex) { - return columnClass[columnIndex]; - } - - @Override - public boolean isCellEditable(int rowIndex, int columnIndex) { - return columnIndex == 1 && !getEntry(rowIndex).isFinal(); - } - - @Override - public Object getValueAt(int row, int column) { - OptionModel key = getEntry(row); - Object value = null; - switch (column) { - case 0: - value = key.getKey(); - break; - case 1: - value = key.getValue(); - break; - case 2: - value = key.getDefaultValue(); - if (value != null) { - value = ConverterUtil.convert(key.getType(), value); - } - break; - } - return value; -// if (column == 0) { -// return key.getKey(); -// } -// return key.getValue(); - } - - @Override - public void setValueAt(Object aValue, int row, int column) { - if (column != 1) { - // seul la colonne 1 est editable (valeur de l'option) - throw new IllegalArgumentException("can not edit column " + column); - } - OptionModel key = getEntry(row); - Object val; - if (aValue == null || key.getType() == aValue.getClass()) { - val = aValue; - } else { - String valStr = String.valueOf(aValue).trim(); - try { - val = ConverterUtil.convert(key.getType(), valStr); - if (val != null && val instanceof Integer) { - if (new Integer(0).equals(val) && !valStr.equals("0")) { - val = null; - } - } - } catch (Exception e) { - val = null; - } - } - categoryModel.setValue(key, val); - fireTableRowsUpdated(row, row); - } -} Copied: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigTableModel.java (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigTableModel.java) =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigTableModel.java (rev 0) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigTableModel.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,136 @@ +/** + * *##% + * JAXX Widgets + * 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>. + * ##%* + */ +package jaxx.runtime.swing.editor.config.model; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import javax.swing.table.AbstractTableModel; +import org.nuiton.util.ConverterUtil; + +/** + * le modele du tableau d'options pour une categorie donnee. + * + * Le modele se base sur le modele d'une categorie d'option. + * + * @author tchemit + * + * @see CategoryModel + */ +public class ConfigTableModel extends AbstractTableModel { + + private static final long serialVersionUID = 1L; + private static final Class<?>[] columnClass = {String.class, Object.class, String.class}; + /** le modele d'une categorie */ + protected final CategoryModel categoryModel; + + public ConfigTableModel(CategoryModel categoryModel) { + this.categoryModel = categoryModel; + // listen of property reload of the category model + // to known when to refresh table + this.categoryModel.addPropertyChangeListener(CategoryModel.RELOAD_PROPERTY_NAME, new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent evt) { + fireTableDataChanged(); + } + }); + } + + public CategoryModel getCategoryModel() { + return categoryModel; + } + + public OptionModel getEntry(int rowIndex) { + return categoryModel.getEntries().get(rowIndex); + } + + @Override + public int getRowCount() { + return categoryModel.getEntries().size(); + } + + @Override + public int getColumnCount() { + return columnClass.length; + } + + @Override + public Class<?> getColumnClass(int columnIndex) { + return columnClass[columnIndex]; + } + + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + return columnIndex == 1 && !getEntry(rowIndex).isFinal(); + } + + @Override + public Object getValueAt(int row, int column) { + OptionModel key = getEntry(row); + Object value = null; + switch (column) { + case 0: + value = key.getKey(); + break; + case 1: + value = key.getValue(); + break; + case 2: + value = key.getDefaultValue(); + if (value != null) { + value = ConverterUtil.convert(key.getType(), value); + } + break; + } + return value; +// if (column == 0) { +// return key.getKey(); +// } +// return key.getValue(); + } + + @Override + public void setValueAt(Object aValue, int row, int column) { + if (column != 1) { + // seul la colonne 1 est editable (valeur de l'option) + throw new IllegalArgumentException("can not edit column " + column); + } + OptionModel key = getEntry(row); + Object val; + if (aValue == null || key.getType() == aValue.getClass()) { + val = aValue; + } else { + String valStr = String.valueOf(aValue).trim(); + try { + val = ConverterUtil.convert(key.getType(), valStr); + if (val != null && val instanceof Integer) { + if (new Integer(0).equals(val) && !valStr.equals("0")) { + val = null; + } + } + } catch (Exception e) { + val = null; + } + } + categoryModel.setValue(key, val); + fireTableRowsUpdated(row, row); + } +} Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,226 +0,0 @@ -/** - * *##% - * JAXX Widgets - * 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>. - * ##%* - */ -package jaxx.runtime.swing.editor.config.model; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import org.nuiton.util.ApplicationConfig; -import org.nuiton.util.ApplicationConfig.OptionDef; -import static org.nuiton.i18n.I18n._; - -/** - * Le modele de l'ui des preferences. - * - * Ce modele contient les catégories des options. - * - * @author chemit - */ -public class ConfigUIModel implements Iterable<CategoryModel> { - - public static final String CATEGORY_MODEL_PROPERTY_NAME = "categoryModel"; - /** le dictionnaire des options disponibles par categorie */ - protected final Map<String, CategoryModel> categories; - /** La configuration de l'application */ - protected final ApplicationConfig config; - /** la cateogrie en cours d'utilisation */ - protected CategoryModel categoryModel; - /** - * un drapeau pour savoir si la configuration a été modifiée au moins une - * fois. - * - * On utilise ce drapeau lors de la sortie pour verifier s'il faut ou non - * redemarer l'application (si non en mode standalone) - */ - protected boolean saved; - /** - * un drapeau pour savoir si l'ui de configuration a été lancée en mode - * standalone ou pas. - * - * Si pas lancée en mode standalone, et si la confi a été sauvé on vérifie - * s'il ne faut pas relancer l'application. - */ - protected boolean standalone; - /** suport of modification */ - protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this); - - public ConfigUIModel(ApplicationConfig config) { - this.config = config; - this.categories = new LinkedHashMap<String, CategoryModel>(); - } - - /** - * Ajoute une categorie dans le modele. - * - * @param category l'id de la categorie (la clef de traduction du nom de la categorie) - * @param categoryLabel la clef de traduction de la description de la categorie - * @param keys les options de la categorie - */ - public void addCategory(String category, String categoryLabel, OptionDef... keys) { - if (categories.containsKey(category)) { - throw new IllegalArgumentException(_("config.error.category.already.exists", category)); - } - OptionModel[] entries = new OptionModel[keys.length]; - int index = 0; - for (OptionDef d : keys) { - Object value = config.getOption(d); - OptionModel e = new OptionModel(d, value); - entries[index++] = e; - } - CategoryModel m = new CategoryModel(category, categoryLabel, entries); - categories.put(category, m); - } - - /** - * Change la categorie en cours d'édition. - * - * @param category l'id de la categorie courante - */ - public void setCategory(String category) { - if (!categories.containsKey(category)) { - throw new IllegalArgumentException(_("config.error.category.not.found", category)); - } - CategoryModel newCategoryModel = categories.get(category); - setCategoryModel(newCategoryModel); - newCategoryModel.firePropertyChange(CategoryModel.MODIFIED_PROPERTY_NAME, false, getCategoryModel().isModified()); - newCategoryModel.firePropertyChange(CategoryModel.VALID_PROPERTY_NAME, false, getCategoryModel().isValid()); - } - - @Override - public Iterator<CategoryModel> iterator() { - return categories.values().iterator(); - } - - public CategoryModel getCategoryModel() { - return categoryModel; - } - - public void setCategoryModel(CategoryModel categoryModel) { - CategoryModel old = this.categoryModel; - this.categoryModel = categoryModel; - firePropertyChange(CATEGORY_MODEL_PROPERTY_NAME, old, categoryModel); - } - - public boolean isSaved() { - return saved; - } - - public void setSaved(boolean saved) { - this.saved = saved; - } - - public boolean isStandalone() { - return standalone; - } - - public void setStandalone(boolean standalone) { - this.standalone = standalone; - } - - public void saveModified() { - // compute transients keys (to never be saved) - List<String> transients = new ArrayList<String>(); - - for (OptionModel option : categoryModel) { - if (option.isModified()) { - Object value = option.getValue(); - //TODO TC-20090245 : should try to seek for a mutator, since - // mutator could have extra code to be done when modify an option - config.setOption(option.getKey(), value == null ? null : value.toString()); - // l'option a été sauvegardée, on la marque - option.setSaved(true); - // this is the new original value - option.initValue(value); - } - if (option.isTransient()) { - transients.add(option.getKey()); - } - } - setSaved(true); - // save config - config.saveForUser(transients.toArray(new String[transients.size()])); - // notify data has changed - categoryModel.firePropertyChange(CategoryModel.MODIFIED_PROPERTY_NAME, categoryModel.isModified(), true); - categoryModel.firePropertyChange(CategoryModel.VALID_PROPERTY_NAME, false, categoryModel.isValid()); - categoryModel.firePropertyChange(CategoryModel.RELOAD_PROPERTY_NAME, false, true); - } - - public void reset() { - // reset all modified options of the current category - for (OptionModel key : categoryModel) { - if (key.isModified()) { - key.initValue(key.getOriginalValue()); - } - } - // notify data has changed - categoryModel.firePropertyChange(CategoryModel.MODIFIED_PROPERTY_NAME, categoryModel.isModified(), true); - categoryModel.firePropertyChange(CategoryModel.VALID_PROPERTY_NAME, false, categoryModel.isValid()); - categoryModel.firePropertyChange(CategoryModel.RELOAD_PROPERTY_NAME, false, true); - } - - public int getCategoryIndex(String category) { - int i = 0; - for (CategoryModel m : this) { - if (category.equals(m.getCategory())) { - return i; - } - i++; - } - // not found - return -1; - } - - public void firePropertyChange(String propertyName, Object oldValue, Object newValue) { - pcs.firePropertyChange(propertyName, oldValue, newValue); - } - - 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 synchronized boolean hasListeners(String propertyName) { - return pcs.hasListeners(propertyName); - } - - public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) { - return pcs.getPropertyChangeListeners(propertyName); - } - - public synchronized PropertyChangeListener[] getPropertyChangeListeners() { - return pcs.getPropertyChangeListeners(); - } -} Copied: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java) =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java (rev 0) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,226 @@ +/** + * *##% + * JAXX Widgets + * 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>. + * ##%* + */ +package jaxx.runtime.swing.editor.config.model; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import org.nuiton.util.ApplicationConfig; +import org.nuiton.util.ApplicationConfig.OptionDef; +import static org.nuiton.i18n.I18n._; + +/** + * Le modele de l'ui des preferences. + * + * Ce modele contient les catégories des options. + * + * @author chemit + */ +public class ConfigUIModel implements Iterable<CategoryModel> { + + public static final String CATEGORY_MODEL_PROPERTY_NAME = "categoryModel"; + /** le dictionnaire des options disponibles par categorie */ + protected final Map<String, CategoryModel> categories; + /** La configuration de l'application */ + protected final ApplicationConfig config; + /** la cateogrie en cours d'utilisation */ + protected CategoryModel categoryModel; + /** + * un drapeau pour savoir si la configuration a été modifiée au moins une + * fois. + * + * On utilise ce drapeau lors de la sortie pour verifier s'il faut ou non + * redemarer l'application (si non en mode standalone) + */ + protected boolean saved; + /** + * un drapeau pour savoir si l'ui de configuration a été lancée en mode + * standalone ou pas. + * + * Si pas lancée en mode standalone, et si la confi a été sauvé on vérifie + * s'il ne faut pas relancer l'application. + */ + protected boolean standalone; + /** suport of modification */ + protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this); + + public ConfigUIModel(ApplicationConfig config) { + this.config = config; + this.categories = new LinkedHashMap<String, CategoryModel>(); + } + + /** + * Ajoute une categorie dans le modele. + * + * @param category l'id de la categorie (la clef de traduction du nom de la categorie) + * @param categoryLabel la clef de traduction de la description de la categorie + * @param keys les options de la categorie + */ + public void addCategory(String category, String categoryLabel, OptionDef... keys) { + if (categories.containsKey(category)) { + throw new IllegalArgumentException(_("config.error.category.already.exists", category)); + } + OptionModel[] entries = new OptionModel[keys.length]; + int index = 0; + for (OptionDef d : keys) { + Object value = config.getOption(d); + OptionModel e = new OptionModel(d, value); + entries[index++] = e; + } + CategoryModel m = new CategoryModel(category, categoryLabel, entries); + categories.put(category, m); + } + + /** + * Change la categorie en cours d'édition. + * + * @param category l'id de la categorie courante + */ + public void setCategory(String category) { + if (!categories.containsKey(category)) { + throw new IllegalArgumentException(_("config.error.category.not.found", category)); + } + CategoryModel newCategoryModel = categories.get(category); + setCategoryModel(newCategoryModel); + newCategoryModel.firePropertyChange(CategoryModel.MODIFIED_PROPERTY_NAME, false, getCategoryModel().isModified()); + newCategoryModel.firePropertyChange(CategoryModel.VALID_PROPERTY_NAME, false, getCategoryModel().isValid()); + } + + @Override + public Iterator<CategoryModel> iterator() { + return categories.values().iterator(); + } + + public CategoryModel getCategoryModel() { + return categoryModel; + } + + public void setCategoryModel(CategoryModel categoryModel) { + CategoryModel old = this.categoryModel; + this.categoryModel = categoryModel; + firePropertyChange(CATEGORY_MODEL_PROPERTY_NAME, old, categoryModel); + } + + public boolean isSaved() { + return saved; + } + + public void setSaved(boolean saved) { + this.saved = saved; + } + + public boolean isStandalone() { + return standalone; + } + + public void setStandalone(boolean standalone) { + this.standalone = standalone; + } + + public void saveModified() { + // compute transients keys (to never be saved) + List<String> transients = new ArrayList<String>(); + + for (OptionModel option : categoryModel) { + if (option.isModified()) { + Object value = option.getValue(); + //TODO TC-20090245 : should try to seek for a mutator, since + // mutator could have extra code to be done when modify an option + config.setOption(option.getKey(), value == null ? null : value.toString()); + // l'option a été sauvegardée, on la marque + option.setSaved(true); + // this is the new original value + option.initValue(value); + } + if (option.isTransient()) { + transients.add(option.getKey()); + } + } + setSaved(true); + // save config + config.saveForUser(transients.toArray(new String[transients.size()])); + // notify data has changed + categoryModel.firePropertyChange(CategoryModel.MODIFIED_PROPERTY_NAME, categoryModel.isModified(), true); + categoryModel.firePropertyChange(CategoryModel.VALID_PROPERTY_NAME, false, categoryModel.isValid()); + categoryModel.firePropertyChange(CategoryModel.RELOAD_PROPERTY_NAME, false, true); + } + + public void reset() { + // reset all modified options of the current category + for (OptionModel key : categoryModel) { + if (key.isModified()) { + key.initValue(key.getOriginalValue()); + } + } + // notify data has changed + categoryModel.firePropertyChange(CategoryModel.MODIFIED_PROPERTY_NAME, categoryModel.isModified(), true); + categoryModel.firePropertyChange(CategoryModel.VALID_PROPERTY_NAME, false, categoryModel.isValid()); + categoryModel.firePropertyChange(CategoryModel.RELOAD_PROPERTY_NAME, false, true); + } + + public int getCategoryIndex(String category) { + int i = 0; + for (CategoryModel m : this) { + if (category.equals(m.getCategory())) { + return i; + } + i++; + } + // not found + return -1; + } + + public void firePropertyChange(String propertyName, Object oldValue, Object newValue) { + pcs.firePropertyChange(propertyName, oldValue, newValue); + } + + 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 synchronized boolean hasListeners(String propertyName) { + return pcs.hasListeners(propertyName); + } + + public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) { + return pcs.getPropertyChangeListeners(propertyName); + } + + public synchronized PropertyChangeListener[] getPropertyChangeListeners() { + return pcs.getPropertyChangeListeners(); + } +} Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,114 +0,0 @@ -/** - * *##% - * JAXX Widgets - * 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>. - * ##%* - */ -package jaxx.runtime.swing.editor.config.model; - -import org.nuiton.util.ApplicationConfig.OptionDef; - -/** - * le modele d'une option de la configuration a editer. - * - * @author tchemit - */ -public class OptionModel implements OptionDef { - - /** la definition de l'option ( venant de la config) */ - protected final OptionDef def; - /** un drapeau pour savoir si l'option est valide (n'est pas utilisé actuellement) */ - protected boolean valid = true; - /** un drapeau pour savoir si l'option a été sauvée */ - protected boolean saved = false; - /** la valeur non modifié de l'option */ - protected Object originalValue; - /** la valeur actuelle de l'option (peut être la valeur orignal si non modifée)*/ - protected Object value; - - protected OptionModel(OptionDef def, Object value) { - this.def = def; - initValue(value); - } - - @Override - public String getKey() { - return def.getKey(); - } - - @Override - public Class<?> getType() { - return def.getType(); - } - - @Override - public String getDescription() { - return def.getDescription(); - } - - @Override - public String getDefaultValue() { - return def.getDefaultValue(); - } - - @Override - public boolean isTransient() { - return def.isTransient(); - } - - @Override - public boolean isFinal() { - return def.isFinal(); - } - - public Object getOriginalValue() { - return originalValue; - } - - public Object getValue() { - return value; - } - - public void setValue(Object value) { - this.value = value; - } - - public boolean isModified() { - return !originalValue.equals(value); - } - - public boolean isValid() { - return valid; - } - - public void setValid(boolean valid) { - this.valid = valid; - } - - public boolean isSaved() { - return saved; - } - - public void setSaved(boolean saved) { - this.saved = saved; - } - - public void initValue(Object originalValue) { - this.originalValue = originalValue; - this.value = originalValue; - } -} Copied: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java) =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java (rev 0) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,114 @@ +/** + * *##% + * JAXX Widgets + * 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>. + * ##%* + */ +package jaxx.runtime.swing.editor.config.model; + +import org.nuiton.util.ApplicationConfig.OptionDef; + +/** + * le modele d'une option de la configuration a editer. + * + * @author tchemit + */ +public class OptionModel implements OptionDef { + + /** la definition de l'option ( venant de la config) */ + protected final OptionDef def; + /** un drapeau pour savoir si l'option est valide (n'est pas utilisé actuellement) */ + protected boolean valid = true; + /** un drapeau pour savoir si l'option a été sauvée */ + protected boolean saved = false; + /** la valeur non modifié de l'option */ + protected Object originalValue; + /** la valeur actuelle de l'option (peut être la valeur orignal si non modifée)*/ + protected Object value; + + protected OptionModel(OptionDef def, Object value) { + this.def = def; + initValue(value); + } + + @Override + public String getKey() { + return def.getKey(); + } + + @Override + public Class<?> getType() { + return def.getType(); + } + + @Override + public String getDescription() { + return def.getDescription(); + } + + @Override + public String getDefaultValue() { + return def.getDefaultValue(); + } + + @Override + public boolean isTransient() { + return def.isTransient(); + } + + @Override + public boolean isFinal() { + return def.isFinal(); + } + + public Object getOriginalValue() { + return originalValue; + } + + public Object getValue() { + return value; + } + + public void setValue(Object value) { + this.value = value; + } + + public boolean isModified() { + return !originalValue.equals(value); + } + + public boolean isValid() { + return valid; + } + + public void setValid(boolean valid) { + this.valid = valid; + } + + public boolean isSaved() { + return saved; + } + + public void setSaved(boolean saved) { + this.saved = saved; + } + + public void initValue(Object originalValue) { + this.originalValue = originalValue; + this.value = originalValue; + } +} Deleted: trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,74 +0,0 @@ -aboutframe.about=About -aboutframe.license=License -aboutframe.ok=OK -aboutframe.thirdparty=Third party -columnselector.action.tip=Select the columns -config.action.quit=Quit -config.action.quit.tip=Quit the configuration editor -config.action.reset=Cancel -config.action.reset.tip=Cancel the modifications for the category -config.action.save=Save -config.action.save.tip=Save the modifications for the category -config.category.saved=The category '%1$s' was modified \: -config.choice.cancel=Cancel -config.choice.continue=Continue -config.choice.doNotSave=Do not save -config.choice.ok=Ok -config.choice.save=Save -config.defaultValue=Default value -config.defaultValue.tip=Default value of the option -config.descrition=Description -config.error.category.already.exists=category with name '%1$s' does already exist\! -config.error.category.not.found=category with name '%1$s' does not exist\! -config.key=Key -config.key.tip=Key of the option -config.message.quit.invalid.category=The category '%1$s' is not valid\! -config.message.quit.valid.and.modified.category=The category '%1$s' has some modified options \: -config.modified=Option was modified (previous value \: %1$s) -config.no.option.selected=< No selected option > -config.option.final=This option can not be modified -config.option.label=Option '%1$s' (%2$s) -config.option.modified=Value is modified < original value \: '%1$s' - new value \: '%2$s' > -config.title=Preferences -config.title.need.confirm=A confirmation is required -config.title.will.reload.application=The application need to be restarted -config.unmodifiable=Can not be modified -config.unvalid=Option is not valid \! (previous value \: %1$s, required type \: %2$s) -config.value=Value -config.value.tip=Value of the option -entitycombobox.action.reset.tip=Reset the selected value -entitycombobox.action.sort.tip=Change the sorted property -entitycombobox.popup.label=Object '%1$s' -entitycombobox.popup.title=Change the sorted property -entitycombobox.sort.off=Click to activate the sort on this property -entitycombobox.sort.on=This is the property actually used -entitycombobox.unknown.type=Object of unkown type -errorUI.action.close=Close -errorUI.message=An error wad detected... -errorUI.title=Error... -hidor.collapseTip=Hide -hidor.expandTip=Show -i18neditor.empty.locales=< No locale to select > -i18neditor.popup.title=Change language -i18neditor.selected=Selected language \: %1$s -i18neditor.unselected=Select this langage \: %1$s -listSelector.hideList=Hide the list -listSelector.showList=Show the list -memorywidget.memory=%d/%dMb -numbereditor..=. -numbereditor.0=0 -numbereditor.1=1 -numbereditor.2=2 -numbereditor.3=3 -numbereditor.4=4 -numbereditor.5=5 -numbereditor.6=6 -numbereditor.7=7 -numbereditor.8=8 -numbereditor.9=9 -numbereditor.action.reset.tip=Reset -numbereditor.action.show.tip=Show numeric panel -numbereditor.clearAll=C -numbereditor.clearOne=CE -numbereditor.toggleSign=+/- -timeeditor.H=H Copied: trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties) =================================================================== --- trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties (rev 0) +++ trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,74 @@ +aboutframe.about=About +aboutframe.license=License +aboutframe.ok=OK +aboutframe.thirdparty=Third party +columnselector.action.tip=Select the columns +config.action.quit=Quit +config.action.quit.tip=Quit the configuration editor +config.action.reset=Cancel +config.action.reset.tip=Cancel the modifications for the category +config.action.save=Save +config.action.save.tip=Save the modifications for the category +config.category.saved=The category '%1$s' was modified \: +config.choice.cancel=Cancel +config.choice.continue=Continue +config.choice.doNotSave=Do not save +config.choice.ok=Ok +config.choice.save=Save +config.defaultValue=Default value +config.defaultValue.tip=Default value of the option +config.descrition=Description +config.error.category.already.exists=category with name '%1$s' does already exist\! +config.error.category.not.found=category with name '%1$s' does not exist\! +config.key=Key +config.key.tip=Key of the option +config.message.quit.invalid.category=The category '%1$s' is not valid\! +config.message.quit.valid.and.modified.category=The category '%1$s' has some modified options \: +config.modified=Option was modified (previous value \: %1$s) +config.no.option.selected=< No selected option > +config.option.final=This option can not be modified +config.option.label=Option '%1$s' (%2$s) +config.option.modified=Value is modified < original value \: '%1$s' - new value \: '%2$s' > +config.title=Preferences +config.title.need.confirm=A confirmation is required +config.title.will.reload.application=The application need to be restarted +config.unmodifiable=Can not be modified +config.unvalid=Option is not valid \! (previous value \: %1$s, required type \: %2$s) +config.value=Value +config.value.tip=Value of the option +entitycombobox.action.reset.tip=Reset the selected value +entitycombobox.action.sort.tip=Change the sorted property +entitycombobox.popup.label=Object '%1$s' +entitycombobox.popup.title=Change the sorted property +entitycombobox.sort.off=Click to activate the sort on this property +entitycombobox.sort.on=This is the property actually used +entitycombobox.unknown.type=Object of unkown type +errorUI.action.close=Close +errorUI.message=An error wad detected... +errorUI.title=Error... +hidor.collapseTip=Hide +hidor.expandTip=Show +i18neditor.empty.locales=< No locale to select > +i18neditor.popup.title=Change language +i18neditor.selected=Selected language \: %1$s +i18neditor.unselected=Select this langage \: %1$s +listSelector.hideList=Hide the list +listSelector.showList=Show the list +memorywidget.memory=%d/%dMb +numbereditor..=. +numbereditor.0=0 +numbereditor.1=1 +numbereditor.2=2 +numbereditor.3=3 +numbereditor.4=4 +numbereditor.5=5 +numbereditor.6=6 +numbereditor.7=7 +numbereditor.8=8 +numbereditor.9=9 +numbereditor.action.reset.tip=Reset +numbereditor.action.show.tip=Show numeric panel +numbereditor.clearAll=C +numbereditor.clearOne=CE +numbereditor.toggleSign=+/- +timeeditor.H=H Deleted: trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,74 +0,0 @@ -aboutframe.about=\u00C0 propos -aboutframe.license=Licence -aboutframe.ok=OK -aboutframe.thirdparty=Tierce partie -columnselector.action.tip=S\u00E9lectionner les colonnes -config.action.quit=Quitter -config.action.quit.tip=Quitter l'\u00E9diteur de configuration -config.action.reset=Annuler -config.action.reset.tip=Annuler les modifications de cette cat\u00E9gorie -config.action.save=Enregistrer -config.action.save.tip=Sauver les modifications de cette cat\u00E9gorie -config.category.saved=La cat\u00E9gorie '%1$s' a \u00E9t\u00E9 modifi\u00E9e \: -config.choice.cancel=Annuler -config.choice.continue=Continuer -config.choice.doNotSave=Ne pas enregistrer -config.choice.ok=Ok -config.choice.save=Enregistrer -config.defaultValue=Valeur par d\u00E9faut -config.defaultValue.tip=Valeur par d\u00E9faut de l'option -config.descrition=Description -config.error.category.already.exists=La cat\u00E9gorie de nom '%1$s' existe d\u00E9j\u00E0\! -config.error.category.not.found=La cat\u00E9gorie de nom '%1$s' n'existe pas\! -config.key=Clef -config.key.tip=Clef de l'option -config.message.quit.invalid.category=La cat\u00E9gorie '%1$s' n'est pas valide\! -config.message.quit.valid.and.modified.category=La cat\u00E9gorie '%1$s' poss\u00E8dent des options modifi\u00E9es \: -config.modified=Option modifi\u00E9e (valeur originale \: %1$s) -config.no.option.selected=< Pas d'option s\u00E9lectionn\u00E9e > -config.option.final=Option non modifiable -config.option.label=Option '%1$s' (%2$s) -config.option.modified=Valeur modifi\u00E9e < ancienne valeur \: '%1$s' - nouvelle valeur \: '%2$s' > -config.title=Pr\u00E9f\u00E9rences -config.title.need.confirm=Une confirmation de votre part est requise... -config.title.will.reload.application=L'application doit \u00EAtre red\u00E9marrer... -config.unmodifiable=Ne peut pas \u00EAtre modifi\u00E9 -config.unvalid=Option non valide (valeur originale \: %1$s, type requis \: %2$s) -config.value=Valeur -config.value.tip=Valeur de l'option -entitycombobox.action.reset.tip=R\u00E9initialiser la valeur de la liste d\u00E9roulante -entitycombobox.action.sort.tip=Modifier le tri de la liste d\u00E9roulante -entitycombobox.popup.label=Objet '%1$s' -entitycombobox.popup.title=Modifier le tri -entitycombobox.sort.off=Cliquer pour activer le tri sur la propri\u00E9t\u00E9 '%1$s' -entitycombobox.sort.on=Le tri est effectu\u00E9 sur la propri\u00E9t\u00E9 '%1$s' -entitycombobox.unknown.type=Objet de type inconnu -errorUI.action.close=Fermer -errorUI.message=Une erreur est survenue \! -errorUI.title=Erreur... -hidor.collapseTip=Cacher -hidor.expandTip=Voir -i18neditor.empty.locales=< Aucune locale \u00E0 s\u00E9lectionner > -i18neditor.popup.title=Changer de langue -i18neditor.selected=Langue actuellement utilis\u00E9e \: %1$s -i18neditor.unselected=Pour utiliser cette langue \: %1$s -listSelector.hideList=Cacher la liste -listSelector.showList=Afficher la liste -memorywidget.memory=%d/%dMo -numbereditor..=. -numbereditor.0=0 -numbereditor.1=1 -numbereditor.2=2 -numbereditor.3=3 -numbereditor.4=4 -numbereditor.5=5 -numbereditor.6=6 -numbereditor.7=7 -numbereditor.8=8 -numbereditor.9=9 -numbereditor.action.reset.tip=R\u00E9initialiser -numbereditor.action.show.tip=Afficher le pav\u00E9 num\u00E9rique -numbereditor.clearAll=C -numbereditor.clearOne=CE -numbereditor.toggleSign=+/- -timeeditor.H=H Copied: trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties) =================================================================== --- trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties (rev 0) +++ trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,74 @@ +aboutframe.about=\u00C0 propos +aboutframe.license=Licence +aboutframe.ok=OK +aboutframe.thirdparty=Tierce partie +columnselector.action.tip=S\u00E9lectionner les colonnes +config.action.quit=Quitter +config.action.quit.tip=Quitter l'\u00E9diteur de configuration +config.action.reset=Annuler +config.action.reset.tip=Annuler les modifications de cette cat\u00E9gorie +config.action.save=Enregistrer +config.action.save.tip=Sauver les modifications de cette cat\u00E9gorie +config.category.saved=La cat\u00E9gorie '%1$s' a \u00E9t\u00E9 modifi\u00E9e \: +config.choice.cancel=Annuler +config.choice.continue=Continuer +config.choice.doNotSave=Ne pas enregistrer +config.choice.ok=Ok +config.choice.save=Enregistrer +config.defaultValue=Valeur par d\u00E9faut +config.defaultValue.tip=Valeur par d\u00E9faut de l'option +config.descrition=Description +config.error.category.already.exists=La cat\u00E9gorie de nom '%1$s' existe d\u00E9j\u00E0\! +config.error.category.not.found=La cat\u00E9gorie de nom '%1$s' n'existe pas\! +config.key=Clef +config.key.tip=Clef de l'option +config.message.quit.invalid.category=La cat\u00E9gorie '%1$s' n'est pas valide\! +config.message.quit.valid.and.modified.category=La cat\u00E9gorie '%1$s' poss\u00E8dent des options modifi\u00E9es \: +config.modified=Option modifi\u00E9e (valeur originale \: %1$s) +config.no.option.selected=< Pas d'option s\u00E9lectionn\u00E9e > +config.option.final=Option non modifiable +config.option.label=Option '%1$s' (%2$s) +config.option.modified=Valeur modifi\u00E9e < ancienne valeur \: '%1$s' - nouvelle valeur \: '%2$s' > +config.title=Pr\u00E9f\u00E9rences +config.title.need.confirm=Une confirmation de votre part est requise... +config.title.will.reload.application=L'application doit \u00EAtre red\u00E9marrer... +config.unmodifiable=Ne peut pas \u00EAtre modifi\u00E9 +config.unvalid=Option non valide (valeur originale \: %1$s, type requis \: %2$s) +config.value=Valeur +config.value.tip=Valeur de l'option +entitycombobox.action.reset.tip=R\u00E9initialiser la valeur de la liste d\u00E9roulante +entitycombobox.action.sort.tip=Modifier le tri de la liste d\u00E9roulante +entitycombobox.popup.label=Objet '%1$s' +entitycombobox.popup.title=Modifier le tri +entitycombobox.sort.off=Cliquer pour activer le tri sur la propri\u00E9t\u00E9 '%1$s' +entitycombobox.sort.on=Le tri est effectu\u00E9 sur la propri\u00E9t\u00E9 '%1$s' +entitycombobox.unknown.type=Objet de type inconnu +errorUI.action.close=Fermer +errorUI.message=Une erreur est survenue \! +errorUI.title=Erreur... +hidor.collapseTip=Cacher +hidor.expandTip=Voir +i18neditor.empty.locales=< Aucune locale \u00E0 s\u00E9lectionner > +i18neditor.popup.title=Changer de langue +i18neditor.selected=Langue actuellement utilis\u00E9e \: %1$s +i18neditor.unselected=Pour utiliser cette langue \: %1$s +listSelector.hideList=Cacher la liste +listSelector.showList=Afficher la liste +memorywidget.memory=%d/%dMo +numbereditor..=. +numbereditor.0=0 +numbereditor.1=1 +numbereditor.2=2 +numbereditor.3=3 +numbereditor.4=4 +numbereditor.5=5 +numbereditor.6=6 +numbereditor.7=7 +numbereditor.8=8 +numbereditor.9=9 +numbereditor.action.reset.tip=R\u00E9initialiser +numbereditor.action.show.tip=Afficher le pav\u00E9 num\u00E9rique +numbereditor.clearAll=C +numbereditor.clearOne=CE +numbereditor.toggleSign=+/- +timeeditor.H=H Deleted: trunk/jaxx-widgets/src/main/resources/icons/action-add.png =================================================================== (Binary files differ) Copied: trunk/jaxx-widgets/src/main/resources/icons/action-add.png (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/resources/icons/action-add.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-widgets/src/main/resources/icons/action-collapse.png =================================================================== (Binary files differ) Copied: trunk/jaxx-widgets/src/main/resources/icons/action-collapse.png (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/resources/icons/action-collapse.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-widgets/src/main/resources/icons/action-config-quit.png =================================================================== (Binary files differ) Copied: trunk/jaxx-widgets/src/main/resources/icons/action-config-quit.png (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/resources/icons/action-config-quit.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-widgets/src/main/resources/icons/action-config-reset.png =================================================================== (Binary files differ) Copied: trunk/jaxx-widgets/src/main/resources/icons/action-config-reset.png (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/resources/icons/action-config-reset.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-widgets/src/main/resources/icons/action-config-save.png =================================================================== (Binary files differ) Copied: trunk/jaxx-widgets/src/main/resources/icons/action-config-save.png (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/resources/icons/action-config-save.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-widgets/src/main/resources/icons/action-expand.png =================================================================== (Binary files differ) Copied: trunk/jaxx-widgets/src/main/resources/icons/action-expand.png (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/resources/icons/action-expand.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-widgets/src/main/resources/icons/action-i18n-be.png =================================================================== (Binary files differ) Copied: trunk/jaxx-widgets/src/main/resources/icons/action-i18n-be.png (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/resources/icons/action-i18n-be.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-widgets/src/main/resources/icons/action-i18n-ca.png =================================================================== (Binary files differ) Copied: trunk/jaxx-widgets/src/main/resources/icons/action-i18n-ca.png (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/resources/icons/action-i18n-ca.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-widgets/src/main/resources/icons/action-i18n-ch.png =================================================================== (Binary files differ) Copied: trunk/jaxx-widgets/src/main/resources/icons/action-i18n-ch.png (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/resources/icons/action-i18n-ch.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-widgets/src/main/resources/icons/action-i18n-de.png =================================================================== (Binary files differ) Copied: trunk/jaxx-widgets/src/main/resources/icons/action-i18n-de.png (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/resources/icons/action-i18n-de.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-widgets/src/main/resources/icons/action-i18n-dk.png =================================================================== (Binary files differ) Copied: trunk/jaxx-widgets/src/main/resources/icons/action-i18n-dk.png (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/resources/icons/action-i18n-dk.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-widgets/src/main/resources/icons/action-i18n-es.png =================================================================== (Binary files differ) Copied: trunk/jaxx-widgets/src/main/resources/icons/action-i18n-es.png (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/resources/icons/action-i18n-es.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-widgets/src/main/resources/icons/action-i18n-fi.png =================================================================== (Binary files differ) Copied: trunk/jaxx-widgets/src/main/resources/icons/action-i18n-fi.png (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/resources/icons/action-i18n-fi.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-widgets/src/main/resources/icons/action-i18n-fr.png =================================================================== (Binary files differ) Copied: trunk/jaxx-widgets/src/main/resources/icons/action-i18n-fr.png (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/resources/icons/action-i18n-fr.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-widgets/src/main/resources/icons/action-i18n-gb.png =================================================================== (Binary files differ) Copied: trunk/jaxx-widgets/src/main/resources/icons/action-i18n-gb.png (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/resources/icons/action-i18n-gb.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-widgets/src/main/resources/icons/action-i18n-it.png =================================================================== (Binary files differ) Copied: trunk/jaxx-widgets/src/main/resources/icons/action-i18n-it.png (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/resources/icons/action-i18n-it.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-widgets/src/main/resources/icons/action-i18n-nl.png =================================================================== (Binary files differ) Copied: trunk/jaxx-widgets/src/main/resources/icons/action-i18n-nl.png (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/resources/icons/action-i18n-nl.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-widgets/src/main/resources/icons/action-i18n-no.png =================================================================== (Binary files differ) Copied: trunk/jaxx-widgets/src/main/resources/icons/action-i18n-no.png (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/resources/icons/action-i18n-no.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-widgets/src/main/resources/icons/action-i18n-se.png =================================================================== (Binary files differ) Copied: trunk/jaxx-widgets/src/main/resources/icons/action-i18n-se.png (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/resources/icons/action-i18n-se.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-widgets/src/main/resources/icons/action-i18n-us.png =================================================================== (Binary files differ) Copied: trunk/jaxx-widgets/src/main/resources/icons/action-i18n-us.png (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/resources/icons/action-i18n-us.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-widgets/src/main/resources/icons/action-numbereditor-calculator.png =================================================================== (Binary files differ) Copied: trunk/jaxx-widgets/src/main/resources/icons/action-numbereditor-calculator.png (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/resources/icons/action-numbereditor-calculator.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-widgets/src/main/resources/icons/action-numbereditor-reset.png =================================================================== (Binary files differ) Copied: trunk/jaxx-widgets/src/main/resources/icons/action-numbereditor-reset.png (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/resources/icons/action-numbereditor-reset.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-widgets/src/main/resources/icons/action-numbereditor-validate.png =================================================================== (Binary files differ) Copied: trunk/jaxx-widgets/src/main/resources/icons/action-numbereditor-validate.png (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/resources/icons/action-numbereditor-validate.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-widgets/src/main/resources/icons/action-remove.png =================================================================== (Binary files differ) Copied: trunk/jaxx-widgets/src/main/resources/icons/action-remove.png (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/main/resources/icons/action-remove.png) =================================================================== (Binary files differ) Deleted: trunk/jaxx-widgets/src/site/rst/images/Components-screenshot.gif =================================================================== (Binary files differ) Copied: trunk/jaxx-widgets/src/site/rst/images/Components-screenshot.gif (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/site/rst/images/Components-screenshot.gif) =================================================================== (Binary files differ) Deleted: trunk/jaxx-widgets/src/site/rst/images/webstart.gif =================================================================== (Binary files differ) Copied: trunk/jaxx-widgets/src/site/rst/images/webstart.gif (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/site/rst/images/webstart.gif) =================================================================== (Binary files differ) Deleted: trunk/jaxx-widgets/src/site/rst/index.rst =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/site/rst/index.rst 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/site/rst/index.rst 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,40 +0,0 @@ -=================== -Examples/Components -=================== - -The Components demo displays many different Swing components being used in a variety of ways; it is JAXX's equivalent -of the SwingSet demo. Various pages use advanced features such as data binding, scripting, event handling, and -CSS stylesheets. - -Examples/Calculator -=================== - -This is an implementation of Challenge #2 from the `XUL Grand Coding Challenge 2004`_ . Because this example program -has been implemented in so many different languages, you can easily compare JAXX's -syntax against the competition and decide for yourself which you prefer. - -Screen shot ------------ - -.. image:: images/Components-screenshot.gif - -Set it in action ----------------- - -|webstart| - -To run this example in `Java Web Start`_, click the `following link`_. - - -Source code ------------ - -Unlike the other examples, the source code for Components is too big to display here. You can view it yourself by -downloading JAXX, and you can also view the source code for the individual demos by clicking the "Source" tabs. - - -.. _Java Web Start: http://java.sun.com/products/javawebstart/ - -.. |webstart| image:: images/webstart.gif - -.. _following link: ./launch-demo.jnlp Copied: trunk/jaxx-widgets/src/site/rst/index.rst (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/site/rst/index.rst) =================================================================== --- trunk/jaxx-widgets/src/site/rst/index.rst (rev 0) +++ trunk/jaxx-widgets/src/site/rst/index.rst 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,40 @@ +=================== +Examples/Components +=================== + +The Components demo displays many different Swing components being used in a variety of ways; it is JAXX's equivalent +of the SwingSet demo. Various pages use advanced features such as data binding, scripting, event handling, and +CSS stylesheets. + +Examples/Calculator +=================== + +This is an implementation of Challenge #2 from the `XUL Grand Coding Challenge 2004`_ . Because this example program +has been implemented in so many different languages, you can easily compare JAXX's +syntax against the competition and decide for yourself which you prefer. + +Screen shot +----------- + +.. image:: images/Components-screenshot.gif + +Set it in action +---------------- + +|webstart| + +To run this example in `Java Web Start`_, click the `following link`_. + + +Source code +----------- + +Unlike the other examples, the source code for Components is too big to display here. You can view it yourself by +downloading JAXX, and you can also view the source code for the individual demos by clicking the "Source" tabs. + + +.. _Java Web Start: http://java.sun.com/products/javawebstart/ + +.. |webstart| image:: images/webstart.gif + +.. _following link: ./launch-demo.jnlp Deleted: trunk/jaxx-widgets/src/site/site.xml =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/site/site.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/jaxx-widgets/src/site/site.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project name="${project.name}"> - - <bannerLeft> - <name>${project.name}</name> - <src>${site.home.url}/jaxx.png</src> - <href>index.html</href> - </bannerLeft> - - <body> - - <breadcrumbs> - <item name="${project.name}" href="${project.url}" /> - </breadcrumbs> - - <menu ref="parent"/> - - <menu name="Utilisateur" inherited="top"/> - - <menu ref="reports"/> - - <menu ref="modules"/> - - </body> -</project> Copied: trunk/jaxx-widgets/src/site/site.xml (from rev 1672, branches/jaxx-2.X/jaxx-widgets/src/site/site.xml) =================================================================== --- trunk/jaxx-widgets/src/site/site.xml (rev 0) +++ trunk/jaxx-widgets/src/site/site.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project name="${project.name}"> + + <bannerLeft> + <name>${project.name}</name> + <src>${site.home.url}/jaxx.png</src> + <href>index.html</href> + </bannerLeft> + + <body> + + <breadcrumbs> + <item name="${project.name}" href="${project.url}" /> + </breadcrumbs> + + <menu ref="parent"/> + + <menu name="Utilisateur" inherited="top"/> + + <menu ref="reports"/> + + <menu ref="modules"/> + + </body> +</project> Property changes on: trunk/maven-jaxx-plugin ___________________________________________________________________ Modified: svn:ignore - target + target *.iml *.ipr *.iws Modified: trunk/maven-jaxx-plugin/pom.xml =================================================================== --- trunk/maven-jaxx-plugin/pom.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/pom.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -10,7 +10,7 @@ <parent> <groupId>org.nuiton</groupId> <artifactId>jaxx</artifactId> - <version>1.7.2-SNAPSHOT</version> + <version>2.0.0-beta-3-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> @@ -51,6 +57,11 @@ <artifactId>maven-helper-plugin</artifactId> </dependency> + <dependency> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-velocity</artifactId> + </dependency> + <!-- pour acceder aux BeansInfos swing via Introspector --> <dependency> <groupId>com.sun</groupId> @@ -61,27 +72,13 @@ </dependency> <!-- tests dependencies --> -<!-- + <dependency> <groupId>org.apache.maven.shared</groupId> - <artifactId>maven-plugin-testing-harness</artifactId> - <version>1.1</version> - <scope>test</scope> - </dependency> ---> - <dependency> - <groupId>org.apache.maven.shared</groupId> <artifactId>maven-verifier</artifactId> - <version>1.0</version> - <scope>test</scope> </dependency> - + <dependency> - <groupId>org.apache.velocity</groupId> - <artifactId>velocity</artifactId> - <version>1.5</version> - </dependency> - <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> </dependency> @@ -108,10 +105,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> <!-- ************************************************************* --> @@ -133,8 +129,190 @@ </execution> </executions> </plugin> + + </plugins> - </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,7 +320,176 @@ <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> - -</project> \ No newline at end of file + +</project> Modified: trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java =================================================================== --- trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,21 +1,21 @@ -/* *##% - * Copyright (C) 2007 - * JaxxPlugin, Code Lutin +/* *##% + * JAXX Maven plugin + * Copyright (C) 2008 - 2009 CodeLutin * - * 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 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 Public License for more details. + * GNU General Lesser 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. - *##%*/ + * 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 org.nuiton.jaxx.plugin; import org.apache.maven.project.MavenProject; @@ -32,6 +32,9 @@ */ public abstract class AbstractJaxxMojo extends AbstractPlugin { + public abstract File getTargetDirectory(); + + public abstract void setTargetDirectory(File targetDirectory); /** * Dépendance du projet. * @@ -41,11 +44,12 @@ */ protected MavenProject project; /** - * Repertoire de destination des fichiers java a generer. + * Encoding pour la generation des fichiers * - * @parameter expression="${jaxx.outJava}" default-value="${basedir}/target/generated-sources/java" + * @parameter expression="${jaxx.encoding}" default-value="${project.build.sourceEncoding}" + * @since 2.0.0 */ - protected File outJava; + protected String encoding; /** * verbose flag * @@ -55,115 +59,20 @@ */ protected boolean verbose; /** - * to make compiler i18nable, says add the {@link org.nuiton.i18n.I18n#_(String, Object[])} method - * invocation on {@link jaxx.compiler.I18nHelper#I18N_ATTRIBUTES} attributes. - * - * @parameter expression="${jaxx.i18nable}" default-value="true" - * @see jaxx.compiler.I18nHelper - */ - protected boolean i18nable; - /** - * The store of helpIds generated by {@link JaxxGeneratorMojo}. - * <p/> - * - * @parameter expression="${jaxx.helpIdStore}" default-value="target/helpIds.properties" + * The store of helpIds generated by the goal {@link GenerateMojo} and then + * used by the goal {@link GenerateHelpMojo}. + * + * @parameter expression="${jaxx.helpIdsStore}" default-value="target/generated-sources/jaxx/helpIds.properties" * @required * * @since 1.3 */ - protected File helpIdStore; - /** - * The name of the helpset to generate. - * - * @parameter expression="${jaxx.helpSetName}" default-value="${project.artifactId}" - * @required - * - * @since 1.3 - */ - protected String helpSetName; - /** - * The prefix to add to i18n key for any help i18n key. - * - * @parameter expression="${jaxx.helpsetI18nPrefix}" default-value="${jaxx.helpSetName}.help." - * @required - * - * @since 1.3 - */ - protected String helpsetI18nPrefix; - /** - * The suffix to add to i18n key for an help Id. - * - * @parameter expression="${jaxx.helpsetTitleI18nSuffix}" default-value=".title" - * @required - * - * @since 1.3 - */ - protected String helpsetTitleI18nSuffix; - /** - * The suffix to add to i18n key for an toc Id. - * - * @parameter expression="${jaxx.helpsetTocI18nSuffix}" default-value=".toc" - * @required - * - * @since 1.3 - */ - protected String helpsetTocI18nSuffix; - /** - * The suffix to add to i18n key for an toc Id. - * - * @parameter expression="${jaxx.helpsetIndexI18nSuffix}" default-value=".index" - * @required - * - * @since 1.3 - */ - protected String helpsetIndexI18nSuffix; - protected boolean skip; - protected ClassLoader cl; + protected File helpIdsStore; @Override 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() { @@ -184,4 +93,20 @@ public void setVerbose(boolean verbose) { this.verbose = verbose; } + + public File getHelpIdsStore() { + return helpIdsStore; + } + + public void setHelpIdsStore(File helpIdsStore) { + this.helpIdsStore = helpIdsStore; + } + + public String getEncoding() { + return encoding; + } + + public void setEncoding(String encoding) { + this.encoding = encoding; + } } Copied: trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java) =================================================================== --- trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java (rev 0) +++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,589 @@ +/* *##% + * JAXX Maven plugin + * 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>. + * ##%*/ +package org.nuiton.jaxx.plugin; + +import com.sun.java.help.search.Indexer; +import java.io.BufferedReader; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import org.apache.maven.plugin.MojoFailureException; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStreamReader; +import java.io.PrintStream; +import java.lang.reflect.Method; +import java.net.URL; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; +import java.util.Locale; +import java.util.Properties; +import org.codehaus.plexus.util.DirectoryScanner; +import org.codehaus.plexus.util.FileUtils; +import org.codehaus.plexus.util.StringUtils; +import org.nuiton.i18n.I18n; +import org.nuiton.plugin.VelocityTemplateGenerator; +import org.nuiton.util.FileUtil; +import org.nuiton.util.SortedProperties; + +/** + * Mojo to generate javax help stuff for your project. + * + * HelpIds should have been discovered by the JaxxMojo. + * + * @author chemit + * @goal generate-help + * @phase process-sources + * + * @requiresProject + * @requiresDependencyResolution compile + * @since 1.3 + */ +public class GenerateHelpMojo extends AbstractJaxxMojo { + + private static final String AUTOREMOVE_LINE = "REMOVE THS LINE TO DISABLE AUTO-REGENERATE THE FILE"; + /** + * The directory where to generate help files. + * + * @parameter expression="${jaxx.outHelp}" default-value="${project.basedir}/src/main/help" + * @required + * + * @since 1.3 + */ + protected File outHelp; + /** + * The locales to generate for help, seprated by comma. + * + * The first locale given is the default locale. + * + * @parameter expression="${jaxx.locales}" + * @required + * + * @since 2.0.0 + */ + protected String locales; + /** + * The name of the helpset to generate. + * + * @parameter expression="${jaxx.helpsetName}" default-value="${project.artifactId}" + * @required + * + * @since 1.3 + */ + protected String helpsetName; + /** + * The template used to generate helpset file. + * + * Must be an existing file or a ressource in class-path + * + * @parameter expression="${jaxx.helpsetTemplate}" default-value="/defaultHelpSet.hs.vm" + * @required + * + * @since 1.3 + */ + protected File helpsetTemplate; + /** + * The template used to generate helpset map file. + * + * Must be an existing file or a ressource in class-path + * + * @parameter expression="${jaxx.mapTemplate}" default-value="/defaultMap.jhm.vm" + * @required + * + * @since 1.3 + */ + protected File mapTemplate; + /** + * The template used to generate helpset index file. + * + * Must be an existing file or a ressource in class-path + * + * @parameter expression="${jaxx.indexTemplate}" default-value="/defaultIndex.xml.vm" + * @required + * + * @since 1.3 + */ + protected File indexTemplate; + /** + * The template used to generate helpset toc file. + * + * Must be an existing file or a ressource in class-path + * + * @parameter expression="${jaxx.tocTemplate}" default-value="/defaultToc.xml.vm" + * @required + * + * @since 1.3 + */ + protected File tocTemplate; + /** + * The template used to generate helpset content file. + * + * Must be an existing file or a ressource in class-path + * + * @parameter expression="${jaxx.contentTemplate}" default-value="/defaultContent.html.vm" + * @required + * + * @since 1.3 + */ + protected File contentTemplate; + /** + * Flag to generate the search index. + * + * @parameter expression="${jaxx.generateSearch}" default-value="true" + * @required + * + * @since 1.3 + */ + protected boolean generateSearch; + /** + * The help ids discovered in {@link #helpIdsStore} files. + */ + private Properties helpIds; + /** + * Default locale (the first locale in {@link #localesToTreate}. + */ + private Locale defaultLocale; + /** + * Locales to treate + */ + private Locale[] localesToTreate; + + @Override + public boolean init() throws Exception { + + File idsStore = getHelpIdsStore(); + + if (!idsStore.exists()) { + getLog().info("no helpIdStore to react at " + idsStore); + return false; + } + + if (locales == null || locales.trim().isEmpty()) { + throw new MojoFailureException("You must set the 'locales' property properly (was " + locales + ")."); + } + + // check there is a outHelp + if (outHelp == null) { + throw new MojoFailureException("You must set the 'target' property."); + } + + List<Locale> tmp = new ArrayList<Locale>(); + for (String loc : locales.split(",")) { + Locale l = I18n.newLocale(loc); + tmp.add(l); + } + + if (tmp.isEmpty()) { + throw new MojoFailureException("you must set the 'locales' property."); + } + + localesToTreate = tmp.toArray(new Locale[tmp.size()]); + defaultLocale = localesToTreate[0]; + + // check ressources + checkResource(helpsetTemplate); + checkResource(mapTemplate); + checkResource(indexTemplate); + checkResource(tocTemplate); + checkResource(contentTemplate); + + if (!getTargetDirectory().exists()) { + getLog().info("mkdir " + getTargetDirectory()); + getTargetDirectory().mkdirs(); + } + + // load ids from idsStore file + + helpIds = new SortedProperties(); + + BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(idsStore), getEncoding())); + String id = null; + while ((id = reader.readLine()) != null) { + id = id.trim(); + String path = id.replaceAll("\\.", File.separator) + ".html"; + helpIds.put(id, path); + } + + if (helpIds.isEmpty()) { + + // no ids detected + getLog().warn("No helpIds detected, will skip."); + return false; + } + return true; + } + + @Override + public void doAction() throws Exception { + + int touchedFiles = 0; + + String mapFileName = helpsetName + "Map.jhm"; + String indexFileName = helpsetName + "Index.xml"; + String tocFileName = helpsetName + "TOC.xml"; + + for (Locale locale : localesToTreate) { + + boolean isDefaultLocale = locale == defaultLocale; + + String language = locale.getLanguage(); + + String localePath = (isDefaultLocale ? "default" : language); + + File localizedTarget = new File(outHelp, localePath); + + if (!localizedTarget.exists()) { + localizedTarget.mkdirs(); + } + getLog().info("Generate help for language " + language); + if (isVerbose()) { + getLog().info(" Localized target : " + localizedTarget); + } + + Properties env = new Properties(); + + env.put("helpSetName", helpsetName); + env.put("locale", language); + env.put("localePath", localePath); + env.put("separator", " "); + env.put("autoremoveLine", AUTOREMOVE_LINE); + + String localeSuffix = isDefaultLocale ? "" : "_" + language; + String helpsetFileName = helpsetName + localeSuffix + ".hs"; + + env.put("helpSetFileName", helpsetFileName); + + env.put("mapFileName", mapFileName); + env.put("indexFileName", indexFileName); + env.put("tocFileName", tocFileName); + env.put("generateSearch", generateSearch); + + // --------------------------------------------------------------- + // --- main helpset file ----------------------------------------- + // --------------------------------------------------------------- + + File file = new File(outHelp, helpsetFileName); + + boolean doCreate = generateHelpsetFile(file, env); + + if (doCreate) { + touchedFiles++; + } + + // --------------------------------------------------------------- + // --- helpset map file ------------------------------------------ + // --------------------------------------------------------------- + + file = new File(localizedTarget, mapFileName); + + generateMapFile(file, env); + touchedFiles++; + + // --------------------------------------------------------------- + // --- helpset index file ---------------------------------------- + // --------------------------------------------------------------- + + file = new File(localizedTarget, indexFileName); + + generateIndexFile(file, env); + touchedFiles++; + + // --------------------------------------------------------------- + // --- helpset toc file ------------------------------------------ + // --------------------------------------------------------------- + + file = new File(localizedTarget, tocFileName); + + generateTocFile(file, env); + touchedFiles++; + + // --------------------------------------------------------------- + // --- helpset content files ------------------------------------- + // --------------------------------------------------------------- + + touchedFiles += generateContentFiles(localizedTarget, env, localePath); + + // --------------------------------------------------------------- + // --- generate search index ------------------------------------- + // --------------------------------------------------------------- + + if (generateSearch) { + + generateSearchIndex(localizedTarget, locale); + } + + + } + + getLog().info(touchedFiles + " file(s) treated."); + } + + @Override + public File getTargetDirectory() { + return outHelp; + } + + @Override + public void setTargetDirectory(File targetDirectory) { + this.outHelp = targetDirectory; + } + + protected int generateContentFiles(File localizedTarget, Properties env, String localePath) throws Exception { + + int touchedFiles = 0; + VelocityTemplateGenerator gen = prepareGenerator(contentTemplate); + Enumeration<?> keys = helpIds.keys(); + while (keys.hasMoreElements()) { + String key = (String) keys.nextElement(); + String url = (String) helpIds.get(key); + url = helpsetName + File.separator + url; + File f = new File(localizedTarget, url); + boolean exist = f.exists(); + if (exist) { + // check if there is a autoremoveLine in content + String content = FileUtil.readAsString(f); + if (!content.contains(AUTOREMOVE_LINE)) { + // no regenerate marker detected, so skip this file + if (verbose) { + getLog().debug("skip existing file " + f); + } + continue; + } + } + f.getParentFile().mkdirs(); + if (verbose) { + if (exist) { + getLog().info("regenerate content file " + f); + } else { + getLog().info("generate content file " + f); + } + } + env.put("helpId", key); + env.put("helpIdUrl", localePath + "/" + url); + gen.generate(env, f); + touchedFiles++; + } + return touchedFiles; + } + + protected boolean generateHelpsetFile(File file, Properties env) throws Exception { + + if (file.exists()) { + // check the autoremove line presence + String content = FileUtil.readAsString(file); + if (!content.contains(AUTOREMOVE_LINE)) { + // no regenerate marker detected, so skip this file + if (verbose) { + getLog().info("skip existing helpset main file " + file); + } + return false; + } + } + + if (verbose) { + if (file.exists()) { + getLog().info("regenerate helpset main file " + file); + } else { + getLog().info("generate helpset main file " + file); + } + } + doGen(helpsetTemplate, file, env); + return true; + } + + protected Properties generateMapFile(File file, Properties env) throws Exception { + + boolean create; + + Properties mergedHelpIds = null; + if (file.exists()) { + + // get back the exisiting data and merge it with incoming ones + + if (verbose) { + getLog().info("loading existing helpset map file " + file); + } + + mergedHelpIds = XmlHelper.getExistingHelpIds(file, verbose, getLog()); + create = false; + + } else { + + mergedHelpIds = new SortedProperties(); + create = true; + } + + // inject new helpIds + + for (Object k : helpIds.keySet()) { + mergedHelpIds.put(k, helpsetName + "/" + helpIds.get(k)); + } + + if (!mergedHelpIds.contains("top")) { + + // on ajoute une entree vers le root du helpset + + String topUrl = helpsetName + ".html"; + helpIds.put("top", topUrl); + mergedHelpIds.put("top", helpsetName + "/" + topUrl); + if (verbose) { + getLog().debug("add top entry with url " + topUrl); + } + } + + if (verbose) { + if (create) { + getLog().info("generate helpset map file " + file); + } else { + getLog().info("udpate helpset map file " + file); + } + } + + env.put("helpIds", mergedHelpIds); + doGen(mapTemplate, file, env); + env.remove("helpIds"); + return mergedHelpIds; + } + + protected NodeItem generateIndexFile(File file, Properties env) throws Exception { + NodeItem rootItem = null; + + boolean create; + + if (file.exists()) { + + create = false; + + rootItem = XmlHelper.getExistingItems("indexitem", file); + } else { + create = true; + } + + if (rootItem == null) { + rootItem = new NodeItem("top", helpsetName); + } + + // inject new index entries + + for (Object k : helpIds.keySet()) { + NodeItem toc = rootItem.findChild(k + ""); + if (verbose) { + getLog().debug("index " + k + " : " + toc); + } + } + + if (verbose) { + if (create) { + getLog().info("generate helpset index file " + file); + } else { + getLog().info("udpate helpset index file " + file); + } + } + + env.put("rootItem", rootItem); + doGen(indexTemplate, file, env); + env.remove("rootItem"); + return rootItem; + } + + protected void generateSearchIndex(File localizedTarget, Locale locale) throws IllegalArgumentException, IOException, InvocationTargetException, SecurityException, IllegalAccessException, NoSuchMethodException { + + Method m = Indexer.class.getDeclaredMethod("main", String[].class); + File indexDir = new File(localizedTarget, "JavaHelpSearch"); + // remove old index + FileUtils.deleteDirectory(indexDir); + //copy resources to a tmp dir (without any VCS infos) + File tmpDir = new File(project.getBasedir(), "target" + File.separator + "jaxx-tmp" + File.separator + "indexer-" + locale + "-" + System.nanoTime()); + getLog().info("copy files to " + tmpDir + " for indexing them"); + FileUtils.copyDirectory(localizedTarget, tmpDir, "**/*", StringUtils.join(DirectoryScanner.DEFAULTEXCLUDES, ",")); + List<String> params = new ArrayList<String>(); + params.add("-verbose"); + params.add("-db"); + params.add(indexDir.getAbsolutePath()); + params.add("-logfile"); + File logFile = new File(project.getBasedir(), "target" + File.separator + "generated-sources" + File.separator + "jaxx" + File.separator + "indexer-" + locale + ".log"); + params.add(logFile.getAbsolutePath()); + params.add(tmpDir.getAbsolutePath()); + PrintStream out = System.out; + PrintStream err = System.err; + try { + m.invoke(null, (Object) params.toArray(new String[params.size()])); + } finally { + System.setOut(out); + System.setErr(err); + } + getLog().info("Search Index generated"); + } + + protected NodeItem generateTocFile(File file, Properties env) throws Exception { + NodeItem rootItem = null; + + boolean create; + + if (file.exists()) { + + create = false; + + rootItem = XmlHelper.getExistingItems("tocitem", file); + } else { + create = true; + } + + if (rootItem == null) { + rootItem = new NodeItem("top", helpsetName); + } + // inject new toc entries + + for (Object k : helpIds.keySet()) { + NodeItem toc = rootItem.findChild(k + ""); + if (verbose) { + getLog().debug("toc " + k + " : " + toc); + } + } + + if (verbose) { + if (create) { + getLog().info("generate helpset toc file " + file); + } else { + getLog().info("udpate helpset toc file " + file); + } + } + + env.put("rootItem", rootItem); + doGen(tocTemplate, file, env); + env.remove("rootItem"); + return rootItem; + } + + protected void doGen(File template, File f, Properties env) throws Exception { + VelocityTemplateGenerator gen = prepareGenerator(template); + gen.generate(env, f); + } + + protected VelocityTemplateGenerator prepareGenerator(File template) throws Exception { + URL templateURL = getTemplate(template); + + if (verbose) { + getLog().info("using template " + templateURL); + } + VelocityTemplateGenerator gen = new VelocityTemplateGenerator(project, templateURL); + return gen; + } +} Copied: trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java) =================================================================== --- trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java (rev 0) +++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,616 @@ +/* *##% + * JAXX Maven plugin + * 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>. + * ##%*/ +package org.nuiton.jaxx.plugin; + +import java.util.List; + +import jaxx.compiler.CompilerConfiguration; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.JAXXEngine; +import jaxx.compiler.beans.BeanInfoUtil; +import jaxx.compiler.CompiledObjectDecorator; +import jaxx.compiler.binding.DataBindingHelper; +import jaxx.compiler.decorators.HelpRootCompiledObjectDecorator; +import jaxx.compiler.tags.TagManager; +import jaxx.runtime.JAXXContext; + +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; + +import org.nuiton.io.FileUpdaterHelper; +import org.nuiton.io.MirroredFileUpdater; + +import java.io.File; +import java.io.IOException; +import java.util.Map; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Set; + +import jaxx.runtime.swing.help.JAXXHelpBroker; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + +/** + * Generates some java code from jaxx files. + * + * @author chemit + * @goal generate + * @phase process-sources + * @requiresDependencyResolution compile + * @requiresProject + */ +public class GenerateMojo extends AbstractJaxxMojo implements CompilerConfiguration { + + /** + * Default includes to use, if none provided + */ + private static final String[] INCLUDES = {"**\\/*.jaxx"}; + /** + * Repertoire sources des fichiers jaxx a generer. + * + * @parameter expression="${jaxx.src}" default-value="${basedir}/src/main/java" + */ + protected File src; + /** + * Repertoire de destination des fichiers java a generer. + * + * @parameter expression="${jaxx.outJava}" default-value="${basedir}/target/generated-sources/java" + */ + protected File outJava; + /** + * pour filter les fichiers a traiter + * + * @parameter expression="${jaxx.includes}" + */ + protected String[] includes; + /** + * pour filter les fichiers a ne pas traiter + * + * @parameter expression="${jaxx.excludes}" + */ + protected String[] excludes; + /** + * Le compilateur à utiliser (par défaut celui de Swing) + * + * @parameter expression="${jaxx.compilerFQN}" default-value="jaxx.compiler.JAXXCompiler" + */ + protected String compilerFQN; + /** + * Le compilateur à utiliser (par défaut celui de Swing) + * + * @parameter expression="${jaxx.validatorFQN}" default-value="jaxx.runtime.validator.swing.SwingValidator" + */ + protected String validatorFQN; + /** + * the name of implementation of {@link jaxx.runtime.JAXXContext} + * to be used on {@link jaxx.runtime.JAXXObject}. + * <p/> + * Must not be abstract. + * + * @parameter expression="${jaxx.jaxxContextFQN}" default-value="jaxx.runtime.context.DefaultJAXXContext" + * @required + */ + protected String jaxxContextFQN; + /** + * the FQN of the ui to use for error notification. + * <p/> + * If not given, will use the one defined in validator + * + * @parameter expression="${jaxx.defaultErrorUIFQN}" + */ + protected String defaultErrorUIFQN; + /** + * the FQN of the ui to use for error notification. + * <p/> + * If not given, will use the one defined in validator + * + * @parameter expression="${jaxx.defaultDecoratorFQN}" default-value="jaxx.compiler.decorators.DefaultCompiledObjectDecorator" + * @see jaxx.compiler.CompiledObjectDecorator + */ + protected String defaultDecoratorFQN; + /** + * flag to include in compiler classpath the java sources directories (src and outJava). + * <p/> + * By default, false. + * + * @parameter expression="${jaxx.addSourcesToClassPath}" default-value="false" + */ + protected boolean addSourcesToClassPath; + /** + * flag to include in compiler classpath the java resources directories (src and outJava). + * <p/> + * By default, false. + * + * @parameter expression="${jaxx.addResourcesToClassPath}" default-value="false" + * @since 1.6.0 + */ + protected boolean addResourcesToClassPath; + /** + * flag to include in compiler classpath the compile class-path (can only be used in a test phase). + * <p/> + * By default, false. + * + * @parameter expression="${jaxx.addCompileClassPath}" default-value="false" + * @since 1.6.0 + */ + protected boolean addCompileClassPath; + /** + * flag to include in compiler classpath the project compile classpath. + * <p/> + * By default, false. + * + * @parameter expression="${jaxx.addProjectClassPath}" default-value="false" + */ + protected boolean addProjectClassPath; + /** + * to force generation of java source for any jaxx files with no timestamp checking. + * <p/> + * By default, never force generation. + * + * @parameter expression="${jaxx.force}" default-value="false" + */ + protected boolean force; + /** + * A flag to mark themojo to be used in a test phase. This will permits to add generated sources in test compile roots. + * + * @parameter expression="${jaxx.testPhase}" default-value="false" + * @since 1.6.0 + */ + protected boolean testPhase; + /** + * to make compiler i18nable, says add the {@link org.nuiton.i18n.I18n#_(String, Object...)} method + * invocation on {@link jaxx.compiler.I18nHelper#I18N_ATTRIBUTES} attributes. + * + * @parameter expression="${jaxx.i18nable}" default-value="true" + * @see jaxx.compiler.I18nHelper + */ + protected boolean i18nable; + /** + * pour optimizer le code compile ou genere ? + * + * @parameter expression="${jaxx.optimize}" default-value="false" + */ + protected boolean optimize; + /** + * flag to add logger to each generated jaxx file. + * <p/> + * By default, always add it. + * + * @parameter expression="${jaxx.addLogger}" default-value="true" + */ + protected boolean addLogger; + /** + * flag to keep compilers after the generate operation (usefull for tests. + * <p/> + * By default, always reset. + * + * @parameter expression="${jaxx.resetAfterCompile}" default-value="true" + */ + protected boolean resetAfterCompile; + /** + * extra path to be added in {@link java.beans.Introspector#setBeanInfoSearchPath(java.lang.String[])}. + * <p/> + * add beanInfoSearchPath to be registred by {@link BeanInfoUtil#addJaxxBeanInfoPath(java.lang.String...)} + * <p/> + * and then will be use by {@link jaxx.compiler.spi.DefaultInitializer#initialize()}. + * <p/> + * <p/> + * This permit to use real beanInfo of imported graphic libraries. + * + * @parameter expression="${jaxx.beanInfoSearchPath}" + */ + protected String[] beanInfoSearchPath; + /** + * list of fqn of class toimport for all generated jaxx files + * + * @parameter expression="${jaxx.extraImportList}" + */ + protected String extraImportList; + /** + * a flag to use UIManager to retreave icons. + * + * @parameter expression="${jaxx.useUIManagerForIcon}" default-value="false" + */ + protected boolean useUIManagerForIcon; + /** + * flag to activate profile mode. + * <p/> + * By default, not active. + * + * @parameter expression="${jaxx.profile}" default-value="false" + */ + protected boolean profile; + /** + * To show detected bindings. + * <p/> + * By default, do not show them. + * + * @parameter expression="${jaxx.showBinding}" default-value="false" + * @since 2.0.0 + */ + protected boolean showBinding; + /** + * flag to activate help generation process. + * <p/> + * By default, not active. + * + * @parameter expression="${jaxx.generateHelp}" default-value="false" + * @since 1.3 + */ + protected boolean generateHelp; + /** + * the FQN of help broker + * <p/> + * By default, use the JAXX implementation {@link JAXXHelpBroker}. + * + * @parameter expression="${jaxx.helpBrokerFQN}" default-value="jaxx.runtime.swing.help.JAXXHelpBroker" + * @since 1.3 + */ + protected String helpBrokerFQN; + /** + * detected jaxx files in {@link #init()} method + */ + protected String[] files; + /** + * file updater used to detect jaxx files. + * <p/> + * <b>Note:</b> if {@link #verbose} flag is on, will ne be used + */ + protected MirroredFileUpdater updater; + /** + * + */ + private Class<?> defaultErrorUIClass; + /** + * + */ + private Class<?> validatorClass; + /** + * + */ + private Class<? extends CompiledObjectDecorator> defaultDecoratorClass; + /** + * + */ + private Class<? extends JAXXContext> jaxxContextClass; + /** + * + */ + private Class<? extends JAXXCompiler> compilerClass; + /** + * + */ + private String[] extraImports; + /** + * + */ + private boolean nofiles; + /** + * + */ + protected ClassLoader cl; + /** + * JAXX engine + */ + private JAXXEngine engine; + + @SuppressWarnings("unchecked") + @Override + public boolean init() throws Exception { + + if (generateHelp) { + // check there is some bundle + if (getHelpIdsStore() == null) { + throw new MojoFailureException("you must set the 'helpIdStore' property."); + } + } + + fixCompileSourceRoots(); + + if (includes == null || includes.length == 0) { + // use default includes + includes = INCLUDES; + } + updater = FileUpdaterHelper.newJaxxFileUpdater(src, outJava); + + Map<File, String[]> result = new HashMap<File, String[]>(); + getFilesToTreateForRoots(includes, excludes, Arrays.asList(src.getAbsolutePath()), result, force ? null : updater); + + this.files = result.get(src); + + nofiles = files == null || files.length == 0; + if (nofiles) { + return true; + } + + cl = initClassLoader(project, + src, + addSourcesToClassPath, + testPhase, + addResourcesToClassPath, + addCompileClassPath, + addProjectClassPath); + + Thread.currentThread().setContextClassLoader(cl); + + compilerClass = (Class<? extends JAXXCompiler>) Class.forName(compilerFQN, false, cl); + defaultDecoratorClass = (Class<? extends CompiledObjectDecorator>) Class.forName(defaultDecoratorFQN, false, cl); + jaxxContextClass = (Class<? extends JAXXContext>) Class.forName(jaxxContextFQN, false, cl); + if (!JAXXContext.class.isAssignableFrom(jaxxContextClass)) { + throw new MojoExecutionException("jaxxContextFQN must be an implementation of " + JAXXContext.class + " but was : " + jaxxContextClass); + } + validatorClass = Class.forName(validatorFQN, false, cl); + + if (defaultErrorUIFQN != null && !defaultErrorUIFQN.trim().isEmpty()) { + defaultErrorUIClass = Class.forName(defaultErrorUIFQN, false, cl); + } + + if (beanInfoSearchPath != null && beanInfoSearchPath.length > 0) { + // register extra path + BeanInfoUtil.addJaxxBeanInfoPath(beanInfoSearchPath); + } + + if (!getTargetDirectory().exists()) { + getTargetDirectory().mkdirs(); + } + + // compute extra imports (can not use java classes since some of + // imports can not be still compiled) + if (extraImportList != null && !extraImportList.isEmpty()) { + String[] imports = extraImportList.split(","); + int i = 0; + for (String importS : imports) { + imports[i++] = importS.trim(); + } + if (verbose) { + getLog().info("extra imports " + java.util.Arrays.toString(imports)); + } + extraImports = imports; + } + + if (verbose) { + getLog().info(toString()); + getLog().info("includes : " + Arrays.toString(includes)); + for (String file : files) { + getLog().info("will parse " + file); + } + } + return true; + } + + @Override + public void doAction() throws MojoExecutionException { + + if (nofiles) { + getLog().info("No files to treate."); + return; + } + + getLog().info("Detects " + files.length + " modified jaxx file(s). "); + + if (showBinding) { + DataBindingHelper.SHOW_LOG = showBinding; + } + try { + + // force compiler init from here, not in a static block + TagManager.reset(verbose); + + engine = JAXXEngine.newLaunchor(src, files, this); + int nbFiles = engine.run(); + report(engine); + if (nbFiles == -1) { + throw new MojoExecutionException("Aborting due to errors reported by jaxxc"); + } + getLog().info("Generated " + nbFiles + " file(s). "); + + if (generateHelp) { + // generate help + generateHelp(); + } + + } catch (MojoExecutionException e) { + getLog().error(e); + throw e; + } 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 { + DataBindingHelper.SHOW_LOG = false; + } + } + + @Override + public File getTargetDirectory() { + return outJava; + } + + @Override + public void setTargetDirectory(File targetDirectory) { + this.outJava = targetDirectory; + } + + @Override + public boolean getOptimize() { + return optimize; + } + + @Override + public boolean isI18nable() { + return i18nable; + } + + @Override + public boolean isUseUIManagerForIcon() { + return useUIManagerForIcon; + } + + @Override + public boolean isAddLogger() { + return addLogger; + } + + @Override + public Class<? extends JAXXContext> getJaxxContextClass() { + return jaxxContextClass; + } + + @Override + public String[] getExtraImports() { + return extraImports; + } + + @Override + public boolean isResetAfterCompile() { + return resetAfterCompile; + } + + @Override + public boolean isOptimize() { + return optimize; + } + + @Override + public Class<?> getDefaultErrorUI() { + return defaultErrorUIClass; + } + + @Override + public ClassLoader getClassLoader() { + return cl; + } + + @Override + public Class<? extends JAXXCompiler> getCompilerClass() { + return compilerClass; + } + + @Override + public Class<? extends CompiledObjectDecorator> getDefaultDecoratorClass() { + return defaultDecoratorClass; + } + + @Override + public boolean isProfile() { + return profile; + } + + @Override + public boolean isGenerateHelp() { + return generateHelp; + } + + @Override + public String getHelpBrokerFQN() { + return helpBrokerFQN; + } + + @Override + public Class<?> getValidatorClass() { + return validatorClass; + } + + public JAXXEngine getEngine() { + return engine; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); + } + + protected void fixCompileSourceRoots() { + if (project == null) { + // no project defined, can not fix anything + // this case could appear if we wanted to do some tests of the plugin + return; + } + + if (testPhase) { + addTestCompileSourceRoots(getTargetDirectory()); + } else { + addCompileSourceRoots(getTargetDirectory()); + } + } + + protected void generateHelp() throws IOException { + Set<String> helpIds = HelpRootCompiledObjectDecorator.getHelpIds(); + if (helpIds.isEmpty()) { + if (verbose) { + // no ids detected in this compilation round + getLog().info("no helpIds detected."); + } + return; + } + File idsStore = getHelpIdsStore(); + + if (!idsStore.getParentFile().exists()) { + idsStore.getParentFile().mkdirs(); + } + + StringBuilder buffer = new StringBuilder(); + + for (String helpId : helpIds) { + buffer.append(removeQuote(helpId)).append('\n'); + } + writeFile(idsStore, buffer.toString(), encoding); + + getLog().info("helpIdStore generated in " + idsStore); + + helpIds.clear(); + } + + protected String removeQuote(String txt) { + if (txt.startsWith("\"")) { + txt = txt.substring(1); + } + if (txt.endsWith("\"")) { + txt = txt.substring(0, txt.length() - 1); + } + return txt; + } + + protected void report(JAXXEngine engine) { + List<String> warnings = engine.getWarnings(); + if (!warnings.isEmpty()) { + StringBuilder buffer = new StringBuilder("JAXX detects " + (warnings.size() == 1 ? "1 warning" : warnings.size() + " warnings")); + buffer.append(" :"); + for (String s : warnings) { + buffer.append("\n").append(s); + } + getLog().warn(buffer.toString()); + } + List<String> errors = engine.getErrors(); + if (!errors.isEmpty()) { + StringBuilder buffer = new StringBuilder("JAXX detects " + (errors.size() == 1 ? "1 error" : errors.size() + " errors")); + buffer.append(" :"); + for (String s : errors) { + buffer.append("\n").append(s); + } + getLog().error(buffer.toString()); + } + } +} Deleted: trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java =================================================================== --- trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,663 +0,0 @@ -/* *##% - * Copyright (C) 2007 - * JaxxPlugin, Code Lutin - * - * 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 org.nuiton.jaxx.plugin; - -import jaxx.beaninfos.BeanInfoUtil; -import jaxx.compiler.CompilerOptions; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.JAXXCompilerLaunchor; -import jaxx.runtime.JAXXContext; -import jaxx.tags.TagManager; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.codehaus.plexus.util.DirectoryScanner; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.lang.reflect.Modifier; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Properties; -import java.util.Set; -import jaxx.compiler.CompiledObjectDecorator; -import jaxx.compiler.HelpRootCompiledObjectDecorator; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.model.Resource; -import org.apache.maven.project.MavenProject; -import org.nuiton.io.FileUpdaterHelper; -import org.nuiton.io.MirroredFileUpdater; - -/** - * Classe permettant de transformer des sources jaxx vers du source java. - * - * @author chemit - * @goal generate - * @phase process-sources - * @requiresDependencyResolution compile - * @requiresProject - */ -public class JaxxGeneratorMojo extends AbstractJaxxMojo { - - /** - * Le compilateur à utiliser (par défaut celui de Swing) - * - * @parameter expression="${jaxx.compilerFQN}" default-value="jaxx.compiler.SwingCompiler" - */ - protected String compilerFQN; - /** - * Le compilateur à utiliser (par défaut celui de Swing) - * - * @parameter expression="${jaxx.validatorFQN}" default-value="jaxx.runtime.validator.swing.SwingValidator" - */ - protected String validatorFQN; - /** - * chemin du repertoire de generation des resources. - * - * @parameter expression="${jaxx.outResource}" default-value="${basedir}/target/generated-sources/resources" - */ - protected File outResource; - /** - * chemin du repertoire de compilation des resources. - * - * @parameter expression="${jaxx.outClass}" default-value="${basedir}/target/classes" - */ - protected File outClass; - /** - * Repertoire sources des fichiers jaxx a generer. - * - * @parameter expression="${jaxx.src}" default-value="${maven.src.dir}/main/java" - */ - protected File src; - /** - * pour optimizer le code compile ou genere ? - * - * @parameter expression="${jaxx.optimize}" default-value="false" - */ - protected boolean optimize; - /** - * les options de la compilation - * - * @parameter expression="${jaxx.javaOpts}" - */ - protected String javaOpts = null; - /** - * pour filter les fichiers a traiter - * - * @parameter expression="${jaxx.includes}" - */ - protected String[] includes; - /** - * pour filter les fichiers a ne pas traiter - * - * @parameter expression="${jaxx.excludes}" - */ - protected String[] excludes; - /** - * flag to include in compiler classpath the java sources directories (src and outJava). - * <p/> - * By default, false. - * - * @parameter expression="${jaxx.addSourcesToClassPath}" default-value="false" - */ - protected boolean addSourcesToClassPath; - /** - * flag to include in compiler classpath the java resources directories (src and outJava). - * <p/> - * By default, false. - * - * @parameter expression="${jaxx.addResourcesToClassPath}" default-value="false" - * @since 1.6.0 - */ - protected boolean addResourcesToClassPath; - /** - * flag to include in compiler classpath the compile class-path (can only be used in a test phase). - * <p/> - * By default, false. - * - * @parameter expression="${jaxx.addCompileClassPath}" default-value="false" - * @since 1.6.0 - */ - protected boolean addCompileClassPath; - /** - * flag to include in compiler classpath the project compile classpath. - * <p/> - * By default, false. - * - * @parameter expression="${jaxx.addProjectClassPath}" default-value="false" - */ - protected boolean addProjectClassPath; - /** - * to force generation of java source for any jaxx files with no timestamp checking. - * <p/> - * By default, never force generation. - * - * @parameter expression="${jaxx.force}" default-value="false" - */ - protected boolean force; - /** - * flag to add logger to each generated jaxx file. - * <p/> - * By default, always add it. - * - * @parameter expression="${jaxx.addLogger}" default-value="true" - */ - protected boolean addLogger; - /** - * flag to keep compilers after the generate operation (usefull for tests. - * <p/> - * By default, always reset. - * - * @parameter expression="${jaxx.resetAfterCompile}" default-value="true" - */ - protected boolean resetAfterCompile; - /** - * the name of implementation of {@link jaxx.runtime.JAXXContext} - * to be used on {@link jaxx.runtime.JAXXObject}. - * <p/> - * Must not be abstract. - * - * @parameter expression="${jaxx.jaxxContextImplementorClass}" default-value="jaxx.runtime.DefaultJAXXContext" - * @required - */ - protected String jaxxContextImplementorClass; - /** - * extra path to be added in {@link java.beans.Introspector#setBeanInfoSearchPath(String[])}. - * <p/> - * add beanInfoSearchPath to be registred by {@link BeanInfoUtil#addJaxxBeanInfoPath(String[])} - * <p/> - * and then will be use by {@link jaxx.tags.swing.SwingInitializer#initialize()}. - * <p/> - * <p/> - * This permit to use real beanInfo of imported graphic libraries. - * - * @parameter expression="${jaxx.beanInfoSearchPath}" - */ - protected String[] beanInfoSearchPath; - /** - * list of fqn of class toimport for all generated jaxx files - * - * @parameter expression="${jaxx.extraImports}" - * - * @deprecated Prefer use of extraImportList as a string, so - * could be use in properties section. - */ - protected String[] extraImports; - /** - * list of fqn of class toimport for all generated jaxx files - * - * @parameter expression="${jaxx.extraImportList}" - */ - protected String extraImportList; - /** - * the FQN of the ui to use for error notification. - * <p/> - * If not given, will use the one defined in validator - * - * @parameter expression="${jaxx.defaultErrorUIFQN}" - * @see jaxx.runtime.validator.swing.SwingValidator#DEFAULT_UI_CLASS - */ - protected String defaultErrorUIFQN; - /** - * the FQN of the ui to use for error notification. - * <p/> - * If not given, will use the one defined in validator - * - * @parameter expression="${jaxx.defaultDecorator}" default-value="jaxx.compiler.DefaultCompiledObjectDecorator" - * - * @see jaxx.compiler.CompiledObjectDecorator - */ - protected String defaultDecoratorFQN; - /** - * a flag to use UIManager to retreave icons. - * - * @parameter expression="${jaxx.useUIManagerForIcon}" default-value="false" - */ - protected boolean useUIManagerForIcon; - /** - * flag to activate profile mode. - * <p/> - * By default, not active. - * - * @parameter expression="${jaxx.profile}" default-value="false" - */ - protected boolean profile; - /** - * flag to activate help generation process. - * <p/> - * By default, not active. - * - * @parameter expression="${jaxx.generateHelp}" default-value="false" - * - * @since 1.3 - */ - protected boolean generateHelp; - /** - * the FQN of help broker - * <p/> - * By default, none. - * - * @parameter expression="${jaxx.helpBrokerFQN}" - * - * @since 1.3 - */ - protected String helpBrokerFQN; - /** - * A flag to mark themojo to be used in a test phase. This will permits to add generated sources in test compile roots. - * - * @parameter expression="${jaxx.testPhase}" default-value="false" - * @since 1.6.0 - */ - protected boolean testPhase; - protected String[] files; - private static final String[] INCLUDES = {"**\\/*.jaxx"}; - protected CompilerOptions options; - protected MirroredFileUpdater updater; - private Class<?> defaultErrorUIClass; - private Class<?> validatorClass; - private Class<? extends CompiledObjectDecorator> defaultDecoratorClass; - private Class<? extends JAXXCompiler> compilerClass; - - @SuppressWarnings("unchecked") - @Override - public boolean init() throws Exception { - 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 - if (helpIdStore == null) { - throw new MojoFailureException("you must set the helpIdStore property."); - } - } - skip = false; - - checkJaxxContextImplementorClass(); - - if (beanInfoSearchPath != null && beanInfoSearchPath.length > 0) { - // register extra path - BeanInfoUtil.addJaxxBeanInfoPath(beanInfoSearchPath); - } - if (!outResource.exists()) { - outResource.mkdirs(); - } - - if (!outJava.exists()) { - outJava.mkdirs(); - } - - fixCompileSourceRoots(); - - if (addSourcesToClassPath || addProjectClassPath) { - cl = initClassLoader(project, getLog()); - Thread.currentThread().setContextClassLoader(cl); - } else { - cl = getClass().getClassLoader(); - //cl = Thread.currentThread().getContextClassLoader(); - } - - - compilerClass = (Class<? extends JAXXCompiler>) Class.forName(compilerFQN, false, cl); - defaultDecoratorClass = (Class<? extends CompiledObjectDecorator>) Class.forName(defaultDecoratorFQN, false, cl); - - // check the validator class is correct - validatorClass = Class.forName(validatorFQN, false, cl); - - if (defaultErrorUIFQN != null && !defaultErrorUIFQN.trim().isEmpty()) { - defaultErrorUIClass = Class.forName(defaultErrorUIFQN, false, cl); - } - - DirectoryScanner ds; - ds = new DirectoryScanner(); - ds.setBasedir(src); - boolean noIncludes = includes == null || includes.length == 0; - ds.setIncludes(noIncludes ? INCLUDES : includes); - - if (excludes != null && excludes.length > 0) { - ds.setExcludes(excludes); - } - - ds.scan(); - String[] filesFind = ds.getIncludedFiles(); - if (verbose) { - getLog().info("jaxx - discover " + filesFind.length + " jaxx file(s). "); - } - - updater = FileUpdaterHelper.newJaxxFileUpdater(src, outJava); - - if (force) { - // we will regenerate all files - this.files = filesFind; - } else { - // filter files - List<String> listFiles = new ArrayList<String>(); - - for (String file : filesFind) { - if (updater.isFileUpToDate(new File(src, file))) { - if (verbose) { - getLog().info("jaxx - skip file [" + file + "]."); - } - } else { - if (verbose) { - getLog().info("jaxx - detect modify file [" + file + "]."); - } - listFiles.add(file); - } - } - this.files = listFiles.toArray(new String[listFiles.size()]); - } - - if (extraImportList != null && !extraImportList.isEmpty()) { - String[] imports = extraImportList.split(","); - int i = 0; - for (String importS : imports) { - imports[i++] = importS.trim(); - } - if (verbose) { - getLog().info("extra imports " + java.util.Arrays.toString(imports)); - } - extraImports = imports; - - } - options = toCompilerOptions(); - - if (verbose) { - printInit(); - } - return true; - } - - @Override - public void doAction() throws MojoExecutionException { - if (skip) { - if (verbose) { - getLog().info("jaxx - skip!"); - } - return; - } - getLog().info("jaxx - detects " + this.files.length + " modify jaxx file(s). "); - - try { - - // force compiler init from here, not in a static block - TagManager.reset(verbose); - - JAXXCompilerLaunchor launchor = JAXXCompilerLaunchor.newLaunchor(src, files, options); - boolean success = launchor.compile(); - getLog().info("jaxx - generate " + launchor.getCompilerCount() + " file(s). "); - - if (!success) { - throw new MojoExecutionException("Aborting due to errors reported by jaxxc"); - } - - if (generateHelp) { - // generate help - generateHelp(); - } - - } catch (MojoExecutionException e) { - getLog().error(e); - throw e; - } 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); - } - } - - public CompilerOptions toCompilerOptions() { - CompilerOptions result = new CompilerOptions(); - result.setClassPath(src.getPath()); - if (javaOpts != null && !"".equals(javaOpts)) { - result.setJavacOpts(javaOpts); - } - result.setCompilerClass(compilerClass); - result.setValidatorFQN(validatorFQN); - result.setValidatorClass(validatorClass); - result.setKeepJavaFiles(true); - result.setOptimize(optimize); - result.setJavacTargetDirectory(outClass); - result.setTargetDirectory(outJava); - result.setVerbose(verbose); - result.setI18nable(i18nable); - result.setAddLogger(addLogger); - result.setProfile(profile); - result.setResetAfterCompile(resetAfterCompile); - result.setJaxxContextImplementorClass(jaxxContextImplementorClass); - result.setExtraImports(extraImports); - result.setDefaultErrorUI(defaultErrorUIClass); - result.setUseUIManagerForIcon(useUIManagerForIcon); - result.setDefaultDecoratorClass(defaultDecoratorClass); - result.setGenerateHelp(generateHelp); - result.setHelpBrokerFQN(helpBrokerFQN); - result.setHelpsetTitleI18nSuffix(helpsetTitleI18nSuffix); - result.setHelpsetIndexI18nSuffix(helpsetIndexI18nSuffix); - result.setHelpsetTocI18nSuffix(helpsetTocI18nSuffix); - result.setHelpSetName(helpSetName); - result.setHelpsetI18nPrefix(helpsetI18nPrefix); - - if (cl != null) { - result.setClassLoader(cl); - } - 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 - return; - } - - if (testPhase) { - if (!project.getTestCompileSourceRoots().contains( - outJava.getPath())) { - getLog().info("Add test compile source root : " + outJava); - project.addTestCompileSourceRoot(outJava.getPath()); - } - } else { - if (!project.getCompileSourceRoots().contains(outJava.getPath())) { - getLog().info("Add compile source root : " + outJava); - project.addCompileSourceRoot(outJava.getPath()); - } - } - } - - protected void printInit() { - getLog().info(options.toString()); - getLog().info("includes : " + Arrays.toString(includes)); - for (String file : files) { - getLog().info("will generate " + file); - } - - ClassLoader threadLoader = Thread.currentThread().getContextClassLoader(); - getLog().info(threadLoader.toString()); - if (threadLoader.getClass().getSimpleName().equals("RealmClassLoader")) { - try { - java.lang.reflect.Method m = threadLoader.getClass().getDeclaredMethod("getURLs"); - m.setAccessible(true); - URL[] urls = (URL[]) m.invoke(threadLoader); - - for (URL url : urls) { - getLog().info("url in class loader " + url); - } - } catch (Exception e) { - 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() { - if (jaxxContextImplementorClass == null) { - throw new IllegalArgumentException("jaxxContextImplementor can not be null"); - } - try { - Class<?> jaxxContextImplementor = Class.forName(jaxxContextImplementorClass); - if (!JAXXContext.class.isAssignableFrom(jaxxContextImplementor)) { - throw new IllegalArgumentException("jaxxContextImplementor '" + jaxxContextImplementor + "' does not implements " + JAXXContext.class); - } - if (Modifier.isAbstract(jaxxContextImplementor.getModifiers())) { - throw new IllegalArgumentException("jaxxContextImplementor '" + jaxxContextImplementor + "' can not be abstract."); - - } - } catch (ClassNotFoundException e) { - throw new IllegalArgumentException("could not find jaxxContextImplementor class : " + jaxxContextImplementorClass); - } - } - - protected void generateHelp() throws IOException { - Set<String> helpIds = HelpRootCompiledObjectDecorator.getHelpIds(); - if (helpIds.isEmpty()) { - if (verbose) { - // no ids detected in this compilation round - getLog().info("no helpIds detected."); - } - return; - } - - if (!helpIdStore.getParentFile().exists()) { - helpIdStore.getParentFile().mkdirs(); - } - - Properties p = new Properties(); - - for (String helpId : helpIds) { - String path = helpId.replaceAll("\\.", File.separator); - path = removeQuote(path) + ".html"; - p.put(removeQuote(helpId), path); - } - - FileOutputStream w = new FileOutputStream(helpIdStore); - - try { - p.store(w, null); - } finally { - w.close(); - } - - getLog().info("helpIdStore generated in " + helpIdStore); - - helpIds.clear(); - } - - //TODO use the AbstractPublig method - @SuppressWarnings({"unchecked"}) - protected URLClassLoader initClassLoader(MavenProject project, org.apache.maven.plugin.logging.Log log) throws MalformedURLException { - URLClassLoader loader = null; - if (project != null) { - - URLClassLoader result; - try { - - List<URL> lUrls = new ArrayList<URL>(); - List<String> sources = project.getCompileSourceRoots(); - - if (addSourcesToClassPath) { - for (String source : sources) { - lUrls.add(new File(source).toURI().toURL()); - } - if (testPhase) { - for (Object source : project.getTestCompileSourceRoots()) { - lUrls.add(new File(source.toString()).toURI().toURL()); - } - } - } - if (addResourcesToClassPath) { - for (Object source : project.getResources()) { - Resource r = (Resource) source; - lUrls.add(new File(r.getDirectory()).toURI().toURL()); - } - } - if (testPhase && addCompileClassPath) { - if (project != null) { - lUrls.add(new File(project.getBuild().getOutputDirectory()).toURI().toURL()); - } - } - if (addProjectClassPath) { - getLog().info("use project compile scope class-path"); - // add also all dependencies of the project in compile scope - Set<?> artifacts = project.getArtifacts(); - for (Object o : artifacts) { - Artifact a = (Artifact) o; - lUrls.add(a.getFile().toURI().toURL()); - } - } - - result = new URLClassLoader(lUrls.toArray(new URL[lUrls.size()]), getClass().getClassLoader()); - - } catch (IOException e) { - throw new RuntimeException("Can't create ClassLoader for reason " + e.getMessage(), e); - } - loader = result; - } else { - List<URL> lUrls = new ArrayList<URL>(); - if (addSourcesToClassPath) { - lUrls.add(src.toURI().toURL()); - } - loader = new URLClassLoader(lUrls.toArray(new URL[lUrls.size()]), getClass().getClassLoader()); - } - if (verbose) { - for (URL entry : loader.getURLs()) { - log.info("classpath : " + entry); - } - } - return loader; - } - - protected String removeQuote(String txt) { - if (txt.startsWith("\"")) { - txt = txt.substring(1); - } - if (txt.endsWith("\"")) { - txt = txt.substring(0, txt.length() - 1); - } - return txt; - } -} Deleted: trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxHelpGeneratorMojo.java =================================================================== --- trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxHelpGeneratorMojo.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxHelpGeneratorMojo.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,795 +0,0 @@ -/* *##% - * Copyright (C) 2007 - * JaxxPlugin, Code Lutin - * - * 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 org.nuiton.jaxx.plugin; - -import org.apache.maven.plugin.MojoFailureException; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.Enumeration; -import java.util.List; -import java.util.Properties; -import java.util.Set; -import java.util.Stack; -import org.apache.maven.model.Resource; -import org.nuiton.i18n.I18n; -import org.nuiton.util.FileUtil; -import org.nuiton.util.SortedProperties; -import org.xml.sax.Attributes; -import org.xml.sax.ContentHandler; -import org.xml.sax.InputSource; -import org.xml.sax.Locator; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.XMLReaderFactory; -import static org.nuiton.i18n.I18n._; - -/** - * Mojo to generate javax help stuff for your project. - * - * HelpIds should have been discovered by the JaxxMojo. - * - * @author chemit - * @goal generate-help - * @phase process-sources - * - * @requiresProject - * @requiresDependencyResolution compile - * @since 1.3 - */ -public class JaxxHelpGeneratorMojo extends AbstractJaxxMojo { - - /** - * The directory where to generate javaHelp skeleton files. - * <p/> - * Is required if generateHelp is on. - * - * @parameter expression="${jaxx.helpTarget}" alias="target" default-value="${maven.src.dir}/main/help" - * @required - * - * @since 1.3 - */ - protected File target; - /** - * The locale to generate for help. - * - * By default, stay in France. - * - * @parameter expression="${jaxx.locale}" default-value="fr" - * @required - * - * @since 1.3 - */ - protected String locale; - /** - * The package where to generate i18n java file. - * - * @parameter expression="${jaxx.packageName}" default-value="${project.groupId}" - * @required - * - * @since 1.3 - */ - protected String packageName; - /** - * The file name of the helpset to generate. - * - * @parameter expression="${jaxx.helpSetFileName}" default-value="${jaxx.helpSetName}.hs" - * @required - * - * @since 1.3 - */ - protected String helpsetFileName; - /** - * The file name of the helpset map to generate. - * - * @parameter expression="${jaxx.mapFileName}" default-value="${jaxx.helpSetName}Map.jhm" - * @required - * - * @since 1.3 - */ - protected String mapFileName; - /** - * The file name of the helpset index to generate. - * - * @parameter expression="${jaxx.indexFileName}" default-value="${jaxx.helpSetName}Index.xml" - * @required - * - * @since 1.3 - */ - protected String indexFileName; - /** - * The file name of the helpset toc to generate. - * - * @parameter expression="${jaxx.tocFileName}" default-value="${jaxx.helpSetName}TOC.xml" - * @required - * - * @since 1.3 - */ - protected String tocFileName; - /** - * The file name of the i18n java file to generate. - * - * @parameter expression="${jaxx.i8nFileName}" default-value="${jaxx.helpSetName}I18n.java" - * @required - * - * @since 1.3 - */ - protected String i8nFileName; - /** - * The template used to generate helpset file. - * - * Must be an existing file or a ressource in classp-ath - * - * @parameter expression="${jaxx.helpSetTemplate}" default-value="/defaultHelpSet.hs.vm" - * @required - * - * @since 1.3 - */ - protected File helpSetTemplate; - /** - * The template used to generate helpset map file. - * - * Must be an existing file or a ressource in classp-ath - * - * @parameter expression="${jaxx.mapTemplate}" default-value="/defaultMap.jhm.vm" - * @required - * - * @since 1.3 - */ - protected File mapTemplate; - /** - * The template used to generate helpset index file. - * - * Must be an existing file or a ressource in classp-ath - * - * @parameter expression="${jaxx.indexTemplate}" default-value="/defaultIndex.xml.vm" - * @required - * - * @since 1.3 - */ - protected File indexTemplate; - /** - * The template used to generate helpset toc file. - * - * Must be an existing file or a ressource in classp-ath - * - * @parameter expression="${jaxx.tocTemplate}" default-value="/defaultToc.xml.vm" - * @required - * - * @since 1.3 - */ - protected File tocTemplate; - /** - * The template used to generate helpset content file. - * - * Must be an existing file or a ressource in classp-ath - * - * @parameter expression="${jaxx.contentTemplate}" default-value="/defaultContent.html.vm" - * @required - * - * @since 1.3 - */ - protected File contentTemplate; - /** - * The template used to generate helpset content file. - * - * Must be an existing file or a ressource in classp-ath - * - * @parameter expression="${jaxx.i18nTemplate}" default-value="/defaultI18n.java.vm" - * @required - * - * @since 1.3 - */ - protected File i18nTemplate; - /** - * The help ids discovered by Jaxx compilation - */ - protected Properties helpIds; - private static final String AUTOREMOVE_LINE = "REMOVE THS LINE TO DISABLE AUTO-REGENERATE THE FILE"; - - @Override - public boolean init() throws Exception { - - if (skip) { - return true; - } - - if (!helpIdStore.exists()) { - skip = true; - getLog().info("no helpIdStore to react at " + helpIdStore); - return false; - } - - // check there is some bundle - if (locale == null) { - throw new MojoFailureException("you must set the bundles property."); - } - // check there is some bundle - if (target == null) { - throw new MojoFailureException("you must set the target property."); - } - // check ressources - checkResource(helpSetTemplate); - checkResource(mapTemplate); - checkResource(indexTemplate); - checkResource(tocTemplate); - checkResource(contentTemplate); - - if (!target.exists()) { - getLog().info("mkdir " + target); - target.mkdirs(); - } - - - helpIds = new SortedProperties(); - - InputStream stream = new FileInputStream(helpIdStore); - - helpIds.load(stream); - - stream.close(); - - if (helpIds.isEmpty()) { - - // no ids detected - getLog().warn("no helpIds detected, will skip."); - skip = true; - return false; - } - - skip = false; - return true; - } - - @Override - public void doAction() throws Exception { - - if (skip) { - if (verbose) { - getLog().info("jaxx - skip!"); - } - return; - } - - if (i18nable) { - - List<URL> lUrls = new java.util.ArrayList<URL>(); - List<?> resources = project.getResources(); - for (Object o : resources) { - Resource resource = (Resource) o; - lUrls.add(new File(resource.getDirectory()).toURI().toURL()); - } - I18n.setExtraURL(lUrls.toArray(new URL[lUrls.size()])); - I18n.init(locale, null); - } - - File file; - - Properties env = new Properties(); - - env.put("helpSetName", helpSetName); - env.put("helpSetFileName", helpsetFileName); - env.put("mapFileName", mapFileName); - env.put("indexFileName", indexFileName); - env.put("tocFileName", tocFileName); - env.put("separator", " "); - env.put("autoremoveLine", AUTOREMOVE_LINE); - - - int touchedFiles = 0; - - // --------------------------------------------------------------- - // --- main helpset file ----------------------------------------- - // --------------------------------------------------------------- - - - file = new File(target, helpsetFileName); - - boolean doCreate = generateHelSetFile(file, env); - - if (doCreate) { - touchedFiles++; - } - - // --------------------------------------------------------------- - // --- helpset map file ------------------------------------------ - // --------------------------------------------------------------- - - file = new File(target, mapFileName); - - Properties mergedHelpIds = generateMapFile(file, env); - touchedFiles++; - - // --------------------------------------------------------------- - // --- helpset index file ---------------------------------------- - // --------------------------------------------------------------- - - file = new File(target, indexFileName); - - NodeItem indexRootItem = generateIndexFile(file, env); - touchedFiles++; - - // --------------------------------------------------------------- - // --- helpset toc file ------------------------------------------ - // --------------------------------------------------------------- - - file = new File(target, tocFileName); - - NodeItem tocRootItem = generateTocFile(file, env); - touchedFiles++; - - // --------------------------------------------------------------- - // --- helpset content files ------------------------------------- - // --------------------------------------------------------------- - - TemplateGenerator gen = prepareGenerator(contentTemplate); - - Enumeration<?> keys = helpIds.keys(); - - while (keys.hasMoreElements()) { - String key = (String) keys.nextElement(); - String url = (String) helpIds.get(key); - url = helpSetName + File.separator + url; - - File f = new File(target, url); - - boolean exist = f.exists(); - - if (exist) { - // check if there is a autoremoveLine in content - String content = FileUtil.readAsString(f); - if (!content.contains(AUTOREMOVE_LINE)) { - // no regenerate marker detected, so skip this file - if (verbose) { - getLog().debug("skip existing file " + f); - } - continue; - } - } - - f.getParentFile().mkdirs(); - - if (verbose) { - if (exist) { - getLog().info("regenerate content file " + f); - } else { - getLog().info("generate content file " + f); - } - } - - env.put("helpId", key); - String i18n = helpsetI18nPrefix + key + helpsetTitleI18nSuffix; - env.put("helpIdTitle", _(i18n)); - env.put("helpIdUrl", url); - - gen.generate(env, f); - touchedFiles++; - } - - // --------------------------------------------------------------- - // --- i18n file ------------------------------------------------- - // --------------------------------------------------------------- - - String path = packageName.replaceAll("\\.", File.separator); - path += File.separator + i8nFileName; - file = new File(outJava, path); - generateI18nFile(file, env, mergedHelpIds, indexRootItem, tocRootItem); - touchedFiles++; - - getLog().info(touchedFiles + " file(s) treated."); - } - - protected void generateI18nFile(File file, Properties env, Properties mergedHelpIds, NodeItem indexRootItem, NodeItem tocRootItem) throws Exception { - - boolean create = !file.exists(); - - if (!file.getParentFile().exists()) { - file.getParentFile().mkdirs(); - } - - Set<String> keys = new java.util.HashSet<String>(); - - for (Object k : mergedHelpIds.keySet()) { - String key = helpsetI18nPrefix + k + helpsetTitleI18nSuffix; - keys.add(key); - } - indexRootItem.extractI18n(keys, helpsetI18nPrefix, helpsetIndexI18nSuffix); - tocRootItem.extractI18n(keys, helpsetI18nPrefix, helpsetTocI18nSuffix); - - env.put("keys", keys); - env.put("packageName", packageName); - String className = file.getName(); - int index = className.lastIndexOf("."); - className = className.substring(0, index); - env.put("className", className); - - if (verbose) { - if (create) { - getLog().info("generate i18n java file " + file); - } else { - getLog().info("udpate i18n java file " + file); - } - } - - doGen(i18nTemplate, file, env); - - } - - protected boolean generateHelSetFile(File file, Properties env) throws Exception { - - if (file.exists()) { - // check the auto removeline presence - String content = FileUtil.readAsString(file); - if (!content.contains(AUTOREMOVE_LINE)) { - // no regenerate marker detected, so skip this file - if (verbose) { - getLog().info("skip existing helpset main file " + file); - } - return false; - } - } - - if (verbose) { - if (file.exists()) { - getLog().info("regenerate helpset main file " + file); - } else { - getLog().info("generate helpset main file " + file); - } - } - doGen(helpSetTemplate, file, env); - return true; - } - - protected Properties generateMapFile(File file, Properties env) throws Exception { - - boolean create; - - Properties mergedHelpIds = null; - if (file.exists()) { - - // get back the exisiting data and merge it with incoming ones - - if (verbose) { - getLog().info("loading existing helpset map file " + file); - } - - mergedHelpIds = getExistingHelpIds(file); - create = false; - - } else { - - mergedHelpIds = new SortedProperties(); - create = true; - } - - // inject new helpIds - - for (Object k : helpIds.keySet()) { - mergedHelpIds.put(k, helpSetName + "/" + helpIds.get(k)); - } - - if (!mergedHelpIds.contains("top")) { - // on ajoute une entree vers le root du helpset - - String topUrl = helpSetName + ".html"; - helpIds.put("top", topUrl); - mergedHelpIds.put("top", helpSetName + "/" + topUrl); - if (verbose) { - getLog().debug("add top entry with url " + topUrl); - } - } - - if (verbose) { - if (create) { - getLog().info("generate helpset map file " + file); - } else { - getLog().info("udpate helpset map file " + file); - } - } - - env.put("helpIds", mergedHelpIds); - doGen(mapTemplate, file, env); - env.remove("helpIds"); - return mergedHelpIds; - } - - protected NodeItem generateIndexFile(File file, Properties env) throws Exception { - NodeItem rootItem = null; - - boolean create; - - if (file.exists()) { - - create = false; - - rootItem = getExistingItems("indexitem", file); - } else { - create = true; - } - - if (rootItem == null) { - rootItem = new NodeItem("top", helpSetName); - } - - // inject new index entries - - for (Object k : helpIds.keySet()) { - NodeItem toc = rootItem.findChild(k + ""); - if (verbose) { - getLog().debug("index " + k + " : " + toc); - } - } - - //String prefix = helpsetI18nPrefix; - //String prefix = helpsetI18nPrefix + helpSetName + "."; - rootItem.applyI18n(helpsetI18nPrefix, helpsetIndexI18nSuffix); - - if (verbose) { - if (create) { - getLog().info("generate helpset index file " + file); - } else { - getLog().info("udpate helpset index file " + file); - } - } - - env.put("rootItem", rootItem); - doGen(indexTemplate, file, env); - env.remove("rootItem"); - return rootItem; - } - - protected NodeItem generateTocFile(File file, Properties env) throws Exception { - NodeItem rootItem = null; - - boolean create; - - if (file.exists()) { - - create = false; - - rootItem = getExistingItems("tocitem", file); - } else { - create = true; - } - - if (rootItem == null) { - rootItem = new NodeItem("top", helpSetName); - } - // inject new toc entries - - for (Object k : helpIds.keySet()) { - NodeItem toc = rootItem.findChild(k + ""); - if (verbose) { - getLog().debug("toc " + k + " : " + toc); - } - } - - //String prefix = helpsetI18nPrefix + helpSetName + "."; - rootItem.applyI18n(helpsetI18nPrefix, helpsetTocI18nSuffix); - - if (verbose) { - if (create) { - getLog().info("generate helpset toc file " + file); - } else { - getLog().info("udpate helpset toc file " + file); - } - } - - env.put("rootItem", rootItem); - doGen(tocTemplate, file, env); - env.remove("rootItem"); - return rootItem; - } - - protected void doGen(File template, File f, Properties env) throws Exception { - TemplateGenerator gen = prepareGenerator(template); - gen.generate(env, f); - } - - protected TemplateGenerator prepareGenerator(File template) throws Exception { - URL templateURL = getTemplate(template); - - if (verbose) { - getLog().info("using template " + templateURL); - } - TemplateGenerator gen = new TemplateGenerator(project, templateURL); - return gen; - } - -// protected URL getTemplate(File f) throws IOException { -// URL r = null; -// if (f.exists()) { -// r = f.toURI().toURL(); -// } else { -// r = getClass().getResource(f.toString()); -// } -// return r; -// } -// -// protected void checkResource(File f) throws MojoFailureException { -// if (!f.exists()) { -// // test in classPath -// InputStream r = getClass().getResourceAsStream(f.toString()); -// if (r == null) { -// throw new MojoFailureException("could not find ressource " + f); -// } -// } -// } - protected Properties getExistingHelpIds(File file) throws SAXException, IOException { - - final Properties result = new SortedProperties(); - - XMLReader parser = XMLReaderFactory.createXMLReader(); - - parser.setContentHandler(new ContentHandlerAdapter() { - - String target; - String url; - - @Override - public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException { - if ("mapID".equals(localName)) { - target = atts.getValue("target"); - url = atts.getValue("url"); - if (verbose) { - getLog().debug("detect map entry : " + target + " : " + url); - } - result.put(target, url); - } - } - }); - - InputStream s = new FileInputStream(file); - try { - parser.parse(new InputSource(s)); - } finally { - s.close(); - } - return result; - } - - protected NodeItem getExistingItems(String tagName, File file) throws SAXException, IOException { - - XMLReader parser = XMLReaderFactory.createXMLReader(); - NodeItemHandler handler = new NodeItemHandler(tagName); - - parser.setContentHandler(handler); - - NodeItem rootItem = null; - InputStream s = new FileInputStream(file); - try { - parser.parse(new InputSource(s)); - rootItem = handler.rootItem; - } finally { - s.close(); - } - return rootItem; - } - - static class NodeItemHandler extends ContentHandlerAdapter { - - NodeItem rootItem; - NodeItem currentItem; - final Stack<NodeItem> stack; - final String tagName; - - public NodeItemHandler(String tagName) { - this.tagName = tagName; - this.stack = new Stack<NodeItem>(); - } - - @Override - public void startDocument() throws SAXException { - rootItem = new NodeItem("top", null); - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException { - if (tagName.equals(localName)) { - - String target = atts.getValue("target"); - String text = atts.getValue("text"); - - // debut d'un item - if (currentItem == null) { - // premier item - if (rootItem.getTarget().equals(target)) { - // le premier item est bien top - //rootItem.setText(text); - currentItem = rootItem; - } else { - // le premier noeud n'est pas top - // en l'encapsule - stack.push(rootItem); - currentItem = new NodeItem(target, text); - rootItem.addChild(currentItem); - } - } else { - NodeItem newItem = new NodeItem(target, text); - currentItem.addChild(newItem); - currentItem = newItem; - } - currentItem.adjustTarget(); - stack.push(currentItem); - - } - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - if (tagName.equals(localName)) { - // fin d'un item - stack.pop(); - if (!stack.isEmpty()) { - currentItem = stack.peek(); - } - } - } - } - - static class ContentHandlerAdapter implements ContentHandler { - - @Override - public void setDocumentLocator(Locator locator) { - } - - @Override - public void startDocument() throws SAXException { - } - - @Override - public void endDocument() throws SAXException { - } - - @Override - public void startPrefixMapping(String prefix, String uri) throws SAXException { - } - - @Override - public void endPrefixMapping(String prefix) throws SAXException { - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException { - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - } - - @Override - public void characters(char[] ch, int start, int length) throws SAXException { - } - - @Override - public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException { - } - - @Override - public void processingInstruction(String target, String data) throws SAXException { - } - - @Override - public void skippedEntity(String name) throws SAXException { - } - } -} Modified: trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/NodeItem.java =================================================================== --- trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/NodeItem.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/NodeItem.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Maven plugin + * 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>. + * ##%* + */ package org.nuiton.jaxx.plugin; import java.util.ArrayList; @@ -35,6 +55,10 @@ return childs; } + public void setText(String text) { + this.text = text; + } + public NodeItem findChild(String path) { NodeItem result = null; String[] paths = path.split("\\."); Deleted: trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/TemplateGenerator.java =================================================================== --- trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/TemplateGenerator.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/TemplateGenerator.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,142 +0,0 @@ -/* - * Copyright 2001-2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License" ); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.nuiton.jaxx.plugin; - -import java.io.File; -import java.io.FileWriter; -import java.net.URISyntaxException; -import java.net.URL; -import java.util.Iterator; -import java.util.Properties; - -import org.apache.maven.project.MavenProject; -import org.apache.velocity.Template; -import org.apache.velocity.VelocityContext; -import org.apache.velocity.app.VelocityEngine; - -/** - * Generator of template base on velocity. - * - * @author chemit - * @since 1.3 - * - */ -public class TemplateGenerator { - - protected VelocityEngine engine; - protected final MavenProject mavenProject; - protected Template velocityTemplate; - - protected TemplateGenerator(MavenProject mavenProject, URL template) throws URISyntaxException { - - if (mavenProject == null) { - throw new IllegalArgumentException("mavenProject must not be null"); - } - - if (template == null) { - throw new IllegalArgumentException("template must not be null"); - } - - this.mavenProject = mavenProject; - - Properties props = new Properties(); - - String templateName; - - if (template.toURI().isOpaque()) { - - // template is in a jar - - props = new Properties(); - props.setProperty("resource.loader", "jar"); - props.setProperty("jar.resource.loader.description", "Jar resource loader for default webstart templates"); - props.setProperty("jar.resource.loader.class", "org.apache.velocity.runtime.resource.loader.JarResourceLoader"); - - // obtain the jar url - - String url = template.toString(); - int i = url.indexOf("!"); - templateName = url.substring(i + 2); - - props.setProperty("jar.resource.loader.path", url.substring(0, i + 2)); - - } else { - - - templateName = new File(template.getFile()).getName(); - - //props.setProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM_CLASS, "org.apache.velocity.runtime.log.NullLogSystem"); - props.setProperty("file.resource.loader.path", template.getFile()); - - } - - try { - engine = new VelocityEngine(); - //engine.setProperty("runtime.log.logsystem", new NullLogSystem()); - engine.init(props); - } catch (Exception e) { - IllegalArgumentException iae = new IllegalArgumentException("Could not initialise Velocity"); - iae.initCause(e); - throw iae; - } - - try { - this.velocityTemplate = engine.getTemplate(templateName); - } catch (Exception e) { - IllegalArgumentException iae = - new IllegalArgumentException("Could not load the template file from '" + template + "'"); - iae.initCause(e); - throw iae; - } - } - - public void generate(Properties context, File outputFile) throws Exception { - - - VelocityContext vcontext = new VelocityContext(); - - // Note: properties that contain dots will not be properly parsed by Velocity. Should we replace dots with underscores ? - addPropertiesToContext(System.getProperties(), vcontext); - - addPropertiesToContext(mavenProject.getProperties(), vcontext); - addPropertiesToContext(context, vcontext); - - vcontext.put("project", mavenProject.getModel()); - - vcontext.put("outputFile", outputFile.getName()); - - FileWriter writer = new FileWriter(outputFile); - - try { - velocityTemplate.merge(vcontext, writer); - writer.flush(); - } catch (Exception e) { - throw new Exception("Could not generate the template " + velocityTemplate.getName() + ": " + e.getMessage(), e); - } finally { - writer.close(); - } - } - - protected void addPropertiesToContext(Properties properties, VelocityContext context) { - - for (Iterator<?> iter = properties.keySet().iterator(); iter.hasNext();) { - String key = (String) iter.next(); - Object value = properties.get(key); - context.put(key, value); - } - - } -} Copied: trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/XmlHelper.java (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/XmlHelper.java) =================================================================== --- trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/XmlHelper.java (rev 0) +++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/XmlHelper.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,207 @@ +/* + * *##% + * JAXX Maven plugin + * 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>. + * ##%* + */ +package org.nuiton.jaxx.plugin; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; +import java.util.Stack; +import org.apache.maven.plugin.logging.Log; +import org.nuiton.util.SortedProperties; +import org.xml.sax.Attributes; +import org.xml.sax.ContentHandler; +import org.xml.sax.InputSource; +import org.xml.sax.Locator; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; +import org.xml.sax.helpers.XMLReaderFactory; + +/** + * To load {@link NodeItem} from xml. + * + * @author chemit + * @since 2.0.0 + */ +public class XmlHelper { + + public static Properties getExistingHelpIds(File file, final boolean verbose, final Log log) throws SAXException, IOException { + + final Properties result = new SortedProperties(); + + XMLReader parser = XMLReaderFactory.createXMLReader(); + + parser.setContentHandler(new ContentHandlerAdapter() { + + String target; + String url; + + @Override + public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException { + if ("mapID".equals(localName)) { + target = atts.getValue("target"); + url = atts.getValue("url"); + if (verbose) { + log.debug("detect map entry : " + target + " : " + url); + } + result.put(target, url); + } + } + }); + + InputStream s = new FileInputStream(file); + try { + parser.parse(new InputSource(s)); + } finally { + if (s != null) { + s.close(); + } + } + return result; + } + + public static NodeItem getExistingItems(String tagName, File file) throws SAXException, IOException { + + XMLReader parser = XMLReaderFactory.createXMLReader(); + NodeItemHandler handler = new NodeItemHandler(tagName); + + parser.setContentHandler(handler); + + NodeItem rootItem = null; + InputStream s = new FileInputStream(file); + try { + parser.parse(new InputSource(s)); + rootItem = handler.rootItem; + } finally { + s.close(); + } + return rootItem; + } + + static class NodeItemHandler extends ContentHandlerAdapter { + + NodeItem rootItem; + NodeItem currentItem; + final Stack<NodeItem> stack; + final String tagName; + + public NodeItemHandler(String tagName) { + this.tagName = tagName; + this.stack = new Stack<NodeItem>(); + } + + @Override + public void startDocument() throws SAXException { + rootItem = new NodeItem("top", null); + } + + @Override + public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException { + if (tagName.equals(localName)) { + + String target = atts.getValue("target"); + String text = atts.getValue("text"); + + // debut d'un item + if (currentItem == null) { + // premier item + if (rootItem.getTarget().equals(target)) { + // le premier item est bien top + rootItem.setText(text); + currentItem = rootItem; + } else { + // le premier noeud n'est pas top + // en l'encapsule + stack.push(rootItem); + currentItem = new NodeItem(target, text); + rootItem.addChild(currentItem); + } + } else { + NodeItem newItem = new NodeItem(target, text); + currentItem.addChild(newItem); + currentItem = newItem; + } + currentItem.adjustTarget(); + stack.push(currentItem); + + } + } + + @Override + public void endElement(String uri, String localName, String qName) throws SAXException { + if (tagName.equals(localName)) { + // fin d'un item + stack.pop(); + if (!stack.isEmpty()) { + currentItem = stack.peek(); + } + } + } + } + + static class ContentHandlerAdapter implements ContentHandler { + + @Override + public void setDocumentLocator(Locator locator) { + } + + @Override + public void startDocument() throws SAXException { + } + + @Override + public void endDocument() throws SAXException { + } + + @Override + public void startPrefixMapping(String prefix, String uri) throws SAXException { + } + + @Override + public void endPrefixMapping(String prefix) throws SAXException { + } + + @Override + public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException { + } + + @Override + public void endElement(String uri, String localName, String qName) throws SAXException { + } + + @Override + public void characters(char[] ch, int start, int length) throws SAXException { + } + + @Override + public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException { + } + + @Override + public void processingInstruction(String target, String data) throws SAXException { + } + + @Override + public void skippedEntity(String name) throws SAXException { + } + } +} Modified: trunk/maven-jaxx-plugin/src/main/resources/defaultContent.html.vm =================================================================== --- trunk/maven-jaxx-plugin/src/main/resources/defaultContent.html.vm 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/main/resources/defaultContent.html.vm 2009-12-02 13:59:28 UTC (rev 1673) @@ -2,11 +2,11 @@ <HTML> <HEAD> <TITLE> -$helpIdTitle +$helpId </TITLE> </HEAD> <BODY BGCOLOR="#ffffff"> -<H1>$helpIdTitle</H1> +<H1>$helpId</H1> <!-- $autoremoveLine --> Modified: trunk/maven-jaxx-plugin/src/main/resources/defaultHelpSet.hs.vm =================================================================== --- trunk/maven-jaxx-plugin/src/main/resources/defaultHelpSet.hs.vm 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/main/resources/defaultHelpSet.hs.vm 2009-12-02 13:59:28 UTC (rev 1673) @@ -3,7 +3,7 @@ PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp HelpSet Version 1.0//EN" "http://java.sun.com/products/javahelp/helpset_1_0.dtd"> -<helpset version="1.0"> +<helpset version="1.0" xml:lang="$locale"> <!-- $autoremoveLine --> @@ -13,7 +13,7 @@ <!-- maps --> <maps> <homeID>top</homeID> - <mapref location="$mapFileName"/> + <mapref location="$localePath/$mapFileName"/> </maps> <!-- views --> @@ -21,23 +21,23 @@ <name>TOC</name> <label>Table Of Contents</label> <type>javax.help.TOCView</type> - <data>$tocFileName</data> + <data>$localePath/$tocFileName</data> </view> <view> <name>Index</name> <label>Index</label> <type>javax.help.IndexView</type> - <data>$indexFileName</data> + <data>$localePath/$indexFileName</data> </view> -#if ( $!searchData != "" ) +#if ( $generateSearch ) <view> <name>Search</name> <label>Search</label> <type>javax.help.SearchView</type> <data engine="com.sun.java.help.search.DefaultSearchEngine"> - $searchData + $localePath/JavaHelpSearch </data> </view> #end Modified: trunk/maven-jaxx-plugin/src/main/resources/log4j.properties =================================================================== --- trunk/maven-jaxx-plugin/src/main/resources/log4j.properties 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/main/resources/log4j.properties 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,9 +1,9 @@ # Global logging configuration -log4j.rootLogger=INFO, stdout +log4j.rootLogger=WARN, stdout # Console output... log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n log4j.logger.org.nuiton.i18n=ERROR -#log4j.logger.jaxx=DEBUG +log4j.logger.jaxx=INFO Modified: trunk/maven-jaxx-plugin/src/site/rst/index.rst =================================================================== --- trunk/maven-jaxx-plugin/src/site/rst/index.rst 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/site/rst/index.rst 2009-12-02 13:59:28 UTC (rev 1673) @@ -4,10 +4,23 @@ .. contents:: -Présentation +Introduction ------------ -Le plugin maven pour lancer le compilateur jaxx dans un projet maven TODO +The plugin permits to generate java files from jaxx files via the `generate`_ goal. -**Veuillez consulter la JavaDoc pour de plus ample détails sur les différentes -librairies.** +You can also generate the java help system via the `generate-help`_ goal. + +Default layout +-------------- + +The plugin defines some directory layout convention, using them is a great +benefit. + + * the jaxx files should be under *src/main/java* + * the generated java files should be under *target/generated-sources/java* + * the java help files should be under *src/main/help* + +.. _generate: generate-mojo.html + +.. _generate-help: generate-help-mojo.html Modified: trunk/maven-jaxx-plugin/src/site/site.xml =================================================================== --- trunk/maven-jaxx-plugin/src/site/site.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/site/site.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -19,17 +19,11 @@ <item name="Accueil" href="index.html"/> <item name="Détail goals" href="plugin-info.html"> <item name="generate" href="generate-mojo.html"/> + <item name="generate-help" href="generate-help-mojo.html"/> <item name="help" href="help-mojo.html"/> </item> </menu> - <menu name="Téléchargement" inherit="top"> - <item href="${labs.builder.url}/org/codelutin/jaxx/${project.artifactId}/${project.version}" - name="Télécharger la dernière version"/> - <item href="${labs.builder.url}/org/codelutin/jaxx/${project.artifactId}" - name="Voir toutes les versions"/> - </menu> - <menu name="Développeur" inherit="top"> <item name="A faire" href="Todo.html"/> </menu> Modified: trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1722Test.java =================================================================== --- trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1722Test.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1722Test.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Maven plugin + * 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>. + * ##%* + */ package org.nuiton.jaxx.plugin; import org.junit.Test; Modified: trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1750Test.java =================================================================== --- trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1750Test.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1750Test.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,8 +1,27 @@ +/* + * *##% + * JAXX Maven plugin + * 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>. + * ##%* + */ package org.nuiton.jaxx.plugin; -import jaxx.Base64Coder; +import jaxx.runtime.Base64Coder; import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.JAXXCompilerLaunchor; import jaxx.runtime.JAXXObjectDescriptor; import jaxx.runtime.Util; @@ -17,7 +36,7 @@ getMojo().execute(); assertNumberJaxxFiles(1); - JAXXCompiler compiler = JAXXCompilerLaunchor.get().getJAXXCompiler("org.nuiton.jaxx.plugin.Bug1750Test.ComboBox"); + JAXXCompiler compiler = getMojo().getEngine().getJAXXCompiler("org.nuiton.jaxx.plugin.bug1750Test.ComboBox"); assertNotNull(compiler); JAXXObjectDescriptor descriptor = compiler.getJAXXObjectDescriptor(); Modified: trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1751Test.java =================================================================== --- trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1751Test.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1751Test.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Maven plugin + * 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>. + * ##%* + */ package org.nuiton.jaxx.plugin; import org.junit.Test; @@ -7,12 +27,12 @@ @Test public void Bug_1751() throws Exception { - JaxxGeneratorMojo mojo = getMojo(); + GenerateMojo mojo = getMojo(); mojo.execute(); assertNumberJaxxFiles(3); checkPattern(mojo, "implements java.io.Serializable", true); - checkPattern(mojo, "label.setText(_(\"test\"))", true); + checkPattern(mojo, "setText(_(\"test\"))", true); } } \ No newline at end of file Modified: trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerTest.java =================================================================== --- trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,15 +1,30 @@ +/* + * *##% + * JAXX Maven plugin + * 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>. + * ##%* + */ package org.nuiton.jaxx.plugin; -import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.JAXXCompilerLaunchor; -import jaxx.runtime.DefaultJAXXContext; -import jaxx.runtime.JAXXContext; +import jaxx.runtime.context.DefaultJAXXContext; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.SystemStreamLog; import java.io.File; -import java.lang.reflect.Field; -import java.util.Map; import org.junit.Test; import static org.junit.Assert.*; @@ -24,7 +39,7 @@ @Test public void Icon() throws Exception { - JaxxGeneratorMojo mojo = getMojo(); + GenerateMojo mojo = getMojo(); mojo.execute(); checkPattern(mojo, ".createImageIcon(\"myIcon.png\")", true); checkPattern(mojo, ".createActionIcon(\"myActionIcon.png\")", true); @@ -41,7 +56,7 @@ @Test public void ClientProperty() throws Exception { - JaxxGeneratorMojo mojo = getMojo(); + GenerateMojo mojo = getMojo(); mojo.execute(); checkPattern(mojo, ".putClientProperty(\"testOne\", \"oneTest\")", true); checkPattern(mojo, ".putClientProperty(\"testTwo\", \"anotherTest\")", true); @@ -61,7 +76,7 @@ @Test public void WithLog() throws Exception { - JaxxGeneratorMojo mojo = getMojo(); + GenerateMojo mojo = getMojo(); mojo.execute(); String[] files = mojo.files; assertNumberJaxxFiles(2); @@ -86,7 +101,7 @@ @Test public void NoLog() throws Exception { - JaxxGeneratorMojo mojo = getMojo(); + GenerateMojo mojo = getMojo(); mojo.execute(); assertNumberJaxxFiles(2); checkPattern(mojo, "Log log = LogFactory.getLog(", false); @@ -97,7 +112,7 @@ @SuppressWarnings({"unchecked"}) @Test public void Errors() throws Exception { - JaxxGeneratorMojo mojo = getMojo(); + GenerateMojo mojo = getMojo(); // init mojo to get alls files to treate mojo.init(); @@ -124,12 +139,7 @@ //do nothing } }); - Field fieldCompilers = JAXXCompilerLaunchor.class.getDeclaredField("compilers"); - Field fieldErrorCount = JAXXCompilerLaunchor.class.getDeclaredField("errorCount"); - fieldCompilers.setAccessible(true); - fieldErrorCount.setAccessible(true); - // execute mjo on each jaxx file to produce the error for (String file : mojo.files) { log.info("test bad file " + file); @@ -141,14 +151,7 @@ } catch (MojoExecutionException e) { // ok jaxx compiler failed assertTrue(true); - - JAXXCompilerLaunchor launchor = JAXXCompilerLaunchor.get(); - Map<String, JAXXCompiler> compilers = (Map<String, JAXXCompiler>) fieldCompilers.get(launchor); - assertEquals(1, compilers.size()); - //JAXXCompiler compiler; - //compiler = compilers.values().iterator().next(); - Integer nberrors = (Integer) fieldErrorCount.get(launchor); - assertTrue(nberrors != null && nberrors > 0); + assertError(mojo.getEngine(), file, 1); } } } @@ -161,32 +164,32 @@ @Test public void ErrorJaxxContextImplementorClass() throws Exception { - JaxxGeneratorMojo mojo = getMojo(); - mojo.jaxxContextImplementorClass = null; + GenerateMojo mojo = getMojo(); + mojo.jaxxContextFQN = null; try { mojo.init(); fail(); - } catch (IllegalArgumentException e) { + } catch (NullPointerException e) { assertTrue(true); } - mojo.jaxxContextImplementorClass = String.class.getName(); + mojo.jaxxContextFQN = String.class.getName(); try { mojo.init(); fail(); - } catch (IllegalArgumentException e) { + } catch (MojoExecutionException e) { assertTrue(true); } +// +// mojo.jaxxContextFQN = JAXXContext.class.getName(); +// try { +// mojo.init(); +// fail(); +// } catch (IllegalArgumentException e) { +// assertTrue(true); +// } - mojo.jaxxContextImplementorClass = JAXXContext.class.getName(); - try { - mojo.init(); - fail(); - } catch (IllegalArgumentException e) { - assertTrue(true); - } - - mojo.jaxxContextImplementorClass = DefaultJAXXContext.class.getName(); + mojo.jaxxContextFQN = DefaultJAXXContext.class.getName(); mojo.init(); assertTrue(true); @@ -214,7 +217,7 @@ public void Force() throws Exception { // first round, with force option so will generate theonly JButton.jaxx file - JaxxGeneratorMojo mojo = getMojo(); + GenerateMojo mojo = getMojo(); mojo.execute(); String[] files = mojo.files; assertNumberJaxxFiles(1); Modified: trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerValidatorTest.java =================================================================== --- trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerValidatorTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerValidatorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,11 +1,28 @@ +/* + * *##% + * JAXX Maven plugin + * 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>. + * ##%* + */ package org.nuiton.jaxx.plugin; -import jaxx.compiler.JAXXCompilerLaunchor; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.SystemStreamLog; -import java.lang.reflect.Field; -import java.util.Map; import org.junit.Test; @@ -24,11 +41,12 @@ @SuppressWarnings({"unchecked"}) public void ValidatorErrors() throws Exception { // init mojo to get alls files to treate - JaxxGeneratorMojo mojo = getMojo(); + GenerateMojo mojo = getMojo(); mojo.init(); String[] files = mojo.files; assertNumberJaxxFiles(19); mojo.setLog(new SystemStreamLog() { + @Override public boolean isErrorEnabled() { return false; @@ -49,12 +67,7 @@ //do nothing } }); - Field fieldCompilers = JAXXCompilerLaunchor.class.getDeclaredField("compilers"); - Field fieldErrorCount = JAXXCompilerLaunchor.class.getDeclaredField("errorCount"); - fieldCompilers.setAccessible(true); - fieldErrorCount.setAccessible(true); - // execute mjo on each jaxx file to produce the error for (String file : files) { log.info("test bad file " + file); @@ -66,14 +79,8 @@ } catch (MojoExecutionException e) { // ok jaxx compiler failed assertTrue(true); - JAXXCompilerLaunchor launchor = JAXXCompilerLaunchor.get(); - Map<String, Compiler> compilers = (Map<String, Compiler>) fieldCompilers.get(launchor); - assertEquals(1, compilers.size()); - //Compiler compiler = compilers.values().iterator().next(); - Integer nberrors = (Integer) fieldErrorCount.get(launchor); - assertEquals(1, nberrors.intValue()); + assertError(mojo.getEngine(), file, 1); } } } - -} \ No newline at end of file +} Deleted: trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBinding/Bean.java =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBinding/Bean.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBinding/Bean.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,36 +0,0 @@ -/* - * *##% - * JAXX Maven plugin - * 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>. - * ##%* - */ -package org.nuiton.jaxx.plugin.DataBinding; - -import java.beans.PropertyChangeListener; - -public interface Bean { - - void addPropertyChangeListener(PropertyChangeListener listener); - - void addPropertyChangeListener(String propertyName, PropertyChangeListener listener); - - void removePropertyChangeListener(PropertyChangeListener listener); - - void removePropertyChangeListener(String propertyName, PropertyChangeListener listener); - - String getText(); -} Copied: trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBinding/Bean.java (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBinding/Bean.java) =================================================================== --- trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBinding/Bean.java (rev 0) +++ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBinding/Bean.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,36 @@ +/* + * *##% + * JAXX Maven plugin + * 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>. + * ##%* + */ +package org.nuiton.jaxx.plugin.DataBinding; + +import java.beans.PropertyChangeListener; + +public interface Bean { + + void addPropertyChangeListener(PropertyChangeListener listener); + + void addPropertyChangeListener(String propertyName, PropertyChangeListener listener); + + void removePropertyChangeListener(PropertyChangeListener listener); + + void removePropertyChangeListener(String propertyName, PropertyChangeListener listener); + + String getText(); +} Deleted: trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBinding/BeanImpl.java =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBinding/BeanImpl.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBinding/BeanImpl.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,58 +0,0 @@ -/* - * *##% - * JAXX Maven plugin - * 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>. - * ##%* - */ -package org.nuiton.jaxx.plugin.DataBinding; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; - -public class BeanImpl implements Bean{ - - protected String text; - PropertyChangeSupport p; - - public BeanImpl() { - p = new PropertyChangeSupport(this); - } - - public void addPropertyChangeListener(PropertyChangeListener listener) { - p.addPropertyChangeListener(listener); - } - - public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { - p.addPropertyChangeListener(propertyName, listener); - } - - public void removePropertyChangeListener(PropertyChangeListener listener) { - p.removePropertyChangeListener(listener); - } - - public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { - p.removePropertyChangeListener(propertyName, listener); - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } -} Copied: trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBinding/BeanImpl.java (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBinding/BeanImpl.java) =================================================================== --- trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBinding/BeanImpl.java (rev 0) +++ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBinding/BeanImpl.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,58 @@ +/* + * *##% + * JAXX Maven plugin + * 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>. + * ##%* + */ +package org.nuiton.jaxx.plugin.DataBinding; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; + +public class BeanImpl implements Bean{ + + protected String text; + PropertyChangeSupport p; + + public BeanImpl() { + p = new PropertyChangeSupport(this); + } + + public void addPropertyChangeListener(PropertyChangeListener listener) { + p.addPropertyChangeListener(listener); + } + + public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { + p.addPropertyChangeListener(propertyName, listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + p.removePropertyChangeListener(listener); + } + + public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { + p.removePropertyChangeListener(propertyName, listener); + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } +} Copied: trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBindingTest.java (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBindingTest.java) =================================================================== --- trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBindingTest.java (rev 0) +++ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBindingTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,54 @@ +/* + * *##% + * JAXX Maven plugin + * 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>. + * ##%* + */ +package org.nuiton.jaxx.plugin; + +import java.io.IOException; +import org.junit.Test; + +/** + * + * @author chemit + * @since 2.0.0 + */ +public class DataBindingTest extends JaxxBaseTest { + + @Test + public void simpleBinding() throws Exception { + + GenerateMojo mojo = getMojo(); + mojo.execute(); + assertNumberJaxxFiles(1); + + // no bindings + checkPattern(mojo, "BINDING_NOBINDING1_TEXT", false); + checkPattern(mojo, "BINDING_NOBINDING2_TEXT", false); + + // with bindings + checkBinding(mojo, "BINDING_BINDING8_TEXT"); + } + + protected void checkBinding(GenerateMojo mojo, String... bindings) throws IOException { + for (String b : bindings) { + checkPattern(mojo, "public static final String " + b + " = ", true); +// checkPattern(mojo, "new DataBindingListener(this, " + b + ");", true); + } + } +} Modified: trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DecoratorTest.java =================================================================== --- trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DecoratorTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DecoratorTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Maven plugin + * 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>. + * ##%* + */ package org.nuiton.jaxx.plugin; import org.junit.Test; @@ -6,10 +26,10 @@ @Test public void Decorator() throws Exception { - JaxxGeneratorMojo mojo = getMojo(); + GenerateMojo mojo = getMojo(); mojo.execute(); assertNumberJaxxFiles(1); - checkPattern(mojo, "root.add(jaxx.runtime.SwingUtil.boxComponentWithJxLayer(boxedButton))", true); + checkPattern(mojo, "add(SwingUtil.boxComponentWithJxLayer(boxedButton))", true); } } \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Evolution74Test.java (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Evolution74Test.java) =================================================================== --- trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Evolution74Test.java (rev 0) +++ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Evolution74Test.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,101 @@ +/* + * *##% + * JAXX Maven plugin + * 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>. + * ##%* + */ +package org.nuiton.jaxx.plugin; + +import org.apache.maven.plugin.MojoExecutionException; + + +import org.apache.maven.plugin.logging.SystemStreamLog; +import org.junit.Test; +import static org.junit.Assert.*; + +public class Evolution74Test extends JaxxBaseTest { + + @Test + public void ok() throws Exception { + GenerateMojo mojo = getMojo(); + mojo.execute(); + assertNumberJaxxFiles(6); + + checkPattern(mojo, "JComboBox", true, "org/nuiton/jaxx/plugin/evolution74Test/ok/swingcombo.java"); + checkPattern(mojo, "JComboBox", false, "org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxcombo.java"); + checkPattern(mojo, "JAXXComboBox", false, "org/nuiton/jaxx/plugin/evolution74Test/ok/swingcombo.java"); + checkPattern(mojo, "JAXXComboBox", true, "org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxcombo.java"); + + checkPattern(mojo, "JList", true, "org/nuiton/jaxx/plugin/evolution74Test/ok/swinglist.java"); + checkPattern(mojo, "JList", false, "org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxlist.java"); + checkPattern(mojo, "JAXXList", false, "org/nuiton/jaxx/plugin/evolution74Test/ok/swinglist.java"); + checkPattern(mojo, "JAXXList", true, "org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxlist.java"); + + checkPattern(mojo, "JTree", true, "org/nuiton/jaxx/plugin/evolution74Test/ok/swingtree.java"); + checkPattern(mojo, "JTree", false, "org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxtree.java"); + checkPattern(mojo, "JAXXTree", false, "org/nuiton/jaxx/plugin/evolution74Test/ok/swingtree.java"); + checkPattern(mojo, "JAXXTree", true, "org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxtree.java"); + } + + @SuppressWarnings({"unchecked"}) + @Test + public void error() throws Exception { + GenerateMojo mojo = getMojo(); + // init mojo to get alls files to treate + mojo.init(); + + assertNumberJaxxFiles(3); + + mojo.setLog(new SystemStreamLog() { + + @Override + public boolean isErrorEnabled() { + return false; + } + + @Override + public void error(Throwable error) { + //do nothing + } + + @Override + public void error(CharSequence content) { + //do nothing + } + + @Override + public void error(CharSequence content, Throwable error) { + //do nothing + } + }); + + // execute mjo on each jaxx file to produce the error + for (String file : mojo.files) { + log.info("test bad file " + file); + mojo.files = new String[]{file}; + try { + mojo.doAction(); + // should never pass + fail(); + } catch (MojoExecutionException e) { + // ok jaxx compiler failed + assertTrue(true); + assertError(mojo.getEngine(), file, 1); + } + } + } +} Modified: trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/I18nTest.java =================================================================== --- trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/I18nTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/I18nTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Maven plugin + * 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>. + * ##%* + */ package org.nuiton.jaxx.plugin; import org.junit.Test; @@ -6,40 +26,40 @@ @Test public void I18nText() throws Exception { - JaxxGeneratorMojo mojo = getMojo(); + GenerateMojo mojo = getMojo(); mojo.i18nable = false; mojo.execute(); - checkPattern(mojo, "testId.setText(_(\"test.text\"));", false); + checkPattern(mojo, "setText(_(\"test.text\"));", false); mojo.i18nable = true; mojo.execute(); - checkPattern(mojo, "testId.setText(_(\"test.text\"));", true); + checkPattern(mojo, "setText(_(\"test.text\"));", true); checkPattern(mojo, "\"_(\\\"test.text\\\")\"", false); } @Test public void I18nTitle() throws Exception { - JaxxGeneratorMojo mojo = getMojo(); + GenerateMojo mojo = getMojo(); mojo.i18nable = false; mojo.execute(); - checkPattern(mojo, "testId.setTitle(_(\"test.title\"));", false); + checkPattern(mojo, "setTitle(_(\"test.title\"));", false); mojo.i18nable = true; mojo.execute(); - checkPattern(mojo, "testId.setTitle(_(\"test.title\"));", true); + checkPattern(mojo, "setTitle(_(\"test.title\"));", true); checkPattern(mojo, "\"_(\\\"test.title\\\")\"", false); } @Test public void I18nToolTipText() throws Exception { - JaxxGeneratorMojo mojo = getMojo(); + GenerateMojo mojo = getMojo(); mojo.i18nable = false; mojo.execute(); - checkPattern(mojo, "testId.setToolTipText(_(\"test.toolTipText\"));", false); + checkPattern(mojo, "setToolTipText(_(\"test.toolTipText\"));", false); mojo.i18nable = true; mojo.execute(); - checkPattern(mojo, "testId.setToolTipText(_(\"test.toolTipText\"));", true); + checkPattern(mojo, "setToolTipText(_(\"test.toolTipText\"));", true); checkPattern(mojo, "\"_(\\\"test.toolTipText\\\")\"", false); } } Modified: trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/JaxxBaseTest.java =================================================================== --- trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/JaxxBaseTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/JaxxBaseTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,38 +1,66 @@ +/* + * *##% + * JAXX Maven plugin + * 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>. + * ##%* + */ package org.nuiton.jaxx.plugin; -import jaxx.runtime.DefaultJAXXContext; +import jaxx.runtime.context.DefaultJAXXContext; import org.nuiton.util.FileUtil; import java.io.File; import java.io.IOException; +import java.lang.reflect.Field; +import java.util.List; +import java.util.Map; +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.JAXXEngine; import org.nuiton.plugin.AbstractMojoTest; import static org.junit.Assert.*; -/** Base test case for a jaxx:generate goal. +/** + * Base test case for a jaxx:generate goal. * * Use {@link AbstractMojoTest} from {@code maven-helper-plugin}. * * @author chemit * @see AbstractMojoTest - * @see JaxxGeneratorMojo + * @see GenerateMojo */ -public abstract class JaxxBaseTest extends AbstractMojoTest<JaxxGeneratorMojo> { +public abstract class JaxxBaseTest extends AbstractMojoTest<GenerateMojo> { + private Field fieldCompilers; + @Override protected String getGoalName(String methodName) { return "generate"; } @Override - protected void setUpMojo(JaxxGeneratorMojo mojo, File pomFile) throws Exception { + protected void setUpMojo(GenerateMojo mojo, File pomFile) throws Exception { super.setUpMojo(mojo, pomFile); - mojo.jaxxContextImplementorClass = DefaultJAXXContext.class.getName(); - mojo.compilerFQN = jaxx.compiler.SwingCompiler.class.getName(); + mojo.jaxxContextFQN = DefaultJAXXContext.class.getName(); + mojo.compilerFQN = jaxx.compiler.JAXXCompiler.class.getName(); mojo.validatorFQN = jaxx.runtime.validator.swing.SwingValidator.class.getName(); - mojo.defaultDecoratorFQN = jaxx.compiler.DefaultCompiledObjectDecorator.class.getName(); + mojo.defaultDecoratorFQN = jaxx.compiler.decorators.DefaultCompiledObjectDecorator.class.getName(); } - protected void checkPattern(JaxxGeneratorMojo mojo, String pattern, boolean required, String... files) throws IOException { + protected void checkPattern(GenerateMojo mojo, String pattern, boolean required, String... files) throws IOException { if (files.length == 0) { files = mojo.files; } @@ -52,6 +80,24 @@ } protected void assertNumberJaxxFiles(int expectedNbFiles) { - assertEquals(expectedNbFiles, getMojo().files.length); + if (expectedNbFiles == 0) { + assertTrue(getMojo().files == null || getMojo().files.length == 0); + } else { + assertEquals(expectedNbFiles, getMojo().files.length); + } } + + @SuppressWarnings("unchecked") + protected void assertError(JAXXEngine engine, String file, int nbCompiler) throws Exception { + if (fieldCompilers == null) { + fieldCompilers = JAXXEngine.class.getDeclaredField("compilers"); + fieldCompilers.setAccessible(true); + } + + Map<String, JAXXCompiler> compilers = (Map<String, JAXXCompiler>) fieldCompilers.get(engine); + assertEquals(nbCompiler, compilers.size()); + List<String> errors = engine.getErrors(); + //Integer nberrors = (Integer) fieldErrorCount.get(launchor); + assertTrue("should have found at least one error for " + file, errors != null && !errors.isEmpty()); + } } Modified: trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/NodeItemTest.java =================================================================== --- trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/NodeItemTest.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/NodeItemTest.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +1,23 @@ +/* + * *##% + * JAXX Maven plugin + * 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>. + * ##%* + */ package org.nuiton.jaxx.plugin; import org.junit.Assert; Deleted: trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerTest/classReferences/JavaTaist.java =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerTest/classReferences/JavaTaist.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerTest/classReferences/JavaTaist.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,9 +0,0 @@ -package org.nuiton.jaxx.plugin.compilerTest.classReferences; - -import javax.swing.*; - -public class JavaTaist extends JLabel { - public void setCustomProperty(String label) { - setText(label); - } -} \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerTest/classReferences/JavaTaist.java (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerTest/classReferences/JavaTaist.java) =================================================================== --- trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerTest/classReferences/JavaTaist.java (rev 0) +++ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerTest/classReferences/JavaTaist.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,9 @@ +package org.nuiton.jaxx.plugin.compilerTest.classReferences; + +import javax.swing.*; + +public class JavaTaist extends JLabel { + public void setCustomProperty(String label) { + setText(label); + } +} \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Identity.java =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Identity.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Identity.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,79 +0,0 @@ -package org.nuiton.jaxx.plugin.compilerValidatorTest.validator.ok; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; - -public class Identity { - - protected String firstName = ""; - - protected String lastName = ""; - - protected String email = "dummy@codelutin.com"; - - protected int age = 51; - - - PropertyChangeSupport p; - - public Identity() { - p = new PropertyChangeSupport(this); - } - - public void addPropertyChangeListener(PropertyChangeListener listener) { - p.addPropertyChangeListener(listener); - } - - public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { - p.addPropertyChangeListener(propertyName, listener); - } - - public void removePropertyChangeListener(PropertyChangeListener listener) { - p.removePropertyChangeListener(listener); - } - - public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { - p.removePropertyChangeListener(propertyName, listener); - } - - - public String getFirstName() { - return firstName; - } - - public String getLastName() { - return lastName; - } - - public String getEmail() { - return email; - } - - public int getAge() { - return age; - } - - public void setFirstName(String firstName) { - String oldFirstName = this.firstName; - this.firstName = firstName; - p.firePropertyChange("firstName", oldFirstName, firstName); - } - - public void setLastName(String lastName) { - String oldLastName = this.lastName; - this.lastName = lastName; - p.firePropertyChange("lastName", oldLastName, lastName); - } - - public void setEmail(String email) { - String oldEmail =this.email; - this.email = email; - p.firePropertyChange("email", oldEmail, email); - } - - public void setAge(int age) { - int oldAge = this.age; - this.age = age; - p.firePropertyChange("age", oldAge, age); - } -} \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Identity.java (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Identity.java) =================================================================== --- trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Identity.java (rev 0) +++ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Identity.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,79 @@ +package org.nuiton.jaxx.plugin.compilerValidatorTest.validator.ok; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; + +public class Identity { + + protected String firstName = ""; + + protected String lastName = ""; + + protected String email = "dummy@codelutin.com"; + + protected int age = 51; + + + PropertyChangeSupport p; + + public Identity() { + p = new PropertyChangeSupport(this); + } + + public void addPropertyChangeListener(PropertyChangeListener listener) { + p.addPropertyChangeListener(listener); + } + + public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { + p.addPropertyChangeListener(propertyName, listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + p.removePropertyChangeListener(listener); + } + + public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { + p.removePropertyChangeListener(propertyName, listener); + } + + + public String getFirstName() { + return firstName; + } + + public String getLastName() { + return lastName; + } + + public String getEmail() { + return email; + } + + public int getAge() { + return age; + } + + public void setFirstName(String firstName) { + String oldFirstName = this.firstName; + this.firstName = firstName; + p.firePropertyChange("firstName", oldFirstName, firstName); + } + + public void setLastName(String lastName) { + String oldLastName = this.lastName; + this.lastName = lastName; + p.firePropertyChange("lastName", oldLastName, lastName); + } + + public void setEmail(String email) { + String oldEmail =this.email; + this.email = email; + p.firePropertyChange("email", oldEmail, email); + } + + public void setAge(int age) { + int oldAge = this.age; + this.age = age; + p.firePropertyChange("age", oldAge, age); + } +} \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Model.java =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Model.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Model.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,66 +0,0 @@ -package org.nuiton.jaxx.plugin.compilerValidatorTest.validator.ok; - -import java.beans.*; - -public class Model { - - protected String text = "text"; - - protected String text2 = "text2"; - - protected int ratio = 51; - - - PropertyChangeSupport p; - - public Model() { - p = new PropertyChangeSupport(this); - } - - public void addPropertyChangeListener(PropertyChangeListener listener) { - p.addPropertyChangeListener(listener); - } - - public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { - p.addPropertyChangeListener(propertyName, listener); - } - - public void removePropertyChangeListener(PropertyChangeListener listener) { - p.removePropertyChangeListener(listener); - } - - public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { - p.removePropertyChangeListener(propertyName, listener); - } - - - public String getText() { - return text; - } - - public String getText2() { - return text2; - } - - public int getRatio() { - return ratio; - } - - public void setText(String text) { - String oldText = this.text; - this.text = text; - p.firePropertyChange("text", oldText, text); - } - - public void setText2(String text2) { - String oldText2 = this.text2; - this.text2 = text2; - p.firePropertyChange("text2", oldText2, text2); - } - - public void setRatio(int ratio) { - int oldRatio = this.ratio; - this.ratio = ratio; - p.firePropertyChange("ratio",oldRatio, ratio); - } -} \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Model.java (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Model.java) =================================================================== --- trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Model.java (rev 0) +++ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Model.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,66 @@ +package org.nuiton.jaxx.plugin.compilerValidatorTest.validator.ok; + +import java.beans.*; + +public class Model { + + protected String text = "text"; + + protected String text2 = "text2"; + + protected int ratio = 51; + + + PropertyChangeSupport p; + + public Model() { + p = new PropertyChangeSupport(this); + } + + public void addPropertyChangeListener(PropertyChangeListener listener) { + p.addPropertyChangeListener(listener); + } + + public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { + p.addPropertyChangeListener(propertyName, listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + p.removePropertyChangeListener(listener); + } + + public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { + p.removePropertyChangeListener(propertyName, listener); + } + + + public String getText() { + return text; + } + + public String getText2() { + return text2; + } + + public int getRatio() { + return ratio; + } + + public void setText(String text) { + String oldText = this.text; + this.text = text; + p.firePropertyChange("text", oldText, text); + } + + public void setText2(String text2) { + String oldText2 = this.text2; + this.text2 = text2; + p.firePropertyChange("text2", oldText2, text2); + } + + public void setRatio(int ratio) { + int oldRatio = this.ratio; + this.ratio = ratio; + p.firePropertyChange("ratio",oldRatio, ratio); + } +} \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/log4j.properties (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/log4j.properties) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/log4j.properties (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/log4j.properties 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,9 @@ +# Global logging configuration +log4j.rootLogger=ERROR, stdout +# Console output... +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n + +log4j.logger.jaxx.compiler=INFO +log4j.logger.jaxx.compiler.binding=DEBUG Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1722Test/Bug_1722.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1722Test/Bug_1722.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1722Test/Bug_1722.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.nuiton.jaxx.test</groupId> - <artifactId>test</artifactId> - <version>0</version> - <build> - <plugins> - <plugin> - <groupId>org.nuiton</groupId> - <artifactId>maven-jaxx-plugin</artifactId> - <configuration> - <src>${basedir}/target/test-classes</src> - <outJava>${basedir}/target/generated-sources/test-java</outJava> - <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> - <force>true</force> - <!--<verbose>true</verbose>--> - <includes> - <value>**/bug1722Test/*.jaxx</value> - </includes> - </configuration> - </plugin> - </plugins> - </build> -</project> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1722Test/Bug_1722.xml (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1722Test/Bug_1722.xml) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1722Test/Bug_1722.xml (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1722Test/Bug_1722.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.nuiton.jaxx.test</groupId> + <artifactId>test</artifactId> + <version>0</version> + <build> + <plugins> + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <configuration> + <src>${basedir}/target/test-classes</src> + <outJava>${basedir}/target/generated-sources/test-java</outJava> + <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> + <force>true</force> + <!--<verbose>true</verbose>--> + <includes> + <value>**/bug1722Test/*.jaxx</value> + </includes> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1722Test/DemoPanel.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1722Test/DemoPanel.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1722Test/DemoPanel.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,7 +0,0 @@ -<JTabbedPane id='top'> - <tab title='Title'> - <JPanel id='demoPanel'> - <JLabel text='override'/> - </JPanel> - </tab> -</JTabbedPane> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1722Test/DemoPanel.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1722Test/DemoPanel.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1722Test/DemoPanel.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1722Test/DemoPanel.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,7 @@ +<JTabbedPane id='top'> + <tab title='Title'> + <JPanel id='demoPanel'> + <JLabel text='override'/> + </JPanel> + </tab> +</JTabbedPane> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1722Test/JButtonDemo.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1722Test/JButtonDemo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1722Test/JButtonDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,5 +0,0 @@ -<DemoPanel> - <JPanel id='demoPanel'> - <JLabel text='override'/> - </JPanel> -</DemoPanel> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1722Test/JButtonDemo.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1722Test/JButtonDemo.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1722Test/JButtonDemo.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1722Test/JButtonDemo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,5 @@ +<DemoPanel> + <JPanel id='demoPanel'> + <JLabel text='override'/> + </JPanel> +</DemoPanel> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1750Test/Bug_1750.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1750Test/Bug_1750.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1750Test/Bug_1750.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.nuiton.jaxx.test</groupId> - <artifactId>test</artifactId> - <version>0</version> - <build> - <plugins> - <plugin> - <groupId>org.nuiton</groupId> - <artifactId>maven-jaxx-plugin</artifactId> - <configuration> - <src>${basedir}/target/test-classes</src> - <outJava>${basedir}/target/generated-sources/test-java</outJava> - <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> - <force>true</force> - <!--<verbose>true</verbose>--> - <resetAfterCompile>false</resetAfterCompile> - <includes> - <value>**/bug1750Test/*.jaxx</value> - </includes> - </configuration> - </plugin> - </plugins> - </build> -</project> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1750Test/Bug_1750.xml (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1750Test/Bug_1750.xml) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1750Test/Bug_1750.xml (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1750Test/Bug_1750.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.nuiton.jaxx.test</groupId> + <artifactId>test</artifactId> + <version>0</version> + <build> + <plugins> + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <configuration> + <src>${basedir}/target/test-classes</src> + <outJava>${basedir}/target/generated-sources/test-java</outJava> + <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> + <force>true</force> + <!--<verbose>true</verbose>--> + <resetAfterCompile>false</resetAfterCompile> + <includes> + <value>**/bug1750Test/*.jaxx</value> + </includes> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1750Test/ComboBox.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1750Test/ComboBox.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1750Test/ComboBox.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,18 +0,0 @@ -<Table> - - <!-- selectedItem state --> - <Object id='selectedItem' javaBean=''/> - - <!-- check state --> - <Boolean id='check' constructorParams='false' javaBean=''/> - - <row> - <cell> - <JComboBox id='combobox' selectedItem='{getSelectedItem()}' - onItemStateChanged='setSelectedItem(combobox.getSelectedItem())'/> - </cell> - <cell> - <JCheckBox id='checkbox' selected='{isCheck()}' onActionPerformed='setCheck(checkbox.isSelected())'/> - </cell> - </row> -</Table> Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1750Test/ComboBox.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1750Test/ComboBox.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1750Test/ComboBox.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1750Test/ComboBox.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,18 @@ +<Table> + + <!-- selectedItem state --> + <Object id='selectedItem' javaBean=''/> + + <!-- check state --> + <Boolean id='check' constructorParams='false' javaBean=''/> + + <row> + <cell> + <JComboBox id='combobox' selectedItem='{getSelectedItem()}' + onItemStateChanged='setSelectedItem(combobox.getSelectedItem())'/> + </cell> + <cell> + <JCheckBox id='checkbox' selected='{isCheck()}' onActionPerformed='setCheck(checkbox.isSelected())'/> + </cell> + </row> +</Table> Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Bug_1751.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Bug_1751.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Bug_1751.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.nuiton.jaxx.test</groupId> - <artifactId>test</artifactId> - <version>0</version> - <build> - <plugins> - <plugin> - <groupId>org.nuiton</groupId> - <artifactId>maven-jaxx-plugin</artifactId> - <configuration> - <src>${basedir}/target/test-classes</src> - <outJava>${basedir}/target/generated-sources/test-java</outJava> - <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> - <i18nable>true</i18nable> - <force>true</force> - <!--<verbose>true</verbose>--> - <resetAfterCompile>false</resetAfterCompile> - <includes> - <value>**/bug1751Test/*.jaxx</value> - </includes> - </configuration> - </plugin> - </plugins> - </build> -</project> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Bug_1751.xml (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Bug_1751.xml) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Bug_1751.xml (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Bug_1751.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.nuiton.jaxx.test</groupId> + <artifactId>test</artifactId> + <version>0</version> + <build> + <plugins> + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <configuration> + <src>${basedir}/target/test-classes</src> + <outJava>${basedir}/target/generated-sources/test-java</outJava> + <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> + <i18nable>true</i18nable> + <force>true</force> + <!--<verbose>true</verbose>--> + <resetAfterCompile>false</resetAfterCompile> + <includes> + <value>**/bug1751Test/*.jaxx</value> + </includes> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Test1.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Test1.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Test1.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1 +0,0 @@ -<JLabel implements="java.io.Serializable" text='test'/> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Test1.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Test1.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Test1.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Test1.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1 @@ +<JLabel implements="java.io.Serializable" text='test'/> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Test2.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Test2.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Test2.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1 +0,0 @@ -<JLabel text='test' implements="java.io.Serializable"/> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Test2.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Test2.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Test2.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Test2.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1 @@ +<JLabel text='test' implements="java.io.Serializable"/> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Test3.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Test3.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Test3.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1 +0,0 @@ -<JLabel implements="java.io.Serializable" text='test'/> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Test3.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Test3.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Test3.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/bug1751Test/Test3.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1 @@ +<JLabel implements="java.io.Serializable" text='test'/> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.nuiton.jaxx.test</groupId> - <artifactId>test</artifactId> - <version>0</version> - <build> - <plugins> - <plugin> - <groupId>org.nuiton</groupId> - <artifactId>maven-jaxx-plugin</artifactId> - <configuration> - <src>${basedir}/target/test-classes</src> - <outJava>${basedir}/target/generated-sources/test-java</outJava> - <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> - <force>true</force> - <i18nable>false</i18nable> - <verbose>true</verbose> - <includes> - <value>**/compilerTest/cSSTests/*.jaxx</value> - </includes> - </configuration> - </plugin> - </plugins> - </build> -</project> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests.xml (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests.xml) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests.xml (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.nuiton.jaxx.test</groupId> + <artifactId>test</artifactId> + <version>0</version> + <build> + <plugins> + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <configuration> + <src>${basedir}/target/test-classes</src> + <outJava>${basedir}/target/generated-sources/test-java</outJava> + <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> + <force>true</force> + <i18nable>false</i18nable> + <verbose>true</verbose> + <includes> + <value>**/compilerTest/cSSTests/*.jaxx</value> + </includes> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.nuiton.jaxx.test</groupId> - <artifactId>test</artifactId> - <version>0</version> - <build> - <plugins> - <plugin> - <groupId>org.nuiton</groupId> - <artifactId>maven-jaxx-plugin</artifactId> - <configuration> - <src>${basedir}/target/test-classes</src> - <outJava>${basedir}/target/generated-sources/test-java</outJava> - <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> - <force>true</force> - <includes> - <value>**/compilerTest/classReferences/*.jaxx</value> - </includes> - </configuration> - </plugin> - </plugins> - </build> -</project> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences.xml (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences.xml) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences.xml (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.nuiton.jaxx.test</groupId> + <artifactId>test</artifactId> + <version>0</version> + <build> + <plugins> + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <configuration> + <src>${basedir}/target/test-classes</src> + <outJava>${basedir}/target/generated-sources/test-java</outJava> + <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> + <force>true</force> + <includes> + <value>**/compilerTest/classReferences/*.jaxx</value> + </includes> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClientProperty.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClientProperty.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClientProperty.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.nuiton.jaxx.test</groupId> - <artifactId>test</artifactId> - <version>0</version> - <build> - <plugins> - <plugin> - <groupId>org.nuiton</groupId> - <artifactId>maven-jaxx-plugin</artifactId> - <configuration> - <src>${basedir}/target/test-classes</src> - <outJava>${basedir}/target/generated-sources/test-java</outJava> - <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> - <force>true</force> - <addLogger>false</addLogger> - <includes> - <value>**/compilerTest/clientProperty/*.jaxx</value> - </includes> - </configuration> - </plugin> - </plugins> - </build> -</project> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClientProperty.xml (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClientProperty.xml) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClientProperty.xml (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClientProperty.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.nuiton.jaxx.test</groupId> + <artifactId>test</artifactId> + <version>0</version> + <build> + <plugins> + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <configuration> + <src>${basedir}/target/test-classes</src> + <outJava>${basedir}/target/generated-sources/test-java</outJava> + <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> + <force>true</force> + <addLogger>false</addLogger> + <includes> + <value>**/compilerTest/clientProperty/*.jaxx</value> + </includes> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ErrorJaxxContextImplementorClass.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ErrorJaxxContextImplementorClass.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ErrorJaxxContextImplementorClass.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.nuiton.jaxx.test</groupId> - <artifactId>test</artifactId> - <version>0</version> - <build> - <plugins> - <plugin> - <groupId>org.nuiton</groupId> - <artifactId>maven-jaxx-plugin</artifactId> - <configuration> - <src>${basedir}/target/test-classes</src> - <outJava>${basedir}/target/generated-sources/test-java</outJava> - <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> - <jaxxContextFQN>java.lang.String</jaxxContextFQN> - <force>true</force> - <includes> - <value>**/evolution74Test/ok/*.jaxx</value> - </includes> - </configuration> - </plugin> - </plugins> - </build> -</project> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ErrorJaxxContextImplementorClass.xml (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ErrorJaxxContextImplementorClass.xml) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ErrorJaxxContextImplementorClass.xml (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ErrorJaxxContextImplementorClass.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.nuiton.jaxx.test</groupId> + <artifactId>test</artifactId> + <version>0</version> + <build> + <plugins> + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <configuration> + <src>${basedir}/target/test-classes</src> + <outJava>${basedir}/target/generated-sources/test-java</outJava> + <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> + <jaxxContextFQN>java.lang.String</jaxxContextFQN> + <force>true</force> + <includes> + <value>**/evolution74Test/ok/*.jaxx</value> + </includes> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Errors.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Errors.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Errors.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.nuiton.jaxx.test</groupId> - <artifactId>test</artifactId> - <version>0</version> - <build> - <plugins> - <plugin> - <groupId>org.nuiton</groupId> - <artifactId>maven-jaxx-plugin</artifactId> - <configuration> - <src>${basedir}/target/test-classes</src> - <outJava>${basedir}/target/generated-sources/test-java</outJava> - <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> - <force>true</force> - <includes> - <value>**/compilerTest/errors/*.jaxx</value> - </includes> - <excludes> - <value>**/compilerTest/validator/errors/*.jaxx</value> - </excludes> - </configuration> - </plugin> - </plugins> - </build> -</project> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Errors.xml (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Errors.xml) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Errors.xml (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Errors.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.nuiton.jaxx.test</groupId> + <artifactId>test</artifactId> + <version>0</version> + <build> + <plugins> + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <configuration> + <src>${basedir}/target/test-classes</src> + <outJava>${basedir}/target/generated-sources/test-java</outJava> + <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> + <force>true</force> + <includes> + <value>**/compilerTest/errors/*.jaxx</value> + </includes> + <excludes> + <value>**/compilerTest/validator/errors/*.jaxx</value> + </excludes> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Force.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Force.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Force.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.nuiton.jaxx.test</groupId> - <artifactId>test</artifactId> - <version>0</version> - <build> - <plugins> - <plugin> - <groupId>org.nuiton</groupId> - <artifactId>maven-jaxx-plugin</artifactId> - <configuration> - <src>${basedir}/target/test-classes</src> - <outJava>${basedir}/target/generated-sources/test-java</outJava> - <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> - <force>true</force> - <includes> - <value>**/compilerTest/force/*.jaxx</value> - </includes> - </configuration> - </plugin> - </plugins> - </build> -</project> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Force.xml (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Force.xml) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Force.xml (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Force.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.nuiton.jaxx.test</groupId> + <artifactId>test</artifactId> + <version>0</version> + <build> + <plugins> + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <configuration> + <src>${basedir}/target/test-classes</src> + <outJava>${basedir}/target/generated-sources/test-java</outJava> + <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> + <force>true</force> + <includes> + <value>**/compilerTest/force/*.jaxx</value> + </includes> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Icon.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Icon.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Icon.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.nuiton.jaxx.test</groupId> - <artifactId>test</artifactId> - <version>0</version> - <build> - <plugins> - <plugin> - <groupId>org.nuiton</groupId> - <artifactId>maven-jaxx-plugin</artifactId> - <configuration> - <src>${basedir}/target/test-classes</src> - <outJava>${basedir}/target/generated-sources/test-java</outJava> - <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> - <i18nable>false</i18nable> - <force>true</force> - <!--<verbose>true</verbose>--> - <resetAfterCompile>true</resetAfterCompile> - <includes> - <value>**/compilerTest/icon/*.jaxx</value> - </includes> - </configuration> - </plugin> - </plugins> - </build> -</project> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Icon.xml (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Icon.xml) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Icon.xml (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Icon.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.nuiton.jaxx.test</groupId> + <artifactId>test</artifactId> + <version>0</version> + <build> + <plugins> + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <configuration> + <src>${basedir}/target/test-classes</src> + <outJava>${basedir}/target/generated-sources/test-java</outJava> + <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> + <i18nable>false</i18nable> + <force>true</force> + <!--<verbose>true</verbose>--> + <resetAfterCompile>true</resetAfterCompile> + <includes> + <value>**/compilerTest/icon/*.jaxx</value> + </includes> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Initializers.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Initializers.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Initializers.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.nuiton.jaxx.test</groupId> - <artifactId>test</artifactId> - <version>0</version> - <build> - <plugins> - <plugin> - <groupId>org.nuiton</groupId> - <artifactId>maven-jaxx-plugin</artifactId> - <configuration> - <src>${basedir}/target/test-classes</src> - <outJava>${basedir}/target/generated-sources/test-java</outJava> - <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> - <force>true</force> - <includes> - <value>**/compilerTest/initializers/*.jaxx</value> - </includes> - </configuration> - </plugin> - </plugins> - </build> -</project> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Initializers.xml (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Initializers.xml) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Initializers.xml (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Initializers.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.nuiton.jaxx.test</groupId> + <artifactId>test</artifactId> + <version>0</version> + <build> + <plugins> + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <configuration> + <src>${basedir}/target/test-classes</src> + <outJava>${basedir}/target/generated-sources/test-java</outJava> + <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> + <force>true</force> + <includes> + <value>**/compilerTest/initializers/*.jaxx</value> + </includes> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/InnerClasses.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/InnerClasses.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/InnerClasses.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.nuiton.jaxx.test</groupId> - <artifactId>test</artifactId> - <version>0</version> - <build> - <plugins> - <plugin> - <groupId>org.nuiton</groupId> - <artifactId>maven-jaxx-plugin</artifactId> - <configuration> - <src>${basedir}/target/test-classes</src> - <outJava>${basedir}/target/generated-sources/test-java</outJava> - <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> - <force>true</force> - <includes> - <value>**/compilerTest/innerClasses/*.jaxx</value> - </includes> - </configuration> - </plugin> - </plugins> - </build> -</project> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/InnerClasses.xml (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/InnerClasses.xml) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/InnerClasses.xml (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/InnerClasses.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.nuiton.jaxx.test</groupId> + <artifactId>test</artifactId> + <version>0</version> + <build> + <plugins> + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <configuration> + <src>${basedir}/target/test-classes</src> + <outJava>${basedir}/target/generated-sources/test-java</outJava> + <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> + <force>true</force> + <includes> + <value>**/compilerTest/innerClasses/*.jaxx</value> + </includes> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/NoLog.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/NoLog.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/NoLog.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.nuiton.jaxx.test</groupId> - <artifactId>test</artifactId> - <version>0</version> - <build> - <plugins> - <plugin> - <groupId>org.nuiton</groupId> - <artifactId>maven-jaxx-plugin</artifactId> - <configuration> - <src>${basedir}/target/test-classes</src> - <outJava>${basedir}/target/generated-sources/test-java</outJava> - <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> - <force>true</force> - <addLogger>false</addLogger> - <includes> - <value>**/compilerTest/log/nolog/*.jaxx</value> - </includes> - </configuration> - </plugin> - </plugins> - </build> -</project> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/NoLog.xml (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/NoLog.xml) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/NoLog.xml (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/NoLog.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.nuiton.jaxx.test</groupId> + <artifactId>test</artifactId> + <version>0</version> + <build> + <plugins> + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <configuration> + <src>${basedir}/target/test-classes</src> + <outJava>${basedir}/target/generated-sources/test-java</outJava> + <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> + <force>true</force> + <addLogger>false</addLogger> + <includes> + <value>**/compilerTest/log/nolog/*.jaxx</value> + </includes> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/OverridingDataBindings.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/OverridingDataBindings.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/OverridingDataBindings.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.nuiton.jaxx.test</groupId> - <artifactId>test</artifactId> - <version>0</version> - <build> - <plugins> - <plugin> - <groupId>org.nuiton</groupId> - <artifactId>maven-jaxx-plugin</artifactId> - <configuration> - <src>${basedir}/target/test-classes</src> - <outJava>${basedir}/target/generated-sources/test-java</outJava> - <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> - <force>true</force> - <includes> - <value>**/compilerTest/overridingDataBindings/*.jaxx</value> - </includes> - </configuration> - </plugin> - </plugins> - </build> -</project> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/OverridingDataBindings.xml (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/OverridingDataBindings.xml) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/OverridingDataBindings.xml (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/OverridingDataBindings.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.nuiton.jaxx.test</groupId> + <artifactId>test</artifactId> + <version>0</version> + <build> + <plugins> + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <configuration> + <src>${basedir}/target/test-classes</src> + <outJava>${basedir}/target/generated-sources/test-java</outJava> + <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> + <force>true</force> + <includes> + <value>**/compilerTest/overridingDataBindings/*.jaxx</value> + </includes> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Script.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Script.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Script.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.nuiton.jaxx.test</groupId> - <artifactId>test</artifactId> - <version>0</version> - <build> - <plugins> - <plugin> - <groupId>org.nuiton</groupId> - <artifactId>maven-jaxx-plugin</artifactId> - <configuration> - <src>${basedir}/target/test-classes</src> - <outJava>${basedir}/target/generated-sources/test-java</outJava> - <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> - <force>true</force> - <includes> - <value>**/compilerTest/script/*.jaxx</value> - </includes> - </configuration> - </plugin> - </plugins> - </build> -</project> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Script.xml (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Script.xml) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Script.xml (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Script.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.nuiton.jaxx.test</groupId> + <artifactId>test</artifactId> + <version>0</version> + <build> + <plugins> + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <configuration> + <src>${basedir}/target/test-classes</src> + <outJava>${basedir}/target/generated-sources/test-java</outJava> + <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> + <force>true</force> + <includes> + <value>**/compilerTest/script/*.jaxx</value> + </includes> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.nuiton.jaxx.test</groupId> - <artifactId>test</artifactId> - <version>0</version> - <build> - <plugins> - <plugin> - <groupId>org.nuiton</groupId> - <artifactId>maven-jaxx-plugin</artifactId> - <configuration> - <src>${basedir}/target/test-classes</src> - <outJava>${basedir}/target/generated-sources/test-java</outJava> - <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> - <force>true</force> - <includes> - <value>**/compilerTest/specialSubclassing/*.jaxx</value> - </includes> - </configuration> - </plugin> - </plugins> - </build> -</project> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing.xml (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing.xml) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing.xml (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.nuiton.jaxx.test</groupId> + <artifactId>test</artifactId> + <version>0</version> + <build> + <plugins> + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <configuration> + <src>${basedir}/target/test-classes</src> + <outJava>${basedir}/target/generated-sources/test-java</outJava> + <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> + <force>true</force> + <includes> + <value>**/compilerTest/specialSubclassing/*.jaxx</value> + </includes> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/WithLog.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/WithLog.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/WithLog.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.nuiton.jaxx.test</groupId> - <artifactId>test</artifactId> - <version>0</version> - <build> - <plugins> - <plugin> - <groupId>org.nuiton</groupId> - <artifactId>maven-jaxx-plugin</artifactId> - <configuration> - <src>${basedir}/target/test-classes</src> - <outJava>${basedir}/target/generated-sources/test-java</outJava> - <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> - <force>true</force> - <addLogger>true</addLogger> - <includes> - <value>**/compilerTest/log/withlog/*.jaxx</value> - </includes> - </configuration> - </plugin> - </plugins> - </build> -</project> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/WithLog.xml (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/WithLog.xml) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/WithLog.xml (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/WithLog.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.nuiton.jaxx.test</groupId> + <artifactId>test</artifactId> + <version>0</version> + <build> + <plugins> + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <configuration> + <src>${basedir}/target/test-classes</src> + <outJava>${basedir}/target/generated-sources/test-java</outJava> + <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> + <force>true</force> + <addLogger>true</addLogger> + <includes> + <value>**/compilerTest/log/withlog/*.jaxx</value> + </includes> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/CSSTests.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/CSSTests.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/CSSTests.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,24 +0,0 @@ -<Application title='CSSTests'> - <style> - Application { lookAndFeel: {String.valueOf(lookAndFeel.getSelectedValue())}; } - </style> - - <JMenuBar> - <JMenu text='View'> - <JMenu text='Look and Feel'> - <JRadioButtonMenuItem text='Ocean' value='cross_platform' buttonGroup='lookAndFeel' selected='true'/> - <JRadioButtonMenuItem text='System' value='system' buttonGroup='lookAndFeel'/> - </JMenu> - </JMenu> - </JMenuBar> - - <JTabbedPane> - <tab title='Simple Tests'> - <SimpleCSS/> - </tab> - - <tab title='Pseudoclasses'> - <Pseudoclasses/> - </tab> - </JTabbedPane> -</Application> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/CSSTests.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/CSSTests.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/CSSTests.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/CSSTests.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,24 @@ +<Application title='CSSTests'> + <style> + Application { lookAndFeel: {String.valueOf(lookAndFeel.getSelectedValue())}; } + </style> + + <JMenuBar> + <JMenu text='View'> + <JMenu text='Look and Feel'> + <JRadioButtonMenuItem text='Ocean' value='cross_platform' buttonGroup='lookAndFeel' selected='true'/> + <JRadioButtonMenuItem text='System' value='system' buttonGroup='lookAndFeel'/> + </JMenu> + </JMenu> + </JMenuBar> + + <JTabbedPane> + <tab title='Simple Tests'> + <SimpleCSS/> + </tab> + + <tab title='Pseudoclasses'> + <Pseudoclasses/> + </tab> + </JTabbedPane> +</Application> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Child.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Child.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Child.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1 +0,0 @@ -<JButton styleClass='yellow' id='child'/> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Child.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Child.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Child.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Child.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1 @@ +<JButton styleClass='yellow' id='child'/> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Child2.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Child2.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Child2.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1 +0,0 @@ -<JButton foreground='#ffcccc'/> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Child2.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Child2.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Child2.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Child2.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1 @@ +<JButton foreground='#ffcccc'/> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/GrandChild.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/GrandChild.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/GrandChild.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,28 +0,0 @@ -<JPanel layout='{new BorderLayout()}'> - <script> - public String getText() { - return grandChild.getText(); - } - - - public void setText(String Text) { - grandChild.setText(Text); - } - - - public Color getForeground() { - if (grandChild != null) - return grandChild.getForeground(); - else - return Color.BLACK; - } - - - public void setForeground(Color foreground) { - if (grandChild != null) - grandChild.setForeground(foreground); - } - </script> - - <GrandChildButton id='grandChild'/> -</JPanel> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/GrandChild.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/GrandChild.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/GrandChild.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/GrandChild.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,28 @@ +<JPanel layout='{new BorderLayout()}'> + <script> + public String getText() { + return grandChild.getText(); + } + + + public void setText(String Text) { + grandChild.setText(Text); + } + + + public Color getForeground() { + if (grandChild != null) + return grandChild.getForeground(); + else + return Color.BLACK; + } + + + public void setForeground(Color foreground) { + if (grandChild != null) + grandChild.setForeground(foreground); + } + </script> + + <GrandChildButton id='grandChild'/> +</JPanel> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/GrandChildButton.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/GrandChildButton.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/GrandChildButton.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1 +0,0 @@ -<JButton/> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/GrandChildButton.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/GrandChildButton.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/GrandChildButton.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/GrandChildButton.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1 @@ +<JButton/> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Pseudoclasses.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Pseudoclasses.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Pseudoclasses.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,99 +0,0 @@ -<JPanel layout='{new GridLayout(0, 2, 6, 6)}'> - <!-- each checkbox has both its own test and all of the ones that came before in order - to make sure that all of the pseudoclass overrides works properly - only the last - pair should have any effect --> - <style> - #test1:enabled { text: "Enabled"; } - #test1:disabled { text: "Disabled"; } - - #test2:enabled { text: "Enabled"; } - #test2:disabled { text: "Disabled"; } - #test2:focused { text: "Focused"; } - #test2:unfocused { text: "Unfocused"; } - - #test3:enabled { text: "Enabled"; } - #test3:disabled { text: "Disabled"; } - #test3:focused { text: "Focused"; } - #test3:unfocused { text: "Unfocused"; } - #test3:selected { text: "Selected"; } - #test3:deselected { text: "Deselected"; } - - #test4:enabled { text: "Enabled"; } - #test4:disabled { text: "Disabled"; } - #test4:focused { text: "Focused"; } - #test4:unfocused { text: "Unfocused"; } - #test4:selected { text: "Selected"; } - #test4:deselected { text: "Deselected"; } - #test4:mouseover { text: "Mouseover"; } - #test4:mouseout { text: "Mouseout"; } - - #test5:enabled { text: "Enabled"; } - #test5:disabled { text: "Disabled"; } - #test5:focused { text: "Focused"; } - #test5:unfocused { text: "Unfocused"; } - #test5:selected { text: "Selected"; } - #test5:deselected { text: "Deselected"; } - #test5:mouseover { text: "Mouseover"; } - #test5:mouseout { text: "Mouseout"; } - #test5:mousedown { text: "Mousedown"; } - #test5:mouseup { text: "Mouseup"; } - - #test6:{object.isSelected()} { text: "Selected"; } - - #test7:selected { text: { "you shouldn't see this".toUpperCase() } } - #test7:selected { text: { currentTime }; } - - #test8:mouseover { text: { test8Field.getText() }; } - </style> - - <script> - import java.text.*; - import javax.swing.Timer; - - DateFormat dateFormat = DateFormat.getTimeInstance(); - String currentTime = dateFormat.format(new Date()); - - Timer timer = new Timer(1000, new ActionListener() { - public void actionPerformed(ActionEvent e) { - currentTime = dateFormat.format(new Date()); - } - }); - - timer.start(); - </script> - - <JPanel border='{BorderFactory.createTitledBorder("Enabled/Disabled")}'> - <JCheckBox text="You shouldn't see this" enabled='{enabledCB.isSelected()}' id='test1'/> - </JPanel> - - <JPanel border='{BorderFactory.createTitledBorder("Focused/Unfocused")}'> - <JCheckBox text="You shouldn't see this" enabled='{enabledCB.isSelected()}' id='test2'/> - </JPanel> - - <JPanel border='{BorderFactory.createTitledBorder("Selected/Deselected")}'> - <JCheckBox text="You shouldn't see this" enabled='{enabledCB.isSelected()}' id='test3'/> - </JPanel> - - <JPanel border='{BorderFactory.createTitledBorder("Mouseover/Mouseout")}'> - <JCheckBox text="You shouldn't see this" enabled='{enabledCB.isSelected()}' id='test4'/> - </JPanel> - - <JPanel border='{BorderFactory.createTitledBorder("Mouseup/Mousedown")}'> - <JCheckBox text="You shouldn't see this" enabled='{enabledCB.isSelected()}' id='test5'/> - </JPanel> - - <JPanel border='{BorderFactory.createTitledBorder("Programmatic Selected")}'> - <JCheckBox text='Unselected' enabled='{enabledCB.isSelected()}' id='test6'/> - </JPanel> - - <JPanel border='{BorderFactory.createTitledBorder("Pseudoclass Data Binding")}'> - <JCheckBox text='Select to see current time' enabled='{enabledCB.isSelected()}' id='test7'/> - </JPanel> - - <VBox border='{BorderFactory.createTitledBorder("Pseudoclass Proxy Data Binding")}'> - <JCheckBox text='Mouse over to see the below text' enabled='{enabledCB.isSelected()}' id='test8'/> - <JTextField id='test8Field'/> - </VBox> - - <JCheckBox text='Enable checkboxes' id='enabledCB' selected='true'/> -</JPanel> Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Pseudoclasses.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Pseudoclasses.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Pseudoclasses.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Pseudoclasses.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,99 @@ +<JPanel layout='{new GridLayout(0, 2, 6, 6)}'> + <!-- each checkbox has both its own test and all of the ones that came before in order + to make sure that all of the pseudoclass overrides works properly - only the last + pair should have any effect --> + <style> + #test1:enabled { text: "Enabled"; } + #test1:disabled { text: "Disabled"; } + + #test2:enabled { text: "Enabled"; } + #test2:disabled { text: "Disabled"; } + #test2:focused { text: "Focused"; } + #test2:unfocused { text: "Unfocused"; } + + #test3:enabled { text: "Enabled"; } + #test3:disabled { text: "Disabled"; } + #test3:focused { text: "Focused"; } + #test3:unfocused { text: "Unfocused"; } + #test3:selected { text: "Selected"; } + #test3:deselected { text: "Deselected"; } + + #test4:enabled { text: "Enabled"; } + #test4:disabled { text: "Disabled"; } + #test4:focused { text: "Focused"; } + #test4:unfocused { text: "Unfocused"; } + #test4:selected { text: "Selected"; } + #test4:deselected { text: "Deselected"; } + #test4:mouseover { text: "Mouseover"; } + #test4:mouseout { text: "Mouseout"; } + + #test5:enabled { text: "Enabled"; } + #test5:disabled { text: "Disabled"; } + #test5:focused { text: "Focused"; } + #test5:unfocused { text: "Unfocused"; } + #test5:selected { text: "Selected"; } + #test5:deselected { text: "Deselected"; } + #test5:mouseover { text: "Mouseover"; } + #test5:mouseout { text: "Mouseout"; } + #test5:mousedown { text: "Mousedown"; } + #test5:mouseup { text: "Mouseup"; } + + #test6:{object.isSelected()} { text: "Selected"; } + + #test7:selected { text: { "you shouldn't see this".toUpperCase() } } + #test7:selected { text: { currentTime }; } + + #test8:mouseover { text: { test8Field.getText() }; } + </style> + + <script> + import java.text.*; + import javax.swing.Timer; + + DateFormat dateFormat = DateFormat.getTimeInstance(); + String currentTime = dateFormat.format(new Date()); + + Timer timer = new Timer(1000, new ActionListener() { + public void actionPerformed(ActionEvent e) { + currentTime = dateFormat.format(new Date()); + } + }); + + timer.start(); + </script> + + <JPanel border='{BorderFactory.createTitledBorder("Enabled/Disabled")}'> + <JCheckBox text="You shouldn't see this" enabled='{enabledCB.isSelected()}' id='test1'/> + </JPanel> + + <JPanel border='{BorderFactory.createTitledBorder("Focused/Unfocused")}'> + <JCheckBox text="You shouldn't see this" enabled='{enabledCB.isSelected()}' id='test2'/> + </JPanel> + + <JPanel border='{BorderFactory.createTitledBorder("Selected/Deselected")}'> + <JCheckBox text="You shouldn't see this" enabled='{enabledCB.isSelected()}' id='test3'/> + </JPanel> + + <JPanel border='{BorderFactory.createTitledBorder("Mouseover/Mouseout")}'> + <JCheckBox text="You shouldn't see this" enabled='{enabledCB.isSelected()}' id='test4'/> + </JPanel> + + <JPanel border='{BorderFactory.createTitledBorder("Mouseup/Mousedown")}'> + <JCheckBox text="You shouldn't see this" enabled='{enabledCB.isSelected()}' id='test5'/> + </JPanel> + + <JPanel border='{BorderFactory.createTitledBorder("Programmatic Selected")}'> + <JCheckBox text='Unselected' enabled='{enabledCB.isSelected()}' id='test6'/> + </JPanel> + + <JPanel border='{BorderFactory.createTitledBorder("Pseudoclass Data Binding")}'> + <JCheckBox text='Select to see current time' enabled='{enabledCB.isSelected()}' id='test7'/> + </JPanel> + + <VBox border='{BorderFactory.createTitledBorder("Pseudoclass Proxy Data Binding")}'> + <JCheckBox text='Mouse over to see the below text' enabled='{enabledCB.isSelected()}' id='test8'/> + <JTextField id='test8Field'/> + </VBox> + + <JCheckBox text='Enable checkboxes' id='enabledCB' selected='true'/> +</JPanel> Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/SimpleCSS.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/SimpleCSS.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/SimpleCSS.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,29 +0,0 @@ -<VBox> - <JPanel layout='{new GridLayout(0, 1, 6, 6)}'> - <style> - JPanel { border: {null}; font-size: 18; } - - JButton { foreground: red } - JButton.green { foreground: green; } - AbstractButton.blue { foreground: blue } - .blue { foreground: white; } - #B4:enabled { foreground: { Color.orange } } - .yellow { foreground: yellow; } - #child.idTest { foreground: white } - #B7:{true} { foreground: cyan; } - #B8 { foreground: black } - #B8.yellow { foreground: { new Color(0, 0, 0) } } - </style> - - <JButton id='B1' text='Red'/> - <JButton id='B2' text='Green' styleClass='green'/> - <JButton id='B3' text='Blue' styleClass='blue'/> - <GrandChild id='B4' text='Orange'/> - <Child id='B5' text='Yellow'/> - <Child id='B6' text='White' styleClass='idTest'/> - <Child id='B7' text='Cyan'/> - <Child2 id='B8' text='Pink' styleClass='yellow'/> - <Child2 id='B9' text='Purple' foreground='#aa20ff'/> - <GrandChild text='Red'/> - </JPanel> -</VBox> Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/SimpleCSS.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/SimpleCSS.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/SimpleCSS.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/SimpleCSS.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,29 @@ +<VBox> + <JPanel layout='{new GridLayout(0, 1, 6, 6)}'> + <style> + JPanel { border: {null}; font-size: 18; } + + JButton { foreground: red } + JButton.green { foreground: green; } + AbstractButton.blue { foreground: blue } + .blue { foreground: white; } + #B4:enabled { foreground: { Color.orange } } + .yellow { foreground: yellow; } + #child.idTest { foreground: white } + #B7:{true} { foreground: cyan; } + #B8 { foreground: black } + #B8.yellow { foreground: { new Color(0, 0, 0) } } + </style> + + <JButton id='B1' text='Red'/> + <JButton id='B2' text='Green' styleClass='green'/> + <JButton id='B3' text='Blue' styleClass='blue'/> + <GrandChild id='B4' text='Orange'/> + <Child id='B5' text='Yellow'/> + <Child id='B6' text='White' styleClass='idTest'/> + <Child id='B7' text='Cyan'/> + <Child2 id='B8' text='Pink' styleClass='yellow'/> + <Child2 id='B9' text='Purple' foreground='#aa20ff'/> + <GrandChild text='Red'/> + </JPanel> +</VBox> Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/ClassReferences.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/ClassReferences.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/ClassReferences.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,18 +0,0 @@ -<Application> - <script> - Object ref1 = new ConstructorReferenceTest(); - box.add(new JLabel(ref1.toString())); - - TypeReference ref2; // this line only compiles if TypeReference.jaxx gets compiled due to this reference - box.add(new JLabel("Type reference worked")); - - box.add(new JLabel(StaticMethodTest.getText())); - </script> - - <VBox id='box'> - <!-- TODO Ce cas ne fonctionne plus (il faut posséder cette classe compilée ? --> - <!--ClassTest customProperty='Compiled class file worked'/--> - <JAXXTest customProperty='Uncompiled JAXX file worked'/> - <JavaTaist customProperty='Uncompiled Java file worked'/> - </VBox> -</Application> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/ClassReferences.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/ClassReferences.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/ClassReferences.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/ClassReferences.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,18 @@ +<Application> + <script> + Object ref1 = new ConstructorReferenceTest(); + box.add(new JLabel(ref1.toString())); + + TypeReference ref2; // this line only compiles if TypeReference.jaxx gets compiled due to this reference + box.add(new JLabel("Type reference worked")); + + box.add(new JLabel(StaticMethodTest.getText())); + </script> + + <VBox id='box'> + <!-- TODO Ce cas ne fonctionne plus (il faut posséder cette classe compilée ? --> + <!--ClassTest customProperty='Compiled class file worked'/--> + <JAXXTest customProperty='Uncompiled JAXX file worked'/> + <JavaTaist customProperty='Uncompiled Java file worked'/> + </VBox> +</Application> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/ConstructorReferenceTest.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/ConstructorReferenceTest.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/ConstructorReferenceTest.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,7 +0,0 @@ -<Object> - <script> - public String toString() { - return "Constructor reference worked"; - } - </script> -</Object> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/ConstructorReferenceTest.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/ConstructorReferenceTest.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/ConstructorReferenceTest.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/ConstructorReferenceTest.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,7 @@ +<Object> + <script> + public String toString() { + return "Constructor reference worked"; + } + </script> +</Object> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/JAXXReferenceTest.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/JAXXReferenceTest.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/JAXXReferenceTest.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,7 +0,0 @@ -<JLabel> - <script> - public void setCustomProperty(String label) { - setText(label); - } - </script> -</JLabel> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/JAXXReferenceTest.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/JAXXReferenceTest.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/JAXXReferenceTest.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/JAXXReferenceTest.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,7 @@ +<JLabel> + <script> + public void setCustomProperty(String label) { + setText(label); + } + </script> +</JLabel> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/JAXXTest.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/JAXXTest.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/JAXXTest.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,7 +0,0 @@ -<JLabel> - <script> - public void setCustomProperty(String label) { - setText(label); - } - </script> -</JLabel> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/JAXXTest.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/JAXXTest.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/JAXXTest.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/JAXXTest.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,7 @@ +<JLabel> + <script> + public void setCustomProperty(String label) { + setText(label); + } + </script> +</JLabel> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/StaticMethodTest.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/StaticMethodTest.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/StaticMethodTest.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,7 +0,0 @@ -<Object> - <script> - public static String getText() { - return "Static method reference worked"; - } - </script> -</Object> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/StaticMethodTest.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/StaticMethodTest.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/StaticMethodTest.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/StaticMethodTest.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,7 @@ +<Object> + <script> + public static String getText() { + return "Static method reference worked"; + } + </script> +</Object> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/TypeReference.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/TypeReference.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/TypeReference.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1 +0,0 @@ -<Object/> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/TypeReference.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/TypeReference.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/TypeReference.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/TypeReference.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1 @@ +<Object/> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/clientProperty/TestOne.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/clientProperty/TestOne.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/clientProperty/TestOne.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +0,0 @@ -<JPanel id='root'> - <JButton id='boxedButton' _testOne='"oneTest"' _testTwo='{"anotherTest"}'/> -</JPanel> Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/clientProperty/TestOne.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/clientProperty/TestOne.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/clientProperty/TestOne.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/clientProperty/TestOne.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,3 @@ +<JPanel id='root'> + <JButton id='boxedButton' _testOne='"oneTest"' _testTwo='{"anotherTest"}'/> +</JPanel> Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/AmbiguousName.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/AmbiguousName.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/AmbiguousName.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,10 +0,0 @@ -<JPanel> - <script> - import java.awt.*; - import java.sql.*; - import java.util.*; - </script> - - <List/> - <Date/> -</JPanel> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/AmbiguousName.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/AmbiguousName.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/AmbiguousName.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/AmbiguousName.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,10 @@ +<JPanel> + <script> + import java.awt.*; + import java.sql.*; + import java.util.*; + </script> + + <List/> + <Date/> +</JPanel> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/BadTypeConversions.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/BadTypeConversions.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/BadTypeConversions.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,4 +0,0 @@ -<JButton opaque='yellow' - margin='42, 1, 7' - mnemonic='AX' - border='true'/> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/BadTypeConversions.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/BadTypeConversions.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/BadTypeConversions.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/BadTypeConversions.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,4 @@ +<JButton opaque='yellow' + margin='42, 1, 7' + mnemonic='AX' + border='true'/> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/CellOutsideOfRow.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/CellOutsideOfRow.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/CellOutsideOfRow.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,5 +0,0 @@ -<JPanel> - <cell><JButton/></cell> - - <cell><JLabel/></cell> -</JPanel> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/CellOutsideOfRow.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/CellOutsideOfRow.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/CellOutsideOfRow.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/CellOutsideOfRow.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,5 @@ +<JPanel> + <cell><JButton/></cell> + + <cell><JLabel/></cell> +</JPanel> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ChildrenInNonContainer.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ChildrenInNonContainer.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ChildrenInNonContainer.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,4 +0,0 @@ -<JButton> - <JPanel/> - <JMenuBar/> -</JButton> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ChildrenInNonContainer.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ChildrenInNonContainer.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ChildrenInNonContainer.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ChildrenInNonContainer.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,4 @@ +<JButton> + <JPanel/> + <JMenuBar/> +</JButton> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ClassNotFound.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ClassNotFound.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ClassNotFound.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +0,0 @@ -<Frame> - <Glob/> -</Frame> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ClassNotFound.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ClassNotFound.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ClassNotFound.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ClassNotFound.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,3 @@ +<Frame> + <Glob/> +</Frame> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ConflictingPackages.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ConflictingPackages.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ConflictingPackages.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1 +0,0 @@ -<awt:javax.swing.JFrame xmlns:awt='java.awt.*'/> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ConflictingPackages.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ConflictingPackages.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ConflictingPackages.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ConflictingPackages.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1 @@ +<awt:javax.swing.JFrame xmlns:awt='java.awt.*'/> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ConstraintsParseError.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ConstraintsParseError.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ConstraintsParseError.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,5 +0,0 @@ -<Application> - <JLabel constraints='BorderLayout*%NORTH'/> - <JButton constraints='BorderLayout.SOUTH'/> - <JTabbedPane constraints='BorderLayout(CENTER'/> -</Application> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ConstraintsParseError.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ConstraintsParseError.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ConstraintsParseError.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ConstraintsParseError.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,5 @@ +<Application> + <JLabel constraints='BorderLayout*%NORTH'/> + <JButton constraints='BorderLayout.SOUTH'/> + <JTabbedPane constraints='BorderLayout(CENTER'/> +</Application> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/DataBindingParseError.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/DataBindingParseError.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/DataBindingParseError.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,6 +0,0 @@ -<JPanel> - <JButton text='{"Missing right brace"'/> - <JLabel text='{Math.PI + Math.E ~= Math.PIE}'/> - <JToolBar visible='{I like pie}'/> - <JButton text='{"This should compile"}}'/> -</JPanel> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/DataBindingParseError.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/DataBindingParseError.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/DataBindingParseError.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/DataBindingParseError.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,6 @@ +<JPanel> + <JButton text='{"Missing right brace"'/> + <JLabel text='{Math.PI + Math.E ~= Math.PIE}'/> + <JToolBar visible='{I like pie}'/> + <JButton text='{"This should compile"}}'/> +</JPanel> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/DuplicateIDs.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/DuplicateIDs.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/DuplicateIDs.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,4 +0,0 @@ -<JPanel id='duplicate'> - <JPanel id='duplicate'/> - <JColorChooser id='duplicate'/> -</JPanel> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/DuplicateIDs.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/DuplicateIDs.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/DuplicateIDs.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/DuplicateIDs.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,4 @@ +<JPanel id='duplicate'> + <JPanel id='duplicate'/> + <JColorChooser id='duplicate'/> +</JPanel> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/EventHandlerParseError.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/EventHandlerParseError.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/EventHandlerParseError.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,4 +0,0 @@ -<JPanel> - <JButton onActionPerformed='!*'/> - <JPanel onMouseEntered='{System.out.println("Remember kids, only use curly braces where appropriate!")}'/> -</JPanel> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/EventHandlerParseError.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/EventHandlerParseError.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/EventHandlerParseError.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/EventHandlerParseError.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,4 @@ +<JPanel> + <JButton onActionPerformed='!*'/> + <JPanel onMouseEntered='{System.out.println("Remember kids, only use curly braces where appropriate!")}'/> +</JPanel> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/InvalidID.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/InvalidID.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/InvalidID.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +0,0 @@ -<Application id='1'> - <JButton id='Hello-'/> -</Application> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/InvalidID.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/InvalidID.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/InvalidID.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/InvalidID.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,3 @@ +<Application id='1'> + <JButton id='Hello-'/> +</Application> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/InvalidRootTag.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/InvalidRootTag.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/InvalidRootTag.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1 +0,0 @@ -<style source='test.css'/> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/InvalidRootTag.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/InvalidRootTag.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/InvalidRootTag.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/InvalidRootTag.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1 @@ +<style source='test.css'/> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/InvalidXML.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/InvalidXML.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/InvalidXML.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,4 +0,0 @@ -<begin> - <valid/> - <so.is.this/> -</end> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/InvalidXML.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/InvalidXML.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/InvalidXML.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/InvalidXML.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,4 @@ +<begin> + <valid/> + <so.is.this/> +</end> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ItemDuplicateValues.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ItemDuplicateValues.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ItemDuplicateValues.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,8 +0,0 @@ -<JAXXList> - <item value='1'/> - <item value='2'/> - <item value='2'/> - <item value='3'/> - <item value='3'/> - <item value='3'/> -</JAXXList> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ItemDuplicateValues.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ItemDuplicateValues.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ItemDuplicateValues.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ItemDuplicateValues.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,8 @@ +<JAXXList> + <item value='1'/> + <item value='2'/> + <item value='2'/> + <item value='3'/> + <item value='3'/> + <item value='3'/> +</JAXXList> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ItemNoValue.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ItemNoValue.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ItemNoValue.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,4 +0,0 @@ -<JAXXList> - <item label='This item doesn&t have a value'/> - <item label='Neither does this one'/> -</JAXXList> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ItemNoValue.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ItemNoValue.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ItemNoValue.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ItemNoValue.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,4 @@ +<JAXXList> + <item label='This item doesn&t have a value'/> + <item label='Neither does this one'/> +</JAXXList> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/MixedContent.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/MixedContent.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/MixedContent.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,19 +0,0 @@ -<JPanel> - mixed1 - - <Table> - <row> - mixed2 - - <cell>mixed3</cell> - </row> - </Table> - - <JList> - <item>mixed4</item> - </JList> - - <JTabbedPane> - <tab>mixed5</tab> - </JTabbedPane> -</JPanel> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/MixedContent.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/MixedContent.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/MixedContent.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/MixedContent.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,19 @@ +<JPanel> + mixed1 + + <Table> + <row> + mixed2 + + <cell>mixed3</cell> + </row> + </Table> + + <JList> + <item>mixed4</item> + </JList> + + <JTabbedPane> + <tab>mixed5</tab> + </JTabbedPane> +</JPanel> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/RowOutsideOfTable.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/RowOutsideOfTable.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/RowOutsideOfTable.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,9 +0,0 @@ -<JPanel> - <row> - <cell><JButton/></cell> - </row> - - <row> - <cell><JLabel/></cell> - </row> -</JPanel> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/RowOutsideOfTable.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/RowOutsideOfTable.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/RowOutsideOfTable.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/RowOutsideOfTable.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,9 @@ +<JPanel> + <row> + <cell><JButton/></cell> + </row> + + <row> + <cell><JLabel/></cell> + </row> +</JPanel> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/RowWrongChild.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/RowWrongChild.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/RowWrongChild.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,9 +0,0 @@ -<Table> - <row> - <JPanel/> - </row> - - <row> - <JScrollPane/> - </row> -</Table> Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/RowWrongChild.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/RowWrongChild.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/RowWrongChild.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/RowWrongChild.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,9 @@ +<Table> + <row> + <JPanel/> + </row> + + <row> + <JScrollPane/> + </row> +</Table> Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ScriptNotFound.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ScriptNotFound.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ScriptNotFound.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1 +0,0 @@ -<script source='notfound.script'/> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ScriptNotFound.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ScriptNotFound.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ScriptNotFound.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ScriptNotFound.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1 @@ +<script source='notfound.script'/> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ScriptParseError.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ScriptParseError.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ScriptParseError.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,6 +0,0 @@ -<JFileChooser> - <script> - System.err.println("this is a valid line"); - System.err.println("this is an unclosed string literal); - </script> -</JFileChooser> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ScriptParseError.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ScriptParseError.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ScriptParseError.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ScriptParseError.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,6 @@ +<JFileChooser> + <script> + System.err.println("this is a valid line"); + System.err.println("this is an unclosed string literal); + </script> +</JFileChooser> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ScriptSourceAndInline.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ScriptSourceAndInline.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ScriptSourceAndInline.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +0,0 @@ -<script source='dependencies/test.script'> - System.err.println("This should not compile"); -</script> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ScriptSourceAndInline.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ScriptSourceAndInline.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ScriptSourceAndInline.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/ScriptSourceAndInline.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,3 @@ +<script source='dependencies/test.script'> + System.err.println("This should not compile"); +</script> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/StyleNotFound.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/StyleNotFound.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/StyleNotFound.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1 +0,0 @@ -<style source='notfound.css'/> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/StyleNotFound.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/StyleNotFound.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/StyleNotFound.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/StyleNotFound.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1 @@ +<style source='notfound.css'/> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/StyleParseError.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/StyleParseError.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/StyleParseError.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,9 +0,0 @@ -<JFileChooser> - <style> - JButton { - foreground: blue; - label: "Parse error on next line"; - *: false; - } - </style> -</JFileChooser> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/StyleParseError.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/StyleParseError.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/StyleParseError.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/StyleParseError.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,9 @@ +<JFileChooser> + <style> + JButton { + foreground: blue; + label: "Parse error on next line"; + *: false; + } + </style> +</JFileChooser> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/StyleSourceAndInline.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/StyleSourceAndInline.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/StyleSourceAndInline.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +0,0 @@ -<style source='dependencies/test.css'> - JLabel { text: "this should not compile" } -</style> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/StyleSourceAndInline.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/StyleSourceAndInline.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/StyleSourceAndInline.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/StyleSourceAndInline.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,3 @@ +<style source='dependencies/test.css'> + JLabel { text: "this should not compile" } +</style> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TabOutsideOfTabbedPane.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TabOutsideOfTabbedPane.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TabOutsideOfTabbedPane.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,9 +0,0 @@ -<JPanel> - <tab> - <JButton/> - </tab> - - <tab> - <JLabel/> - </tab> -</JPanel> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TabOutsideOfTabbedPane.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TabOutsideOfTabbedPane.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TabOutsideOfTabbedPane.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TabOutsideOfTabbedPane.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,9 @@ +<JPanel> + <tab> + <JButton/> + </tab> + + <tab> + <JLabel/> + </tab> +</JPanel> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TabbedPaneWrongChild.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TabbedPaneWrongChild.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TabbedPaneWrongChild.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,6 +0,0 @@ -<Application> - <JTabbedPane> - <JPanel/> - <JScrollPane/> - </JTabbedPane> -</Application> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TabbedPaneWrongChild.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TabbedPaneWrongChild.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TabbedPaneWrongChild.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TabbedPaneWrongChild.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,6 @@ +<Application> + <JTabbedPane> + <JPanel/> + <JScrollPane/> + </JTabbedPane> +</Application> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TableWrongChild.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TableWrongChild.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TableWrongChild.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,6 +0,0 @@ -<Application> - <Table> - <JPanel/> - <JScrollPane/> - </Table> -</Application> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TableWrongChild.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TableWrongChild.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TableWrongChild.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TableWrongChild.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,6 @@ +<Application> + <Table> + <JPanel/> + <JScrollPane/> + </Table> +</Application> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManyCellChildren.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManyCellChildren.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManyCellChildren.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,15 +0,0 @@ -<Application> - <Table> - <row> - <cell> - <JButton/> - <JButton/> - </cell> - - <cell> - <JPanel/> - <JToolBar/> - </cell> - </row> - </Table> -</Application> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManyCellChildren.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManyCellChildren.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManyCellChildren.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManyCellChildren.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,15 @@ +<Application> + <Table> + <row> + <cell> + <JButton/> + <JButton/> + </cell> + + <cell> + <JPanel/> + <JToolBar/> + </cell> + </row> + </Table> +</Application> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManyScrollPaneChildren.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManyScrollPaneChildren.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManyScrollPaneChildren.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,5 +0,0 @@ -<JScrollPane> - <JButton/> - <JToolBar/> - <JPanel/> -</JScrollPane> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManyScrollPaneChildren.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManyScrollPaneChildren.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManyScrollPaneChildren.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManyScrollPaneChildren.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,5 @@ +<JScrollPane> + <JButton/> + <JToolBar/> + <JPanel/> +</JScrollPane> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManySplitPaneChildren.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManySplitPaneChildren.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManySplitPaneChildren.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,7 +0,0 @@ -<Application> - <JSplitPane> - <JButton text='one'/> - <JButton text='two'/> - <JButton text='three'/> - </JSplitPane> -</Application> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManySplitPaneChildren.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManySplitPaneChildren.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManySplitPaneChildren.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManySplitPaneChildren.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,7 @@ +<Application> + <JSplitPane> + <JButton text='one'/> + <JButton text='two'/> + <JButton text='three'/> + </JSplitPane> +</Application> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManyTabChildren.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManyTabChildren.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManyTabChildren.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,13 +0,0 @@ -<Application> - <JTabbedPane> - <tab> - <JButton/> - <JButton/> - </tab> - - <tab> - <JPanel/> - <JToolBar/> - </tab> - </JTabbedPane> -</Application> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManyTabChildren.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManyTabChildren.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManyTabChildren.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/TooManyTabChildren.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,13 @@ +<Application> + <JTabbedPane> + <tab> + <JButton/> + <JButton/> + </tab> + + <tab> + <JPanel/> + <JToolBar/> + </tab> + </JTabbedPane> +</Application> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/UnsupportedAttribute.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/UnsupportedAttribute.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/UnsupportedAttribute.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +0,0 @@ -<JPanel widgetCount='7'> - <JLabel mnemonic='A'/> -</JPanel> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/UnsupportedAttribute.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/UnsupportedAttribute.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/UnsupportedAttribute.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/UnsupportedAttribute.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,3 @@ +<JPanel widgetCount='7'> + <JLabel mnemonic='A'/> +</JPanel> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/UnsupportedEvent.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/UnsupportedEvent.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/UnsupportedEvent.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +0,0 @@ -<JPanel onWink='7'> - <JLabel onWonLottery='A'/> -</JPanel> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/UnsupportedEvent.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/UnsupportedEvent.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/UnsupportedEvent.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/UnsupportedEvent.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,3 @@ +<JPanel onWink='7'> + <JLabel onWonLottery='A'/> +</JPanel> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/UnsupportedPseudoclass.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/UnsupportedPseudoclass.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/UnsupportedPseudoclass.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,5 +0,0 @@ -<JButton> - <style> - :opaque { enabled: false; } - </style> -</JButton> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/UnsupportedPseudoclass.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/UnsupportedPseudoclass.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/UnsupportedPseudoclass.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/UnsupportedPseudoclass.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,5 @@ +<JButton> + <style> + :opaque { enabled: false; } + </style> +</JButton> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/dependencies/test.css =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/dependencies/test.css 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/dependencies/test.css 2009-12-02 13:59:28 UTC (rev 1673) @@ -1 +0,0 @@ -JLabel { text: "This should not compile" } \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/dependencies/test.css (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/dependencies/test.css) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/dependencies/test.css (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/dependencies/test.css 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1 @@ +JLabel { text: "This should not compile" } \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/dependencies/test.script =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/dependencies/test.script 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/dependencies/test.script 2009-12-02 13:59:28 UTC (rev 1673) @@ -1 +0,0 @@ -System.err.println("This should not compile."); \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/dependencies/test.script (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/dependencies/test.script) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/dependencies/test.script (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/dependencies/test.script 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1 @@ +System.err.println("This should not compile."); \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/force/JButton.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/force/JButton.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/force/JButton.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1 +0,0 @@ -<javax.swing.JButton id='testId' text='test.text'/> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/force/JButton.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/force/JButton.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/force/JButton.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/force/JButton.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1 @@ +<javax.swing.JButton id='testId' text='test.text'/> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/icon/Test1.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/icon/Test1.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/icon/Test1.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,4 +0,0 @@ -<JPanel> - <JLabel icon='myIcon.png'/> - <JLabel actionIcon='myActionIcon.png'/> -</JPanel> Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/icon/Test1.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/icon/Test1.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/icon/Test1.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/icon/Test1.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,4 @@ +<JPanel> + <JLabel icon='myIcon.png'/> + <JLabel actionIcon='myActionIcon.png'/> +</JPanel> Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/initializers/Initializers.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/initializers/Initializers.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/initializers/Initializers.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,37 +0,0 @@ -<Application> - <script> - private static String staticInitializerText = "Static initializer FAILED"; - - static { - staticInitializerText = "Static initializer worked!"; - } - - { initializerTest.setText("Initializer worked!"); } - - public Initializers(String label) { - this(1, "Custom constructor test 2 worked!"); - constructorTest1.setText(label); - } - - - public Initializers(int dummy, String label) { - super("Test 3 worked! "+dummy); - constructorTest2.setText(label); - } - - - public static void main(String[] arg) { // test custom main method - Initializers test = new Initializers("Custom constructor test 1 worked!"); - test.mainTest.setText("Custom main method worked!"); - test.setVisible(true); - } - </script> - - <VBox> - <JLabel id='mainTest' text='Custom main method FAILED'/> - <JLabel id='constructorTest1' text='Custom constructor TEST 1 FAILED'/> - <JLabel id='constructorTest2' text='Custom constructor TEST 2 FAILED'/> - <JLabel id='initializerTest' text='Initializer FAILED'/> - <JLabel id='staticInitializerTest' text='{Initializers.staticInitializerText}'/> - </VBox> -</Application> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/initializers/Initializers.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/initializers/Initializers.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/initializers/Initializers.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/initializers/Initializers.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,37 @@ +<Application> + <script> + private static String staticInitializerText = "Static initializer FAILED"; + + static { + staticInitializerText = "Static initializer worked!"; + } + + { initializerTest.setText("Initializer worked!"); } + + public Initializers(String label) { + this(1, "Custom constructor test 2 worked!"); + constructorTest1.setText(label); + } + + + public Initializers(int dummy, String label) { + super("Test 3 worked! "+dummy); + constructorTest2.setText(label); + } + + + public static void main(String[] arg) { // test custom main method + Initializers test = new Initializers("Custom constructor test 1 worked!"); + test.mainTest.setText("Custom main method worked!"); + test.setVisible(true); + } + </script> + + <VBox> + <JLabel id='mainTest' text='Custom main method FAILED'/> + <JLabel id='constructorTest1' text='Custom constructor TEST 1 FAILED'/> + <JLabel id='constructorTest2' text='Custom constructor TEST 2 FAILED'/> + <JLabel id='initializerTest' text='Initializer FAILED'/> + <JLabel id='staticInitializerTest' text='{Initializers.staticInitializerText}'/> + </VBox> +</Application> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/innerClasses/InnerClasses.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/innerClasses/InnerClasses.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/innerClasses/InnerClasses.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,17 +0,0 @@ -<Application> - <JMenuBar> - <JMenu text='Test'> - <JMenuItem text='1'/> - <JPopupMenu.Separator/> - <JMenuItem text='2'/> - <javax.swing.JPopupMenu.Separator/> - <JMenuItem text='3'/> - <JPopupMenu.Separator xmlns="javax.swing.*"/> - <JMenuItem text='4'/> - <swing:JPopupMenu.Separator xmlns:swing="javax.swing.*"/> - <JMenuItem text='5'/> - <swing:javax.swing.JPopupMenu.Separator xmlns:swing="javax.swing.*"/> - <JMenuItem text='6'/> - </JMenu> - </JMenuBar> -</Application> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/innerClasses/InnerClasses.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/innerClasses/InnerClasses.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/innerClasses/InnerClasses.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/innerClasses/InnerClasses.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,17 @@ +<Application> + <JMenuBar> + <JMenu text='Test'> + <JMenuItem text='1'/> + <JPopupMenu.Separator/> + <JMenuItem text='2'/> + <javax.swing.JPopupMenu.Separator/> + <JMenuItem text='3'/> + <JPopupMenu.Separator xmlns="javax.swing.*"/> + <JMenuItem text='4'/> + <swing:JPopupMenu.Separator xmlns:swing="javax.swing.*"/> + <JMenuItem text='5'/> + <swing:javax.swing.JPopupMenu.Separator xmlns:swing="javax.swing.*"/> + <JMenuItem text='6'/> + </JMenu> + </JMenuBar> +</Application> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/nolog/NoLog.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/nolog/NoLog.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/nolog/NoLog.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1 +0,0 @@ -<JButton id='testId' text='test.text'/> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/nolog/NoLog.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/nolog/NoLog.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/nolog/NoLog.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/nolog/NoLog.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1 @@ +<JButton id='testId' text='test.text'/> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/nolog/NoLogSon.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/nolog/NoLogSon.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/nolog/NoLogSon.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1 +0,0 @@ -<NoLog id='testId' text='test.text'/> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/nolog/NoLogSon.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/nolog/NoLogSon.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/nolog/NoLogSon.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/nolog/NoLogSon.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1 @@ +<NoLog id='testId' text='test.text'/> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/withlog/NoLog.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/withlog/NoLog.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/withlog/NoLog.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1 +0,0 @@ -<WithLog id='testId' text='test.text'/> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/withlog/NoLog.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/withlog/NoLog.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/withlog/NoLog.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/withlog/NoLog.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1 @@ +<WithLog id='testId' text='test.text'/> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/withlog/WithLog.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/withlog/WithLog.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/withlog/WithLog.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1 +0,0 @@ -<JButton id='testId' text='test.text'/> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/withlog/WithLog.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/withlog/WithLog.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/withlog/WithLog.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/log/withlog/WithLog.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1 @@ +<JButton id='testId' text='test.text'/> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/CurrentTime.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/CurrentTime.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/CurrentTime.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,17 +0,0 @@ -<JLabel text='{currentTime}' foreground='blue'> - <script> - import java.text.*; - import javax.swing.Timer; - - DateFormat dateFormat = DateFormat.getTimeInstance(); - String currentTime = dateFormat.format(new Date()); - - Timer timer = new Timer(1000, new ActionListener() { - public void actionPerformed(ActionEvent e) { - currentTime = dateFormat.format(new Date()); - } - }); - - timer.start(); - </script> -</JLabel> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/CurrentTime.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/CurrentTime.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/CurrentTime.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/CurrentTime.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,17 @@ +<JLabel text='{currentTime}' foreground='blue'> + <script> + import java.text.*; + import javax.swing.Timer; + + DateFormat dateFormat = DateFormat.getTimeInstance(); + String currentTime = dateFormat.format(new Date()); + + Timer timer = new Timer(1000, new ActionListener() { + public void actionPerformed(ActionEvent e) { + currentTime = dateFormat.format(new Date()); + } + }); + + timer.start(); + </script> +</JLabel> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/OverriddenCurrentTime.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/OverriddenCurrentTime.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/OverriddenCurrentTime.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1 +0,0 @@ -<CurrentTime text='Parent Working'/> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/OverriddenCurrentTime.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/OverriddenCurrentTime.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/OverriddenCurrentTime.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/OverriddenCurrentTime.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1 @@ +<CurrentTime text='Parent Working'/> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/OverridingDataBindings.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/OverridingDataBindings.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/OverridingDataBindings.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,12 +0,0 @@ -<Application> - <VBox> - <JLabel text='The text below should display the time'/> - <CurrentTime/> - - <JLabel text='The text below should read "Child Working"'/> - <CurrentTime text='Child Working'/> - - <JLabel text='The text below should read "Parent Working"'/> - <OverriddenCurrentTime/> - </VBox> -</Application> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/OverridingDataBindings.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/OverridingDataBindings.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/OverridingDataBindings.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/OverridingDataBindings.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,12 @@ +<Application> + <VBox> + <JLabel text='The text below should display the time'/> + <CurrentTime/> + + <JLabel text='The text below should read "Child Working"'/> + <CurrentTime text='Child Working'/> + + <JLabel text='The text below should read "Parent Working"'/> + <OverriddenCurrentTime/> + </VBox> +</Application> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/script/JScriptInitializer.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/script/JScriptInitializer.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/script/JScriptInitializer.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,19 +0,0 @@ -<JDialog> - <script> - protected boolean value - </script> - <script> - value=false - </script> - - <script> - value=getOk(); - - public boolean getOk() { - return true; - } - </script> - <VBox> - <JButton text='close' onActionPerformed="dispose()"/> - </VBox> -</JDialog> Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/script/JScriptInitializer.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/script/JScriptInitializer.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/script/JScriptInitializer.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/script/JScriptInitializer.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,19 @@ +<JDialog> + <script> + protected boolean value + </script> + <script> + value=false + </script> + + <script> + value=getOk(); + + public boolean getOk() { + return true; + } + </script> + <VBox> + <JButton text='close' onActionPerformed="dispose()"/> + </VBox> +</JDialog> Deleted: trunk/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-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JComboBoxTest1.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +0,0 @@ -<JAXXComboBox> - <item value='Working' selected='true'/> -</JAXXComboBox> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JComboBoxTest1.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JComboBoxTest1.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JComboBoxTest1.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JComboBoxTest1.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,3 @@ +<JAXXComboBox> + <item value='Working' selected='true'/> +</JAXXComboBox> \ No newline at end of file Deleted: trunk/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-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JComboBoxTest2.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +0,0 @@ -<JAXXComboBox> - <item value='Failed!'/> -</JAXXComboBox> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JComboBoxTest2.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JComboBoxTest2.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JComboBoxTest2.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JComboBoxTest2.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,3 @@ +<JAXXComboBox> + <item value='Failed!'/> +</JAXXComboBox> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JListTest1.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JListTest1.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JListTest1.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +0,0 @@ -<JAXXList> - <item value='Working' selected='true'/> -</JAXXList> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JListTest1.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JListTest1.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JListTest1.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JListTest1.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,3 @@ +<JAXXList> + <item value='Working' selected='true'/> +</JAXXList> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JListTest2.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JListTest2.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JListTest2.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +0,0 @@ -<JAXXList> - <item value='Failed!'/> -</JAXXList> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JListTest2.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JListTest2.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JListTest2.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JListTest2.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,3 @@ +<JAXXList> + <item value='Failed!'/> +</JAXXList> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JTreeTest1.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JTreeTest1.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JTreeTest1.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +0,0 @@ -<JAXXTree> - <item value='Working' selected='true'/> -</JAXXTree> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JTreeTest1.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JTreeTest1.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JTreeTest1.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JTreeTest1.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,3 @@ +<JAXXTree> + <item value='Working' selected='true'/> +</JAXXTree> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JTreeTest2.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JTreeTest2.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JTreeTest2.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +0,0 @@ -<JAXXTree> - <item value='Failed!'/> -</JAXXTree> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JTreeTest2.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JTreeTest2.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JTreeTest2.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JTreeTest2.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,3 @@ +<JAXXTree> + <item value='Failed!'/> +</JAXXTree> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/SpecialSubclassing.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/SpecialSubclassing.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/SpecialSubclassing.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,26 +0,0 @@ -<Application title='Special Subclassing'> - <VBox> - <JComboBoxTest1/> - <JComboBoxTest2> - <item value='Working' selected='true'/> - </JComboBoxTest2> - - <JScrollPane> - <JListTest1/> - </JScrollPane> - <JScrollPane> - <JListTest2> - <item value='Working' selected='true'/> - </JListTest2> - </JScrollPane> - - <JScrollPane width='80' height='80'> - <JTreeTest1/> - </JScrollPane> - <JScrollPane width='80' height='80'> - <JTreeTest2> - <item value='Working' selected='true'/> - </JTreeTest2> - </JScrollPane> - </VBox> -</Application> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/SpecialSubclassing.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/SpecialSubclassing.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/SpecialSubclassing.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/SpecialSubclassing.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,26 @@ +<Application title='Special Subclassing'> + <VBox> + <JComboBoxTest1/> + <JComboBoxTest2> + <item value='Working' selected='true'/> + </JComboBoxTest2> + + <JScrollPane> + <JListTest1/> + </JScrollPane> + <JScrollPane> + <JListTest2> + <item value='Working' selected='true'/> + </JListTest2> + </JScrollPane> + + <JScrollPane width='80' height='80'> + <JTreeTest1/> + </JScrollPane> + <JScrollPane width='80' height='80'> + <JTreeTest2> + <item value='Working' selected='true'/> + </JTreeTest2> + </JScrollPane> + </VBox> +</Application> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/ValidatorErrors.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/ValidatorErrors.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/ValidatorErrors.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.nuiton.jaxx.test</groupId> - <artifactId>test</artifactId> - <version>0</version> - - <build> - <plugins> - <plugin> - <groupId>org.nuiton</groupId> - <artifactId>maven-jaxx-plugin</artifactId> - <configuration> - <src>${basedir}/target/test-classes</src> - <outJava>${basedir}/target/generated-sources/test-java</outJava> - <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> - <force>true</force> - <!--<verbose>true</verbose>--> - <includes> - <value>**/compilerValidatorTest/validator/errors/*.jaxx</value> - </includes> - </configuration> - </plugin> - </plugins> - </build> -</project> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/ValidatorErrors.xml (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/ValidatorErrors.xml) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/ValidatorErrors.xml (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/ValidatorErrors.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.nuiton.jaxx.test</groupId> + <artifactId>test</artifactId> + <version>0</version> + + <build> + <plugins> + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <configuration> + <src>${basedir}/target/test-classes</src> + <outJava>${basedir}/target/generated-sources/test-java</outJava> + <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> + <force>true</force> + <!--<verbose>true</verbose>--> + <includes> + <value>**/compilerValidatorTest/validator/errors/*.jaxx</value> + </includes> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/ValidatorOk.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/ValidatorOk.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/ValidatorOk.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.nuiton.jaxx.test</groupId> - <artifactId>test</artifactId> - <version>0</version> - <build> - <plugins> - <plugin> - <groupId>org.nuiton</groupId> - <artifactId>maven-jaxx-plugin</artifactId> - <configuration> - <src>${basedir}/target/test-classes</src> - <outJava>${basedir}/target/generated-sources/test-java</outJava> - <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> - <force>true</force> - <!--<verbose>true</verbose>--> - <includes> - <value>**/compilerValidatorTest/validator/ok/*.jaxx</value> - </includes> - </configuration> - </plugin> - </plugins> - </build> -</project> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/ValidatorOk.xml (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/ValidatorOk.xml) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/ValidatorOk.xml (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/ValidatorOk.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.nuiton.jaxx.test</groupId> + <artifactId>test</artifactId> + <version>0</version> + <build> + <plugins> + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <configuration> + <src>${basedir}/target/test-classes</src> + <outJava>${basedir}/target/generated-sources/test-java</outJava> + <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> + <force>true</force> + <!--<verbose>true</verbose>--> + <includes> + <value>**/compilerValidatorTest/validator/ok/*.jaxx</value> + </includes> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/AutoFieldComponentNotFound.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/AutoFieldComponentNotFound.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/AutoFieldComponentNotFound.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,5 +0,0 @@ -<Application> - <BeanValidator beanClass="org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors.Model" autoField='true' strictMode='true'/> - <JTextField id='text'/> - <JTextField id='text2'/> -</Application> Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/AutoFieldComponentNotFound.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/AutoFieldComponentNotFound.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/AutoFieldComponentNotFound.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/AutoFieldComponentNotFound.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,5 @@ +<Application> + <BeanValidator beanClass="org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors.Model" autoField='true' strictMode='true'/> + <JTextField id='text'/> + <JTextField id='text2'/> +</Application> Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedBean.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedBean.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedBean.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +0,0 @@ -<Application> - <BeanValidator bean='model' errorListModel='errors' bean='yo'/> -</Application> Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedBean.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedBean.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedBean.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedBean.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,3 @@ +<Application> + <BeanValidator bean='model' errorListModel='errors' bean='yo'/> +</Application> Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedBean2.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedBean2.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedBean2.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,5 +0,0 @@ -<Application> - <Model id='model'/> - <BeanValidator bean='model'/> - <BeanValidator bean='model'/> -</Application> Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedBean2.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedBean2.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedBean2.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedBean2.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,5 @@ +<Application> + <Model id='model'/> + <BeanValidator bean='model'/> + <BeanValidator bean='model'/> +</Application> Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedErrorListModel.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedErrorListModel.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedErrorListModel.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,4 +0,0 @@ -<Application> - <jaxx.runtime.validator.swing.SwingValidatorMessageListModel id='errors'/> - <BeanValidator beanClass='org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors.Model' errorListModel='errors' errorListModel='fake'/> -</Application> Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedErrorListModel.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedErrorListModel.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedErrorListModel.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedErrorListModel.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,4 @@ +<Application> + <jaxx.runtime.validator.swing.SwingValidatorMessageListModel id='errors'/> + <BeanValidator beanClass='org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors.Model' errorListModel='errors' errorListModel='fake'/> +</Application> Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedErrorTableModel.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedErrorTableModel.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedErrorTableModel.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,4 +0,0 @@ -<Application> - <jaxx.runtime.validator.swing.SwingValidatorMessageListModel id='errors'/> - <BeanValidator beanClass='org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors.Model' errorTableModel='errors' errorTableModel='fake'/> -</Application> Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedErrorTableModel.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedErrorTableModel.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedErrorTableModel.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedErrorTableModel.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,4 @@ +<Application> + <jaxx.runtime.validator.swing.SwingValidatorMessageListModel id='errors'/> + <BeanValidator beanClass='org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors.Model' errorTableModel='errors' errorTableModel='fake'/> +</Application> Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedFieldInSameValidator.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedFieldInSameValidator.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedFieldInSameValidator.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,7 +0,0 @@ -<Application> - <BeanValidator beanClass="org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors.Model"> - <field name="text"/> - <field name="text"/> - </BeanValidator> - <JTextField id='text'/> -</Application> Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedFieldInSameValidator.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedFieldInSameValidator.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedFieldInSameValidator.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/DuplicatedFieldInSameValidator.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,7 @@ +<Application> + <BeanValidator beanClass="org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors.Model"> + <field name="text"/> + <field name="text"/> + </BeanValidator> + <JTextField id='text'/> +</Application> Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldBeanPropertyNotFound.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldBeanPropertyNotFound.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldBeanPropertyNotFound.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,5 +0,0 @@ -<Application> - <BeanValidator beanClass="org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors.Model"> - <field name="fake"/> - </BeanValidator> -</Application> Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldBeanPropertyNotFound.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldBeanPropertyNotFound.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldBeanPropertyNotFound.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldBeanPropertyNotFound.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,5 @@ +<Application> + <BeanValidator beanClass="org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors.Model"> + <field name="fake"/> + </BeanValidator> +</Application> Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldComponentDuplicated.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldComponentDuplicated.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldComponentDuplicated.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,7 +0,0 @@ -<Application> - <BeanValidator beanClass="org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors.Model"> - <field name="text2" component="text"/> - <field name="text" component="text"/> - </BeanValidator> - <JTextField id='text'/> -</Application> Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldComponentDuplicated.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldComponentDuplicated.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldComponentDuplicated.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldComponentDuplicated.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,7 @@ +<Application> + <BeanValidator beanClass="org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors.Model"> + <field name="text2" component="text"/> + <field name="text" component="text"/> + </BeanValidator> + <JTextField id='text'/> +</Application> Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldComponentNotFound.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldComponentNotFound.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldComponentNotFound.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,5 +0,0 @@ -<Application> - <BeanValidator beanClass="org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors.Model"> - <field name="text" component="fake"/> - </BeanValidator> -</Application> Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldComponentNotFound.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldComponentNotFound.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldComponentNotFound.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldComponentNotFound.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,5 @@ +<Application> + <BeanValidator beanClass="org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors.Model"> + <field name="text" component="fake"/> + </BeanValidator> +</Application> Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldComponentNotFound2.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldComponentNotFound2.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldComponentNotFound2.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,5 +0,0 @@ -<Application> - <BeanValidator beanClass="org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors.Model"> - <field name="fake"/> - </BeanValidator> -</Application> Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldComponentNotFound2.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldComponentNotFound2.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldComponentNotFound2.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldComponentNotFound2.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,5 @@ +<Application> + <BeanValidator beanClass="org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors.Model"> + <field name="fake"/> + </BeanValidator> +</Application> Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldNoName.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldNoName.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldNoName.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,5 +0,0 @@ -<Application> - <BeanValidator beanClass="org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors.Model"> - <field/> - </BeanValidator> -</Application> Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldNoName.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldNoName.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldNoName.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldNoName.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,5 @@ +<Application> + <BeanValidator beanClass="org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors.Model"> + <field/> + </BeanValidator> +</Application> Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldNoName2.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldNoName2.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldNoName2.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,5 +0,0 @@ -<Application> - <BeanValidator beanClass="org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors.Model"> - <field component="text"/> - </BeanValidator> -</Application> Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldNoName2.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldNoName2.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldNoName2.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/FieldNoName2.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,5 @@ +<Application> + <BeanValidator beanClass="org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors.Model"> + <field component="text"/> + </BeanValidator> +</Application> Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/Model.java =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/Model.java 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/Model.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,66 +0,0 @@ -package org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors; - -import java.beans.*; - -public class Model { - - protected String text = "text"; - - protected String text2 = "text2"; - - protected int ratio = 51; - - - PropertyChangeSupport p; - - public Model() { - p = new PropertyChangeSupport(this); - } - - public void addPropertyChangeListener(PropertyChangeListener listener) { - p.addPropertyChangeListener(listener); - } - - public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { - p.addPropertyChangeListener(propertyName, listener); - } - - public void removePropertyChangeListener(PropertyChangeListener listener) { - p.removePropertyChangeListener(listener); - } - - public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { - p.removePropertyChangeListener(propertyName, listener); - } - - - public String getText() { - return text; - } - - public String getText2() { - return text2; - } - - public int getRatio() { - return ratio; - } - - public void setText(String text) { - String oldText = this.text; - this.text = text; - p.firePropertyChange("text", oldText, text); - } - - public void setText2(String text2) { - String oldText2 = this.text2; - this.text2 = text2; - p.firePropertyChange("text2", oldText2, text2); - } - - public void setRatio(int ratio) { - int oldRatio = this.ratio; - this.ratio = ratio; - p.firePropertyChange("ratio",oldRatio, ratio); - } -} \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/Model.java (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/Model.java) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/Model.java (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/Model.java 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,66 @@ +package org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors; + +import java.beans.*; + +public class Model { + + protected String text = "text"; + + protected String text2 = "text2"; + + protected int ratio = 51; + + + PropertyChangeSupport p; + + public Model() { + p = new PropertyChangeSupport(this); + } + + public void addPropertyChangeListener(PropertyChangeListener listener) { + p.addPropertyChangeListener(listener); + } + + public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { + p.addPropertyChangeListener(propertyName, listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + p.removePropertyChangeListener(listener); + } + + public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { + p.removePropertyChangeListener(propertyName, listener); + } + + + public String getText() { + return text; + } + + public String getText2() { + return text2; + } + + public int getRatio() { + return ratio; + } + + public void setText(String text) { + String oldText = this.text; + this.text = text; + p.firePropertyChange("text", oldText, text); + } + + public void setText2(String text2) { + String oldText2 = this.text2; + this.text2 = text2; + p.firePropertyChange("text2", oldText2, text2); + } + + public void setRatio(int ratio) { + int oldRatio = this.ratio; + this.ratio = ratio; + p.firePropertyChange("ratio",oldRatio, ratio); + } +} \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/NoBean.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/NoBean.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/NoBean.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,5 +0,0 @@ -<Application> - - <BeanValidator id='validator'/> - -</Application> Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/NoBean.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/NoBean.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/NoBean.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/NoBean.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,5 @@ +<Application> + + <BeanValidator id='validator'/> + +</Application> Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundBean.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundBean.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundBean.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +0,0 @@ -<Application> - <BeanValidator bean='fake'/> -</Application> Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundBean.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundBean.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundBean.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundBean.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,3 @@ +<Application> + <BeanValidator bean='fake'/> +</Application> Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorList.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorList.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorList.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +0,0 @@ -<Application> - <BeanValidator beanClass='org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors.Model' errorList='fake'/> -</Application> Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorList.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorList.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorList.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorList.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,3 @@ +<Application> + <BeanValidator beanClass='org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors.Model' errorList='fake'/> +</Application> Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorListModel.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorListModel.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorListModel.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +0,0 @@ -<Application> - <BeanValidator beanClass='org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors.Model' errorListModel='fake'/> -</Application> Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorListModel.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorListModel.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorListModel.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorListModel.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,3 @@ +<Application> + <BeanValidator beanClass='org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors.Model' errorListModel='fake'/> +</Application> Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorTable.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorTable.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorTable.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +0,0 @@ -<Application> - <BeanValidator beanClass='org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors.Model' errorTable='fake'/> -</Application> Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorTable.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorTable.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorTable.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorTable.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,3 @@ +<Application> + <BeanValidator beanClass='org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors.Model' errorTable='fake'/> +</Application> Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorTableModel.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorTableModel.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorTableModel.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +0,0 @@ -<Application> - <BeanValidator bean='org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors.Model' errorTableModel='fake'/> -</Application> Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorTableModel.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorTableModel.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorTableModel.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundErrorTableModel.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,3 @@ +<Application> + <BeanValidator bean='org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors.Model' errorTableModel='fake'/> +</Application> Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundParentValidator.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundParentValidator.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundParentValidator.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +0,0 @@ -<Application> - <BeanValidator beanClass='org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors.Model' parentValidator='fake'/> -</Application> Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundParentValidator.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundParentValidator.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundParentValidator.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/errors/UnfoundParentValidator.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,3 @@ +<Application> + <BeanValidator beanClass='org.nuiton.jaxx.plugin.compilerValidatorTest.validator.errors.Model' parentValidator='fake'/> +</Application> Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Validation.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Validation.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Validation.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,274 +0,0 @@ -<Application title="Validation.jaxx"> - - <!-- models --> - <Model id='model'/> - <Model id='model2'/> - <Identity id='identity'/> - - <!-- errors model --> - <jaxx.runtime.validator.swing.SwingValidatorMessageListModel id='errors' - onContentsChanged='ok.setEnabled(errors.isEmpty())'/> - - <!-- validators --> - <BeanValidator id='validator' bean='model' errorListModel='errors'> - <field name="text"/> - <field name="text2"/> - <field name="ratio"/> - </BeanValidator> - <BeanValidator id='validator2' bean='model2' errorListModel='errors' - uiClass="jaxx.runtime.validator.swing.ui.IconValidationUI"> - <field name="text" component="_text"/> - <field name="text2" component="_text2"/> - <field name="ratio" component="_ratio"/> - </BeanValidator> - <BeanValidator id='validator3' autoField='true' bean='identity' errorListModel='errors' - uiClass="jaxx.runtime.validator.swing.ui.TranslucentValidationUI"> - <field name="email" component="email2"/> - </BeanValidator> - - <Table fill='both'> - <row> - <cell weightx='1' weighty='1' insets='6, 3, 0, 0'> - <JPanel border='{BorderFactory.createTitledBorder("Form")}' - layout='{new GridLayout()}' width='250' height='120'> - <Table anchor='west' fill='both'> - <row> - <cell> - <JLabel text='Text:'/> - </cell> - <cell weightx='1'> - <JTextField id='text' text='{model.getText()}' - onKeyReleased='model.setText(text.getText())'/> - </cell> - </row> - <row> - <cell> - <JLabel text='Text2:'/> - </cell> - <cell weightx='1'> - <JTextField id='text2' text='{model.getText2()}' - onKeyReleased='model.setText2(text2.getText())'/> - </cell> - </row> - - <row> - <cell> - <JLabel text='Ratio:'/> - </cell> - <cell> - <JSlider id='ratio' minimum='0' maximum='100' value='{model.getRatio()}' - onStateChanged='model.setRatio(ratio.getValue())'/> - </cell> - </row> - </Table> - </JPanel> - </cell> - <cell weightx='1' weighty='1' insets='6, 3, 0, 0'> - <JPanel border='{BorderFactory.createTitledBorder("Model")}' - layout='{new GridLayout()}' width='250' height='120'> - <Table anchor='west' fill='both'> - <row> - <cell> - <JLabel text='Text:'/> - </cell> - <cell weightx='1'> - <JLabel text='{model.getText()}'/> - </cell> - </row> - <row> - <cell> - <JLabel text='Text2:'/> - </cell> - <cell weightx='1'> - <JLabel text='{model.getText2()}'/> - </cell> - </row> - - <row> - <cell> - <JLabel text='Ratio:'/> - </cell> - <cell> - <JLabel text='{model.getRatio()+""}'/> - </cell> - </row> - </Table> - </JPanel> - </cell> - </row> - <row> - <cell weightx='1' weighty='1' insets='6, 3, 0, 0'> - <JPanel border='{BorderFactory.createTitledBorder("Form2")}' - layout='{new GridLayout()}' width='250' height='120'> - <Table anchor='west' fill='both'> - <row> - <cell> - <JLabel text='Text:'/> - </cell> - <cell weightx='1'> - <JTextField id='_text' text='{model2.getText()}' - onKeyReleased='model2.setText(_text.getText())'/> - </cell> - </row> - <row> - <cell> - <JLabel text='Text2:'/> - </cell> - <cell weightx='1'> - <JTextField id='_text2' text='{model2.getText2()}' - onKeyReleased='model2.setText2(_text2.getText())'/> - </cell> - </row> - - <row> - <cell> - <JLabel text='Ratio:'/> - </cell> - <cell> - <JSlider id='_ratio' minimum='0' maximum='100' value='{model2.getRatio()}' - onStateChanged='model2.setRatio(_ratio.getValue())'/> - </cell> - </row> - </Table> - </JPanel> - </cell> - <cell weightx='1' weighty='1' insets='6, 3, 0, 0'> - <JPanel border='{BorderFactory.createTitledBorder("Model2")}' - layout='{new GridLayout()}' width='250' height='120'> - <Table anchor='west' fill='both'> - <row> - <cell> - <JLabel text='Text:'/> - </cell> - <cell weightx='1'> - <JLabel text='{model2.getText()}'/> - </cell> - </row> - <row> - <cell> - <JLabel text='Text2:'/> - </cell> - <cell weightx='1'> - <JLabel text='{model2.getText2()}'/> - </cell> - </row> - - <row> - <cell> - <JLabel text='Ratio:'/> - </cell> - <cell> - <JLabel text='{model2.getRatio()+""}'/> - </cell> - </row> - </Table> - </JPanel> - </cell> - </row> - <row> - <cell weightx='1' weighty='1' insets='6, 3, 0, 0'> - <JPanel border='{BorderFactory.createTitledBorder("Identify Form")}' - layout='{new GridLayout()}' width='250' height='140'> - <Table anchor='west' fill='both'> - <row> - <cell> - <JLabel text='FirstName:'/> - </cell> - <cell weightx='1'> - <JTextField id='firstName' text='{identity.getFirstName()}' - onKeyReleased='identity.setFirstName(firstName.getText())'/> - </cell> - </row> - <row> - <cell> - <JLabel text='LastName:'/> - </cell> - <cell weightx='1'> - <JTextField id='lastName' text='{identity.getLastName()}' - onKeyReleased='identity.setLastName(lastName.getText())'/> - </cell> - </row> - <row> - <cell> - <JLabel text='Email:'/> - </cell> - <cell weightx='1'> - <JTextField id='email2' text='{identity.getEmail()}' - onKeyReleased='identity.setEmail(email2.getText())'/> - </cell> - </row> - - <row> - <cell> - <JLabel text='Age:'/> - </cell> - <cell> - <JSlider id='age' minimum='0' maximum='100' value='{identity.getAge()}' - onStateChanged='identity.setAge(age.getValue())'/> - </cell> - </row> - </Table> - </JPanel> - </cell> - <cell weightx='1' weighty='1' insets='6, 3, 0, 0'> - <JPanel border='{BorderFactory.createTitledBorder("Identity Model")}' - layout='{new GridLayout()}' width='250' height='120'> - <Table anchor='west' fill='both'> - <row> - <cell> - <JLabel text='FirstName:'/> - </cell> - <cell weightx='1'> - <JLabel text='{identity.getFirstName()}'/> - </cell> - </row> - <row> - <cell> - <JLabel text='LastName:'/> - </cell> - <cell weightx='1'> - <JLabel text='{identity.getLastName()}'/> - </cell> - </row> - <row> - <cell> - <JLabel text='Email:'/> - </cell> - <cell weightx='1'> - <JLabel text='{identity.getEmail()}'/> - </cell> - </row> - - <row> - <cell> - <JLabel text='Age:'/> - </cell> - <cell> - <JLabel text='{identity.getAge()+""}'/> - </cell> - </row> - </Table> - </JPanel> - </cell> - </row> - <row> - <cell columns='2' fill="both"> - <JPanel border='{BorderFactory.createTitledBorder("Errors")}' layout='{new GridLayout()}' height='200' - width='500'> - <JScrollPane> - <JList model='{errors}'/> - </JScrollPane> - </JPanel> - </cell> - </row> - <row> - <cell columns='2' fill="both"> - <JPanel layout='{new GridLayout(1,2,0,0)}'> - <JButton text='cancel' onActionPerformed='dispose()'/> - <JButton id='ok' text='valid' onActionPerformed='dispose()'/> - </JPanel> - </cell> - </row> - - </Table> -</Application> Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Validation.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Validation.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Validation.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Validation.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,274 @@ +<Application title="Validation.jaxx"> + + <!-- models --> + <Model id='model'/> + <Model id='model2'/> + <Identity id='identity'/> + + <!-- errors model --> + <jaxx.runtime.validator.swing.SwingValidatorMessageListModel id='errors' + onContentsChanged='ok.setEnabled(errors.isEmpty())'/> + + <!-- validators --> + <BeanValidator id='validator' bean='model' errorListModel='errors'> + <field name="text"/> + <field name="text2"/> + <field name="ratio"/> + </BeanValidator> + <BeanValidator id='validator2' bean='model2' errorListModel='errors' + uiClass="jaxx.runtime.validator.swing.ui.IconValidationUI"> + <field name="text" component="_text"/> + <field name="text2" component="_text2"/> + <field name="ratio" component="_ratio"/> + </BeanValidator> + <BeanValidator id='validator3' autoField='true' bean='identity' errorListModel='errors' + uiClass="jaxx.runtime.validator.swing.ui.TranslucentValidationUI"> + <field name="email" component="email2"/> + </BeanValidator> + + <Table fill='both'> + <row> + <cell weightx='1' weighty='1' insets='6, 3, 0, 0'> + <JPanel border='{BorderFactory.createTitledBorder("Form")}' + layout='{new GridLayout()}' width='250' height='120'> + <Table anchor='west' fill='both'> + <row> + <cell> + <JLabel text='Text:'/> + </cell> + <cell weightx='1'> + <JTextField id='text' text='{model.getText()}' + onKeyReleased='model.setText(text.getText())'/> + </cell> + </row> + <row> + <cell> + <JLabel text='Text2:'/> + </cell> + <cell weightx='1'> + <JTextField id='text2' text='{model.getText2()}' + onKeyReleased='model.setText2(text2.getText())'/> + </cell> + </row> + + <row> + <cell> + <JLabel text='Ratio:'/> + </cell> + <cell> + <JSlider id='ratio' minimum='0' maximum='100' value='{model.getRatio()}' + onStateChanged='model.setRatio(ratio.getValue())'/> + </cell> + </row> + </Table> + </JPanel> + </cell> + <cell weightx='1' weighty='1' insets='6, 3, 0, 0'> + <JPanel border='{BorderFactory.createTitledBorder("Model")}' + layout='{new GridLayout()}' width='250' height='120'> + <Table anchor='west' fill='both'> + <row> + <cell> + <JLabel text='Text:'/> + </cell> + <cell weightx='1'> + <JLabel text='{model.getText()}'/> + </cell> + </row> + <row> + <cell> + <JLabel text='Text2:'/> + </cell> + <cell weightx='1'> + <JLabel text='{model.getText2()}'/> + </cell> + </row> + + <row> + <cell> + <JLabel text='Ratio:'/> + </cell> + <cell> + <JLabel text='{model.getRatio()+""}'/> + </cell> + </row> + </Table> + </JPanel> + </cell> + </row> + <row> + <cell weightx='1' weighty='1' insets='6, 3, 0, 0'> + <JPanel border='{BorderFactory.createTitledBorder("Form2")}' + layout='{new GridLayout()}' width='250' height='120'> + <Table anchor='west' fill='both'> + <row> + <cell> + <JLabel text='Text:'/> + </cell> + <cell weightx='1'> + <JTextField id='_text' text='{model2.getText()}' + onKeyReleased='model2.setText(_text.getText())'/> + </cell> + </row> + <row> + <cell> + <JLabel text='Text2:'/> + </cell> + <cell weightx='1'> + <JTextField id='_text2' text='{model2.getText2()}' + onKeyReleased='model2.setText2(_text2.getText())'/> + </cell> + </row> + + <row> + <cell> + <JLabel text='Ratio:'/> + </cell> + <cell> + <JSlider id='_ratio' minimum='0' maximum='100' value='{model2.getRatio()}' + onStateChanged='model2.setRatio(_ratio.getValue())'/> + </cell> + </row> + </Table> + </JPanel> + </cell> + <cell weightx='1' weighty='1' insets='6, 3, 0, 0'> + <JPanel border='{BorderFactory.createTitledBorder("Model2")}' + layout='{new GridLayout()}' width='250' height='120'> + <Table anchor='west' fill='both'> + <row> + <cell> + <JLabel text='Text:'/> + </cell> + <cell weightx='1'> + <JLabel text='{model2.getText()}'/> + </cell> + </row> + <row> + <cell> + <JLabel text='Text2:'/> + </cell> + <cell weightx='1'> + <JLabel text='{model2.getText2()}'/> + </cell> + </row> + + <row> + <cell> + <JLabel text='Ratio:'/> + </cell> + <cell> + <JLabel text='{model2.getRatio()+""}'/> + </cell> + </row> + </Table> + </JPanel> + </cell> + </row> + <row> + <cell weightx='1' weighty='1' insets='6, 3, 0, 0'> + <JPanel border='{BorderFactory.createTitledBorder("Identify Form")}' + layout='{new GridLayout()}' width='250' height='140'> + <Table anchor='west' fill='both'> + <row> + <cell> + <JLabel text='FirstName:'/> + </cell> + <cell weightx='1'> + <JTextField id='firstName' text='{identity.getFirstName()}' + onKeyReleased='identity.setFirstName(firstName.getText())'/> + </cell> + </row> + <row> + <cell> + <JLabel text='LastName:'/> + </cell> + <cell weightx='1'> + <JTextField id='lastName' text='{identity.getLastName()}' + onKeyReleased='identity.setLastName(lastName.getText())'/> + </cell> + </row> + <row> + <cell> + <JLabel text='Email:'/> + </cell> + <cell weightx='1'> + <JTextField id='email2' text='{identity.getEmail()}' + onKeyReleased='identity.setEmail(email2.getText())'/> + </cell> + </row> + + <row> + <cell> + <JLabel text='Age:'/> + </cell> + <cell> + <JSlider id='age' minimum='0' maximum='100' value='{identity.getAge()}' + onStateChanged='identity.setAge(age.getValue())'/> + </cell> + </row> + </Table> + </JPanel> + </cell> + <cell weightx='1' weighty='1' insets='6, 3, 0, 0'> + <JPanel border='{BorderFactory.createTitledBorder("Identity Model")}' + layout='{new GridLayout()}' width='250' height='120'> + <Table anchor='west' fill='both'> + <row> + <cell> + <JLabel text='FirstName:'/> + </cell> + <cell weightx='1'> + <JLabel text='{identity.getFirstName()}'/> + </cell> + </row> + <row> + <cell> + <JLabel text='LastName:'/> + </cell> + <cell weightx='1'> + <JLabel text='{identity.getLastName()}'/> + </cell> + </row> + <row> + <cell> + <JLabel text='Email:'/> + </cell> + <cell weightx='1'> + <JLabel text='{identity.getEmail()}'/> + </cell> + </row> + + <row> + <cell> + <JLabel text='Age:'/> + </cell> + <cell> + <JLabel text='{identity.getAge()+""}'/> + </cell> + </row> + </Table> + </JPanel> + </cell> + </row> + <row> + <cell columns='2' fill="both"> + <JPanel border='{BorderFactory.createTitledBorder("Errors")}' layout='{new GridLayout()}' height='200' + width='500'> + <JScrollPane> + <JList model='{errors}'/> + </JScrollPane> + </JPanel> + </cell> + </row> + <row> + <cell columns='2' fill="both"> + <JPanel layout='{new GridLayout(1,2,0,0)}'> + <JButton text='cancel' onActionPerformed='dispose()'/> + <JButton id='ok' text='valid' onActionPerformed='dispose()'/> + </JPanel> + </cell> + </row> + + </Table> +</Application> Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/ValidationBeanClass.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/ValidationBeanClass.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/ValidationBeanClass.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,112 +0,0 @@ -<Application title="Validation.jaxx"> - - <!-- models --> - <Identity id='identity'/> - - <!-- errors model --> - <jaxx.runtime.validator.swing.SwingValidatorMessageListModel id='errors'/> - - <!-- validators --> - <BeanValidator id='validator3' autoField='true' beanClass='org.nuiton.jaxx.plugin.compilerValidatorTest.validator.ok.Identity' errorListModel='errors'> - <field name="email" component="email2"/> - </BeanValidator> - - <Table fill='both'> - <row> - <cell weightx='1' weighty='1' insets='6, 3, 0, 0'> - <JPanel border='{BorderFactory.createTitledBorder("Identify Form")}' - layout='{new GridLayout()}' width='250' height='140'> - <Table anchor='west' fill='both'> - <row> - <cell> - <JLabel text='FirstName:'/> - </cell> - <cell weightx='1'> - <JTextField id='firstName' text='{identity.getFirstName()}' - onKeyReleased='identity.setFirstName(firstName.getText())'/> - </cell> - </row> - <row> - <cell> - <JLabel text='LastName:'/> - </cell> - <cell weightx='1'> - <JTextField id='lastName' text='{identity.getLastName()}' - onKeyReleased='identity.setLastName(lastName.getText())'/> - </cell> - </row> - <row> - <cell> - <JLabel text='Email:'/> - </cell> - <cell weightx='1'> - <JTextField id='email2' text='{identity.getEmail()}' - onKeyReleased='identity.setEmail(email2.getText())'/> - </cell> - </row> - - <row> - <cell> - <JLabel text='Age:'/> - </cell> - <cell> - <JSlider id='age' minimum='0' maximum='100' value='{identity.getAge()}' - onStateChanged='identity.setAge(age.getValue())'/> - </cell> - </row> - </Table> - </JPanel> - </cell> - <cell weightx='1' weighty='1' insets='6, 3, 0, 0'> - <JPanel border='{BorderFactory.createTitledBorder("Identity Model")}' - layout='{new GridLayout()}' width='250' height='120'> - <Table anchor='west' fill='both'> - <row> - <cell> - <JLabel text='FirstName:'/> - </cell> - <cell weightx='1'> - <JLabel text='{identity.getFirstName()}'/> - </cell> - </row> - <row> - <cell> - <JLabel text='LastName:'/> - </cell> - <cell weightx='1'> - <JLabel text='{identity.getLastName()}'/> - </cell> - </row> - <row> - <cell> - <JLabel text='Email:'/> - </cell> - <cell weightx='1'> - <JLabel text='{identity.getEmail()}'/> - </cell> - </row> - - <row> - <cell> - <JLabel text='Age:'/> - </cell> - <cell> - <JLabel text='{identity.getAge()+""}'/> - </cell> - </row> - </Table> - </JPanel> - </cell> - </row> - <row> - <cell columns='2' fill="both"> - <JPanel border='{BorderFactory.createTitledBorder("Errors")}' layout='{new GridLayout()}' height='200' - width='500'> - <JScrollPane> - <JList model='{errors}'/> - </JScrollPane> - </JPanel> - </cell> - </row> - </Table> -</Application> Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/ValidationBeanClass.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/ValidationBeanClass.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/ValidationBeanClass.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/ValidationBeanClass.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,112 @@ +<Application title="Validation.jaxx"> + + <!-- models --> + <Identity id='identity'/> + + <!-- errors model --> + <jaxx.runtime.validator.swing.SwingValidatorMessageListModel id='errors'/> + + <!-- validators --> + <BeanValidator id='validator3' autoField='true' beanClass='org.nuiton.jaxx.plugin.compilerValidatorTest.validator.ok.Identity' errorListModel='errors'> + <field name="email" component="email2"/> + </BeanValidator> + + <Table fill='both'> + <row> + <cell weightx='1' weighty='1' insets='6, 3, 0, 0'> + <JPanel border='{BorderFactory.createTitledBorder("Identify Form")}' + layout='{new GridLayout()}' width='250' height='140'> + <Table anchor='west' fill='both'> + <row> + <cell> + <JLabel text='FirstName:'/> + </cell> + <cell weightx='1'> + <JTextField id='firstName' text='{identity.getFirstName()}' + onKeyReleased='identity.setFirstName(firstName.getText())'/> + </cell> + </row> + <row> + <cell> + <JLabel text='LastName:'/> + </cell> + <cell weightx='1'> + <JTextField id='lastName' text='{identity.getLastName()}' + onKeyReleased='identity.setLastName(lastName.getText())'/> + </cell> + </row> + <row> + <cell> + <JLabel text='Email:'/> + </cell> + <cell weightx='1'> + <JTextField id='email2' text='{identity.getEmail()}' + onKeyReleased='identity.setEmail(email2.getText())'/> + </cell> + </row> + + <row> + <cell> + <JLabel text='Age:'/> + </cell> + <cell> + <JSlider id='age' minimum='0' maximum='100' value='{identity.getAge()}' + onStateChanged='identity.setAge(age.getValue())'/> + </cell> + </row> + </Table> + </JPanel> + </cell> + <cell weightx='1' weighty='1' insets='6, 3, 0, 0'> + <JPanel border='{BorderFactory.createTitledBorder("Identity Model")}' + layout='{new GridLayout()}' width='250' height='120'> + <Table anchor='west' fill='both'> + <row> + <cell> + <JLabel text='FirstName:'/> + </cell> + <cell weightx='1'> + <JLabel text='{identity.getFirstName()}'/> + </cell> + </row> + <row> + <cell> + <JLabel text='LastName:'/> + </cell> + <cell weightx='1'> + <JLabel text='{identity.getLastName()}'/> + </cell> + </row> + <row> + <cell> + <JLabel text='Email:'/> + </cell> + <cell weightx='1'> + <JLabel text='{identity.getEmail()}'/> + </cell> + </row> + + <row> + <cell> + <JLabel text='Age:'/> + </cell> + <cell> + <JLabel text='{identity.getAge()+""}'/> + </cell> + </row> + </Table> + </JPanel> + </cell> + </row> + <row> + <cell columns='2' fill="both"> + <JPanel border='{BorderFactory.createTitledBorder("Errors")}' layout='{new GridLayout()}' height='200' + width='500'> + <JScrollPane> + <JList model='{errors}'/> + </JScrollPane> + </JPanel> + </cell> + </row> + </Table> +</Application> Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/dataBindingTest/First.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/dataBindingTest/First.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/dataBindingTest/First.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,24 +0,0 @@ - -<JPanel> - - <java.io.File id='file' constructorParams='""'/> - <java.io.File id='file2' javaBean='new File("")'/> - - <org.nuiton.jaxx.plugin.DataBinding.Bean id='bean' javaBean='new org.nuiton.jaxx.plugin.DataBinding.BeanImpl()'/> - <org.nuiton.jaxx.plugin.DataBinding.BeanImpl id='beanImpl' javaBean='new org.nuiton.jaxx.plugin.DataBinding.BeanImpl()'/> - - <JLabel id='nobinding1' text='{file.getAbsolutePath()}'/> - <JLabel id='nobinding2' text='{getFile().getAbsolutePath()}'/> - - <JLabel id='binding0' text='{file2.getAbsolutePath()}' javaBean='new JLabel()'/> - <JLabel id='binding1' text='{this.getFile2().getAbsolutePath()}'/> - <JLabel id='binding2' text='{getFile2().getAbsolutePath()}'/> - <JLabel id='binding3' text='{bean.getText()}'/> - <JLabel id='binding4' text='{getBean().getText()}'/> - <JLabel id='binding5' text='{beanImpl.getText()}'/> - <JLabel id='binding6' text='{getBeanImpl().getText()}'/> - <JLabel id='binding7' text='{binding0.getText()}'/> - <JLabel id='binding8' text='{getBinding0().getText()}'/> - <JLabel id='binding9' text='{binding0.getText() + binding1.getText()}'/> - -</JPanel> Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/dataBindingTest/First.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/dataBindingTest/First.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/dataBindingTest/First.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/dataBindingTest/First.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,24 @@ + +<JPanel> + + <java.io.File id='file' constructorParams='""'/> + <java.io.File id='file2' javaBean='new File("")'/> + + <org.nuiton.jaxx.plugin.DataBinding.Bean id='bean' javaBean='new org.nuiton.jaxx.plugin.DataBinding.BeanImpl()'/> + <org.nuiton.jaxx.plugin.DataBinding.BeanImpl id='beanImpl' javaBean='new org.nuiton.jaxx.plugin.DataBinding.BeanImpl()'/> + + <JLabel id='nobinding1' text='{file.getAbsolutePath()}'/> + <JLabel id='nobinding2' text='{getFile().getAbsolutePath()}'/> + + <JLabel id='binding0' text='{file2.getAbsolutePath()}' javaBean='new JLabel()'/> + <JLabel id='binding1' text='{this.getFile2().getAbsolutePath()}'/> + <JLabel id='binding2' text='{getFile2().getAbsolutePath()}'/> + <JLabel id='binding3' text='{bean.getText()}'/> + <JLabel id='binding4' text='{getBean().getText()}'/> + <JLabel id='binding5' text='{beanImpl.getText()}'/> + <JLabel id='binding6' text='{getBeanImpl().getText()}'/> + <JLabel id='binding7' text='{binding0.getText()}'/> + <JLabel id='binding8' text='{getBinding0().getText()}'/> + <JLabel id='binding9' text='{binding0.getText() + binding1.getText()}'/> + +</JPanel> Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/dataBindingTest/simpleBinding.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/dataBindingTest/simpleBinding.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/dataBindingTest/simpleBinding.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.nuiton.jaxx.test</groupId> - <artifactId>test</artifactId> - <version>0</version> - <build> - <plugins> - <plugin> - <groupId>org.nuiton</groupId> - <artifactId>maven-jaxx-plugin</artifactId> - <configuration> - <src>${basedir}/target/test-classes</src> - <outJava>${basedir}/target/generated-sources/test-java</outJava> - <force>true</force> - <!--<verbose>true</verbose>--> - <includes> - <value>**/dataBindingTest/*.jaxx</value> - </includes> - </configuration> - </plugin> - </plugins> - </build> -</project> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/dataBindingTest/simpleBinding.xml (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/dataBindingTest/simpleBinding.xml) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/dataBindingTest/simpleBinding.xml (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/dataBindingTest/simpleBinding.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.nuiton.jaxx.test</groupId> + <artifactId>test</artifactId> + <version>0</version> + <build> + <plugins> + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <configuration> + <src>${basedir}/target/test-classes</src> + <outJava>${basedir}/target/generated-sources/test-java</outJava> + <force>true</force> + <!--<verbose>true</verbose>--> + <includes> + <value>**/dataBindingTest/*.jaxx</value> + </includes> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/decoratorTest/BoxedDecorator.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/decoratorTest/BoxedDecorator.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/decoratorTest/BoxedDecorator.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +0,0 @@ -<JPanel> - <JButton id='boxedButton' decorator='boxed'/> -</JPanel> Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/decoratorTest/BoxedDecorator.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/decoratorTest/BoxedDecorator.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/decoratorTest/BoxedDecorator.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/decoratorTest/BoxedDecorator.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,3 @@ +<JPanel> + <JButton id='boxedButton' decorator='boxed'/> +</JPanel> Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/decoratorTest/Decorator.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/decoratorTest/Decorator.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/decoratorTest/Decorator.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.nuiton.jaxx.test</groupId> - <artifactId>test</artifactId> - <version>0</version> - <build> - <plugins> - <plugin> - <groupId>org.nuiton</groupId> - <artifactId>maven-jaxx-plugin</artifactId> - <configuration> - <src>${basedir}/target/test-classes</src> - <outJava>${basedir}/target/generated-sources/test-java</outJava> - <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> - <force>true</force> - <addLogger>false</addLogger> - <includes> - <value>**/decoratorTest/*.jaxx</value> - </includes> - </configuration> - </plugin> - </plugins> - </build> -</project> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/decoratorTest/Decorator.xml (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/decoratorTest/Decorator.xml) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/decoratorTest/Decorator.xml (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/decoratorTest/Decorator.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.nuiton.jaxx.test</groupId> + <artifactId>test</artifactId> + <version>0</version> + <build> + <plugins> + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <configuration> + <src>${basedir}/target/test-classes</src> + <outJava>${basedir}/target/generated-sources/test-java</outJava> + <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> + <force>true</force> + <addLogger>false</addLogger> + <includes> + <value>**/decoratorTest/*.jaxx</value> + </includes> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Property changes on: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test ___________________________________________________________________ Added: svn:mergeinfo + Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error/swingcombo.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error/swingcombo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error/swingcombo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,4 +0,0 @@ - -<JComboBox id='comboBox'> - <item value='{_("OK")}' selected='true'/> -</JComboBox> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error/swingcombo.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error/swingcombo.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error/swingcombo.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error/swingcombo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,4 @@ + +<JComboBox id='comboBox'> + <item value='{_("OK")}' selected='true'/> +</JComboBox> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error/swinglist.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error/swinglist.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error/swinglist.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,4 +0,0 @@ - -<JList> - <item value='OK'/> -</JList> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error/swinglist.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error/swinglist.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error/swinglist.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error/swinglist.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,4 @@ + +<JList> + <item value='OK'/> +</JList> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error/swingtree.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error/swingtree.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error/swingtree.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,4 +0,0 @@ - -<JTree> - <item value='OK'/> -</JTree> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error/swingtree.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error/swingtree.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error/swingtree.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error/swingtree.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,4 @@ + +<JTree> + <item value='OK'/> +</JTree> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.nuiton.jaxx.test</groupId> - <artifactId>test</artifactId> - <version>0</version> - <build> - <plugins> - <plugin> - <groupId>org.nuiton</groupId> - <artifactId>maven-jaxx-plugin</artifactId> - <configuration> - <src>${basedir}/target/test-classes</src> - <outJava>${basedir}/target/generated-sources/test-java</outJava> - <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> - <force>true</force> - <!--<verbose>true</verbose>--> - <includes> - <value>**/evolution74Test/error/*.jaxx</value> - </includes> - </configuration> - </plugin> - </plugins> - </build> -</project> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error.xml (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error.xml) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error.xml (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/error.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.nuiton.jaxx.test</groupId> + <artifactId>test</artifactId> + <version>0</version> + <build> + <plugins> + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <configuration> + <src>${basedir}/target/test-classes</src> + <outJava>${basedir}/target/generated-sources/test-java</outJava> + <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> + <force>true</force> + <!--<verbose>true</verbose>--> + <includes> + <value>**/evolution74Test/error/*.jaxx</value> + </includes> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxcombo.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxcombo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxcombo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,4 +0,0 @@ - -<JAXXComboBox> - <item value='OK'/> -</JAXXComboBox> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxcombo.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxcombo.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxcombo.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxcombo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,4 @@ + +<JAXXComboBox> + <item value='OK'/> +</JAXXComboBox> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxlist.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxlist.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxlist.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,4 +0,0 @@ - -<JAXXList> - <item value='OK'/> -</JAXXList> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxlist.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxlist.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxlist.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxlist.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,4 @@ + +<JAXXList> + <item value='OK'/> +</JAXXList> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxtree.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxtree.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxtree.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,4 +0,0 @@ - -<JAXXTree> - <item value='OK'/> -</JAXXTree> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxtree.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxtree.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxtree.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxtree.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,4 @@ + +<JAXXTree> + <item value='OK'/> +</JAXXTree> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/swingcombo.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/swingcombo.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/swingcombo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,2 +0,0 @@ - -<JComboBox/> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/swingcombo.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/swingcombo.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/swingcombo.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/swingcombo.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,2 @@ + +<JComboBox/> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/swinglist.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/swinglist.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/swinglist.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1 +0,0 @@ -<JList/> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/swinglist.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/swinglist.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/swinglist.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/swinglist.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1 @@ +<JList/> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/swingtree.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/swingtree.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/swingtree.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,2 +0,0 @@ - -<JTree/> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/swingtree.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/swingtree.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/swingtree.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok/swingtree.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,2 @@ + +<JTree/> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.nuiton.jaxx.test</groupId> - <artifactId>test</artifactId> - <version>0</version> - <build> - <plugins> - <plugin> - <groupId>org.nuiton</groupId> - <artifactId>maven-jaxx-plugin</artifactId> - <configuration> - <src>${basedir}/target/test-classes</src> - <outJava>${basedir}/target/generated-sources/test-java</outJava> - <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> - <force>true</force> - <includes> - <value>**/evolution74Test/ok/*.jaxx</value> - </includes> - </configuration> - </plugin> - </plugins> - </build> -</project> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok.xml (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok.xml) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok.xml (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/evolution74Test/ok.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.nuiton.jaxx.test</groupId> + <artifactId>test</artifactId> + <version>0</version> + <build> + <plugins> + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <configuration> + <src>${basedir}/target/test-classes</src> + <outJava>${basedir}/target/generated-sources/test-java</outJava> + <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> + <force>true</force> + <includes> + <value>**/evolution74Test/ok/*.jaxx</value> + </includes> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/I18nText.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/I18nText.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/I18nText.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.nuiton.jaxx.test</groupId> - <artifactId>test</artifactId> - <version>0</version> - <build> - <plugins> - <plugin> - <groupId>org.nuiton</groupId> - <artifactId>maven-jaxx-plugin</artifactId> - <configuration> - <src>${basedir}/target/test-classes</src> - <outJava>${basedir}/target/generated-sources/test-java</outJava> - <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> - <force>true</force> - <i18nable>true</i18nable> - <includes> - <value>**/i18nTest/text/*.jaxx</value> - </includes> - </configuration> - </plugin> - </plugins> - </build> -</project> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/I18nText.xml (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/I18nText.xml) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/I18nText.xml (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/I18nText.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.nuiton.jaxx.test</groupId> + <artifactId>test</artifactId> + <version>0</version> + <build> + <plugins> + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <configuration> + <src>${basedir}/target/test-classes</src> + <outJava>${basedir}/target/generated-sources/test-java</outJava> + <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> + <force>true</force> + <i18nable>true</i18nable> + <includes> + <value>**/i18nTest/text/*.jaxx</value> + </includes> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/I18nTitle.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/I18nTitle.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/I18nTitle.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.nuiton.jaxx.test</groupId> - <artifactId>test</artifactId> - <version>0</version> - <build> - <plugins> - <plugin> - <groupId>org.nuiton</groupId> - <artifactId>maven-jaxx-plugin</artifactId> - <configuration> - <src>${basedir}/target/test-classes</src> - <outJava>${basedir}/target/generated-sources/test-java</outJava> - <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> - <force>true</force> - <i18nable>true</i18nable> - <includes> - <value>**/i18nTest/title/*.jaxx</value> - </includes> - </configuration> - </plugin> - </plugins> - </build> -</project> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/I18nTitle.xml (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/I18nTitle.xml) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/I18nTitle.xml (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/I18nTitle.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.nuiton.jaxx.test</groupId> + <artifactId>test</artifactId> + <version>0</version> + <build> + <plugins> + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <configuration> + <src>${basedir}/target/test-classes</src> + <outJava>${basedir}/target/generated-sources/test-java</outJava> + <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> + <force>true</force> + <i18nable>true</i18nable> + <includes> + <value>**/i18nTest/title/*.jaxx</value> + </includes> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/I18nToolTipText.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/I18nToolTipText.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/I18nToolTipText.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.nuiton.jaxx.test</groupId> - <artifactId>test</artifactId> - <version>0</version> - <build> - <plugins> - <plugin> - <groupId>org.nuiton</groupId> - <artifactId>maven-jaxx-plugin</artifactId> - <configuration> - <src>${basedir}/target/test-classes</src> - <outJava>${basedir}/target/generated-sources/test-java</outJava> - <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> - <force>true</force> - <i18nable>true</i18nable> - <includes> - <value>**/i18nTest/tooltiptext/*.jaxx</value> - </includes> - </configuration> - </plugin> - </plugins> - </build> -</project> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/I18nToolTipText.xml (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/I18nToolTipText.xml) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/I18nToolTipText.xml (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/I18nToolTipText.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.nuiton.jaxx.test</groupId> + <artifactId>test</artifactId> + <version>0</version> + <build> + <plugins> + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <configuration> + <src>${basedir}/target/test-classes</src> + <outJava>${basedir}/target/generated-sources/test-java</outJava> + <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> + <force>true</force> + <i18nable>true</i18nable> + <includes> + <value>**/i18nTest/tooltiptext/*.jaxx</value> + </includes> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/text/JButton.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/text/JButton.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/text/JButton.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1 +0,0 @@ -<javax.swing.JButton text='test.text'/> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/text/JButton.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/text/JButton.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/text/JButton.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/text/JButton.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1 @@ +<javax.swing.JButton text='test.text'/> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/title/JDialog.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/title/JDialog.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/title/JDialog.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1 +0,0 @@ -<JDialog title='test.title'/> Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/title/JDialog.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/title/JDialog.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/title/JDialog.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/title/JDialog.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1 @@ +<JDialog title='test.title'/> Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/title/JTabbedPane.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/title/JTabbedPane.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/title/JTabbedPane.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +0,0 @@ - <JTabbedPane> - <tab title='test.title'/> -</JTabbedPane> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/title/JTabbedPane.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/title/JTabbedPane.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/title/JTabbedPane.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/title/JTabbedPane.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,3 @@ + <JTabbedPane> + <tab title='test.title'/> +</JTabbedPane> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/title/JTabbedPane2.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/title/JTabbedPane2.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/title/JTabbedPane2.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,5 +0,0 @@ -<JTabbedPane> - <tab title='test.title'> - <JLabel text='testLabel'/> - </tab> -</JTabbedPane> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/title/JTabbedPane2.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/title/JTabbedPane2.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/title/JTabbedPane2.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/title/JTabbedPane2.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,5 @@ +<JTabbedPane> + <tab title='test.title'> + <JLabel text='testLabel'/> + </tab> +</JTabbedPane> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JButton.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JButton.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JButton.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1 +0,0 @@ -<javax.swing.JButton toolTipText='test.toolTipText'/> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JButton.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JButton.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JButton.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JButton.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1 @@ +<javax.swing.JButton toolTipText='test.toolTipText'/> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JTabbedPane.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JTabbedPane.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JTabbedPane.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +0,0 @@ - <JTabbedPane toolTipText='test.toolTipText'> - <tab title="text"/> -</JTabbedPane> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JTabbedPane.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JTabbedPane.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JTabbedPane.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JTabbedPane.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,3 @@ + <JTabbedPane toolTipText='test.toolTipText'> + <tab title="text"/> +</JTabbedPane> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JTabbedPane2.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JTabbedPane2.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JTabbedPane2.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,3 +0,0 @@ - <JTabbedPane> - <tab toolTipText='test.toolTipText'/> -</JTabbedPane> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JTabbedPane2.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JTabbedPane2.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JTabbedPane2.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JTabbedPane2.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,3 @@ + <JTabbedPane> + <tab toolTipText='test.toolTipText'/> +</JTabbedPane> \ No newline at end of file Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JTabbedPane3.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JTabbedPane3.jaxx 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JTabbedPane3.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,5 +0,0 @@ -<JTabbedPane> - <tab toolTipText='test.toolTipText'> - <JLabel text='yo'/> - </tab> -</JTabbedPane> \ No newline at end of file Copied: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JTabbedPane3.jaxx (from rev 1672, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JTabbedPane3.jaxx) =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JTabbedPane3.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/i18nTest/tooltiptext/JTabbedPane3.jaxx 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,5 @@ +<JTabbedPane> + <tab toolTipText='test.toolTipText'> + <JLabel text='yo'/> + </tab> +</JTabbedPane> \ No newline at end of file Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/pom.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,6 +1,6 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> <!-- ************************************************************* --> @@ -10,25 +10,22 @@ <parent> <groupId>org.nuiton</groupId> <artifactId>mavenpom</artifactId> - <version>1.0.3-SNAPSHOT</version> + <version>1.1.0</version> </parent> <artifactId>jaxx</artifactId> - <version>1.7.2-SNAPSHOT</version> + <version>2.0.0-beta-3-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--> <module>jaxx-demo</module> </modules> @@ -233,6 +230,13 @@ </exclusions> </dependency> + <!-- rsyntaxtextarea dependency --> + <dependency> + <groupId>org.nuiton.thirdparty</groupId> + <artifactId>rsyntaxtextarea</artifactId> + <version>1.3.3</version> + </dependency> + <!-- swinglabs dependencies --> <dependency> @@ -256,10 +260,30 @@ <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> - <version>1.2.9</version> + <version>1.2.14</version> </dependency> - + <dependency> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-velocity</artifactId> + <version>1.1.7</version> + <exclusions> + <exclusion> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-container-default</artifactId> + </exclusion> + <exclusion> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-component-api</artifactId> + </exclusion> + <exclusion> + <groupId>velocity</groupId> + <artifactId>velocity</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.7</version> @@ -267,6 +291,13 @@ </dependency> <dependency> + <groupId>org.apache.maven.shared</groupId> + <artifactId>maven-verifier</artifactId> + <version>1.0</version> + <scope>test</scope> + </dependency> + + <dependency> <groupId>org.apache.maven.plugin-testing</groupId> <artifactId>maven-plugin-testing-harness</artifactId> <version>1.2</version> @@ -300,7 +331,7 @@ </exclusions> </dependency> - + </dependencies> </dependencyManagement> @@ -308,11 +339,11 @@ <!-- *** Project Information ************************************* --> <!-- ************************************************************* --> - <name>${project.artifactId}</name> - <description>Jaxx library parent pom</description> + <name>JAXX</name> + <description>JAXX Project</description> <inceptionYear>2008</inceptionYear> <url>http://maven-site.nuiton.org/jaxx</url> - + <!-- ************************************************************* --> <!-- *** Build Settings ****************************************** --> <!-- ************************************************************* --> @@ -325,12 +356,16 @@ <projectId>jaxx</projectId> <lutinutil.version>1.1.0</lutinutil.version> - <i18n.version>1.0.1-SNAPSHOT</i18n.version> + <i18n.version>1.0.1</i18n.version> <jxlayer.version>3.0.3</jxlayer.version> - + <javahelp.version>2.0.02</javahelp.version> + <!-- to include (or not) attached files to redmine file to publish --> + <!-- will be remove when using mavenpom 1.1.1 --> + <redmine.includeAttached>false</redmine.includeAttached> + </properties> <build> @@ -355,7 +390,7 @@ </dependency> </dependencies> </plugin> - + </plugins> </pluginManagement> Modified: trunk/src/site/rst/JAXXContext.rst =================================================================== --- trunk/src/site/rst/JAXXContext.rst 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/src/site/rst/JAXXContext.rst 2009-12-02 13:59:28 UTC (rev 1673) @@ -32,7 +32,7 @@ Le nom qui est facultatif permet de pouvoir distinguer plusieurs données d'un même type dans le context. Si le nom n'est pas utilisé pour caractériser une données on fixera alors sa valeur à *null*. -Afin de pouvoir caractériser les entrées dans le context, une classe a été définie *jaxx.runtime.JAXXContextEntryDef*. +Afin de pouvoir caractériser les entrées dans le context, une classe a été définie *jaxx.runtime.context.JAXXContextEntryDef*. Les méthodes de lecture *********************** @@ -87,7 +87,7 @@ Cette entrée spéciale ne sera pas stockée avec les autres entrées afin d'optimiser les algorithmes d'injection et de restitution. -jaxx.runtime.JAXXInitialContext +jaxx.runtime.context.JAXXInitialContext ******************************* On a implanté un second type de context qui lui peut servir à l'initialisation des JAXXObject. Modified: trunk/src/site/rst/index.rst =================================================================== --- trunk/src/site/rst/index.rst 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/src/site/rst/index.rst 2009-12-02 13:59:28 UTC (rev 1673) @@ -1,5 +1,5 @@ -jaxx-core -========= +JAXX +==== .. contents:: @@ -7,8 +7,11 @@ Présentation ------------ -Le projet Jaxx. +TODO A faire car plus a jour... +Le projet JAXX ... + + Depuis la version 1.0, et en prévision de nouveaux générateurs s'appuyant sur Jaxx,on a revu l'architecture du projet. Désormais, une séparation a été effectuée entre le code de compilation et le code d'exécution. @@ -22,6 +25,13 @@ **Veuillez consulter la JavaDoc pour de plus ample détails sur les différentes librairies.** +Migration vers JAXX 2.0 +----------------------- + +La version 2.0 de JAXX n'est pas compatible avec les versions antérieures. + +Pour plus de détail consulter la page `Migration`_. + Nouvelles fonctionnalités ------------------------- @@ -35,6 +45,8 @@ * NavigationTreeModel_ +.. _Migration: migration.html + .. _Core: Core.html .. _I18n: I18n.html Copied: trunk/src/site/rst/migration.rst (from rev 1672, branches/jaxx-2.X/src/site/rst/migration.rst) =================================================================== --- trunk/src/site/rst/migration.rst (rev 0) +++ trunk/src/site/rst/migration.rst 2009-12-02 13:59:28 UTC (rev 1673) @@ -0,0 +1,25 @@ +Migration vers JAXX 2.0 +======================= + +.. contents:: + + +Présentation +------------ + +Ce document énumère les choses à migrer pour passer sur la version 2.0 de JAXX. + +Nouvelles fonctionnalités +------------------------- + + * JList, JComboBox et JTree n'acceptent plus de fils Item (utiliser JAXXList, + JAXXComboBox, JAXXTree). + + * changement de paquetage de jaxx.runtime.JAXXContext vers jaxx.runtime.JAXXContext + + * changement de paquetage de jaxx.runtime.\*Decorator vers jaxx.runtime.decorator.\*Decorator + + * le framwork NavigationTree n'est plus compatible avec l'ancien... TODO + +TODO finish it + Modified: trunk/src/site/site.xml =================================================================== --- trunk/src/site/site.xml 2009-12-02 13:09:57 UTC (rev 1672) +++ trunk/src/site/site.xml 2009-12-02 13:59:28 UTC (rev 1673) @@ -24,6 +24,7 @@ <menu name="Utilisateur"> <item name="Accueil" href="index.html"/> + <item name="Migration JAXX 2.0" href="migration.html"/> </menu> <menu name="Développeur">
participants (1)
-
tchemit@users.nuiton.org