[Buix-commits] r1182 - in jaxx/trunk: jaxx-compiler-api jaxx-compiler-api/src/main/java/jaxx/tags jaxx-runtime-api jaxx-runtime-api/src/main/java/jaxx/runtime maven-jaxx-plugin maven-jaxx-plugin/src/test/java/org/codelutin/jaxx maven-jaxx-plugin/src/test/resources/testcases maven-jaxx-plugin/src/test/resources/testcases/icon
Author: tchemit Date: 2009-01-23 21:54:09 +0000 (Fri, 23 Jan 2009) New Revision: 1182 Added: jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Icon.xml jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/icon/ jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/icon/Test1.jaxx Modified: jaxx/trunk/jaxx-compiler-api/changelog.txt jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/tags/DefaultComponentHandler.java jaxx/trunk/jaxx-runtime-api/changelog.txt jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/Util.java jaxx/trunk/maven-jaxx-plugin/changelog.txt jaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompilerTest.java Log: - add a simple createIcon method in Util classe (to create an icon with no path prefix) - can directly give the icon relatif path (in /icons/ directory) - add an actionIcon attribute to be surronded in the Util.createActionIcon - add tests for icon improvment Modified: jaxx/trunk/jaxx-compiler-api/changelog.txt =================================================================== --- jaxx/trunk/jaxx-compiler-api/changelog.txt 2009-01-23 21:45:08 UTC (rev 1181) +++ jaxx/trunk/jaxx-compiler-api/changelog.txt 2009-01-23 21:54:09 UTC (rev 1182) @@ -1,5 +1,8 @@ 1.1 chemit 200901?? * 20090123 [chemit] - cache the lineSeparator property in JAXXCompiler + - can directly give the icon relatif path (in /icons/ directory) + - add an actionIcon attribute to be surronded in the Util.createActionIcon + * 20090122 [chemit] - refactor poms (sibling dependencies, pluginsManagment,...) 1.0 chemit 20090111 Modified: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/tags/DefaultComponentHandler.java =================================================================== --- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/tags/DefaultComponentHandler.java 2009-01-23 21:45:08 UTC (rev 1181) +++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/tags/DefaultComponentHandler.java 2009-01-23 21:54:09 UTC (rev 1182) @@ -195,6 +195,25 @@ return super.getSetPropertyCode(id, name, valueCode, compiler); } + @Override + public void setAttribute(CompiledObject object, String propertyName, String stringValue, boolean inline, JAXXCompiler compiler) { + if ("icon".equals(propertyName)) { + if (!(stringValue.startsWith("{") || stringValue.endsWith("}"))) { + // this is a customized icon, add the icon creation code + stringValue = "{" + jaxx.runtime.Util.class.getName() + ".createImageIcon(\"" + stringValue + "\")}"; + } + } else if ("actionIcon".equals(propertyName)) { + // customized actionIcon property + if (stringValue.startsWith("{") && stringValue.endsWith("}")) { + // there is a script to define the action icon, this is forbidden + compiler.reportError("the actionIcon does not support script, remove braces..., fix the file " + compiler.getOutputClassName()); + return; + } + propertyName = "icon"; + stringValue = "{" + jaxx.runtime.Util.class.getName() + ".createActionIcon(\"" + stringValue + "\")}"; + } + super.setAttribute(object, propertyName, stringValue, inline, compiler); + } /** * Maps string values onto integers, so that int-valued enumeration properties can be specified by strings. For Modified: jaxx/trunk/jaxx-runtime-api/changelog.txt =================================================================== --- jaxx/trunk/jaxx-runtime-api/changelog.txt 2009-01-23 21:45:08 UTC (rev 1181) +++ jaxx/trunk/jaxx-runtime-api/changelog.txt 2009-01-23 21:54:09 UTC (rev 1182) @@ -1,4 +1,5 @@ 1.1 chemit 200901?? + * 20090123 [chemit] - add a simple createIcon method in Util classe (to create an icon with no path prefix) * 20090122 [chemit] - refactor poms (sibling dependencies, pluginsManagment,...) 1.0 chemit 20090111 Modified: jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/Util.java =================================================================== --- jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/Util.java 2009-01-23 21:45:08 UTC (rev 1181) +++ jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/Util.java 2009-01-23 21:54:09 UTC (rev 1182) @@ -6,9 +6,9 @@ import org.jdesktop.jxlayer.JXLayer; import javax.swing.DefaultListCellRenderer; +import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.JList; -import javax.swing.ImageIcon; import java.awt.Component; import java.awt.Container; import java.awt.Dimension; @@ -434,8 +434,8 @@ }; } - public static ImageIcon createImageIcon(String path) { - java.net.URL imgURL = Util.class.getResource("/icons/" + path); + public static ImageIcon createIcon(String path) { + java.net.URL imgURL = Util.class.getResource(path); if (imgURL != null) { return new ImageIcon(imgURL); } else { @@ -443,12 +443,20 @@ } } + /** + * @param path the location of icons in root directory icons + * @return the icon at "/icons/"+path + */ + public static ImageIcon createImageIcon(String path) { + return createIcon("/icons/" + path); + } + public static ImageIcon createActionIcon(String name) { - return createImageIcon("action-" + name + ".png"); + return createIcon("/icons/action-" + name + ".png"); } public static ImageIcon createI18nIcon(String name) { - return createImageIcon("i18n/" + name + ".png"); + return createIcon("/icons/i18n/" + name + ".png"); } } Modified: jaxx/trunk/maven-jaxx-plugin/changelog.txt =================================================================== --- jaxx/trunk/maven-jaxx-plugin/changelog.txt 2009-01-23 21:45:08 UTC (rev 1181) +++ jaxx/trunk/maven-jaxx-plugin/changelog.txt 2009-01-23 21:54:09 UTC (rev 1182) @@ -1,4 +1,5 @@ 1.1 chemit 200901?? + * 20090123 [chemit] - add tests for icon improvment * 20090122 [chemit] - refactor poms (sibling dependencies, pluginsManagment,...) - rename i18n bundles according artifactId * 20090113 [chemit] - fix bug : when using addProjectClassPath property, sometimes does not retreave Modified: jaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompilerTest.java =================================================================== --- jaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompilerTest.java 2009-01-23 21:45:08 UTC (rev 1181) +++ jaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompilerTest.java 2009-01-23 21:54:09 UTC (rev 1182) @@ -18,6 +18,11 @@ assertEquals(1, mojo.getFiles().length); } + public void testIcon() throws Exception { + mojo.execute(); + assertEquals(1, mojo.getFiles().length); + } + public void testSpecialSubclassing() throws Exception { mojo.execute(); assertEquals(7, mojo.getFiles().length); Copied: jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Icon.xml (from rev 1173, jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Bug_1751.xml) =================================================================== --- jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Icon.xml (rev 0) +++ jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Icon.xml 2009-01-23 21:54:09 UTC (rev 1182) @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <build> + <plugins> + <plugin> + <groupId>org.codelutin</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <configuration> + <src>${basedir}/src/test/resources</src> + <outJava>${basedir}/target/it-generated-sources/java</outJava> + <outResource>${basedir}/target/it-generated-sources/resources</outResource> + <i18nable>false</i18nable> + <force>true</force> + <verbose>true</verbose> + <resetAfterCompile>true</resetAfterCompile> + <includes> + <value>**/icon/*.jaxx</value> + </includes> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Added: jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/icon/Test1.jaxx =================================================================== --- jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/icon/Test1.jaxx (rev 0) +++ jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/icon/Test1.jaxx 2009-01-23 21:54:09 UTC (rev 1182) @@ -0,0 +1,4 @@ +<JPanel> + <JLabel actionIcon='myIcon.png'/> + <JLabel icon='myIcon.png'/> +</JPanel>
participants (1)
-
tchemit@users.labs.libre-entreprise.org