Author: chemit Date: 2008-11-21 10:47:28 +0000 (Fri, 21 Nov 2008) New Revision: 1027 Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXCompilerHelper.java lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXObjectGenerator.java lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXObjectGeneratorConstants.java lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/Utils.java Log: deplacement des methodes de creation d'icones directement dans Jaxx (jaxx.runtil.swing.Utils) delegateContext est final et ne doit pas etre instanciee dans les constructeurs (au cas ou on definit un nouveau constructeur)... Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXCompilerHelper.java =================================================================== --- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXCompilerHelper.java 2008-11-19 10:24:31 UTC (rev 1026) +++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXCompilerHelper.java 2008-11-21 10:47:28 UTC (rev 1027) @@ -85,8 +85,7 @@ staticImports.add("jaxx.runtime.swing.VBox"); staticImports.add("jaxx.runtime.swing.Table"); staticImports.add("static org.codelutin.i18n.I18n._"); - // do not link with jaxx-util here... - //staticImports.add("static org.codelutin.jaxx.util.UIHelper.createImageIcon"); + staticImports.add("static jaxx.runtime.swing.Utils.createImageIcon"); } protected static DefaultObjectHandler firstPassClassTagHandler = new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(Object.class)); Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXObjectGenerator.java =================================================================== --- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXObjectGenerator.java 2008-11-19 10:24:31 UTC (rev 1026) +++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXObjectGenerator.java 2008-11-21 10:47:28 UTC (rev 1027) @@ -20,6 +20,8 @@ import java.io.ObjectOutputStream; import java.io.PrintWriter; import java.lang.reflect.Modifier; +import static java.lang.reflect.Modifier.PROTECTED; +import static java.lang.reflect.Modifier.FINAL; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -146,7 +148,7 @@ if (getOptions().isAddLogger()) { javaFile.addImport(org.apache.commons.logging.Log.class); javaFile.addImport(org.apache.commons.logging.LogFactory.class); - javaFile.addField(newField(Modifier.PUBLIC + Modifier.STATIC + Modifier.FINAL, "Log", "log", "LogFactory.getLog(" + fullClassName + ".class)")); + javaFile.addField(newField(Modifier.PUBLIC + Modifier.STATIC + FINAL, "Log", "log", "LogFactory.getLog(" + fullClassName + ".class)")); } // JAXXObject @@ -157,7 +159,7 @@ // JAXXContext - javaFile.addField(DELEGATE_CONTEXT_FIELD); + javaFile.addField(newField(PROTECTED| FINAL, "jaxx.runtime.JAXXContext", "delegateContext","new "+ jaxxContextImplementorClass+ "(this);")); javaFile.addMethod(SET_CONTEXT_VALUE_METHOD); javaFile.addMethod(SET_CONTEXT_VALUE_NAMED_METHOD); javaFile.addMethod(GET_CONTEXT_VALUE_METHOD); @@ -188,8 +190,8 @@ javaFile.addField(PREVIOUS_VALUES_FIELD); } - javaFile.addMethod(createConstructor(className, superclassIsJAXXObject, jaxxContextImplementorClass)); - javaFile.addMethod(createConstructorWithInitialContext(className, superclassIsJAXXObject, jaxxContextImplementorClass)); + javaFile.addMethod(createConstructor(className, superclassIsJAXXObject)); + javaFile.addMethod(createConstructorWithInitialContext(className, superclassIsJAXXObject)); javaFile.addMethod(createInitializer()); javaFile.addMethod(GET_JAXX_OBJECT_DESCRIPTOR_METHOD); @@ -357,7 +359,7 @@ } } - protected JavaMethod createConstructor(String className, boolean superclassIsJAXXObject, String jaxxContextImplementorClass) throws CompilerException { + protected JavaMethod createConstructor(String className, boolean superclassIsJAXXObject) throws CompilerException { StringBuffer code = new StringBuffer(); String constructorParams = compiler.getRootObject().getConstructorParams(); if (constructorParams != null) { @@ -367,16 +369,16 @@ code.append(" super();").append(JAXXCompiler.getLineSeparator()); } } - if (!superclassIsJAXXObject) { + /*if (!superclassIsJAXXObject) { code.append("delegateContext = new ").append(jaxxContextImplementorClass).append("(this);"); code.append(JAXXCompiler.getLineSeparator()); - } + }*/ code.append("$initialize();"); code.append(JAXXCompiler.getLineSeparator()); return newMethod(Modifier.PUBLIC, null, className, code.toString()); } - protected JavaMethod createConstructorWithInitialContext(String className, boolean superclassIsJAXXObject, String jaxxContextImplementorClass) throws CompilerException { + protected JavaMethod createConstructorWithInitialContext(String className, boolean superclassIsJAXXObject) throws CompilerException { StringBuffer code = new StringBuffer(); String constructorParams = compiler.getRootObject().getConstructorParams(); if (constructorParams != null) { @@ -387,8 +389,8 @@ } } if (!superclassIsJAXXObject) { - code.append("delegateContext = new ").append(jaxxContextImplementorClass).append("(this);"); - code.append(JAXXCompiler.getLineSeparator()); + //code.append("delegateContext = new ").append(jaxxContextImplementorClass).append("(this);"); + //code.append(JAXXCompiler.getLineSeparator()); code.append("if (parentContext instanceof jaxx.runtime.JAXXInitialContext) {"); code.append(JAXXCompiler.getLineSeparator()); code.append(" ((jaxx.runtime.JAXXInitialContext)parentContext).to(this);"); Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXObjectGeneratorConstants.java =================================================================== --- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXObjectGeneratorConstants.java 2008-11-19 10:24:31 UTC (rev 1026) +++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXObjectGeneratorConstants.java 2008-11-21 10:47:28 UTC (rev 1027) @@ -1,6 +1,5 @@ package jaxx.compiler; -import static java.lang.reflect.Modifier.FINAL; import static java.lang.reflect.Modifier.PRIVATE; import static java.lang.reflect.Modifier.PROTECTED; import static java.lang.reflect.Modifier.PUBLIC; @@ -35,7 +34,7 @@ "java.util.Map", "$previousValues", "new java.util.HashMap()" ); - protected static final JavaField DELEGATE_CONTEXT_FIELD = newField(PROTECTED | FINAL, + protected static final JavaField DELEGATE_CONTEXT_FIELD = newField(PROTECTED, "jaxx.runtime.JAXXContext", "delegateContext" ); Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/Utils.java =================================================================== --- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/Utils.java 2008-11-19 10:24:31 UTC (rev 1026) +++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/Utils.java 2008-11-21 10:47:28 UTC (rev 1027) @@ -4,6 +4,7 @@ */ package jaxx.runtime.swing; +import javax.swing.ImageIcon; import javax.swing.SwingUtilities; import javax.swing.text.AbstractDocument; import javax.swing.text.JTextComponent; @@ -29,22 +30,25 @@ notifyingListeners.setAccessible(true); } - if (notifyingListeners.get(document).equals(Boolean.TRUE)) + if (notifyingListeners.get(document).equals(Boolean.TRUE)) { return; + } if (((Integer) numReaders.get(document)).intValue() > 0) { SwingUtilities.invokeLater(new Runnable() { public void run() { - if (!c.getText().equals(text)) + if (!c.getText().equals(text)) { c.setText(text); + } } }); return; } String oldText = c.getText(); - if (oldText == null || !oldText.equals(text)) + if (oldText == null || !oldText.equals(text)) { c.setText(text); + } } catch (NoSuchFieldException e) { throw new RuntimeException(e); @@ -57,5 +61,21 @@ } } - + public static ImageIcon createImageIcon(String path) { + java.net.URL imgURL = Utils.class.getResource("/icons/" + path); + if (imgURL != null) { + return new ImageIcon(imgURL); + } else { + throw new IllegalArgumentException("could not find icon " + path); + } + } + + public static ImageIcon createActionIcon(String name) { + return createImageIcon("action-" + name + ".png"); + } + + public static ImageIcon createI18nIcon(String name) { + return createImageIcon("i18n/" + name + ".png"); + } + }