Author: tchemit Date: 2009-12-02 13:33:53 +0100 (Wed, 02 Dec 2009) New Revision: 1669 Added: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/IDHelper.java branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/TypeManagerTest.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXBinding.java Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/BoxedCompiledObjectDecorator.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/ValidatorFinalizer.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptorLoader.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/script/ScriptInitializer.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultComponentHandler.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ApplicationHandler.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXListHandler.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTreeHandler.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JRadioButtonHandler.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTabbedPaneHandler.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TableHandler.java branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/ColorConverterTest.java branches/jaxx-2.X/jaxx-compiler/src/test/resources/log4j.properties branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/Calculator.css branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyle.css branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Util.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DecoratorTest.java Log: - introduce JAXXBinding class to make binding simplier and programmatic - move some Swing methods from Util to SwingUtil (this should probably breaks some projects...) - improve generated code (use as soon as possible simple class name rather than fqn) - use method from TypeManager (were previously in JAXXCompiler) - introduce IDHelper to generate ids (will be attached in JAXXCompiler) - add TypeManagerTest - reformat css in demo Added: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/IDHelper.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/IDHelper.java (rev 0) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/IDHelper.java 2009-12-02 12:33:53 UTC (rev 1669) @@ -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(); + } +} Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/IDHelper.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL Modified: branches/jaxx-2.X/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 12:21:40 UTC (rev 1668) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/BoxedCompiledObjectDecorator.java 2009-12-02 12:33:53 UTC (rev 1669) @@ -49,7 +49,7 @@ for (ChildRef child : parent.getChilds()) { if (child.getChild() == object) { String javaCode = child.getChildJavaCode(); - child.setChildJavaCode(SwingUtil.class.getName() + ".boxComponentWithJxLayer(" + javaCode + ")"); + child.setChildJavaCode(SwingUtil.class.getSimpleName() + ".boxComponentWithJxLayer(" + javaCode + ")"); break; } } Modified: branches/jaxx-2.X/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 12:21:40 UTC (rev 1668) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java 2009-12-02 12:33:53 UTC (rev 1669) @@ -99,7 +99,7 @@ if (helpID != null) { buffer.append(eol); // detects a helpId to register - buffer.append("registerHelpId(_broker, " + o.getJavaCode() + ", " + helpID + ");"); + buffer.append("registerHelpId(_broker, ").append(o.getJavaCode()).append(", ").append(helpID).append(");"); //keep the helpID for helpSet generation helpIds.add(helpID); } Modified: branches/jaxx-2.X/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 12:21:40 UTC (rev 1668) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/ValidatorFinalizer.java 2009-12-02 12:33:53 UTC (rev 1669) @@ -32,6 +32,8 @@ import jaxx.compiler.tags.validator.BeanValidatorHandler.CompiledBeanValidator; import java.util.List; + +import jaxx.compiler.types.TypeManager; import jaxx.runtime.SwingUtil; /** @author chemit */ @@ -58,7 +60,7 @@ boolean found = BeanValidatorHandler.isComponentUsedByValidator(compiler, child.getChild().getId()); if (found) { // box the child component in a JxLayer - child.setChildJavaCode(SwingUtil.class.getName() + ".boxComponentWithJxLayer(" + javaCode + ")"); + child.setChildJavaCode(SwingUtil.class.getSimpleName() + ".boxComponentWithJxLayer(" + javaCode + ")"); } } } @@ -66,7 +68,7 @@ // register validator compiler.appendLateInitializer("// validator setup" + eol); for (CompiledBeanValidator validator : BeanValidatorHandler.getValidators(compiler)) { - String id = compiler.getJavaCode(validator.getId()); + String id = TypeManager.getJavaCode(validator.getId()); compiler.appendLateInitializer("validatorIds.add(" + id + ");"); compiler.appendLateInitializer(eol); compiler.appendLateInitializer("getValidator(" + id + ").installUIs();"); Modified: branches/jaxx-2.X/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 12:21:40 UTC (rev 1668) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptorLoader.java 2009-12-02 12:33:53 UTC (rev 1669) @@ -207,7 +207,7 @@ arrayCount++; className = className.substring(0, className.length() - 2); } - Class<?> klass = null; + Class<?> klass; if (arrayCount > 0) { klass = getPrimitiveClass(className); if (klass == null) { @@ -299,7 +299,8 @@ return null; } try { - Method getJAXXObjectDescriptor = jaxxClass.getMethod("$getJAXXObjectDescriptor", new Class<?>[0]); + 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"); Modified: branches/jaxx-2.X/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 12:21:40 UTC (rev 1668) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/script/ScriptInitializer.java 2009-12-02 12:33:53 UTC (rev 1669) @@ -32,7 +32,8 @@ public class ScriptInitializer extends CompiledObject { public ScriptInitializer(String initializer, JAXXCompiler compiler) { - super(compiler.getAutoId(ClassDescriptorLoader.getClassDescriptor(ScriptInitializer.class)), +// super(compiler.getAutoId(ClassDescriptorLoader.getClassDescriptor(ScriptInitializer.class)), + super(compiler.getAutoId(ScriptInitializer.class.getSimpleName()), ClassDescriptorLoader.getClassDescriptor(ScriptInitializer.class), compiler, false); appendInitializationCode(initializer); } Modified: branches/jaxx-2.X/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 12:21:40 UTC (rev 1668) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultComponentHandler.java 2009-12-02 12:33:53 UTC (rev 1669) @@ -27,6 +27,7 @@ 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; @@ -40,7 +41,6 @@ import java.io.IOException; import java.lang.reflect.Field; -import jaxx.runtime.Util; import org.w3c.dom.Attr; import org.w3c.dom.NamedNodeMap; @@ -182,10 +182,10 @@ } if (name.equals(WIDTH_ATTRIBUTE)) { // need to optimize case when both width and height are being assigned - return Util.class.getName() + ".setComponentWidth(" + id + "," + valueCode + ");"; + return SwingUtil.class.getSimpleName() + ".setComponentWidth(" + id + "," + valueCode + ");"; } if (name.equals(HEIGHT_ATTRIBUTE)) { - return Util.class.getName() + ".setComponentHeight(" + id + "," + valueCode + ");"; + 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}"; @@ -202,7 +202,7 @@ } 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 } 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); @@ -255,9 +255,9 @@ if (!(stringValue.startsWith("{") || stringValue.endsWith("}"))) { // this is a customized icon, add the icon creation code if (compiler.getConfiguration().isUseUIManagerForIcon()) { - stringValue = "{" + Util.class.getName() + ".getUIManagerIcon(\"" + stringValue + "\")}"; + stringValue = "{" + SwingUtil.class.getName() + ".getUIManagerIcon(\"" + stringValue + "\")}"; } else { - stringValue = "{" + Util.class.getName() + ".createImageIcon(\"" + stringValue + "\")}"; + stringValue = "{" + SwingUtil.class.getName() + ".createImageIcon(\"" + stringValue + "\")}"; } } } else if (ACTION_ICON_ATTRIBUTE.equals(propertyName)) { @@ -269,9 +269,9 @@ } propertyName = ICON_ATTRIBUTE; if (compiler.getConfiguration().isUseUIManagerForIcon()) { - stringValue = "{" + Util.class.getName() + ".getUIManagerActionIcon(\"" + stringValue + "\")}"; + stringValue = "{" + SwingUtil.class.getName() + ".getUIManagerActionIcon(\"" + stringValue + "\")}"; } else { - stringValue = "{" + Util.class.getName() + ".createActionIcon(\"" + stringValue + "\")}"; + stringValue = "{" + SwingUtil.class.getName() + ".createActionIcon(\"" + stringValue + "\")}"; } } super.setAttribute(object, propertyName, stringValue, inline, compiler); Modified: branches/jaxx-2.X/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 12:21:40 UTC (rev 1668) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ApplicationHandler.java 2009-12-02 12:33:53 UTC (rev 1669) @@ -41,7 +41,7 @@ @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(" + compiler.getJavaCode(stringValue) + "); }" + JAXXCompiler.getLineSeparator()); + compiler.appendBodyCode("{ " + object.getJavaCode() + ".setLookAndFeel(" + TypeManager.getJavaCode(stringValue) + "); }" + JAXXCompiler.getLineSeparator()); } else { super.setAttribute(object, propertyName, stringValue, inline, compiler); } Modified: branches/jaxx-2.X/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 12:21:40 UTC (rev 1668) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXListHandler.java 2009-12-02 12:33:53 UTC (rev 1669) @@ -26,6 +26,7 @@ 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; @@ -67,7 +68,7 @@ for (Item item : items) { String id = item.getId(); CompiledObject compiledItem = new CompiledObject(id, ClassDescriptorLoader.getClassDescriptor(Item.class), compiler); - compiledItem.setConstructorParams(compiler.getJavaCode(id) + ", " + compiler.getJavaCode(item.getLabel()) + ", " + compiler.getJavaCode(item.getValue()) + ", " + item.isSelected()); + compiledItem.setConstructorParams(TypeManager.getJavaCode(id) + ", " + TypeManager.getJavaCode(item.getLabel()) + ", " + TypeManager.getJavaCode(item.getValue()) + ", " + item.isSelected()); compiler.registerCompiledObject(compiledItem); list.appendAdditionCode(listName + ".add(" + id + ");"); } Modified: branches/jaxx-2.X/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 12:21:40 UTC (rev 1668) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTreeHandler.java 2009-12-02 12:33:53 UTC (rev 1669) @@ -26,6 +26,7 @@ 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; @@ -60,7 +61,7 @@ for (Item item : items) { String id = item.getId(); CompiledObject compiledItem = new CompiledObject(id, ClassDescriptorLoader.getClassDescriptor(Item.class), compiler); - compiledItem.setConstructorParams(compiler.getJavaCode(id) + ", " + compiler.getJavaCode(item.getLabel()) + ", " + compiler.getJavaCode(item.getValue()) + ", " + item.isSelected()); + 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); Modified: branches/jaxx-2.X/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 12:21:40 UTC (rev 1668) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JRadioButtonHandler.java 2009-12-02 12:33:53 UTC (rev 1669) @@ -27,6 +27,7 @@ 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; @@ -68,7 +69,7 @@ @Override public void setProperty(CompiledObject object, String name, Object value, JAXXCompiler compiler) { if (name.equals(BUTTON_GROUP_PROPERTY)) { - object.appendAdditionCode(getSetPropertyCode(object.getJavaCode(), name, compiler.getJavaCode(value), compiler)); + object.appendAdditionCode(getSetPropertyCode(object.getJavaCode(), name, TypeManager.getJavaCode(value), compiler)); } else { super.setProperty(object, name, value, compiler); } Modified: branches/jaxx-2.X/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 12:21:40 UTC (rev 1668) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTabbedPaneHandler.java 2009-12-02 12:33:53 UTC (rev 1669) @@ -27,6 +27,7 @@ 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; @@ -76,10 +77,10 @@ if (I18nHelper.isI18nAttribute("title")) { if (!title.startsWith("_(\"")) { // we did not have the invocation code, add it - title = I18nHelper.addI18nInvocation(getId(), "title", compiler.getJavaCode(title), compiler); + title = I18nHelper.addI18nInvocation(getId(), "title", TypeManager.getJavaCode(title), compiler); } } else { - title = compiler.getJavaCode(title); + title = TypeManager.getJavaCode(title); } appendAdditionCode(getId() + ".setTitleAt(" + tabIndex + ", " + title + ");"); } @@ -89,10 +90,10 @@ if (I18nHelper.isI18nAttribute("toolTipText")) { if (!toolTipText.startsWith("_(\"")) { // we did not have the invocation code, add it - toolTipText = I18nHelper.addI18nInvocation(getId(), "toolTipText", compiler.getJavaCode(toolTipText), compiler); + toolTipText = I18nHelper.addI18nInvocation(getId(), "toolTipText", TypeManager.getJavaCode(toolTipText), compiler); } } else { - toolTipText = compiler.getJavaCode(toolTipText); + toolTipText = TypeManager.getJavaCode(toolTipText); } appendAdditionCode(getId() + ".setToolTipTextAt(" + tabIndex + ", " + toolTipText + ");"); } @@ -104,12 +105,12 @@ Color foreground = tabInfo.getForeground(); if (foreground != null) { - appendAdditionCode(getId() + ".setForegroundAt(" + tabIndex + ", " + compiler.getJavaCode(foreground) + ");"); + appendAdditionCode(getId() + ".setForegroundAt(" + tabIndex + ", " + TypeManager.getJavaCode(foreground) + ");"); } Color background = tabInfo.getBackground(); if (background != null) { - appendAdditionCode(getId() + ".setBackgroundAt(" + tabIndex + ", " + compiler.getJavaCode(background) + ");"); + appendAdditionCode(getId() + ".setBackgroundAt(" + tabIndex + ", " + TypeManager.getJavaCode(background) + ");"); } int mnemonic = tabInfo.getMnemonic(); Modified: branches/jaxx-2.X/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 12:21:40 UTC (rev 1668) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TableHandler.java 2009-12-02 12:33:53 UTC (rev 1669) @@ -27,6 +27,7 @@ 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; @@ -92,7 +93,7 @@ rowSpans.set(x, c.gridheight); } - super.addChild(child, compiler.getJavaCode(c), compiler); + super.addChild(child, TypeManager.getJavaCode(c), compiler); emptyCell = false; } Modified: branches/jaxx-2.X/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 12:21:40 UTC (rev 1668) +++ branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/ColorConverterTest.java 2009-12-02 12:33:53 UTC (rev 1669) @@ -1,31 +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>. - * ##%* - */ +/* + * *##% + * 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.ColorConverter; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import java.awt.Color; +import java.awt.*; public class ColorConverterTest { Added: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/TypeManagerTest.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/TypeManagerTest.java (rev 0) +++ branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/TypeManagerTest.java 2009-12-02 12:33:53 UTC (rev 1669) @@ -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); + } + +} Property changes on: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/TypeManagerTest.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL Modified: branches/jaxx-2.X/jaxx-compiler/src/test/resources/log4j.properties =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/test/resources/log4j.properties 2009-12-02 12:21:40 UTC (rev 1668) +++ branches/jaxx-2.X/jaxx-compiler/src/test/resources/log4j.properties 2009-12-02 12:33:53 UTC (rev 1669) @@ -5,4 +5,4 @@ log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n -log4j.logger.jaxx=DEBUG +log4j.logger.jaxx=INFO Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx 2009-12-02 12:21:40 UTC (rev 1668) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx 2009-12-02 12:33:53 UTC (rev 1669) @@ -95,8 +95,8 @@ <JSplitPane id='splitPane' constraints='BorderLayout.CENTER'> <JScrollPane id='navigationPane'> <JTree id='navigation' - model='{getTreeHelper().createTreeModel(this)}' - selectionModel="{getTreeHelper().createTreeHandler(this)}"/> + model='{getTreeHelper().createTreeModel(DemoUI.this)}' + selectionModel="{getTreeHelper().createTreeHandler(DemoUI.this)}"/> </JScrollPane> <JPanel id='content'/> Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/Calculator.css =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/Calculator.css 2009-12-02 12:21:40 UTC (rev 1668) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/Calculator.css 2009-12-02 12:33:53 UTC (rev 1669) @@ -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: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyle.css =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyle.css 2009-12-02 12:21:40 UTC (rev 1668) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyle.css 2009-12-02 12:33:53 UTC (rev 1669) @@ -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 Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXBinding.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXBinding.java (rev 0) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXBinding.java 2009-12-02 12:33:53 UTC (rev 1669) @@ -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 Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXBinding.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL Modified: branches/jaxx-2.X/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 12:21:40 UTC (rev 1668) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java 2009-12-02 12:33:53 UTC (rev 1669) @@ -85,6 +85,8 @@ * 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."; @@ -227,6 +229,29 @@ 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) { @@ -593,7 +618,7 @@ if (iconKey instanceof Icon) { icon = (Icon) iconKey; } else if (iconKey instanceof String) { - icon = jaxx.runtime.Util.getUIManagerActionIcon((String) iconKey); + icon = getUIManagerActionIcon((String) iconKey); } JLabel result; if (icon == null) { @@ -799,4 +824,97 @@ } }); } + + /** + * 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; + } } Modified: branches/jaxx-2.X/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 12:21:40 UTC (rev 1668) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Util.java 2009-12-02 12:33:53 UTC (rev 1669) @@ -24,11 +24,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import javax.swing.Icon; -import javax.swing.ImageIcon; -import javax.swing.JComponent; -import javax.swing.UIManager; -import java.awt.*; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListenerProxy; import java.io.IOException; @@ -37,18 +32,12 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Proxy; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.EventListener; -import java.util.List; -import java.util.Map; -import java.util.WeakHashMap; +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"; + // public static final String DEFAULT_ICON_PATH = "/icons/"; + // public static final String DEFAULT_ICON_PATH_PROPERTY = "default.icon.path"; /** * Logger */ @@ -125,29 +114,36 @@ return contextEntryDef; } - /** - * 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 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(); @@ -220,9 +216,10 @@ 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(e); + throw new RuntimeException("could not invoke on container " + methodContainer, e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } @@ -268,29 +265,29 @@ 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 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 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"); @@ -409,53 +406,53 @@ } } - 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); - } - } +// 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 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"); +// } /** - * @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} * @@ -494,15 +491,15 @@ 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; - } +// 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; +// } } Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java 2009-12-02 12:21:40 UTC (rev 1668) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java 2009-12-02 12:33:53 UTC (rev 1669) @@ -25,7 +25,6 @@ import com.opensymphony.xwork2.config.ConfigurationManager; import com.opensymphony.xwork2.util.ValueStack; import com.opensymphony.xwork2.util.ValueStackFactory; -import jaxx.runtime.validator.*; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java 2009-12-02 12:21:40 UTC (rev 1668) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java 2009-12-02 12:33:53 UTC (rev 1669) @@ -32,7 +32,7 @@ /** * The model of the table of errors. - * + * <p/> * The model listens validators messages and update his internal model from it. * * @author chemit @@ -43,13 +43,19 @@ implements jaxx.runtime.validator.BeanValidatorListener { private static final long serialVersionUID = 1L; - /** to use log facility, just put in your code: log.info(\"...\"); */ + /** + * 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 */ + /** + * list of registred validators + */ protected transient List<SwingValidator<?>> validators; - /** list of messages actual displayed */ + /** + * list of messages actual displayed + */ protected List<SwingValidatorMessage> data; public SwingValidatorMessageTableModel() { @@ -60,8 +66,8 @@ /** * 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 @@ -123,7 +129,7 @@ /** * Obtain the message for a given row. - * + * * @param rowIndex the row index * @return the message for the given row index */ Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java 2009-12-02 12:21:40 UTC (rev 1668) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java 2009-12-02 12:33:53 UTC (rev 1669) @@ -49,21 +49,21 @@ public static ImageIcon getErrorIcon() { if (errorIcon == null) { - errorIcon = jaxx.runtime.Util.createImageIcon("error.png"); + errorIcon = SwingUtil.createImageIcon("error.png"); } return errorIcon; } public static ImageIcon getInfoIcon() { if (infoIcon == null) { - infoIcon = jaxx.runtime.Util.createImageIcon("info.png"); + infoIcon = SwingUtil.createImageIcon("info.png"); } return infoIcon; } public static ImageIcon getWarningIcon() { if (warningIcon == null) { - warningIcon = jaxx.runtime.Util.createImageIcon("warning.png"); + warningIcon = SwingUtil.createImageIcon("warning.png"); } return warningIcon; } @@ -149,7 +149,7 @@ public static SwingValidatorMessageListMouseListener getErrorListMouseListener(JList list) { if (list != null) { for (MouseListener listener : list.getMouseListeners()) { - if (listener instanceof SwingValidatorMessageTableMouseListener) { + if (listener instanceof SwingValidatorMessageListMouseListener) { return (SwingValidatorMessageListMouseListener) listener; } } Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java 2009-12-02 12:21:40 UTC (rev 1668) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java 2009-12-02 12:33:53 UTC (rev 1669) @@ -20,6 +20,7 @@ */ package jaxx.runtime.validator.swing.ui; +import jaxx.runtime.SwingUtil; import org.jdesktop.jxlayer.JXLayer; import javax.swing.BorderFactory; @@ -41,13 +42,13 @@ public ImageValidationUI(BeanValidatorField<?> field) { super(field); if (errorIcon == null) { - errorIcon = prepareIcon(jaxx.runtime.Util.createImageIcon("error.png")); + errorIcon = prepareIcon(SwingUtil.createImageIcon("error.png")); } if (warningIcon == null) { - warningIcon = prepareIcon(jaxx.runtime.Util.createImageIcon("warning.png")); + warningIcon = prepareIcon(SwingUtil.createImageIcon("warning.png")); } if (infoIcon == null) { - infoIcon = prepareIcon(jaxx.runtime.Util.createImageIcon("info.png")); + infoIcon = prepareIcon(SwingUtil.createImageIcon("info.png")); } } Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DecoratorTest.java =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DecoratorTest.java 2009-12-02 12:21:40 UTC (rev 1668) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DecoratorTest.java 2009-12-02 12:33:53 UTC (rev 1669) @@ -29,7 +29,7 @@ GenerateMojo mojo = getMojo(); mojo.execute(); assertNumberJaxxFiles(1); - checkPattern(mojo, "add(jaxx.runtime.SwingUtil.boxComponentWithJxLayer(boxedButton))", true); + checkPattern(mojo, "add(SwingUtil.boxComponentWithJxLayer(boxedButton))", true); } } \ No newline at end of file