r2757 - in trunk: jaxx-compiler/src/main/java/jaxx/compiler jaxx-compiler/src/main/java/jaxx/compiler/finalizers jaxx-compiler/src/main/java/jaxx/compiler/tags jaxx-compiler/src/main/java/jaxx/compiler/tasks jaxx-demo jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor jaxx-demo/src/main/java/jaxx/demo/tree jaxx-demo/src/main/resources/i18n jaxx-maven-plugin/src/main/java/org/nuiton/jaxx/plugin jaxx-runtime/src/main/java/jaxx/runtime jaxx-runtime/src/main/java/jaxx/runtime/spi jaxx-widget
Author: tchemit Date: 2013-11-28 10:29:10 +0100 (Thu, 28 Nov 2013) New Revision: 2757 Url: http://nuiton.org/projects/jaxx/repository/revisions/2757 Log: fixes #2946: Introduce UIHandler contract and a way to glue it to any generated jaxx object - update jaxx demo - update doc Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/CoordinateDemo.css trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/CoordinateDemo.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/CoordinateDemoHandler.java trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/CoordinateDemoModel.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/spi/ trunk/jaxx-runtime/src/main/java/jaxx/runtime/spi/UIHandler.java Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/DefaultFinalizer.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tasks/GenerateConstructorsTask.java trunk/jaxx-demo/pom.xml trunk/jaxx-demo/src/main/java/jaxx/demo/tree/DemoDataProvider.java trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo_en_GB.properties trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo_es_ES.properties trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo_fr_FR.properties trunk/jaxx-maven-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java trunk/jaxx-widgets/pom.xml trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditor.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditorHandler.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditor.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditorHandler.java trunk/src/site/rst/index.rst Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java 2013-11-26 14:10:47 UTC (rev 2756) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java 2013-11-28 09:29:10 UTC (rev 2757) @@ -28,6 +28,7 @@ import jaxx.compiler.finalizers.JAXXCompilerFinalizer; import jaxx.compiler.spi.Initializer; import jaxx.runtime.JAXXContext; +import jaxx.runtime.spi.UIHandler; import java.io.File; import java.util.Map; @@ -136,6 +137,20 @@ */ boolean isShowClassDescriptorLoading(); + /** + * + * @return {@code true} to detect and add {@link UIHandler} if found in class-path. + * @since 2.6 + */ + boolean isAddAutoHandlerUI(); + + /** + * + * @param addAutoHandlerUI + * @since 2.6 + */ + void setAddAutoHandlerUI(boolean addAutoHandlerUI); + /** @return the encoding to use to write files */ String getEncoding(); Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java 2013-11-26 14:10:47 UTC (rev 2756) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java 2013-11-28 09:29:10 UTC (rev 2757) @@ -29,6 +29,7 @@ import jaxx.compiler.spi.Initializer; import jaxx.runtime.JAXXContext; import jaxx.runtime.JAXXObject; +import jaxx.runtime.spi.UIHandler; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.logging.Log; @@ -106,6 +107,7 @@ /** * Fully qualified name of validator factory. + * * @since 2.6 */ private String validatorFactoryFQN; @@ -133,6 +135,13 @@ */ private boolean showClassDescriptorLoading; + /** + * To detect {@link UIHandler} if found. + * + * @since 2.6 + */ + private boolean addAutoHandlerUI; + @Override public File getTargetDirectory() { return targetDirectory; @@ -153,6 +162,17 @@ return showClassDescriptorLoading; } + @Override + public boolean isAddAutoHandlerUI() { + return addAutoHandlerUI; + } + + @Override + public void setAddAutoHandlerUI(boolean addAutoHandlerUI) { + this.addAutoHandlerUI = addAutoHandlerUI; + } + + public void setVerbose(boolean verbose) { this.verbose = verbose; } Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java 2013-11-26 14:10:47 UTC (rev 2756) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java 2013-11-28 09:29:10 UTC (rev 2757) @@ -46,6 +46,7 @@ import jaxx.runtime.JAXXObjectDescriptor; import jaxx.runtime.css.Rule; import jaxx.runtime.css.Stylesheet; +import jaxx.runtime.spi.UIHandler; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -95,6 +96,8 @@ import java.util.Set; import java.util.Stack; +import static jaxx.compiler.finalizers.DefaultFinalizer.METHOD_NAME$BEFORE_INIT; + /** * Compiles a given {@link #jaxxFile} into a {@link #javaFile}. * @@ -294,8 +297,8 @@ * * @since 2.4 * @deprecated since 2.4.1, will be removed in version 3.0, it is not a good - * idea to do special treatment for a particular class, to use SwingUtil, - * do like for other class : import it! + * idea to do special treatment for a particular class, to use SwingUtil, + * do like for other class : import it! */ @Deprecated protected boolean needSwingUtil; @@ -466,7 +469,7 @@ Modifier.PUBLIC, fullClassName, EMPTY_STRING_ARRAY, - classLoader + getClassLoader() ); symbolTable.getScriptMethods().add(methodDescriptor); if (Boolean.class.getName().equals(fullClassName)) { @@ -475,7 +478,7 @@ Modifier.PUBLIC, fullClassName, EMPTY_STRING_ARRAY, - classLoader + getClassLoader() ); symbolTable.getScriptMethods().add(methodDescriptor); } @@ -484,7 +487,7 @@ Modifier.PUBLIC, JAXXCompilerFinalizer.TYPE_VOID, new String[]{fullClassName}, - classLoader + getClassLoader() ); symbolTable.getScriptMethods().add(methodDescriptor); } else { @@ -496,7 +499,7 @@ Modifier.PUBLIC, fullClassName, EMPTY_STRING_ARRAY, - classLoader + getClassLoader() ); symbolTable.getScriptMethods().add(methodDescriptor); } @@ -656,7 +659,69 @@ InputStream in = new FileInputStream(src); try { document = parseDocument(in); - compileFirstPass(document.getDocumentElement()); + + Element documentElement = document.getDocumentElement(); + + boolean addAutoHandlerUI = + getEngine().getConfiguration().isAddAutoHandlerUI(); + + String uiHandlerFullClassName; + + if (addAutoHandlerUI) { + + // try to find the + + uiHandlerFullClassName = getOutputClassName() + "Handler"; + ClassDescriptor uiHandlerClass = null; + try { + uiHandlerClass = ClassDescriptorHelper.getClassDescriptor(uiHandlerFullClassName, getClassLoader()); + if (uiHandlerClass != null && !ClassDescriptorHelper.isAssignableFrom(uiHandlerClass, UIHandler.class)) { + reportWarning( + "Found a handler " + uiHandlerFullClassName + + " which does not implements " + UIHandler.class.getName()); + uiHandlerClass = null; + } + + } catch (ClassNotFoundException e) { + // not found + } + + if (uiHandlerClass == null) { + uiHandlerFullClassName = null; + } + } else { + + uiHandlerFullClassName = documentElement.getAttribute( + DefaultObjectHandler.HANDLER_ATTRIBUTE); + if (StringUtils.isNotBlank(uiHandlerFullClassName)) { + + // get his class descriptor + ClassDescriptor uiHandlerClass = null; + try { + uiHandlerClass = ClassDescriptorHelper.getClassDescriptor(uiHandlerFullClassName, getClassLoader()); + + // check if implements UIHandler + if (uiHandlerClass != null && !ClassDescriptorHelper.isAssignableFrom(uiHandlerClass, UIHandler.class)) { + reportError( + "Found a handler " + uiHandlerFullClassName + + " which does not implements " + UIHandler.class.getName()); + uiHandlerClass = null; + } + } catch (ClassNotFoundException e) { + reportError("Could not find type " + uiHandlerFullClassName); + } + if (uiHandlerClass == null) { + uiHandlerFullClassName = null; + } + } + } + + if (uiHandlerFullClassName != null) { + + setUiHandler(uiHandlerFullClassName); + } + + compileFirstPass(documentElement); } catch (SAXParseException e) { reportError(e.getLineNumber(), "Invalid XML: " + e.getMessage()); } catch (SAXException e) { @@ -672,6 +737,20 @@ "Internal error: starting pass two, but tagsBeingCompiled" + " is not empty: " + tagsBeingCompiled); } + + if (isUseHandler()) { + + String handler = getUiHandler(); + + JavaField field = JavaElementFactory.newField( + Modifier.PROTECTED | Modifier.FINAL, + handler, + DefaultObjectHandler.HANDLER_ATTRIBUTE, + false, + "new " + getImportedType(handler) + "()" + ); + javaFile.addField(field, false); + } compileSecondPass(document.getDocumentElement()); } @@ -1242,7 +1321,7 @@ * * @param type the type to check against super class * @return {@code true} if super class exists and is assignable against the - * given type, {@code false} otherwise + * given type, {@code false} otherwise * @throws ClassNotFoundException if could not find class descriptor for * super-class */ @@ -1476,7 +1555,7 @@ * * @param javaCode the Java code snippet to test * @return a "cooked" version of the string which has enclosing curly - * braces removed. + * braces removed. * @throws CompilerException if the code cannot be parsed */ public String checkJavaCode(String javaCode) { @@ -1494,7 +1573,7 @@ * @param attribute (if not null reference the attribute where is defined * the reference) * @return <code>true</code> if reference was found, <code>false</code> - * otherwise and add an error in compiler + * otherwise and add an error in compiler */ public boolean checkReference(Element tag, String reference, @@ -1769,7 +1848,7 @@ * * @param raw the raw string to be escape * @return a string in which all 'dangerous' characters have been replaced - * by equivalent Java escape sequences + * by equivalent Java escape sequences */ public static String escapeJavaString(String raw) { StringBuilder out = new StringBuilder(raw); @@ -1959,8 +2038,8 @@ } public String getImportedTypeForSimpleName(String type) { - String suffix = "."+type; - String result=null; + String suffix = "." + type; + String result = null; for (String importedClass : getImportedClasses()) { if (importedClass.endsWith(suffix)) { result = importedClass; @@ -1974,8 +2053,8 @@ * @return the javafile import manager * @since 2.4 * @deprecated since 2.4.1, will be removed in version 3.0 : do not want - * to expose eugene export manager in rest of api, this is purpose of - * JavaFile only + * to expose eugene export manager in rest of api, this is purpose of + * JavaFile only */ @Deprecated public ImportsManager getImportManager() { @@ -2011,4 +2090,25 @@ } return false; } + + protected String uiHandler; + + public String getUiHandler() { + return uiHandler; + } + + public void setUiHandler(String uiHandler) { + this.uiHandler = uiHandler; + } + + public boolean isUseHandler() { + return StringUtils.isNotBlank(uiHandler); + } + + public void addHandlerBeforeInitInvocation(StringBuilder code) { + if (isUseHandler()) { + code.append("handler." + METHOD_NAME$BEFORE_INIT + "(this);"); + code.append(JAXXCompiler.getLineSeparator()); + } + } } Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/DefaultFinalizer.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/DefaultFinalizer.java 2013-11-26 14:10:47 UTC (rev 2756) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/DefaultFinalizer.java 2013-11-28 09:29:10 UTC (rev 2757) @@ -498,7 +498,10 @@ private static final String PARAMETER_NAME_PARENT_CONTEXT = "parentContext"; + public static final String METHOD_NAME$BEFORE_INIT = "beforeInit"; + private static final String METHOD_NAME$AFTER_INIT = "afterInit"; + @Override public boolean accept(JAXXCompiler compiler) { @@ -986,6 +989,7 @@ // code.append(" super();").append(eol); // } } + compiler.addHandlerBeforeInitInvocation(code); code.append(METHOD_NAME_$INITIALIZE + "();"); code.append(eol); return JavaElementFactory.newMethod(PUBLIC, @@ -1049,6 +1053,7 @@ code.append(".initContext(this, " + PARAMETER_NAME_PARENT_CONTEXT + ");"); code.append(eol); } + compiler.addHandlerBeforeInitInvocation(code); code.append(METHOD_NAME_$INITIALIZE + "();"); code.append(eol); JavaArgument argument = JavaElementFactory.newArgument( @@ -1164,6 +1169,17 @@ //TC-20090313 add an extra method after complete setup MethodDescriptor method = compiler.getScriptMethod(METHOD_NAME_$AFTER_COMPLETE_SETUP); + + boolean useHandler = compiler.isUseHandler(); + if (useHandler) { + + code.append("handler." + METHOD_NAME$AFTER_INIT + "(this);").append(eol); + + if (method != null) { + compiler.reportWarning("Should not use deprecated api $afterCompleteSetup, prefer declare a 'handler' attribute on root object."); + } + } + if (method != null) { code.append(METHOD_NAME_$AFTER_COMPLETE_SETUP + "();").append(eol); } Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java 2013-11-26 14:10:47 UTC (rev 2756) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java 2013-11-28 09:29:10 UTC (rev 2757) @@ -87,6 +87,8 @@ /** Logger. */ private static final Log log = LogFactory.getLog(DefaultObjectHandler.class); + public static final String HANDLER_ATTRIBUTE = "handler"; + public static final String ABSTRACT_ATTRIBUTE = "abstract"; public static final String CONSTRAINTS_ATTRIBUTE = "constraints"; @@ -242,7 +244,7 @@ /** * @return the <code>JAXXBeanInfo</code> for the class which this <code>DefaultObjectHandler</code> - * supports. + * supports. */ public JAXXBeanInfo getJAXXBeanInfo() { try { @@ -290,10 +292,10 @@ /** * @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>. + * 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 { @@ -542,7 +544,7 @@ /** * @param property property name to test * @return <code>true</code> if the specified property should be inherited by child components when specified - * via CSS. + * via CSS. * @throws UnsupportedAttributeException if attribute is not supported */ public boolean isPropertyInherited(String property) throws UnsupportedAttributeException { @@ -552,7 +554,7 @@ /** * @param name name of event * @return <code>true</code> if the specified name has the form of an event handler attribute - * (e.g. "onActionPerformed"). + * (e.g. "onActionPerformed"). */ public boolean isEventHandlerName(String name) { return name.length() > 2 && @@ -634,6 +636,7 @@ name.equals(CONSTRUCTOR_PARAMS_ATTRIBUTE) || name.equals(STYLE_CLASS_ATTRIBUTE) || name.startsWith(XMLNS_ATTRIBUTE) || + name.startsWith(HANDLER_ATTRIBUTE) || JAXXCompiler.JAXX_INTERNAL_NAMESPACE.equals(attribute.getNamespaceURI())) { // ignore, already handled continue; @@ -733,7 +736,7 @@ } if (ClassDescriptorHelper.getClassDescriptor(BeanTypeAware.class).isAssignableFrom(object.getObjectClass())) { String fqn = compiler.getImportedTypeForSimpleName(value); - if (fqn!=null) { + if (fqn != null) { // add beanType from genericType if (log.isDebugEnabled()) { log.debug("Add beanType property: " + value + " to " + object); Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tasks/GenerateConstructorsTask.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tasks/GenerateConstructorsTask.java 2013-11-26 14:10:47 UTC (rev 2756) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tasks/GenerateConstructorsTask.java 2013-11-28 09:29:10 UTC (rev 2757) @@ -48,6 +48,7 @@ import java.util.List; import static java.lang.reflect.Modifier.PUBLIC; +import static jaxx.compiler.finalizers.DefaultFinalizer.METHOD_NAME$BEFORE_INIT; /** * Task to execute just after finalize task to create all constructors for any @@ -421,6 +422,7 @@ code.append(");").append(eol); } + addHandlerBeforeInitInvocation(compiler, code); code.append(DefaultFinalizer.METHOD_NAME_$INITIALIZE + "();"); code.append(eol); JavaConstructor constructor = JavaElementFactory.newConstructor(PUBLIC, @@ -431,6 +433,12 @@ compiler.getJavaFile().addConstructor(constructor); } + public void addHandlerBeforeInitInvocation(JAXXCompiler compiler, StringBuilder code) { + if (compiler.isUseHandler()) { + code.append("handler." + METHOD_NAME$BEFORE_INIT + "(this);"); + } + } + protected void addConstructorWithInitialContext(JAXXCompiler compiler, String className, List<String> constructorTypes, @@ -499,6 +507,7 @@ code.append(".initContext(this, " + PARAMETER_NAME_PARENT_CONTEXT + ");"); code.append(eol); } + addHandlerBeforeInitInvocation(compiler, code); code.append(DefaultFinalizer.METHOD_NAME_$INITIALIZE + "();"); code.append(eol); JavaConstructor constructor = JavaElementFactory.newConstructor(PUBLIC, Modified: trunk/jaxx-demo/pom.xml =================================================================== --- trunk/jaxx-demo/pom.xml 2013-11-26 14:10:47 UTC (rev 2756) +++ trunk/jaxx-demo/pom.xml 2013-11-28 09:29:10 UTC (rev 2757) @@ -47,6 +47,7 @@ <jaxx.addSourcesToClassPath>true</jaxx.addSourcesToClassPath> <jaxx.autoImportCss>true</jaxx.autoImportCss> <jaxx.autoRecurseInCss>false</jaxx.autoRecurseInCss> + <jaxx.addAutoHandlerUI>true</jaxx.addAutoHandlerUI> <!-- generate license bundled files --> <license.generateBundle>true</license.generateBundle> Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/CoordinateDemo.css =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/CoordinateDemo.css (rev 0) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/CoordinateDemo.css 2013-11-28 09:29:10 UTC (rev 2757) @@ -0,0 +1,125 @@ + +#config { + border: {new TitledBorder(_("jaxxdemo.numbereditor.configuration"))}; +} + +#latitudeShowReset { + text: "jaxxdemo.numbereditor.showReset"; + selected: true; +} + +#latitudeUseDms { + text: "jaxxdemo.coordinate.latitudeDms"; + value: DMS; + buttonGroup: latitudeEditor; + selected: true; +} + +#latitudeUseDmd { + text: "jaxxdemo.coordinate.latitudeDmd"; + value: DMD; + buttonGroup: latitudeEditor; +} + +#latitudeUseDd { + text: "jaxxdemo.coordinate.latitudeDd"; + value: "DD"; + buttonGroup: latitudeEditor; + selected: true; +} + +#longitudeShowReset { + text: "jaxxdemo.numbereditor.showReset"; + selected: true; +} + +#longitudeUseDms { + text: "jaxxdemo.coordinate.longitudeDms"; + value: DMS; + buttonGroup: longitudeEditor; + selected: true; +} + +#longitudeUseDmd { + text: "jaxxdemo.coordinate.longitudeDmd"; + value: DMD; + buttonGroup: longitudeEditor; +} + +#longitudeUseDd { + text: "jaxxdemo.coordinate.longitudeDd"; + value: "DD"; + buttonGroup: longitudeEditor; +} + +#latitudePane { + border: {new TitledBorder(_("jaxxdemo.coordinate.latitude"))}; +} + +#latitudeDmsEditor { + bean: {latitudeDms}; + propertySign: sign; + propertyDegree: degree; + propertyMinute: minute; + propertySecond: second; + showReset: {latitudeShowReset.isSelected()}; +} + +#latitudeDmdEditor { + bean: {latitudeDmd}; + propertySign: sign; + propertyDegree: degree; + propertyMinute: minute; + propertyDecimal: decimal; + showReset: {latitudeShowReset.isSelected()}; +} + +#latitudeDdEditor { + bean: {this}; + property: latitudeDd; + showReset: {latitudeShowReset.isSelected()}; + useFloat: true; + useSign: true; +} + +#longitudePane { + border: {new TitledBorder(_("jaxxdemo.coordinate.longitude"))}; +} + +#longitudeDmsEditor { + bean: {longitudeDms}; + propertySign: sign; + propertyDegree: degree; + propertyMinute: minute; + propertySecond: second; + showReset: {longitudeShowReset.isSelected()}; +} + +#longitudeDmdEditor { + bean: {longitudeDmd}; + propertySign: sign; + propertyDegree: degree; + propertyMinute: minute; + propertyDecimal: decimal; + showReset: {longitudeShowReset.isSelected()}; +} + +#longitudeDdEditor { + bean: {this}; + property: longitudeDd; + showReset: {longitudeShowReset.isSelected()}; + useFloat: true; + useSign: true; +} + +#result { + border: {new TitledBorder(_("jaxxdemo.coordinate.result"))}; +} + +#resultLatitude { + text: {handler.getLatitudeText(model.getLatitude())}; +} + +#resultLongitude { + text: {handler.getLongitudeText(model.getLongitude())}; +} Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/CoordinateDemo.css ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/CoordinateDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/CoordinateDemo.jaxx (rev 0) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/CoordinateDemo.jaxx 2013-11-28 09:29:10 UTC (rev 2757) @@ -0,0 +1,87 @@ +<jaxx.demo.DemoPanel layout='{new BorderLayout()}'> + <!--handler='jaxx.demo.component.jaxx.editor.CoordinateDemoHandler'>--> + + <import> + jaxx.runtime.swing.editor.NumberEditor + jaxx.runtime.swing.editor.gis.DmsCoordinate + jaxx.runtime.swing.editor.gis.DmsCoordinateEditor + jaxx.runtime.swing.editor.gis.DmdCoordinate + jaxx.runtime.swing.editor.gis.DmdCoordinateEditor + </import> + + <!-- model --> + <CoordinateDemoModel id='model'/> + + <DmsCoordinate id='latitudeDms'/> + <DmdCoordinate id='latitudeDmd'/> + <Float id='latitudeDd' javaBean='null'/> + + <DmsCoordinate id='longitudeDms'/> + <DmdCoordinate id='longitudeDmd'/> + <Float id='longitudeDd' javaBean='null'/> + + <script><![CDATA[ + +@Override +protected String[] getSources() { + return new String[]{ getDefaultSource(), "CoordinateDemoModel.java", "CoordinateDemoHandler.java" }; +} + +]]> + </script> + + <Table insets='0' fill='both' weightx='1' constraints='BorderLayout.NORTH'> + <row> + <cell> + <JPanel id='config' layout='{new GridLayout(1,0)}'> + + <JPanel id='configLatitude' layout='{new GridLayout(0,1)}'> + <JCheckBox id='latitudeShowReset'/> + <JRadioButton id='latitudeUseDms' + onActionPerformed='handler.useLatitudeDmsEditor()'/> + <JRadioButton id='latitudeUseDmd' + onActionPerformed='handler.useLatitudeDmdEditor()'/> + <JRadioButton id='latitudeUseDd' + onActionPerformed='handler.useLatitudeDdEditor()'/> + </JPanel> + <JPanel id='configLongitude' layout='{new GridLayout(0,1)}'> + <JCheckBox id='longitudeShowReset'/> + <JRadioButton id='longitudeUseDms' + onActionPerformed='handler.useLongitudeDmsEditor()'/> + <JRadioButton id='longitudeUseDmd' + onActionPerformed='handler.useLongitudeDmdEditor()'/> + <JRadioButton id='longitudeUseDd' + onActionPerformed='handler.useLongitudeDdEditor()'/> + </JPanel> + </JPanel> + </cell> + </row> + <row> + <cell> + <JPanel layout='{new GridLayout(1,0)}'> + <JPanel id='latitudePane' layout='{new GridLayout(0,1)}'> + <DmsCoordinateEditor id='latitudeDmsEditor' constructorParams='this'/> + <DmdCoordinateEditor id='latitudeDmdEditor' constructorParams='this'/> + <NumberEditor id='latitudeDdEditor' constructorParams='this'/> + </JPanel> + <JPanel id='longitudePane' layout='{new GridLayout(0,1)}'> + <DmsCoordinateEditor id='longitudeDmsEditor' + constructorParams='this'/> + <DmdCoordinateEditor id='longitudeDmdEditor' + constructorParams='this'/> + <NumberEditor id='longitudeDdEditor' constructorParams='this'/> + </JPanel> + </JPanel> + </cell> + </row> + <row> + <cell> + <JPanel id='result' layout='{new GridLayout(0,1)}'> + <JLabel id='resultLatitude'/> + <JLabel id='resultLongitude'/> + + </JPanel> + </cell> + </row> + </Table> +</jaxx.demo.DemoPanel> \ No newline at end of file Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/CoordinateDemo.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/CoordinateDemoHandler.java =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/CoordinateDemoHandler.java (rev 0) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/CoordinateDemoHandler.java 2013-11-28 09:29:10 UTC (rev 2757) @@ -0,0 +1,153 @@ +package jaxx.demo.component.jaxx.editor; + +import jaxx.runtime.spi.UIHandler; +import jaxx.runtime.swing.editor.gis.DmdCoordinate; +import jaxx.runtime.swing.editor.gis.DmsCoordinate; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +import static org.nuiton.i18n.I18n._; + +/** + * Created on 11/26/13. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 2.6 + */ +public class CoordinateDemoHandler implements UIHandler<CoordinateDemo> { + + /** Logger. */ + private static final Log log = + LogFactory.getLog(CoordinateDemoHandler.class); + + private CoordinateDemo ui; + + @Override + public void beforeInit(CoordinateDemo ui) { + if (log.isInfoEnabled()) { + log.info("BeforeInit " + ui.getName()); + } + this.ui = ui; + } + + @Override + public void afterInit(CoordinateDemo ui) { + + if (log.isInfoEnabled()) { + log.info("AfterInit " + ui.getName()); + } + + ui.getLatitudeDmsEditor().init(false); + ui.getLatitudeDmdEditor().init(false); + ui.getLatitudeDdEditor().init(); + ui.getLongitudeDmsEditor().init(true); + ui.getLongitudeDmdEditor().init(true); + ui.getLongitudeDdEditor().init(); + + ui.getLatitudeDms().addPropertyChangeListener(new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + DmsCoordinate source = (DmsCoordinate) evt.getSource(); + getModel().setLatitude(source.toDecimal()); + } + }); + ui.getLatitudeDmd().addPropertyChangeListener(new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + DmdCoordinate source = (DmdCoordinate) evt.getSource(); + getModel().setLatitude(source.toDecimal()); + } + }); + + ui.addPropertyChangeListener("latitudeDd", new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + Float source = (Float) evt.getNewValue(); + getModel().setLatitude(source); + } + }); + + ui.getLongitudeDms().addPropertyChangeListener(new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + DmsCoordinate source = (DmsCoordinate) evt.getSource(); + getModel().setLongitude(source.toDecimal()); + } + }); + ui.getLongitudeDmd().addPropertyChangeListener(new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + DmdCoordinate source = (DmdCoordinate) evt.getSource(); + getModel().setLongitude(source.toDecimal()); + } + }); + + ui.addPropertyChangeListener("longitudeDd", new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + Float source = (Float) evt.getNewValue(); + getModel().setLongitude(source); + } + }); + + useLatitudeDmsEditor(); + useLongitudeDmsEditor(); + } + + public void useLatitudeDmsEditor() { + ui.getLatitudeDmsEditor().setValue(DmsCoordinate.valueOf(getModel().getLatitude())); + ui.getLatitudeDmsEditor().setEnabled(true); + ui.getLatitudeDmdEditor().setEnabled(false); + ui.getLatitudeDdEditor().setEnabled(false); + } + + public void useLatitudeDmdEditor() { + ui.getLatitudeDmdEditor().setValue(DmdCoordinate.valueOf(getModel().getLatitude())); + ui.getLatitudeDmsEditor().setEnabled(false); + ui.getLatitudeDmdEditor().setEnabled(true); + ui.getLatitudeDdEditor().setEnabled(false); + } + + public void useLatitudeDdEditor() { + ui.getLatitudeDdEditor().setModel(getModel().getLatitude()); + ui.getLatitudeDmsEditor().setEnabled(false); + ui.getLatitudeDmdEditor().setEnabled(false); + ui.getLatitudeDdEditor().setEnabled(true); + } + + public void useLongitudeDmsEditor() { + ui.getLongitudeDmsEditor().setValue(DmsCoordinate.valueOf(getModel().getLongitude())); + ui.getLongitudeDmsEditor().setEnabled(true); + ui.getLongitudeDmdEditor().setEnabled(false); + ui.getLongitudeDdEditor().setEnabled(false); + } + + public void useLongitudeDmdEditor() { + ui.getLongitudeDmdEditor().setValue(DmdCoordinate.valueOf(getModel().getLongitude())); + ui.getLongitudeDmsEditor().setEnabled(false); + ui.getLongitudeDmdEditor().setEnabled(true); + ui.getLongitudeDdEditor().setEnabled(false); + } + + public void useLongitudeDdEditor() { + ui.getLongitudeDdEditor().setModel(getModel().getLongitude()); + ui.getLongitudeDmsEditor().setEnabled(false); + ui.getLongitudeDmdEditor().setEnabled(false); + ui.getLongitudeDdEditor().setEnabled(true); + } + + public String getLatitudeText(Float latitude) { + return _("jaxxdemo.coordinate.result.latitude", latitude); + } + + public String getLongitudeText(Float longitude) { + return _("jaxxdemo.coordinate.result.longitude", longitude); + } + + protected CoordinateDemoModel getModel() { + return ui.getModel(); + } +} Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/CoordinateDemoHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/CoordinateDemoModel.java =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/CoordinateDemoModel.java (rev 0) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/CoordinateDemoModel.java 2013-11-28 09:29:10 UTC (rev 2757) @@ -0,0 +1,42 @@ +package jaxx.demo.component.jaxx.editor; + +import org.jdesktop.beans.AbstractSerializableBean; + +/** + * Created on 11/26/13. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 2.6 + */ +public class CoordinateDemoModel extends AbstractSerializableBean { + + public static final String PROPERTY_LONGITUDE = "longitude"; + + public static final String PROPERTY_LATITUDE = "latitude"; + + private static final long serialVersionUID = 1L; + + protected Float latitude; + + protected Float longitude; + + public Float getLongitude() { + return longitude; + } + + public void setLongitude(Float longitude) { + Object oldValue = getLongitude(); + this.longitude = longitude; + firePropertyChange(PROPERTY_LONGITUDE, oldValue, longitude); + } + + public Float getLatitude() { + return latitude; + } + + public void setLatitude(Float latitude) { + Object oldValue = getLatitude(); + this.latitude = latitude; + firePropertyChange(PROPERTY_LATITUDE, oldValue, latitude); + } +} Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/CoordinateDemoModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/tree/DemoDataProvider.java =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/tree/DemoDataProvider.java 2013-11-26 14:10:47 UTC (rev 2756) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/tree/DemoDataProvider.java 2013-11-28 09:29:10 UTC (rev 2757) @@ -29,6 +29,7 @@ import jaxx.demo.component.jaxx.StatusMessagePanelDemo; import jaxx.demo.component.jaxx.editor.BeanComboBoxDemo; import jaxx.demo.component.jaxx.editor.ComboEditorDemo; +import jaxx.demo.component.jaxx.editor.CoordinateDemo; import jaxx.demo.component.jaxx.editor.DatePickerDemo; import jaxx.demo.component.jaxx.editor.FileEditorDemo; import jaxx.demo.component.jaxx.editor.I18nEditorDemo; @@ -167,7 +168,8 @@ ListSelectorDemo.class, BeanComboBoxDemo.class, BeanFilterableComboBoxDemo.class, - BeanDoubleListDemo.class + BeanDoubleListDemo.class, + CoordinateDemo.class ); addMapping(n_("jaxxdemo.feature"), 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 2013-11-26 14:10:47 UTC (rev 2756) +++ trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo_en_GB.properties 2013-11-28 09:29:10 UTC (rev 2757) @@ -235,6 +235,20 @@ jaxxdemo.config.ui.locale=Language used in application jaxxdemo.config.ui.logLevel=Log level jaxxdemo.config.ui.logPatternLayout=Log pattern +jaxxdemo.coordinate.latitude= +jaxxdemo.coordinate.latitudeDd= +jaxxdemo.coordinate.latitudeDmd= +jaxxdemo.coordinate.latitudeDms= +jaxxdemo.coordinate.longitude= +jaxxdemo.coordinate.longitudeDd= +jaxxdemo.coordinate.longitudeDmd= +jaxxdemo.coordinate.longitudeDms= +jaxxdemo.coordinate.model= +jaxxdemo.coordinate.model.latitude= +jaxxdemo.coordinate.model.longitude= +jaxxdemo.coordinate.result= +jaxxdemo.coordinate.result.latitude= +jaxxdemo.coordinate.result.longitude= jaxxdemo.datePickerEditor.dateResult=Result display jaxxdemo.datePickerEditor.patternLayout=Date pattern jaxxdemo.datePickerEditor.showPopupButton=Display popup button @@ -283,6 +297,8 @@ jaxxdemo.numbereditor.model=Result jaxxdemo.numbereditor.model.float=Float result \: %1$s jaxxdemo.numbereditor.model.int=Integer result \: %1$s +jaxxdemo.numbereditor.model.latitude= +jaxxdemo.numbereditor.model.longitude= jaxxdemo.numbereditor.model.numberPattern=Editor pattern \: %s jaxxdemo.numbereditor.numberPattern.configuration=Number Pattern jaxxdemo.numbereditor.showPopupButton=Show Popup button Modified: trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo_es_ES.properties =================================================================== --- trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo_es_ES.properties 2013-11-26 14:10:47 UTC (rev 2756) +++ trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo_es_ES.properties 2013-11-28 09:29:10 UTC (rev 2757) @@ -236,6 +236,20 @@ jaxxdemo.config.ui.locale=La langue utilisée par l'application jaxxdemo.config.ui.logLevel=Level de log jaxxdemo.config.ui.logPatternLayout=Pattern des log +jaxxdemo.coordinate.latitude= +jaxxdemo.coordinate.latitudeDd= +jaxxdemo.coordinate.latitudeDmd= +jaxxdemo.coordinate.latitudeDms= +jaxxdemo.coordinate.longitude= +jaxxdemo.coordinate.longitudeDd= +jaxxdemo.coordinate.longitudeDmd= +jaxxdemo.coordinate.longitudeDms= +jaxxdemo.coordinate.model= +jaxxdemo.coordinate.model.latitude= +jaxxdemo.coordinate.model.longitude= +jaxxdemo.coordinate.result= +jaxxdemo.coordinate.result.latitude= +jaxxdemo.coordinate.result.longitude= jaxxdemo.datePickerEditor.dateResult=Affichage du résultat jaxxdemo.datePickerEditor.patternLayout=Pattern de date jaxxdemo.datePickerEditor.showPopupButton=Afficher le boutton pour ouvrir la popup @@ -286,6 +300,8 @@ jaxxdemo.numbereditor.model=Résultat jaxxdemo.numbereditor.model.float=Valeur décimale \: %1$s jaxxdemo.numbereditor.model.int=Valeur entière \: %1$s +jaxxdemo.numbereditor.model.latitude= +jaxxdemo.numbereditor.model.longitude= jaxxdemo.numbereditor.model.numberPattern=Format de l'éditeur \: %s jaxxdemo.numbereditor.numberPattern.configuration=Pattern du nombre jaxxdemo.numbereditor.showPopupButton=Afficher le boutton de popup 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 2013-11-26 14:10:47 UTC (rev 2756) +++ trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo_fr_FR.properties 2013-11-28 09:29:10 UTC (rev 2757) @@ -235,6 +235,17 @@ jaxxdemo.config.ui.locale=La langue utilisée par l'application jaxxdemo.config.ui.logLevel=Level de log jaxxdemo.config.ui.logPatternLayout=Pattern des log +jaxxdemo.coordinate.latitude=Latitude +jaxxdemo.coordinate.latitudeDd=Latitude (au format DD) +jaxxdemo.coordinate.latitudeDmd=Latitude (au format DMD) +jaxxdemo.coordinate.latitudeDms=Latitude (au format DMS) +jaxxdemo.coordinate.longitude=Longitude +jaxxdemo.coordinate.longitudeDd=Longitude (au format DD) +jaxxdemo.coordinate.longitudeDmd=Longitude (au format DMD) +jaxxdemo.coordinate.longitudeDms=Longitude (au format DMS) +jaxxdemo.coordinate.result=Résultat +jaxxdemo.coordinate.result.latitude=<html>Latitude <strong>%s</strong> +jaxxdemo.coordinate.result.longitude=<html>Longitude <strong>%s</strong> jaxxdemo.datePickerEditor.dateResult=Affichage du résultat jaxxdemo.datePickerEditor.patternLayout=Pattern de date jaxxdemo.datePickerEditor.showPopupButton=Afficher le boutton pour ouvrir la popup Modified: trunk/jaxx-maven-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java =================================================================== --- trunk/jaxx-maven-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java 2013-11-26 14:10:47 UTC (rev 2756) +++ trunk/jaxx-maven-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java 2013-11-28 09:29:10 UTC (rev 2757) @@ -38,6 +38,7 @@ import jaxx.compiler.spi.Initializer; import jaxx.runtime.JAXXContext; import jaxx.runtime.JAXXObject; +import jaxx.runtime.spi.UIHandler; import jaxx.runtime.swing.help.JAXXHelpBroker; import jaxx.runtime.validator.swing.SwingValidator; import org.apache.commons.lang3.builder.ToStringBuilder; @@ -302,6 +303,16 @@ private boolean showClassDescriptorLoading; /** + * For each jaxx file, try to add a {@link UIHandler} on it. + * + * The fqn of the handler must be jaxxFileName{@code Handler}. + * + * @since 2.6 + */ + @Parameter(property = "jaxx.addAutoHandlerUI", defaultValue = "false") + private boolean addAutoHandlerUI; + + /** * Decorators available in engine. * * @since 2.0.2 @@ -570,6 +581,16 @@ } @Override + public boolean isAddAutoHandlerUI() { + return addAutoHandlerUI; + } + + @Override + public void setAddAutoHandlerUI(boolean addAutoHandlerUI) { + this.addAutoHandlerUI = addAutoHandlerUI; + } + + @Override public Class<? extends JAXXContext> getJaxxContextClass() { return jaxxContextClass; } Added: trunk/jaxx-runtime/src/main/java/jaxx/runtime/spi/UIHandler.java =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/spi/UIHandler.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/spi/UIHandler.java 2013-11-28 09:29:10 UTC (rev 2757) @@ -0,0 +1,40 @@ +package jaxx.runtime.spi; + +/* + * #%L + * JAXX :: Runtime + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + +import jaxx.runtime.JAXXObject; + +/** + * Created on 11/26/13. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 2.6 + */ +public interface UIHandler<UI extends JAXXObject> { + + void beforeInit(UI ui); + + void afterInit(UI ui); +} Property changes on: trunk/jaxx-runtime/src/main/java/jaxx/runtime/spi/UIHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/jaxx-widgets/pom.xml =================================================================== --- trunk/jaxx-widgets/pom.xml 2013-11-26 14:10:47 UTC (rev 2756) +++ trunk/jaxx-widgets/pom.xml 2013-11-28 09:29:10 UTC (rev 2757) @@ -44,17 +44,9 @@ <properties> <jaxx.addSourcesToClassPath>true</jaxx.addSourcesToClassPath> <jaxx.autoImportCss>true</jaxx.autoImportCss> + <jaxx.addAutoHandlerUI>true</jaxx.addAutoHandlerUI> <!--jaxx.useUIManagerForIcon>true</jaxx.useUIManagerForIcon--> </properties> - - <!-- Source control management. --> - <scm> - <connection>scm:svn:http://svn.nuiton.org/svn/jaxx/trunk/jaxx-widgets</connection> - <developerConnection> - scm:svn:http://svn.nuiton.org/svn/jaxx/trunk/jaxx-widgets - </developerConnection> - <url>http://nuiton.org/projects/jaxx/repository/show/trunkjaxx-widgets</url> - </scm> <dependencies> Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditor.jaxx =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditor.jaxx 2013-11-26 14:10:47 UTC (rev 2756) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditor.jaxx 2013-11-28 09:29:10 UTC (rev 2757) @@ -38,8 +38,8 @@ <!-- model --> <DmdCoordinateEditorModel id='model'/> - <!-- handler --> - <DmdCoordinateEditorHandler id='handler' constructorParams='this'/> + <!--<!– handler –>--> + <!--<DmdCoordinateEditorHandler id='handler' constructorParams='this'/>--> <script><![CDATA[ public void init(boolean longitudeEditor) { handler.init(longitudeEditor); } @@ -48,7 +48,7 @@ public void setPropertyDegree(String property ) { model.setPropertyDegree(property); } public void setPropertyMinute(String property ) { model.setPropertyMinute(property); } public void setPropertyDecimal(String property ) { model.setPropertyDecimal(property); } -public void setValue(DmdCoordinate value) { handler.setValue(value, false); } +public void setValue(DmdCoordinate value) { handler.setValue(value, true); } ]]> </script> Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditorHandler.java =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditorHandler.java 2013-11-26 14:10:47 UTC (rev 2756) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditorHandler.java 2013-11-28 09:29:10 UTC (rev 2757) @@ -25,6 +25,7 @@ */ import com.google.common.base.Preconditions; +import jaxx.runtime.spi.UIHandler; import jaxx.runtime.swing.editor.bean.BeanUIUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -43,13 +44,13 @@ * @author Tony Chemit <chemit@codelutin.com> * @since 2.6 */ -public class DmdCoordinateEditorHandler { +public class DmdCoordinateEditorHandler implements UIHandler<DmdCoordinateEditor>{ /** Logger. */ private static final Log log = LogFactory.getLog(DmdCoordinateEditorHandler.class); - private final DmdCoordinateEditor ui; + private DmdCoordinateEditor ui; protected Method signMutator; @@ -63,33 +64,35 @@ protected boolean valueModelIsAdjusting; - protected final DmdCoordinateConverter signedConverter; + protected DmdCoordinateConverter signedConverter; - protected final DmdCoordinateConverter unsignedConverter; + protected DmdCoordinateConverter unsignedConverter; protected DefaultFormatterFactory signedFormatterFactory; protected DefaultFormatterFactory unsignedFormatterFactory; - public DmdCoordinateEditorHandler(DmdCoordinateEditor ui) { - this.ui = ui; +// public DmdCoordinateEditorHandler(DmdCoordinateEditor ui) { +// this.ui = ui; +// +// // can't use the one from ConverterUtil since we deal with some internal states +// this.signedConverter = new DmdCoordinateConverter(); +// this.signedConverter.setUseSign(true); +// this.unsignedConverter = new DmdCoordinateConverter(); +// } + @Override + public void beforeInit(DmdCoordinateEditor ui) { + this.ui=ui; // can't use the one from ConverterUtil since we deal with some internal states this.signedConverter = new DmdCoordinateConverter(); this.signedConverter.setUseSign(true); this.unsignedConverter = new DmdCoordinateConverter(); } - public String getMaskFormatterPattern(boolean longitudeEditor, boolean useSign) { - String pattern = "**°**''**"; - if (longitudeEditor) { - // add one more degre - pattern = "*" + pattern; - } - if (useSign) { - pattern = "-" + pattern; - } - return pattern; + @Override + public void afterInit(DmdCoordinateEditor ui) { + // nothing special to do here } public void init(boolean longitudeEditor) { @@ -267,6 +270,18 @@ } } + protected String getMaskFormatterPattern(boolean longitudeEditor, boolean useSign) { + String pattern = "**°**''**"; + if (longitudeEditor) { + // add one more degre + pattern = "*" + pattern; + } + if (useSign) { + pattern = "-" + pattern; + } + return pattern; + } + private class ModelPropertyChangeListener implements PropertyChangeListener { private final DmdCoordinateEditorModel model; Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditor.jaxx =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditor.jaxx 2013-11-26 14:10:47 UTC (rev 2756) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditor.jaxx 2013-11-28 09:29:10 UTC (rev 2757) @@ -39,8 +39,8 @@ <!-- model --> <DmsCoordinateEditorModel id='model'/> - <!-- handler --> - <DmsCoordinateEditorHandler id='handler' constructorParams='this'/> + <!--<!– handler –>--> + <!--<DmsCoordinateEditorHandler id='handler' constructorParams='this'/>--> <script><![CDATA[ public void init(boolean longitudeEditor) { handler.init(longitudeEditor); } @@ -49,7 +49,7 @@ public void setPropertyDegree(String property ) { model.setPropertyDegree(property); } public void setPropertyMinute(String property ) { model.setPropertyMinute(property); } public void setPropertySecond(String property ) { model.setPropertySecond(property); } -public void setValue(DmsCoordinate value) { handler.setValue(value, false); } +public void setValue(DmsCoordinate value) { handler.setValue(value, true); } ]]> </script> Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditorHandler.java =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditorHandler.java 2013-11-26 14:10:47 UTC (rev 2756) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditorHandler.java 2013-11-28 09:29:10 UTC (rev 2757) @@ -25,6 +25,7 @@ */ import com.google.common.base.Preconditions; +import jaxx.runtime.spi.UIHandler; import jaxx.runtime.swing.editor.bean.BeanUIUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -43,13 +44,13 @@ * @author Tony Chemit <chemit@codelutin.com> * @since 2.6 */ -public class DmsCoordinateEditorHandler { +public class DmsCoordinateEditorHandler implements UIHandler<DmsCoordinateEditor>{ /** Logger. */ private static final Log log = LogFactory.getLog(DmsCoordinateEditorHandler.class); - private final DmsCoordinateEditor ui; + protected DmsCoordinateEditor ui; protected Method signMutator; @@ -63,23 +64,37 @@ protected boolean valueModelIsAdjusting; - protected final DmsCoordinateConverter signedConverter; + protected DmsCoordinateConverter signedConverter; - protected final DmsCoordinateConverter unsignedConverter; + protected DmsCoordinateConverter unsignedConverter; protected DefaultFormatterFactory signedFormatterFactory; protected DefaultFormatterFactory unsignedFormatterFactory; - public DmsCoordinateEditorHandler(DmsCoordinateEditor ui) { - this.ui = ui; +// public DmsCoordinateEditorHandler(DmsCoordinateEditor ui) { +// this.ui = ui; +// +// // can't use the one from ConverterUtil since we deal with some internal states +// this.signedConverter = new DmsCoordinateConverter(); +// this.signedConverter.setUseSign(true); +// this.unsignedConverter = new DmsCoordinateConverter(); +// } + @Override + public void beforeInit(DmsCoordinateEditor ui) { + this.ui=ui; // can't use the one from ConverterUtil since we deal with some internal states this.signedConverter = new DmsCoordinateConverter(); this.signedConverter.setUseSign(true); this.unsignedConverter = new DmsCoordinateConverter(); } + @Override + public void afterInit(DmsCoordinateEditor ui) { + // nothing special to do here + } + public void init(boolean longitudeEditor) { final DmsCoordinateEditorModel model = ui.getModel(); @@ -256,6 +271,19 @@ } } + protected String getMaskFormatterPattern(boolean longitudeEditor, + boolean useSign) { + String pattern = "**°**''**''''"; + if (longitudeEditor) { + // add one more degre + pattern = "*" + pattern; + } + if (useSign) { + pattern = "-" + pattern; + } + return pattern; + } + private class ModelPropertyChangeListener implements PropertyChangeListener { private final DmsCoordinateEditorModel model; @@ -286,18 +314,6 @@ } } } - } - protected String getMaskFormatterPattern(boolean longitudeEditor, - boolean useSign) { - String pattern = "**°**''**''''"; - if (longitudeEditor) { - // add one more degre - pattern = "*" + pattern; - } - if (useSign) { - pattern = "-" + pattern; - } - return pattern; } } Modified: trunk/src/site/rst/index.rst =================================================================== --- trunk/src/site/rst/index.rst 2013-11-26 14:10:47 UTC (rev 2756) +++ trunk/src/site/rst/index.rst 2013-11-28 09:29:10 UTC (rev 2757) @@ -38,6 +38,36 @@ english translation at the same time. To help you wait, you can have a look to the demo_. +Nouveautés de la version 2.6 +---------------------------- + +Ajout de l'option addAutoUIHandler +__________________________________ + +Cette option permet de détecter un handler associé à chaque fichier jaxx. + +Le handler doit porter le nom du fichier java associé au fichier jaxx suffixé par Handler. + +Ce handler doit de plus implanter un nouveau contract *jaxx.runtime.spi.UIHandler*. + +Le contract contient deux méthodes + +- *beforeInit* qui est appelé juste avant la méthode *$initialize* de chaque object jaxx +- *afterInit* appelée après l'init de l'ojet jaxx, à savoir tout à la fin de la + méthode *$completeSetup*. + +Voir http://nuiton.org/issues/2946. + +Ajout de nouveaux éditeurs +__________________________ + +De nouveaux éditeurs sont intégrés dans JAXX, à savoir : + +- éditeur de temps (http://nuiton.org/issues/2924) +- éditeurs de coordonnées spatiales (http://nuiton.org/issues/2929) + +Ils sont intégrés dans la démo de JAXX. + Nouveautés de la version 2.5 ----------------------------
participants (1)
-
tchemit@users.nuiton.org