Buix-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- 1440 discussions
r1536 - trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator
by kmorin@users.labs.libre-entreprise.org 28 Jul '09
by kmorin@users.labs.libre-entreprise.org 28 Jul '09
28 Jul '09
Author: kmorin
Date: 2009-07-28 12:38:42 +0200 (Tue, 28 Jul 2009)
New Revision: 1536
Modified:
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingGenerator.java
Log:
Correction after the last failed build
Modified: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingGenerator.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingGenerator.java 2009-07-28 10:38:31 UTC (rev 1535)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingGenerator.java 2009-07-28 10:38:42 UTC (rev 1536)
@@ -96,23 +96,32 @@
return jf;
}
- catch (IllegalArgumentException ex) {
- log.error(ex);
+ catch (IllegalArgumentException eee) {
+ if(log.isErrorEnabled()) {
+ log.error(eee);
+ }
}
- catch (IllegalStateException ex) {
- log.error(ex);
+ catch (IllegalStateException eee) {
+ if(log.isErrorEnabled()) {
+ log.error(eee);
+ }
}
- catch (IOException ex) {
- log.error(ex);
+ catch (IOException eee) {
+ if(log.isErrorEnabled()) {
+ log.error(eee);
+ }
}
}
else if (log.isWarnEnabled()) {
log.warn(gmo.getClassDescriptor().getName() + " has already been generated and is up to date.");
}
}
- finally {
- return null;
+ catch(Exception eee) {
+ if(log.isErrorEnabled()) {
+ log.error(eee);
+ }
}
+ return null;
}
@Override
@@ -407,6 +416,7 @@
result.addAll(generateBindings(dbCreation, dbDeletion, th, nextFile, nextClazz, binding, i+1, alreadyChecked, methodToInvoke, generatedFiles));
}
if(listener == null) {
+ log.error("Unable to find the right listener");
return null;
}
if(!result.contains(listener)) {
1
0
r1535 - trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator
by kmorin@users.labs.libre-entreprise.org 28 Jul '09
by kmorin@users.labs.libre-entreprise.org 28 Jul '09
28 Jul '09
Author: kmorin
Date: 2009-07-28 12:38:31 +0200 (Tue, 28 Jul 2009)
New Revision: 1535
Modified:
trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtGenerator.java
Log:
Correction after the last failed build
Modified: trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtGenerator.java
===================================================================
--- trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtGenerator.java 2009-07-28 10:02:13 UTC (rev 1534)
+++ trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtGenerator.java 2009-07-28 10:38:31 UTC (rev 1535)
@@ -125,23 +125,33 @@
return jf;
}
- catch (IllegalArgumentException ex) {
- log.error(ex);
+ catch (IllegalArgumentException eee) {
+ if(log.isErrorEnabled()) {
+ log.error(eee);
+ }
}
- catch (IllegalStateException ex) {
- log.error(ex);
+ catch (IllegalStateException eee) {
+ if(log.isErrorEnabled()) {
+ log.error(eee);
+ }
}
- catch (IOException ex) {
- log.error(ex);
+ catch (IOException eee) {
+ if(log.isErrorEnabled()) {
+ log.error(eee);
+ }
}
}
else if (log.isWarnEnabled()) {
log.warn(gmo.getClassDescriptor().getName() + " has already been generated and is up to date.");
}
}
- finally {
- return null;
+ catch(Exception eee) {
+ if(log.isErrorEnabled()) {
+ log.error(eee);
+ }
}
+
+ return null;
}
@Override
1
0
r1534 - in trunk/guix-compiler-swing/src: main/java/org/nuiton/guix/generator test/java/org/nuiton/guix test/java/org/nuiton/guix/generator
by kmorin@users.labs.libre-entreprise.org 28 Jul '09
by kmorin@users.labs.libre-entreprise.org 28 Jul '09
28 Jul '09
Author: kmorin
Date: 2009-07-28 12:02:13 +0200 (Tue, 28 Jul 2009)
New Revision: 1534
Added:
trunk/guix-compiler-swing/src/test/java/org/nuiton/guix/generator/
trunk/guix-compiler-swing/src/test/java/org/nuiton/guix/generator/SwingGeneratorTest.java
Modified:
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingGenerator.java
trunk/guix-compiler-swing/src/test/java/org/nuiton/guix/SwingEventHandlerTest.java
Log:
add not null conditions + tests for the binding generation
Modified: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingGenerator.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingGenerator.java 2009-07-28 10:02:01 UTC (rev 1533)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingGenerator.java 2009-07-28 10:02:13 UTC (rev 1534)
@@ -50,65 +50,69 @@
*/
@Override
public JavaFile generate() {
- String gmoClassName = gmo.getClassDescriptor().getName();
- File out = new File(destDir, gmoClassName + ".java");
- File outAbstract = new File(destDir, gmoClassName + "Abstract.java");
- File outImpl = new File(destDir, gmoClassName + "Impl.java");
+ try {
+ String gmoClassName = gmo.getClassDescriptor().getName();
+ File out = new File(destDir, gmoClassName + ".java");
+ File outAbstract = new File(destDir, gmoClassName + "Abstract.java");
+ File outImpl = new File(destDir, gmoClassName + "Impl.java");
- if (lastModification > out.lastModified()) {
- try {
- if (log.isInfoEnabled()) {
- log.info("Generation of " + gmo.getClassDescriptor().getName());
- }
- if (!out.exists()) {
- try {
- out.createNewFile();
- outAbstract.createNewFile();
- outImpl.createNewFile();
+ if (lastModification > out.lastModified()) {
+ try {
+ if (log.isInfoEnabled()) {
+ log.info("Generation of " + gmo.getClassDescriptor().getName());
}
- catch (IOException ex) {
- log.error(ex);
+ if (!out.exists()) {
+ try {
+ out.createNewFile();
+ outAbstract.createNewFile();
+ outImpl.createNewFile();
+ }
+ catch (IOException ex) {
+ log.error(ex);
+ }
}
- }
- SwingInterfaceGenerator sing = new SwingInterfaceGenerator(gmo, classes);
- SwingAbstractClassGenerator sacg = new SwingAbstractClassGenerator(gmo, classes);
- SwingImplementationGenerator simg = new SwingImplementationGenerator(gmo, classes);
+ SwingInterfaceGenerator sing = new SwingInterfaceGenerator(gmo, classes);
+ SwingAbstractClassGenerator sacg = new SwingAbstractClassGenerator(gmo, classes);
+ SwingImplementationGenerator simg = new SwingImplementationGenerator(gmo, classes);
- sing.generate();
- generators.put(sing, out);
- JavaFile jf = sacg.generate();
- generators.put(sacg, outAbstract);
- simg.generate();
- generators.put(simg, outImpl);
+ sing.generate();
+ generators.put(sing, out);
+ JavaFile jf = sacg.generate();
+ generators.put(sacg, outAbstract);
+ simg.generate();
+ generators.put(simg, outImpl);
- if (mainClass) {
- SwingMainClassGenerator smcg = new SwingMainClassGenerator(gmo);
- File outMain = new File(destDir, launcherName + ".java");
- smcg.generate(outMain);
- }
+ if (mainClass) {
+ SwingMainClassGenerator smcg = new SwingMainClassGenerator(gmo);
+ File outMain = new File(destDir, launcherName + ".java");
+ smcg.generate(outMain);
+ }
- serializer.startTag("", "bean");
- serializer.attribute("", "id", gmoClassName.replace(out.getName().charAt(0),
- Character.toLowerCase(out.getName().charAt(0)))).attribute("", "class", gmoClassName + "Impl").attribute("", "singleton", "false").endTag("", "bean");
+ serializer.startTag("", "bean");
+ serializer.attribute("", "id", gmoClassName.replace(out.getName().charAt(0),
+ Character.toLowerCase(out.getName().charAt(0)))).attribute("", "class", gmoClassName + "Impl").attribute("", "singleton", "false").endTag("", "bean");
- setBindingsToGenerate(sacg.getBindings2Generate());
+ setBindingsToGenerate(sacg.getBindings2Generate());
- return jf;
+ return jf;
+ }
+ catch (IllegalArgumentException ex) {
+ log.error(ex);
+ }
+ catch (IllegalStateException ex) {
+ log.error(ex);
+ }
+ catch (IOException ex) {
+ log.error(ex);
+ }
}
- catch (IllegalArgumentException ex) {
- log.error(ex);
+ else if (log.isWarnEnabled()) {
+ log.warn(gmo.getClassDescriptor().getName() + " has already been generated and is up to date.");
}
- catch (IllegalStateException ex) {
- log.error(ex);
- }
- catch (IOException ex) {
- log.error(ex);
- }
}
- else if (log.isWarnEnabled()) {
- log.warn(gmo.getClassDescriptor().getName() + " has already been generated and is up to date.");
+ finally {
+ return null;
}
- return null;
}
@Override
@@ -121,6 +125,10 @@
@Override
public List<Class> generateBindings(StringBuffer dbCreation, StringBuffer dbDeletion, TagHandler prevTh, JavaFile jf, Class clazz,
String[] binding, int i, List<String> alreadyChecked, String methodToInvoke, Map<GuixGenerator,JavaFile> generatedFiles) {
+ if(dbCreation == null || dbDeletion == null || binding == null || (jf == null && clazz ==null)
+ || methodToInvoke == null || generatedFiles == null || i < 0) {
+ return null;
+ }
//does the attribute or method to bind exists ?
boolean bindingExists = false;
//the return type of the binding
@@ -393,12 +401,20 @@
alreadyChecked = new ArrayList<String>();
}
alreadyChecked.add(getter);
- //if it is not the last element of the binding
- if(i + 1 < binding.length) {
- result.addAll(generateBindings(dbCreation, dbDeletion, th, nextFile, nextClazz, binding, i+1, alreadyChecked, methodToInvoke, generatedFiles));
+ try {
+ //if it is not the last element of the binding
+ if(i + 1 < binding.length) {
+ result.addAll(generateBindings(dbCreation, dbDeletion, th, nextFile, nextClazz, binding, i+1, alreadyChecked, methodToInvoke, generatedFiles));
+ }
+ if(listener == null) {
+ return null;
+ }
+ if(!result.contains(listener)) {
+ result.add(listener);
+ }
}
- if(!result.contains(listener)) {
- result.add(listener);
+ catch(NullPointerException eee) {
+ return null;
}
}
else if(log.isErrorEnabled()) {
Modified: trunk/guix-compiler-swing/src/test/java/org/nuiton/guix/SwingEventHandlerTest.java
===================================================================
--- trunk/guix-compiler-swing/src/test/java/org/nuiton/guix/SwingEventHandlerTest.java 2009-07-28 10:02:01 UTC (rev 1533)
+++ trunk/guix-compiler-swing/src/test/java/org/nuiton/guix/SwingEventHandlerTest.java 2009-07-28 10:02:13 UTC (rev 1534)
@@ -35,6 +35,7 @@
*/
public class SwingEventHandlerTest {
+ /** log */
Log log = LogFactory.getLog(SwingEventHandlerTest.class);
/**
@@ -44,11 +45,15 @@
public void testAddEvent() {
SwingEventHandler seh = new SwingEventHandler();
try {
+ //null parameters return false
assertFalse(seh.addEvent(null, "", ""));
assertFalse(seh.addEvent(JComponent.class, null, ""));
assertFalse(seh.addEvent(JComponent.class, "", null));
+ //tests a basic adding
assertTrue(seh.addEvent(JComponent.class, "propertyChange", "test1"));
+ //tests the adding of some different code for the same event
assertTrue(seh.addEvent(JComponent.class, "propertyChange", "test2"));
+ //tests an unknown event
assertFalse(seh.addEvent(JComponent.class, "azerty", ""));
}
catch (IntrospectionException eee) {
@@ -65,10 +70,19 @@
public void testGenerate() {
SwingEventHandler seh = new SwingEventHandler();
try {
+ //tests a basic generation without any added event
+ assertNotNull(seh.generate("object"));
assertNotNull(seh.generate(""));
+ assertNotNull(seh.generate(null));
+ assertEquals(seh.generate("object"), "");
assertEquals(seh.generate(""), "");
+ assertEquals(seh.generate(null), "");
+ //adds an event
seh.addEvent(JComponent.class, "propertyChange", "");
+ //tests that something is generated
+ assertTrue(seh.generate("object").length() > 0);
assertTrue(seh.generate("").length() > 0);
+ assertTrue(seh.generate(null).length() > 0);
}
catch (IntrospectionException eee) {
if(log.isErrorEnabled()) {
Added: trunk/guix-compiler-swing/src/test/java/org/nuiton/guix/generator/SwingGeneratorTest.java
===================================================================
--- trunk/guix-compiler-swing/src/test/java/org/nuiton/guix/generator/SwingGeneratorTest.java (rev 0)
+++ trunk/guix-compiler-swing/src/test/java/org/nuiton/guix/generator/SwingGeneratorTest.java 2009-07-28 10:02:13 UTC (rev 1534)
@@ -0,0 +1,144 @@
+/**
+ * *##% guix-compiler-gwt
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+package org.nuiton.guix.generator;
+
+import java.beans.PropertyChangeListener;
+import java.lang.reflect.Modifier;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.swing.JToggleButton;
+import javax.swing.event.ChangeListener;
+import org.junit.Assert;
+import org.junit.Test;
+import org.nuiton.guix.SwingGuixInitializer;
+import org.nuiton.guix.tags.swing.ToggleButtonHandler;
+
+/**
+ *
+ * @author kmorin
+ */
+public class SwingGeneratorTest {
+ @Test
+ public void testGenerate() {
+ SwingGenerator sg = new SwingGenerator();
+ Assert.assertNull(sg.generate());
+ }
+
+ @Test
+ public void testGenerateBinding() {
+ SwingGuixInitializer.initialize();
+ SwingGenerator sg = new SwingGenerator();
+ //tests the not null condition for the parameters that needs to be not null
+ Assert.assertNull(sg.generateBindings(null, new StringBuffer(), null, null, Class.class, new String[0], 0, null, "", new HashMap<GuixGenerator, JavaFile>()));
+ Assert.assertNull(sg.generateBindings(new StringBuffer(), null, null, null, Class.class, new String[0], 0, null, "", new HashMap<GuixGenerator, JavaFile>()));
+ Assert.assertNull(sg.generateBindings(new StringBuffer(), new StringBuffer(), null, null, Class.class, null, 0, null, "", new HashMap<GuixGenerator, JavaFile>()));
+ Assert.assertNull(sg.generateBindings(new StringBuffer(), new StringBuffer(), null, null, Class.class, new String[0], -1, null, "", new HashMap<GuixGenerator, JavaFile>()));
+ Assert.assertNull(sg.generateBindings(new StringBuffer(), new StringBuffer(), null, null, Class.class, new String[0], -1, null, "", new HashMap<GuixGenerator, JavaFile>()));
+ Assert.assertNull(sg.generateBindings(new StringBuffer(), new StringBuffer(), null, null, Class.class, new String[0], 0, null, null, new HashMap<GuixGenerator, JavaFile>()));
+ Assert.assertNull(sg.generateBindings(new StringBuffer(), new StringBuffer(), null, null, Class.class, new String[0], 0, null, "", null));
+ Assert.assertNull(sg.generateBindings(new StringBuffer(), new StringBuffer(), null, null, null, new String[0], 0, null, "", new HashMap<GuixGenerator, JavaFile>()));
+
+ //tests with a class parameter not null
+ //tests without TagHandlers
+ List<Class> l = sg.generateBindings(new StringBuffer(), new StringBuffer(), null, null, JToggleButton.class, new String[]{"isSelected()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>());
+ Assert.assertNotNull(l);
+ Assert.assertEquals(l.size(), 1);
+ Assert.assertNotNull(l.get(0));
+ Assert.assertEquals(l.get(0), PropertyChangeListener.class);
+ //tests a successful generation with a method as a binding
+ l = sg.generateBindings(new StringBuffer(), new StringBuffer(), new ToggleButtonHandler(), null, JToggleButton.class, new String[]{"isSelected()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>());
+ Assert.assertNotNull(l);
+ Assert.assertEquals(l.size(), 1);
+ Assert.assertNotNull(l.get(0));
+ Assert.assertEquals(l.get(0), ChangeListener.class);
+ //tests a successful generation with an attribute as a binding
+ l = sg.generateBindings(new StringBuffer(), new StringBuffer(), new ToggleButtonHandler(), null, JToggleButton.class, new String[]{"selected"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>());
+ Assert.assertNotNull(l);
+ Assert.assertEquals(l.size(), 1);
+ Assert.assertNotNull(l.get(0));
+ Assert.assertEquals(l.get(0), ChangeListener.class);
+
+ //tests with a javafile parameter not null
+ //tests if the result is null without the taghandler associated to the field
+ JavaFile jf = new JavaFile();
+ jf.addField(new JavaField(Modifier.PRIVATE, "javax.swing.JToggleButton", "button", null));
+ jf.addMethod(new JavaMethod(Modifier.PUBLIC, "javax.swing.JToggleButton", "getButton", null, null, "", null));
+ l = sg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"getButton()", "isSelected()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>());
+ Assert.assertNotNull(l);
+ Assert.assertEquals(l.size(), 1);
+ Assert.assertNotNull(l.get(0));
+ Assert.assertEquals(l.get(0), PropertyChangeListener.class);
+
+ //tests a successful generation with a method as a binding
+ jf = new JavaFile();
+ jf.addField(new JavaField(Modifier.PRIVATE, "javax.swing.JToggleButton", "button", null, new ToggleButtonHandler()));
+ jf.addMethod(new JavaMethod(Modifier.PUBLIC, "javax.swing.JToggleButton", "getButton", null, null, "", null));
+ l = sg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"getButton()", "isSelected()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>());
+ Assert.assertNotNull(l);
+ Assert.assertEquals(l.size(), 2);
+ Assert.assertNotNull(l.get(0));
+ Assert.assertEquals(l.get(0), ChangeListener.class);
+ Assert.assertNotNull(l.get(1));
+ Assert.assertEquals(l.get(1), PropertyChangeListener.class);
+ //tests a successful generation with an attribute as a binding
+ l = sg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"button","selected"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>());
+ Assert.assertNotNull(l);
+ Assert.assertEquals(l.size(), 2);
+ Assert.assertNotNull(l.get(0));
+ Assert.assertEquals(l.get(0), ChangeListener.class);
+ Assert.assertNotNull(l.get(1));
+ Assert.assertEquals(l.get(1), PropertyChangeListener.class);
+
+ //tests with a javafile parameter not null with an attribute whose type is another generated file
+ //tests if the result is null without the taghandler associated to the field
+ jf = new JavaFile();
+ jf.addField(new JavaField(Modifier.PRIVATE, "test.Test", "test", null));
+ jf.addMethod(new JavaMethod(Modifier.PUBLIC, "test.Test", "getTest", null, null, "", null));
+ JavaFile jf2 = new JavaFile(Modifier.PUBLIC, 0, "test", "Test", null, null);
+ jf2.addField(new JavaField(Modifier.PRIVATE, "javax.swing.JToggleButton", "button", null));
+ jf2.addMethod(new JavaMethod(Modifier.PUBLIC, "javax.swing.JToggleButton", "getButton", null, null, "", null));
+ Assert.assertNull(sg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"getTest()","getButton()","isSelected()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()));
+ //test without jf2 in the map of generators with JavaFile
+ jf2 = new JavaFile(Modifier.PUBLIC, 0, "test", "Test", null, null);
+ jf2.addField(new JavaField(Modifier.PRIVATE, "javax.swing.JToggleButton", "button", null, new ToggleButtonHandler()));
+ jf2.addMethod(new JavaMethod(Modifier.PUBLIC, "javax.swing.JToggleButton", "getButton", null, null, "", null));
+ Assert.assertNull(sg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"getTest()","getButton()","isSelected()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()));
+ Map<GuixGenerator,JavaFile> map = new HashMap<GuixGenerator, JavaFile>();
+ map.put(sg, jf2);
+ //tests a successful generation with a method as a binding
+ l = sg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"getTest()","getButton()", "isSelected()"}, 0, null, "", map);
+ Assert.assertNotNull(l);
+ Assert.assertEquals(l.size(), 2);
+ Assert.assertNotNull(l.get(0));
+ Assert.assertEquals(l.get(0), ChangeListener.class);
+ //the PropertyChangeListener is recorded only once
+ Assert.assertNotNull(l.get(1));
+ Assert.assertEquals(l.get(1), PropertyChangeListener.class);
+ //tests a successful generation with an attribute as a binding
+ l = sg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"test","button","selected"}, 0, null, "", map);
+ Assert.assertNotNull(l);
+ Assert.assertEquals(l.size(), 2);
+ Assert.assertNotNull(l.get(0));
+ Assert.assertEquals(l.get(0), ChangeListener.class);
+ //the PropertyChangeListener is recorded only once
+ Assert.assertNotNull(l.get(1));
+ Assert.assertEquals(l.get(1), PropertyChangeListener.class);
+ }
+}
1
0
r1533 - in trunk/guix-compiler-gwt/src: main/java/org/nuiton/guix/generator test/java/org/nuiton/guix test/java/org/nuiton/guix/generator
by kmorin@users.labs.libre-entreprise.org 28 Jul '09
by kmorin@users.labs.libre-entreprise.org 28 Jul '09
28 Jul '09
Author: kmorin
Date: 2009-07-28 12:02:01 +0200 (Tue, 28 Jul 2009)
New Revision: 1533
Added:
trunk/guix-compiler-gwt/src/test/java/org/nuiton/guix/generator/
trunk/guix-compiler-gwt/src/test/java/org/nuiton/guix/generator/GwtGeneratorTest.java
Modified:
trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtGenerator.java
trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtJavaFileGenerator.java
trunk/guix-compiler-gwt/src/test/java/org/nuiton/guix/GwtEventHandlerTest.java
Log:
add not null conditions + tests for the binding generation
Modified: trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtGenerator.java
===================================================================
--- trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtGenerator.java 2009-07-27 12:37:53 UTC (rev 1532)
+++ trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtGenerator.java 2009-07-28 10:02:01 UTC (rev 1533)
@@ -49,95 +49,99 @@
@Override
public JavaFile generate() {
- String gmoClassName = gmo.getClassDescriptor().getName();
- File outDir = new File(destDir, "client");
- if (!outDir.exists()) {
- outDir.mkdir();
- }
- File out = new File(outDir, gmoClassName + ".java");
- File outAbstract = new File(outDir, gmoClassName + "Abstract.java");
- File outImpl = new File(outDir, gmoClassName + "Impl.java");
+ try {
+ String gmoClassName = gmo.getClassDescriptor().getName();
+ File outDir = new File(destDir, "client");
+ if (!outDir.exists()) {
+ outDir.mkdir();
+ }
+ File out = new File(outDir, gmoClassName + ".java");
+ File outAbstract = new File(outDir, gmoClassName + "Abstract.java");
+ File outImpl = new File(outDir, gmoClassName + "Impl.java");
- if (lastModification > out.lastModified()) {
- try {
- if (log.isInfoEnabled()) {
- log.info("Generation of " + gmo.getClassDescriptor().getName());
- }
- if (!out.exists()) {
- try {
- out.createNewFile();
- outAbstract.createNewFile();
- outImpl.createNewFile();
+ if (lastModification > out.lastModified()) {
+ try {
+ if (log.isInfoEnabled()) {
+ log.info("Generation of " + gmo.getClassDescriptor().getName());
}
- catch (IOException ex) {
- log.error(ex);
+ if (!out.exists()) {
+ try {
+ out.createNewFile();
+ outAbstract.createNewFile();
+ outImpl.createNewFile();
+ }
+ catch (IOException ex) {
+ log.error(ex);
+ }
}
- }
- GwtInterfaceGenerator ging = new GwtInterfaceGenerator(gmo, classes);
- GwtAbstractClassGenerator gacg = new GwtAbstractClassGenerator(gmo, classes);
- GwtImplementationGenerator gimg = new GwtImplementationGenerator(gmo, classes);
+ GwtInterfaceGenerator ging = new GwtInterfaceGenerator(gmo, classes);
+ GwtAbstractClassGenerator gacg = new GwtAbstractClassGenerator(gmo, classes);
+ GwtImplementationGenerator gimg = new GwtImplementationGenerator(gmo, classes);
- if (mainClass) {
- gimg.addMainMethod();
- GwtConfigGenerator gcg = new GwtConfigGenerator(gmo, getCSSFiles());
- GwtHtmlGenerator ghg = new GwtHtmlGenerator(gmo, launcherName);
- File outConfigMain = new File(destDir, launcherName.substring(launcherName.lastIndexOf('.') + 1) + ".gwt.xml");
- File publicDir = new File(destDir, "public");
- if (!publicDir.exists()) {
- publicDir.mkdir();
- }
- File outHtmlMain = new File(publicDir, launcherName.substring(launcherName.lastIndexOf('.') + 1) + ".html");
- gcg.generate(outConfigMain);
- for(File f : getCSSFiles()) {
- try {
- File fPublic = new File(publicDir, f.getName());
- fPublic.createNewFile();
- FileInputStream fis = new FileInputStream(f);
- FileOutputStream fos = new FileOutputStream(fPublic);
- // segment size : 0.5Mo
- byte buffer[] = new byte[512*1024];
- int read;
- while((read = fis.read(buffer)) != -1) {
- fos.write(buffer, 0, read);
+ if (mainClass) {
+ gimg.addMainMethod();
+ GwtConfigGenerator gcg = new GwtConfigGenerator(gmo, getCSSFiles());
+ GwtHtmlGenerator ghg = new GwtHtmlGenerator(gmo, launcherName);
+ File outConfigMain = new File(destDir, launcherName.substring(launcherName.lastIndexOf('.') + 1) + ".gwt.xml");
+ File publicDir = new File(destDir, "public");
+ if (!publicDir.exists()) {
+ publicDir.mkdir();
+ }
+ File outHtmlMain = new File(publicDir, launcherName.substring(launcherName.lastIndexOf('.') + 1) + ".html");
+ gcg.generate(outConfigMain);
+ for(File f : getCSSFiles()) {
+ try {
+ File fPublic = new File(publicDir, f.getName());
+ fPublic.createNewFile();
+ FileInputStream fis = new FileInputStream(f);
+ FileOutputStream fos = new FileOutputStream(fPublic);
+ // segment size : 0.5Mo
+ byte buffer[] = new byte[512*1024];
+ int read;
+ while((read = fis.read(buffer)) != -1) {
+ fos.write(buffer, 0, read);
+ }
+ fis.close();
+ fos.close();
}
- fis.close();
- fos.close();
+ catch(IOException eee) {
+ log.error(eee);
+ }
}
- catch(IOException eee) {
- log.error(eee);
- }
+ ghg.generate(outHtmlMain);
}
- ghg.generate(outHtmlMain);
- }
- ging.generate();
- generators.put(ging, out);
- JavaFile jf = gacg.generate();
- generators.put(gacg, outAbstract);
- gimg.generate();
- generators.put(gimg, outImpl);
+ ging.generate();
+ generators.put(ging, out);
+ JavaFile jf = gacg.generate();
+ generators.put(gacg, outAbstract);
+ gimg.generate();
+ generators.put(gimg, outImpl);
- serializer.startTag("", "bean");
- serializer.attribute("", "id", gmoClassName.replace(out.getName().charAt(0),
- Character.toLowerCase(out.getName().charAt(0)))).attribute("", "class", gmoClassName + "Impl").attribute("", "singleton", "false").endTag("", "bean");
- setBindingsToGenerate(gacg.getBindings2Generate());
+ serializer.startTag("", "bean");
+ serializer.attribute("", "id", gmoClassName.replace(out.getName().charAt(0),
+ Character.toLowerCase(out.getName().charAt(0)))).attribute("", "class", gmoClassName + "Impl").attribute("", "singleton", "false").endTag("", "bean");
+ setBindingsToGenerate(gacg.getBindings2Generate());
- return jf;
+ return jf;
+ }
+ catch (IllegalArgumentException ex) {
+ log.error(ex);
+ }
+ catch (IllegalStateException ex) {
+ log.error(ex);
+ }
+ catch (IOException ex) {
+ log.error(ex);
+ }
}
- catch (IllegalArgumentException ex) {
- log.error(ex);
+ else if (log.isWarnEnabled()) {
+ log.warn(gmo.getClassDescriptor().getName() + " has already been generated and is up to date.");
}
- catch (IllegalStateException ex) {
- log.error(ex);
- }
- catch (IOException ex) {
- log.error(ex);
- }
}
- else if (log.isWarnEnabled()) {
- log.warn(gmo.getClassDescriptor().getName() + " has already been generated and is up to date.");
+ finally {
+ return null;
}
- return null;
}
@Override
@@ -150,6 +154,11 @@
@Override
public List<Class> generateBindings(StringBuffer dbCreation, StringBuffer dbDeletion, TagHandler prevTh, JavaFile jf, Class clazz,
String[] binding, int i, List<String> alreadyChecked, String methodToInvoke, Map<GuixGenerator, JavaFile> generatedFiles) {
+ if(dbCreation == null || dbDeletion == null || binding == null || (jf == null && clazz ==null)
+ || methodToInvoke == null || generatedFiles == null || i < 0) {
+ return null;
+ }
+
//does the attribute or method to bind exists ?
boolean bindingExists = false;
//the return type of the binding
@@ -399,6 +408,9 @@
return generateBindings(dbCreation, dbDeletion, th, nextFile, nextClazz, binding, i + 1, alreadyChecked, methodToInvoke, generatedFiles);
}
else {
+ if(listener == null) {
+ return null;
+ }
result.add(listener);
return result;
}
Modified: trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtJavaFileGenerator.java
===================================================================
--- trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtJavaFileGenerator.java 2009-07-27 12:37:53 UTC (rev 1532)
+++ trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtJavaFileGenerator.java 2009-07-28 10:02:01 UTC (rev 1533)
@@ -44,6 +44,9 @@
* @param gmo GuixModelObject which represents the class to generate
*/
protected void addImports(GuixModelObject gmo) {
+ if(gmo == null) {
+ return;
+ }
for (GuixModelObject child : gmo.getChildren()) {
if (child.getClassDescriptor().getPackageName() == null
&& TagManager.getGuixClassHandler(child.getClassDescriptor().getName()) != null) {
Modified: trunk/guix-compiler-gwt/src/test/java/org/nuiton/guix/GwtEventHandlerTest.java
===================================================================
--- trunk/guix-compiler-gwt/src/test/java/org/nuiton/guix/GwtEventHandlerTest.java 2009-07-27 12:37:53 UTC (rev 1532)
+++ trunk/guix-compiler-gwt/src/test/java/org/nuiton/guix/GwtEventHandlerTest.java 2009-07-28 10:02:01 UTC (rev 1533)
@@ -36,6 +36,7 @@
*/
public class GwtEventHandlerTest {
+ /** log */
Log log = LogFactory.getLog(GwtEventHandlerTest.class);
/**
@@ -45,11 +46,15 @@
public void testAddEvent() {
GwtEventHandler geh = new GwtEventHandler();
try {
+ //null parameters return false
assertFalse(geh.addEvent(null, "", ""));
assertFalse(geh.addEvent(Widget.class, null, ""));
assertFalse(geh.addEvent(Widget.class, "", null));
+ //tests a basic adding
assertTrue(geh.addEvent(FocusWidget.class, "onClick", "test1"));
+ //tests the adding of some different code for the same event
assertTrue(geh.addEvent(FocusWidget.class, "onClick", "test2"));
+ //tests an unknown event
assertFalse(geh.addEvent(FocusWidget.class, "azerty", ""));
}
catch (IntrospectionException eee) {
@@ -64,12 +69,21 @@
*/
@Test
public void testGenerate() {
- GwtEventHandler seh = new GwtEventHandler();
+ GwtEventHandler geh = new GwtEventHandler();
try {
- assertNotNull(seh.generate(""));
- assertEquals(seh.generate(""), "");
- seh.addEvent(FocusWidget.class, "onClick", "");
- assertTrue(seh.generate("").length() > 0);
+ //tests a basic generation without any added event
+ assertNotNull(geh.generate("object"));
+ assertNotNull(geh.generate(""));
+ assertNotNull(geh.generate(null));
+ assertEquals(geh.generate("object"), "");
+ assertEquals(geh.generate(""), "");
+ assertEquals(geh.generate(null), "");
+ //adds an event
+ geh.addEvent(FocusWidget.class, "onClick", "test");
+ //tests that something is generated
+ assertTrue(geh.generate("object").length() > 0);
+ assertTrue(geh.generate("").length() > 0);
+ assertTrue(geh.generate(null).length() > 0);
}
catch (IntrospectionException eee) {
if(log.isErrorEnabled()) {
Added: trunk/guix-compiler-gwt/src/test/java/org/nuiton/guix/generator/GwtGeneratorTest.java
===================================================================
--- trunk/guix-compiler-gwt/src/test/java/org/nuiton/guix/generator/GwtGeneratorTest.java (rev 0)
+++ trunk/guix-compiler-gwt/src/test/java/org/nuiton/guix/generator/GwtGeneratorTest.java 2009-07-28 10:02:01 UTC (rev 1533)
@@ -0,0 +1,134 @@
+/**
+ * *##% guix-compiler-gwt
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+package org.nuiton.guix.generator;
+
+import org.nuiton.guix.*;
+import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.ui.ToggleButton;
+import java.lang.reflect.Modifier;
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.Test;
+import org.nuiton.guix.generator.GwtGenerator;
+import org.junit.Assert;
+import org.nuiton.guix.generator.GuixGenerator;
+import org.nuiton.guix.generator.JavaField;
+import org.nuiton.guix.generator.JavaFile;
+import org.nuiton.guix.generator.JavaMethod;
+import org.nuiton.guix.tags.gwt.ToggleButtonHandler;
+
+/**
+ * Tests the methods of the GwtGenerator class
+ *
+ * @author kmorin
+ */
+public class GwtGeneratorTest {
+
+ @Test
+ public void testGenerate() {
+ GwtGenerator gg = new GwtGenerator();
+ Assert.assertNull(gg.generate());
+ }
+
+ @Test
+ public void testGenerateBinding() {
+ GwtGuixInitializer.initialize();
+ GwtGenerator gg = new GwtGenerator();
+ //tests the not null condition for the parameters that needs to be not null
+ Assert.assertNull(gg.generateBindings(null, new StringBuffer(), null, null, Class.class, new String[0], 0, null, "", new HashMap<GuixGenerator, JavaFile>()));
+ Assert.assertNull(gg.generateBindings(new StringBuffer(), null, null, null, Class.class, new String[0], 0, null, "", new HashMap<GuixGenerator, JavaFile>()));
+ Assert.assertNull(gg.generateBindings(new StringBuffer(), new StringBuffer(), null, null, Class.class, null, 0, null, "", new HashMap<GuixGenerator, JavaFile>()));
+ Assert.assertNull(gg.generateBindings(new StringBuffer(), new StringBuffer(), null, null, Class.class, new String[0], -1, null, "", new HashMap<GuixGenerator, JavaFile>()));
+ Assert.assertNull(gg.generateBindings(new StringBuffer(), new StringBuffer(), null, null, Class.class, new String[0], -1, null, "", new HashMap<GuixGenerator, JavaFile>()));
+ Assert.assertNull(gg.generateBindings(new StringBuffer(), new StringBuffer(), null, null, Class.class, new String[0], 0, null, null, new HashMap<GuixGenerator, JavaFile>()));
+ Assert.assertNull(gg.generateBindings(new StringBuffer(), new StringBuffer(), null, null, Class.class, new String[0], 0, null, "", null));
+ Assert.assertNull(gg.generateBindings(new StringBuffer(), new StringBuffer(), null, null, null, new String[0], 0, null, "", new HashMap<GuixGenerator, JavaFile>()));
+ //tests with a class parameter not null
+ //tests if a null listener as result returns null
+ Assert.assertNull(gg.generateBindings(new StringBuffer(), new StringBuffer(), null, null, ToggleButton.class, new String[]{"isDown()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()));
+ //tests a successful generation with a method as a binding
+ Assert.assertNotNull(gg.generateBindings(new StringBuffer(), new StringBuffer(), new ToggleButtonHandler(), null, ToggleButton.class, new String[]{"isDown()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()));
+ Assert.assertEquals(gg.generateBindings(new StringBuffer(), new StringBuffer(), new ToggleButtonHandler(), null, ToggleButton.class, new String[]{"isDown()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()).size(),1);
+ Assert.assertNotNull(gg.generateBindings(new StringBuffer(), new StringBuffer(), new ToggleButtonHandler(), null, ToggleButton.class, new String[]{"isDown()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()).get(0));
+ Assert.assertEquals(gg.generateBindings(new StringBuffer(), new StringBuffer(), new ToggleButtonHandler(), null, ToggleButton.class, new String[]{"isDown()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()).get(0),ClickListener.class);
+ //tests a successful generation with an attribute as a binding
+ Assert.assertNotNull(gg.generateBindings(new StringBuffer(), new StringBuffer(), new ToggleButtonHandler(), null, ToggleButton.class, new String[]{"down"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()));
+ Assert.assertEquals(gg.generateBindings(new StringBuffer(), new StringBuffer(), new ToggleButtonHandler(), null, ToggleButton.class, new String[]{"down"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()).size(),1);
+ Assert.assertNotNull(gg.generateBindings(new StringBuffer(), new StringBuffer(), new ToggleButtonHandler(), null, ToggleButton.class, new String[]{"down"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()).get(0));
+ Assert.assertEquals(gg.generateBindings(new StringBuffer(), new StringBuffer(), new ToggleButtonHandler(), null, ToggleButton.class, new String[]{"down"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()).get(0),ClickListener.class);
+ //tests a successful generation with a method with the generic name as a binding
+ Assert.assertNotNull(gg.generateBindings(new StringBuffer(), new StringBuffer(), new ToggleButtonHandler(), null, ToggleButton.class, new String[]{"isSelected()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()));
+ Assert.assertEquals(gg.generateBindings(new StringBuffer(), new StringBuffer(), new ToggleButtonHandler(), null, ToggleButton.class, new String[]{"isSelected()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()).size(),1);
+ Assert.assertNotNull(gg.generateBindings(new StringBuffer(), new StringBuffer(), new ToggleButtonHandler(), null, ToggleButton.class, new String[]{"isSelected()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()).get(0));
+ Assert.assertEquals(gg.generateBindings(new StringBuffer(), new StringBuffer(), new ToggleButtonHandler(), null, ToggleButton.class, new String[]{"isSelected()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()).get(0),ClickListener.class);
+ //tests a successful generation with an attribute with the generic name as a binding
+ Assert.assertNotNull(gg.generateBindings(new StringBuffer(), new StringBuffer(), new ToggleButtonHandler(), null, ToggleButton.class, new String[]{"selected"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()));
+ Assert.assertEquals(gg.generateBindings(new StringBuffer(), new StringBuffer(), new ToggleButtonHandler(), null, ToggleButton.class, new String[]{"selected"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()).size(),1);
+ Assert.assertNotNull(gg.generateBindings(new StringBuffer(), new StringBuffer(), new ToggleButtonHandler(), null, ToggleButton.class, new String[]{"selected"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()).get(0));
+ Assert.assertEquals(gg.generateBindings(new StringBuffer(), new StringBuffer(), new ToggleButtonHandler(), null, ToggleButton.class, new String[]{"selected"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()).get(0),ClickListener.class);
+
+ //tests with a javafile parameter not null
+ //tests if the result is null without the taghandler associated to the field
+ JavaFile jf = new JavaFile();
+ jf.addField(new JavaField(Modifier.PRIVATE, "com.google.gwt.user.client.ui.ToggleButton", "button", null));
+ jf.addMethod(new JavaMethod(Modifier.PUBLIC, "com.google.gwt.user.client.ui.ToggleButton", "getButton", null, null, "", null));
+ Assert.assertNull(gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"getButton()", "isDown()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()));
+ //tests a successful generation with a method as a binding
+ jf = new JavaFile();
+ jf.addField(new JavaField(Modifier.PRIVATE, "com.google.gwt.user.client.ui.ToggleButton", "button", null, new ToggleButtonHandler()));
+ jf.addMethod(new JavaMethod(Modifier.PUBLIC, "com.google.gwt.user.client.ui.ToggleButton", "getButton", null, null, "", null));
+ Assert.assertNotNull(gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"getButton()", "isDown()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()));
+ Assert.assertEquals(gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"getButton()", "isDown()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()).size(),1);
+ Assert.assertNotNull(gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"getButton()", "isDown()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()).get(0));
+ Assert.assertEquals(gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"getButton()", "isDown()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()).get(0),ClickListener.class);
+ //tests a successful generation with an attribute as a binding
+ Assert.assertNotNull(gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"button","down"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()));
+ Assert.assertEquals(gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"button","down"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()).size(),1);
+ Assert.assertNotNull(gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"button","down"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()).get(0));
+ Assert.assertEquals(gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"button","down"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()).get(0),ClickListener.class);
+
+ //tests with a javafile parameter not null with an attribute whose type is another generated file
+ //tests if the result is null without the taghandler associated to the field
+ jf = new JavaFile();
+ jf.addField(new JavaField(Modifier.PRIVATE, "test.Test", "test", null));
+ jf.addMethod(new JavaMethod(Modifier.PUBLIC, "test.Test", "getTest", null, null, "", null));
+ JavaFile jf2 = new JavaFile(Modifier.PUBLIC, JavaFile.CLASS, "test", "Test", null, null);
+ jf2.addField(new JavaField(Modifier.PRIVATE, "com.google.gwt.user.client.ui.ToggleButton", "button", null));
+ jf2.addMethod(new JavaMethod(Modifier.PUBLIC, "com.google.gwt.user.client.ui.ToggleButton", "getButton", null, null, "", null));
+ Assert.assertNull(gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"getTest()","getButton()","isDown()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()));
+ //test without jf2 in the map of generators with JavaFile
+ jf2 = new JavaFile(Modifier.PUBLIC, JavaFile.CLASS, "test", "Test", null, null);
+ jf2.addField(new JavaField(Modifier.PRIVATE, "com.google.gwt.user.client.ui.ToggleButton", "button", null, new ToggleButtonHandler()));
+ jf2.addMethod(new JavaMethod(Modifier.PUBLIC, "com.google.gwt.user.client.ui.ToggleButton", "getButton", null, null, "", null));
+ Assert.assertNull(gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"getTest()","getButton()","isDown()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()));
+ Map<GuixGenerator,JavaFile> map = new HashMap<GuixGenerator, JavaFile>();
+ map.put(gg, jf2);
+ //tests a successful generation with a method as a binding
+ Assert.assertNotNull(gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"getTest()","getButton()", "isDown()"}, 0, null, "", map));
+ Assert.assertEquals(gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"getTest()","getButton()", "isDown()"}, 0, null, "", map).size(),1);
+ Assert.assertNotNull(gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"getTest()","getButton()", "isDown()"}, 0, null, "", map).get(0));
+ Assert.assertEquals(gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"getTest()","getButton()", "isDown()"}, 0, null, "", map).get(0),ClickListener.class);
+ //tests a successful generation with an attribute as a binding
+ Assert.assertNotNull(gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"test","button","down"}, 0, null, "", map));
+ Assert.assertEquals(gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"test","button","down"}, 0, null, "", map).size(),1);
+ Assert.assertNotNull(gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"test","button","down"}, 0, null, "", map).get(0));
+ Assert.assertEquals(gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"test","button","down"}, 0, null, "", map).get(0),ClickListener.class);
+ }
+
+}
1
0
r1511 - in trunk/jaxx-runtime-swing-widget/src/main: java/jaxx/runtime/swing/editor java/jaxx/runtime/swing/editor/config java/jaxx/runtime/swing/editor/config/model resources/icons
by tchemit@users.labs.libre-entreprise.org 27 Jul '09
by tchemit@users.labs.libre-entreprise.org 27 Jul '09
27 Jul '09
Author: tchemit
Date: 2009-07-27 22:27:58 +0200 (Mon, 27 Jul 2009)
New Revision: 1511
Added:
trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/ColumnSelector.jaxx
trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/
trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.css
trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.jaxx
trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableEditor.java
trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableRenderer.java
trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.css
trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.jaxx
trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java
trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/model/
trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java
trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigTableModel.java
trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java
trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java
trunk/jaxx-runtime-swing-widget/src/main/resources/icons/action-config-quit.png
trunk/jaxx-runtime-swing-widget/src/main/resources/icons/action-config-reset.png
trunk/jaxx-runtime-swing-widget/src/main/resources/icons/action-config-save.png
Log:
normalize i18n keys in widgets, add ApplicationConfig ui to change preferences, degin of a ColumnSelector (should have a look in swingx...)
Added: trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/ColumnSelector.jaxx
===================================================================
--- trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/ColumnSelector.jaxx (rev 0)
+++ trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/ColumnSelector.jaxx 2009-07-27 20:27:58 UTC (rev 1511)
@@ -0,0 +1,152 @@
+<!--
+
+/**
+ * *##% jaxx-runtime-swing-widget
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+-->
+<JPanel implements='PropertyChangeListener, ActionListener'
+ layout='{new BorderLayout()}'
+ onFocusGained='button.requestFocus()'
+ onFocusLost='setPopupVisible(false)'>
+
+ <!-- table to works with -->
+ <Object id='myTable' javaBean='null'/>
+
+ <!-- internal state -->
+ <Boolean id='popupVisible' javaBean='false'/>
+
+ <!-- ui handler -->
+ <!--ColumnSelectorHandler id='handler' constructorParams='this'/-->
+
+ <JPopupMenu id='popup'
+ border='{new TitledBorder(_("i18neditor.popup.title"))}'
+ onPopupMenuWillBecomeInvisible='button.setSelected(false)'
+ onPopupMenuCanceled='button.setSelected(false)'>
+ <JLabel id='popupLabel' enabled='false' text='i18neditor.empty.locales'/>
+ </JPopupMenu>
+
+ <script><![CDATA[
+import javax.swing.table.TableColumn;
+import javax.swing.table.TableCellRenderer;
+import jaxx.runtime.swing.I18nTableCellRenderer;
+
+public static final String TABLE_PROPERTY = "myTable";
+public static final String POPUP_VISIBLE_PROPERTY = "popupVisible";
+
+@Override
+public void propertyChange(PropertyChangeEvent evt) {
+ String name = evt.getPropertyName();
+ if (log.isDebugEnabled()) {
+ log.debug(name+" <old:"+evt.getOldValue()+" - new:"+evt.getNewValue()+">");
+ }
+ //log.info(name+" <old:"+evt.getOldValue()+" - new:"+evt.getNewValue()+">");
+ if (TABLE_PROPERTY.equals(name)) {
+ // table has changed, rebuild the popup
+ try {
+
+ popup.removeAll();
+ JTable t = (JTable) evt.getNewValue();
+ if (t != null) {
+ log.info("table has changed ! " + t.getName());
+ for (int i = 0, columnCount = t.getColumnCount(); i < columnCount; i++) {
+ TableColumn column = t.getColumnModel().getColumn(i);
+ TableCellRenderer defaultRenderer = t.getTableHeader().getDefaultRenderer();
+ String columnName = column.getHeaderValue() + "";
+ if (defaultRenderer instanceof I18nTableCellRenderer) {
+ I18nTableCellRenderer renderer = (I18nTableCellRenderer) defaultRenderer;
+ columnName = _(renderer.getKeys()[i]);
+ }
+ JRadioButtonMenuItem b = new JRadioButtonMenuItem(columnName, null, true);
+ popup.add(b);
+ b.addActionListener(this);
+ b.putClientProperty("columnIndex", i);
+ b.putClientProperty("columnName", columnName);
+ b.putClientProperty("column", column);
+ }
+ }
+ } finally {
+ popup.invalidate();
+ }
+ return;
+ }
+ if (POPUP_VISIBLE_PROPERTY.equals(name)) {
+ Boolean newValue = (Boolean) evt.getNewValue();
+ if (newValue == null || !newValue) {
+ if (getPopup() != null && getPopup().isVisible()) {
+ getPopup().setVisible(false);
+ }
+ return;
+ }
+ if (!getPopup().isVisible()) {
+ SwingUtilities.invokeLater(showPopupRunnable);
+ }
+ return;
+ }
+
+}
+
+@Override
+public void actionPerformed(ActionEvent event) {
+ JRadioButtonMenuItem source = (JRadioButtonMenuItem) event.getSource();
+ boolean selected = source.isSelected();
+ TableColumn column = (TableColumn) source.getClientProperty("column");
+ Integer columnIndex = (Integer) source.getClientProperty("columnIndex");
+ String columnName = (String) source.getClientProperty("columnName");
+ log.info(columnName + ", selected : " + selected);
+ JTable t = (JTable) myTable;
+ if (selected) {
+ // reinject the column in table
+ t.getColumnModel().addColumn(column);
+ } else {
+ // remove column from table
+ t.getColumnModel().removeColumn(column);
+ }
+}
+
+protected Runnable showPopupRunnable = new Runnable() {
+ @Override
+ public void run() {
+ getPopup().pack();
+ Dimension dim = getPopup().getPreferredSize();
+ JToggleButton invoker = getButton();
+ getPopup().show(invoker, (int) (invoker.getPreferredSize().getWidth() - dim.getWidth()), invoker.getHeight());
+ }
+};
+
+
+addPropertyChangeListener(TABLE_PROPERTY,this);
+addPropertyChangeListener(POPUP_VISIBLE_PROPERTY,this);
+]]>
+ </script>
+ <JToolBar floatable='false'
+ opaque='false'
+ borderPainted='false'>
+ <JToggleButton
+ id='button'
+ toolTipText='columnselector.action.tip'
+ actionIcon='numbereditor-calculator'
+ constraints='BorderLayout.CENTER'
+ selected='{popup.isVisible()}'
+ focusable='true'
+ focusPainted='false'
+ borderPainted='false'
+ rolloverEnabled='false'
+ onItemStateChanged='if (event.getStateChange() == ItemEvent.SELECTED) { setPopupVisible(true); } else { popupVisible = false; }'/>
+ </JToolBar>
+</JPanel>
\ No newline at end of file
Added: trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.css
===================================================================
--- trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.css (rev 0)
+++ trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.css 2009-07-27 20:27:58 UTC (rev 1511)
@@ -0,0 +1,60 @@
+/**
+ * *##% jaxx-runtime-swing-widget
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+*/
+
+#categoryLabelPanel {
+ background:{Color.WHITE};
+}
+
+#descriptionPane {
+ columnHeaderView:{new JLabel(_("config.descrition"), jaxx.runtime.Util.getUIManagerActionIcon("information"), 10)};
+}
+
+#description {
+ rows:3;
+ editable:false;
+ focusable:false;
+ font-size:10;
+ text:{_("config.no.option.selected")};
+}
+
+#tablePane {
+ columnHeaderView:{table.getTableHeader()};
+ verticalScrollBarPolicy:{ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS};
+horizontalScrollBarPolicy:{ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER};
+}
+
+#table {
+ rowSelectionAllowed:false;
+ autoCreateRowSorter:true;
+ autoResizeMode:{JTable.AUTO_RESIZE_ALL_COLUMNS};
+}
+
+#reset{
+ text:"config.action.reset";
+ toolTipText:"config.action.reset.tip";
+ actionIcon:"config-reset";
+ enabled:{getCategoryModel().isModified()};
+}
+
+#save{
+ text:"config.action.save";
+ toolTipText:"config.action.save.tip";
+ actionIcon:"config-save";
+ enabled:{getCategoryModel().isModified() && getCategoryModel().isValid()};
+}
Added: trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.jaxx
===================================================================
--- trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.jaxx (rev 0)
+++ trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.jaxx 2009-07-27 20:27:58 UTC (rev 1511)
@@ -0,0 +1,120 @@
+<!--
+
+/**
+ * *##% jaxx-runtime-swing-widget
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+-->
+
+<JPanel layout='{new BorderLayout()}'>
+
+ <style source='ConfigCategoryUI.css'/>
+
+ <script><![CDATA[
+import jaxx.runtime.SwingUtil;
+import jaxx.runtime.swing.editor.config.model.*;
+import jaxx.runtime.swing.editor.ColumnSelector;
+import static org.nuiton.i18n.I18n.n_;
+
+void $afterCompleteSetup() {
+ // prepare table
+ SwingUtil.setI18nTableHeaderRenderer(table,
+ n_("config.key"),
+ n_("config.key.tip"),
+ n_("config.value"),
+ n_("config.value.tip"),
+ n_("config.defaultValue"),
+ n_("config.defaultValue.tip"));
+
+ ConfigTableRenderer renderer = new ConfigTableRenderer();
+ SwingUtil.setTableColumnRenderer(table, 0, renderer);
+ SwingUtil.setTableColumnRenderer(table, 1, renderer);
+ SwingUtil.setTableColumnRenderer(table, 2, renderer);
+ Font f = table.getFont().deriveFont(Font.ITALIC | Font.BOLD);
+ int width = SwingUtil.computeTableColumnWidth(table, f, 0, "___*");
+ SwingUtil.fixTableColumnWidth(table, 0, width);
+ SwingUtil.setTableColumnEditor(table, 1, new ConfigTableEditor((ConfigTableModel) table.getModel()));
+ //TODO to be continued...
+ //columnSelector.setMyTable(table);
+ //tablePane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, columnSelector);
+}
+
+protected void updateDescriptionText() {
+ OptionModel option;
+ if (selectionModel.isSelectionEmpty()) {
+ option = null;
+ } else {
+ int row = selectionModel.getAnchorSelectionIndex();
+ ConfigTableModel m = (ConfigTableModel) table.getModel();
+ option = m.getEntry(row);
+ if (log.isDebugEnabled()) {
+ log.debug(row + " : " + option);
+ }
+ }
+ StringBuilder buffer = new StringBuilder();
+ if (option == null) {
+ buffer.append(_("config.no.option.selected"));
+ } else {
+ buffer.append(_("config.option.label", option.getKey(), _(option.getDescription()))).append('\n');
+ if (option.isModified()) {
+ buffer.append(_("config.option.modified", option.getOriginalValue(), option.getValue())).append('\n');
+ }
+ if (option.isFinal()) {
+ buffer.append(_("config.option.final")).append('\n');
+ }
+ }
+ description.setText(buffer.toString());
+}
+]]>
+ </script>
+
+ <CategoryModel id='categoryModel' javaBean='getContextValue(CategoryModel.class)'/>
+
+ <ConfigTableModel id='tableModel' constructorParams='categoryModel'
+ onTableChanged='updateDescriptionText()'/>
+
+ <ListSelectionModel id='selectionModel' javaBean='new DefaultListSelectionModel()'
+ onValueChanged='if (!event.getValueIsAdjusting()) { updateDescriptionText(); }'/>
+
+ <!--<ColumnSelector id='columnSelector' />-->
+
+ <!-- categorie label -->
+ <JPanel id="categoryLabelPanel" constraints='BorderLayout.NORTH'>
+ <JLabel id='categoryLabel'/>
+ </JPanel>
+
+ <!-- table of options -->
+ <JScrollPane id='tablePane' constraints='BorderLayout.CENTER'>
+ <JTable id="table" constructorParams='tableModel'
+ selectionModel='{selectionModel}'/>
+ </JScrollPane>
+
+ <JPanel layout='{new BorderLayout()}' constraints='BorderLayout.SOUTH'>
+
+ <!-- description of selected option in table -->
+ <JScrollPane id="descriptionPane" constraints='BorderLayout.CENTER'>
+ <JTextArea id='description'/>
+ </JScrollPane>
+
+ <!-- actions of the category -->
+ <JPanel layout='{new GridLayout(1,0)}' constraints='BorderLayout.SOUTH'>
+ <JButton id='reset' onActionPerformed='getContextValue(ConfigUIModel.class).reset()'/>
+ <JButton id='save' onActionPerformed='getContextValue(ConfigUIModel.class).saveModified()'/>
+ </JPanel>
+ </JPanel>
+</JPanel>
Added: trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableEditor.java
===================================================================
--- trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableEditor.java (rev 0)
+++ trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableEditor.java 2009-07-27 20:27:58 UTC (rev 1511)
@@ -0,0 +1,125 @@
+/*
+* *##% jaxx-runtime-swing-widget
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */
+package jaxx.runtime.swing.editor.config;
+
+import jaxx.runtime.swing.editor.config.model.ConfigTableModel;
+import javax.swing.DefaultCellEditor;
+import javax.swing.JTable;
+import javax.swing.event.CellEditorListener;
+import javax.swing.table.TableCellEditor;
+import java.awt.Component;
+import java.util.EventObject;
+import java.util.Locale;
+import jaxx.runtime.swing.editor.ClassCellEditor;
+import jaxx.runtime.swing.editor.EnumEditor;
+import jaxx.runtime.swing.editor.LocaleEditor;
+
+/**
+ * L'éditeur des valeurs des propriétés d'une configuration
+ *
+ * @author chemit
+ */
+public class ConfigTableEditor implements TableCellEditor {
+
+ protected TableCellEditor delegate;
+ protected ConfigTableModel model;
+
+ public ConfigTableEditor(ConfigTableModel model) {
+ this.model = model;
+ }
+
+ @Override
+ public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
+ delegate = findDelegate(table, model.getEntry(row).getType());
+ return delegate.getTableCellEditorComponent(table, value, isSelected, row, column);
+ }
+
+ @Override
+ public Object getCellEditorValue() {
+ return !hasDelegate() ? null : delegate.getCellEditorValue();
+ }
+
+ @Override
+ public boolean isCellEditable(EventObject anEvent) {
+ return !hasDelegate() || delegate.isCellEditable(anEvent);
+ }
+
+ @Override
+ public boolean shouldSelectCell(EventObject anEvent) {
+ return hasDelegate() && delegate.shouldSelectCell(anEvent);
+ }
+
+ @Override
+ public boolean stopCellEditing() {
+ return !hasDelegate() || delegate.stopCellEditing();
+ }
+
+ @Override
+ public void cancelCellEditing() {
+ if (hasDelegate()) {
+ delegate.cancelCellEditing();
+ }
+ }
+
+ @Override
+ public void addCellEditorListener(CellEditorListener l) {
+ if (hasDelegate()) {
+ delegate.addCellEditorListener(l);
+ }
+ }
+
+ @Override
+ public void removeCellEditorListener(CellEditorListener l) {
+ if (hasDelegate()) {
+ delegate.removeCellEditorListener(l);
+ }
+ }
+
+ protected TableCellEditor findDelegate(JTable table, Class<?> type) {
+ TableCellEditor editor = table.getDefaultEditor(type);
+ TableCellEditor defaultEditor = table.getDefaultEditor(Object.class);
+ if (editor == defaultEditor) {
+ // find not a specialized editor for the type
+ if (type.isEnum()) {
+ // add a EnumEditor to table
+ editor = new DefaultCellEditor(EnumEditor.newEditor((Class<Enum>) type));
+ table.setDefaultEditor(type, editor);
+ } else if (type == Class.class) {
+ editor = new ClassCellEditor();
+ table.setDefaultEditor(type, editor);
+ } //else if (type == File.class){
+ // TODO a FileEditor
+ // table.setDefaultEditor(type, delegate);
+ //}
+ else if (type.equals(Locale.class)) {
+ editor = new DefaultCellEditor(LocaleEditor.newEditor());
+ table.setDefaultEditor(Locale.class, editor);
+ } else {
+ editor = table.getDefaultEditor(String.class);
+ }
+ }
+ if (editor == null) {
+ throw new IllegalStateException("could not find a editor for type +" + type);
+ }
+ return editor;
+ }
+
+ protected boolean hasDelegate() {
+ return delegate != null;
+ }
+}
Added: trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableRenderer.java
===================================================================
--- trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableRenderer.java (rev 0)
+++ trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableRenderer.java 2009-07-27 20:27:58 UTC (rev 1511)
@@ -0,0 +1,112 @@
+/*
+ * *##% jaxx-runtime-swing-widget
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */
+package jaxx.runtime.swing.editor.config;
+
+import static org.nuiton.i18n.I18n._;
+
+import javax.swing.JComponent;
+import javax.swing.JTable;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.TableCellRenderer;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Font;
+import jaxx.runtime.swing.editor.config.model.ConfigTableModel;
+import jaxx.runtime.swing.editor.config.model.OptionModel;
+
+/**
+ * Pour le rendu du tableau des options d'une categorie
+ *
+ * @author chemit
+ * @see ConfigTableModel
+ */
+public class ConfigTableRenderer extends DefaultTableCellRenderer {
+
+ private static final long serialVersionUID = 1L;
+ protected static Color col;
+ protected static Font font;
+ protected static Font font2;
+
+ public ConfigTableRenderer() {
+ col = getForeground();
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+ int modelRow = table.convertRowIndexToModel(row);
+ int modelColumn = table.convertColumnIndexToModel(column);
+ ConfigTableModel model = (ConfigTableModel) table.getModel();
+ OptionModel key = model.getEntry(modelRow);
+ boolean isModified = key.isModified();
+
+ boolean isValid = key.isValid();
+
+ if (font == null) {
+ font = getFont();
+ font2 = font.deriveFont(Font.ITALIC | Font.BOLD);
+ }
+ Component cellRenderer = null;
+ switch (modelColumn) {
+ case 0:
+ cellRenderer = getKeyCellRenderer(table, value, isSelected, hasFocus, modelRow, modelColumn, key, isValid, isModified);
+ break;
+ case 1:
+ cellRenderer = getValueCellRenderer(table, value, isSelected, hasFocus, modelRow, modelColumn, key, isValid, isModified);
+ break;
+ case 2:
+ cellRenderer = getValueCellRenderer(table, value, isSelected, hasFocus, modelRow, modelColumn, key, isValid, isModified);
+ break;
+ default:
+ throw new IllegalStateException("no renderer find for column " + modelColumn);
+ }
+ return cellRenderer;
+ }
+
+ protected Component getKeyCellRenderer(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column, OptionModel key, boolean isValid, boolean isModified) {
+ String tooltip = _(key.getDescription());
+ Object originalValue = key.getOriginalValue();
+ boolean isFinal = key.isFinal();
+ if (isFinal) {
+ tooltip += " [" + _("config.unmodifiable") + ']';
+ }
+ if (isModified) {
+ String s = _("config.modified", originalValue);
+ value = value + " *";
+ tooltip += " [" + s + ']';
+ }
+ if (!isValid) {
+ String s2 = _("config.unvalid", originalValue, key.getType());
+ tooltip += " (" + s2 + ")";
+ value = value + " !";
+ }
+ JComponent result = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ result.setToolTipText(tooltip);
+ result.setForeground(isValid ? col : Color.RED);
+ result.setFont(isModified || !isValid ? font2 : font);
+ result.setEnabled(!isFinal);
+ return result;
+ }
+
+ protected Component getValueCellRenderer(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column, OptionModel key, boolean isValid, boolean isModified) {
+ TableCellRenderer defaultRenderer = table.getDefaultRenderer(key.getType());
+
+ Component result;
+ result = defaultRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ return result;
+ }
+}
Added: trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.css
===================================================================
--- trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.css (rev 0)
+++ trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.css 2009-07-27 20:27:58 UTC (rev 1511)
@@ -0,0 +1,27 @@
+/**
+ * *##% jaxx-runtime-swing-widget
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+*/
+#quit{
+ text:"config.action.quit";
+ toolTipText:"config.action.quit.tip";
+ actionIcon:"config-quit";
+}
+
+#categories{
+ tabPlacement:{JTabbedPane.LEFT};
+}
Added: trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.jaxx
===================================================================
--- trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.jaxx (rev 0)
+++ trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.jaxx 2009-07-27 20:27:58 UTC (rev 1511)
@@ -0,0 +1,72 @@
+<!--
+
+/**
+ * *##% jaxx-runtime-swing-widget
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+-->
+
+<JPanel layout='{new BorderLayout()}'>
+
+ <style source='ConfigUI.css'/>
+
+ <script><![CDATA[
+ import jaxx.runtime.swing.editor.config.model.ConfigUIModel;
+
+ categories.setModel(new DefaultSingleSelectionModel() {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void setSelectedIndex(int index) {
+ // check if catgeory can be quit
+ boolean canContinue = !isSelected() || ConfigUIBuilder.canQuitCategory(ConfigUI.this);
+ if (canContinue) {
+ if (log.isDebugEnabled()) {
+ log.debug("new index : " + index);
+ }
+ // was authorized to continue
+ super.setSelectedIndex(index);
+ }
+ }
+ });
+
+ protected void changeCategory(ChangeEvent e) {
+ JPanel p = (JPanel) getCategories().getSelectedComponent();
+ if (p == null) {
+ // pas de selection
+ return;
+ }
+ getModel().setCategory(p.getName());
+ getCategories().invalidate();
+ }
+ ]]>
+ </script>
+
+ <!-- le modele de l'ui -->
+ <ConfigUIModel id='model' javaBean='getContextValue(ConfigUIModel.class)'/>
+
+ <!-- les differentes categories de la configuration -->
+ <JTabbedPane id='categories' constraints='BorderLayout.CENTER'
+ onStateChanged='changeCategory(event)' />
+
+ <!-- pour quitter l'ui -->
+ <JPanel layout='{new GridLayout(1,0)}' constraints='BorderLayout.SOUTH'>
+ <JButton id='quit'/>
+ </JPanel>
+</JPanel>
Added: trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java
===================================================================
--- trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java (rev 0)
+++ trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java 2009-07-27 20:27:58 UTC (rev 1511)
@@ -0,0 +1,220 @@
+/**
+ * *##% jaxx-runtime-swing-widget
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+package jaxx.runtime.swing.editor.config;
+
+import java.awt.Frame;
+import java.awt.event.ActionEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JDialog;
+import javax.swing.JOptionPane;
+import javax.swing.JRootPane;
+import javax.swing.KeyStroke;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXInitialContext;
+import jaxx.runtime.SwingUtil;
+
+import jaxx.runtime.swing.editor.config.model.CategoryModel;
+import jaxx.runtime.swing.editor.config.model.ConfigUIModel;
+import jaxx.runtime.swing.editor.config.model.OptionModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * La classe pour construire l'ui
+ * @author chemit
+ */
+public class ConfigUIBuilder {
+
+ public static final Log log = LogFactory.getLog(ConfigUIBuilder.class);
+
+ /**
+ * Construire l'ui de configuration (sous forme de panel)
+ *
+ * @param parentContext le context applicatif
+ * @param model le modele de l'ui de configuration
+ * @param defaultCategory la categorie a selectionner
+ * @return l'ui instanciate
+ */
+ public static ConfigUI newConfigUI(jaxx.runtime.JAXXContext parentContext, final ConfigUIModel model, String defaultCategory) {
+ JAXXContext tx = new JAXXInitialContext().add(parentContext).add(model);
+
+ final ConfigUI ui = new ConfigUI(tx);
+ JButton quitButton = ui.getQuit();
+
+ // prepare quit action
+ Action quitAction = new AbstractAction(quitButton.getText(), quitButton.getIcon()) {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (canQuitCategory(ui)) {
+ ui.getParentContainer(JDialog.class).dispose();
+ }
+ }
+ };
+ String tip = quitButton.getToolTipText();
+ quitButton.setAction(quitAction);
+ quitButton.setToolTipText(tip);
+
+ // build categories tabs
+ for (CategoryModel categoryModel : model) {
+ String category = categoryModel.getCategory();
+ String categoryLabel = _(categoryModel.getCategoryLabel());
+ ConfigCategoryUI p = new ConfigCategoryUI(new JAXXInitialContext().add(ui).add(categoryModel));
+ p.getCategoryLabel().setText(categoryLabel);
+ p.setName(category);
+ ui.getCategories().addTab(_(category), null, p, categoryLabel);
+ }
+
+ model.setCategory(defaultCategory);
+ int categoryIndex = model.getCategoryIndex(defaultCategory);
+ if (log.isDebugEnabled()) {
+ log.debug("index of default category (" + defaultCategory + ") : " + categoryIndex);
+ }
+ ui.getCategories().setSelectedIndex(categoryIndex);
+ return ui;
+ }
+
+ /**
+ * Affiche l'ui de configuration dans un boite de dialogue.
+ *
+ * @param configUI l'ui de configuration
+ * @param ui l'ui parent de la boite de dialogue a afficher (peut etre nulle)
+ * @param undecorated un drapeau pour savoir si on affiche les decorations de fenetre
+ */
+ public static void showConfigUI(final ConfigUI configUI, Frame ui, boolean undecorated) {
+ JDialog f = new JDialog(ui, true);
+ f.setTitle(_("config.title"));
+ f.add(configUI);
+ if (ui != null) {
+ f.setIconImage(ui.getIconImage());
+ }
+ // pour savoir si l'ui est autonome
+ configUI.putClientProperty("standalone", ui == null);
+
+ f.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
+ f.addWindowListener(new WindowAdapter() {
+
+ @Override
+ public void windowClosing(WindowEvent e) {
+
+ if (canQuitCategory(configUI)) {
+ e.getWindow().dispose();
+ }
+ }
+ });
+ f.setUndecorated(undecorated);
+ JRootPane rootPane = f.getRootPane();
+ rootPane.setDefaultButton(configUI.getQuit());
+ rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "quit");
+ rootPane.getActionMap().put("quit", configUI.getQuit().getAction());
+ f.pack();
+ SwingUtil.center(ui, f);
+ f.setVisible(true);
+ }
+
+ protected static boolean canQuitCategory(ConfigUI ui) {
+ boolean canContinue = true;
+ ConfigUIModel model = ui.getModel();
+ CategoryModel categoryModel = model.getCategoryModel();
+ String categoryName = _(categoryModel.getCategory());
+ if (!categoryModel.isValid()) {
+
+ // the category is not valid
+ // get all the invalid options
+
+ StringBuilder buffer = new StringBuilder();
+ buffer.append(_("config.message.quit.invalid.category", categoryName)).append('\n');
+ for (OptionModel m : categoryModel.getInvalidOptions()) {
+ buffer.append("\n- ").append(m.getKey());
+ }
+ buffer.append('\n');
+ int reponse = askUser(ui,
+ _("config.title.need.confirm"),
+ buffer.toString(),
+ JOptionPane.ERROR_MESSAGE,
+ new Object[]{
+ _("config.choice.continue"),
+ _("config.choice.cancel")},
+ 0);
+
+ switch (reponse) {
+ case JOptionPane.CLOSED_OPTION:
+ case 1:
+ canContinue = false;
+ break;
+ case 0:
+ if (categoryModel.isModified()) {
+ // wil reset category
+ model.reset();
+ }
+ break;
+ }
+ } else if (categoryModel.isModified()) {
+
+ // category was modified, ask user if wants to save
+
+ StringBuilder buffer = new StringBuilder();
+ buffer.append(_("config.message.quit.valid.and.modified.category", categoryName)).append('\n');
+ for (OptionModel m : categoryModel.getModifiedOptions()) {
+ buffer.append("\n- ").append(m.getKey());
+ }
+ buffer.append('\n');
+
+ int reponse = askUser(ui,
+ _("config.title.need.confirm"), buffer.toString(),
+ JOptionPane.WARNING_MESSAGE,
+ new Object[]{
+ _("config.choice.save"),
+ _("config.choice.doNotSave"),
+ _("config.choice.cancel")},
+ 0);
+
+ switch (reponse) {
+ case JOptionPane.CLOSED_OPTION:
+ case 2:
+ canContinue = false;
+ break;
+ case 0:
+ // will save ui
+ model.saveModified();
+ break;
+ case 1:
+ // wil reset ui
+ model.reset();
+ break;
+ }
+
+ }
+ return canContinue;
+ }
+
+ public static int askUser(ConfigUI parent, String title, String message, int typeMessage, Object[] options, int defaultOption) {
+
+ int response = JOptionPane.showOptionDialog(parent, message, title, JOptionPane.DEFAULT_OPTION, typeMessage, null, options, options[defaultOption]);
+ return response;
+ }
+}
Added: trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java
===================================================================
--- trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java (rev 0)
+++ trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java 2009-07-27 20:27:58 UTC (rev 1511)
@@ -0,0 +1,165 @@
+/**
+ * *##% jaxx-runtime-swing-widget
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+package jaxx.runtime.swing.editor.config.model;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * le modele d'une categorie d'options.
+ *
+ * Une categorie est un ensemble d'options.
+ *
+ * @author tchemit
+ */
+public class CategoryModel implements Iterable<OptionModel> {
+
+ public static final String RELOAD_PROPERTY_NAME = "reload";
+ public static final String MODIFIED_PROPERTY_NAME = "modified";
+ public static final String VALID_PROPERTY_NAME = "valid";
+ /** category short name (i18n key) */
+ protected String category;
+ /** category long name (i18n key) */
+ protected String categoryLabel;
+ /** options of the category */
+ protected List<OptionModel> entries;
+ /** suport of modification */
+ protected PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+
+ public CategoryModel(String category, String categoryLabel, OptionModel[] entries) {
+ super();
+ this.category = category;
+ this.categoryLabel = categoryLabel;
+ this.entries = Collections.unmodifiableList(Arrays.asList(entries));
+ }
+
+ public String getCategory() {
+ return category;
+ }
+
+ public String getCategoryLabel() {
+ return categoryLabel;
+ }
+
+ public List<OptionModel> getEntries() {
+ return entries;
+ }
+
+ public boolean isModified() {
+ boolean modified = false;
+ for (OptionModel m : this) {
+ if (m.isModified()) {
+ modified = true;
+ break;
+ }
+ }
+ return modified;
+ }
+
+ public boolean isValid() {
+ boolean valid = true;
+ for (OptionModel m : this) {
+ if (!m.isValid()) {
+ valid = false;
+ break;
+ }
+ }
+ return valid;
+ }
+
+ public void setValue(OptionModel key, Object val) {
+ boolean wasModified = isModified();
+ boolean wasValid = isValid();
+ key.setValue(val);
+ boolean modified = isModified();
+ boolean valid = isValid();
+ if (wasModified != modified) {
+ // change modified state
+ firePropertyChange(MODIFIED_PROPERTY_NAME, wasModified, modified);
+ }
+ if (wasValid != valid) {
+ // change valid state
+ firePropertyChange(VALID_PROPERTY_NAME, wasValid, valid);
+ }
+ }
+
+ @Override
+ public Iterator<OptionModel> iterator() {
+ return entries.iterator();
+ }
+
+ public List<OptionModel> getInvalidOptions() {
+
+ List<OptionModel> result = new ArrayList<OptionModel>();
+ for (OptionModel m : this) {
+ if (!m.isValid()) {
+ result.add(m);
+ }
+ }
+ return result;
+ }
+
+ public List<OptionModel> getModifiedOptions() {
+
+ List<OptionModel> result = new ArrayList<OptionModel>();
+ for (OptionModel m : this) {
+ if (m.isModified()) {
+ result.add(m);
+ }
+ }
+ return result;
+ }
+
+ public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
+ pcs.firePropertyChange(propertyName, oldValue, newValue);
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(propertyName, listener);
+ }
+
+ public synchronized boolean hasListeners(String propertyName) {
+ return pcs.hasListeners(propertyName);
+ }
+
+ public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
+ return pcs.getPropertyChangeListeners(propertyName);
+ }
+
+ public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
+ return pcs.getPropertyChangeListeners();
+ }
+}
Added: trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigTableModel.java
===================================================================
--- trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigTableModel.java (rev 0)
+++ trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigTableModel.java 2009-07-27 20:27:58 UTC (rev 1511)
@@ -0,0 +1,134 @@
+/**
+ * *##% jaxx-runtime-swing-widget
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+package jaxx.runtime.swing.editor.config.model;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import javax.swing.table.AbstractTableModel;
+import org.nuiton.util.ConverterUtil;
+
+/**
+ * le modele du tableau d'options pour une categorie donnee.
+ *
+ * Le modele se base sur le modele d'une categorie d'option.
+ *
+ * @author tchemit
+ *
+ * @see CategoryModel
+ */
+public class ConfigTableModel extends AbstractTableModel {
+
+ private static final long serialVersionUID = 1L;
+ private static final Class<?>[] columnClass = {String.class, Object.class, String.class};
+ /** le modele d'une categorie */
+ protected final CategoryModel categoryModel;
+
+ public ConfigTableModel(CategoryModel categoryModel) {
+ this.categoryModel = categoryModel;
+ // listen of property reload of the category model
+ // to known when to refresh table
+ this.categoryModel.addPropertyChangeListener(CategoryModel.RELOAD_PROPERTY_NAME, new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ fireTableDataChanged();
+ }
+ });
+ }
+
+ public CategoryModel getCategoryModel() {
+ return categoryModel;
+ }
+
+ public OptionModel getEntry(int rowIndex) {
+ return categoryModel.getEntries().get(rowIndex);
+ }
+
+ @Override
+ public int getRowCount() {
+ return categoryModel.getEntries().size();
+ }
+
+ @Override
+ public int getColumnCount() {
+ return columnClass.length;
+ }
+
+ @Override
+ public Class<?> getColumnClass(int columnIndex) {
+ return columnClass[columnIndex];
+ }
+
+ @Override
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ return columnIndex == 1 && !getEntry(rowIndex).isFinal();
+ }
+
+ @Override
+ public Object getValueAt(int row, int column) {
+ OptionModel key = getEntry(row);
+ Object value = null;
+ switch (column) {
+ case 0:
+ value = key.getKey();
+ break;
+ case 1:
+ value = key.getValue();
+ break;
+ case 2:
+ value = key.getDefaultValue();
+ if (value != null) {
+ value = ConverterUtil.convert(key.getType(), value);
+ }
+ break;
+ }
+ return value;
+// if (column == 0) {
+// return key.getKey();
+// }
+// return key.getValue();
+ }
+
+ @Override
+ public void setValueAt(Object aValue, int row, int column) {
+ if (column != 1) {
+ // seul la colonne 1 est editable (valeur de l'option)
+ throw new IllegalArgumentException("can not edit column " + column);
+ }
+ OptionModel key = getEntry(row);
+ Object val;
+ if (aValue == null || key.getType() == aValue.getClass()) {
+ val = aValue;
+ } else {
+ String valStr = String.valueOf(aValue).trim();
+ try {
+ val = ConverterUtil.convert(key.getType(), valStr);
+ if (val != null && val instanceof Integer) {
+ if (new Integer(0).equals(val) && !valStr.equals("0")) {
+ val = null;
+ }
+ }
+ } catch (Exception e) {
+ val = null;
+ }
+ }
+ categoryModel.setValue(key, val);
+ fireTableRowsUpdated(row, row);
+ }
+}
Added: trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java
===================================================================
--- trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java (rev 0)
+++ trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java 2009-07-27 20:27:58 UTC (rev 1511)
@@ -0,0 +1,189 @@
+/**
+ * *##% jaxx-runtime-swing-widget
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+package jaxx.runtime.swing.editor.config.model;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import org.nuiton.util.ApplicationConfig;
+import org.nuiton.util.ApplicationConfig.OptionDef;
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Le modele de l'ui des preferences.
+ *
+ * Ce modele contient les catégories des options.
+ *
+ * @author chemit
+ */
+public class ConfigUIModel implements Iterable<CategoryModel> {
+
+ public static final String CATEGORY_MODEL_PROPERTY_NAME = "categoryModel";
+ /** le dictionnaire des options disponibles par categorie */
+ protected final Map<String, CategoryModel> categories;
+ /** La configuration de l'application */
+ protected final ApplicationConfig config;
+ /** la cateogrie en cours d'utilisation */
+ protected CategoryModel categoryModel;
+ /** suport of modification */
+ protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+
+ public ConfigUIModel(ApplicationConfig config) {
+ this.config = config;
+ this.categories = new LinkedHashMap<String, CategoryModel>();
+ }
+
+ /**
+ * Ajoute une categorie dans le modele.
+ *
+ * @param category l'id de la categorie (la clef de traduction du nom de la categorie)
+ * @param categoryLabel la clef de traduction de la description de la categorie
+ * @param keys les options de la categorie
+ */
+ public void addCategory(String category, String categoryLabel, OptionDef... keys) {
+ if (categories.containsKey(category)) {
+ throw new IllegalArgumentException(_("config.error.category.already.exists", category));
+ }
+ OptionModel[] entries = new OptionModel[keys.length];
+ int index = 0;
+ for (OptionDef d : keys) {
+ Object value = config.getOption(d);
+ OptionModel e = new OptionModel(d, value);
+ entries[index++] = e;
+ }
+ CategoryModel m = new CategoryModel(category, categoryLabel, entries);
+ categories.put(category, m);
+ }
+
+ /**
+ * Change la categorie en cours d'édition.
+ *
+ * @param category l'id de la categorie courante
+ */
+ public void setCategory(String category) {
+ if (!categories.containsKey(category)) {
+ throw new IllegalArgumentException(_("config.error.category.not.found", category));
+ }
+ CategoryModel newCategoryModel = categories.get(category);
+ setCategoryModel(newCategoryModel);
+ newCategoryModel.firePropertyChange(CategoryModel.MODIFIED_PROPERTY_NAME, false, getCategoryModel().isModified());
+ newCategoryModel.firePropertyChange(CategoryModel.VALID_PROPERTY_NAME, false, getCategoryModel().isValid());
+ }
+
+ @Override
+ public Iterator<CategoryModel> iterator() {
+ return categories.values().iterator();
+ }
+
+ public CategoryModel getCategoryModel() {
+ return categoryModel;
+ }
+
+ public void setCategoryModel(CategoryModel categoryModel) {
+ CategoryModel old = this.categoryModel;
+ this.categoryModel = categoryModel;
+ firePropertyChange(CATEGORY_MODEL_PROPERTY_NAME, old, categoryModel);
+ }
+
+ public void saveModified() {
+ // compute transients keys (to never be saved)
+ List<String> transients = new ArrayList<String>();
+
+ for (OptionModel option : categoryModel) {
+ if (option.isModified()) {
+ Object value = option.getValue();
+ //TODO TC-20090245 : should try to seek for a mutator, since
+ // mutator could have extra code to be done when modify an option
+ config.setOption(option.getKey(), value == null ? null : value.toString());
+ // this is the new original value
+ option.initValue(value);
+ }
+ if (option.isTransient()) {
+ transients.add(option.getKey());
+ }
+ }
+ // save config
+ config.saveForUser(transients.toArray(new String[transients.size()]));
+ // notify data has changed
+ categoryModel.firePropertyChange(CategoryModel.MODIFIED_PROPERTY_NAME, categoryModel.isModified(), true);
+ categoryModel.firePropertyChange(CategoryModel.VALID_PROPERTY_NAME, false, categoryModel.isValid());
+ categoryModel.firePropertyChange(CategoryModel.RELOAD_PROPERTY_NAME, false, true);
+ }
+
+ public void reset() {
+ // reset all modified options of the current category
+ for (OptionModel key : categoryModel) {
+ if (key.isModified()) {
+ key.initValue(key.getOriginalValue());
+ }
+ }
+ // notify data has changed
+ categoryModel.firePropertyChange(CategoryModel.MODIFIED_PROPERTY_NAME, categoryModel.isModified(), true);
+ categoryModel.firePropertyChange(CategoryModel.VALID_PROPERTY_NAME, false, categoryModel.isValid());
+ categoryModel.firePropertyChange(CategoryModel.RELOAD_PROPERTY_NAME, false, true);
+ }
+
+ public int getCategoryIndex(String category) {
+ int i = 0;
+ for (CategoryModel m : this) {
+ if (category.equals(m.getCategory())) {
+ return i;
+ }
+ i++;
+ }
+ // not found
+ return -1;
+ }
+
+ public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
+ pcs.firePropertyChange(propertyName, oldValue, newValue);
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(propertyName, listener);
+ }
+
+ public synchronized boolean hasListeners(String propertyName) {
+ return pcs.hasListeners(propertyName);
+ }
+
+ public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
+ return pcs.getPropertyChangeListeners(propertyName);
+ }
+
+ public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
+ return pcs.getPropertyChangeListeners();
+ }
+}
Added: trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java
===================================================================
--- trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java (rev 0)
+++ trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java 2009-07-27 20:27:58 UTC (rev 1511)
@@ -0,0 +1,98 @@
+/**
+ * *##% jaxx-runtime-swing-widget
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+package jaxx.runtime.swing.editor.config.model;
+
+import org.nuiton.util.ApplicationConfig.OptionDef;
+
+/**
+ * le modele d'une option de la configuration a editer.
+ *
+ * @author tchemit
+ */
+public class OptionModel implements OptionDef {
+
+ protected final OptionDef def;
+ protected boolean valid = true;
+ protected Object originalValue;
+ protected Object value;
+
+ protected OptionModel(OptionDef def, Object value) {
+ this.def = def;
+ initValue(value);
+ }
+
+ @Override
+ public String getKey() {
+ return def.getKey();
+ }
+
+ @Override
+ public Class<?> getType() {
+ return def.getType();
+ }
+
+ @Override
+ public String getDescription() {
+ return def.getDescription();
+ }
+
+ @Override
+ public String getDefaultValue() {
+ return def.getDefaultValue();
+ }
+
+ @Override
+ public boolean isTransient() {
+ return def.isTransient();
+ }
+
+ @Override
+ public boolean isFinal() {
+ return def.isFinal();
+ }
+
+ public Object getOriginalValue() {
+ return originalValue;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ public void setValue(Object value) {
+ this.value = value;
+ }
+
+ public boolean isModified() {
+ return !originalValue.equals(value);
+ }
+
+ public boolean isValid() {
+ return valid;
+ }
+
+ public void setValid(boolean valid) {
+ this.valid = valid;
+ }
+
+ public void initValue(Object originalValue) {
+ this.originalValue = originalValue;
+ this.value = originalValue;
+ }
+}
Added: trunk/jaxx-runtime-swing-widget/src/main/resources/icons/action-config-quit.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-runtime-swing-widget/src/main/resources/icons/action-config-quit.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-runtime-swing-widget/src/main/resources/icons/action-config-reset.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-runtime-swing-widget/src/main/resources/icons/action-config-reset.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-runtime-swing-widget/src/main/resources/icons/action-config-save.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-runtime-swing-widget/src/main/resources/icons/action-config-save.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
1
0
r1510 - in trunk: . jaxx-runtime-swing/src/main/java/jaxx/runtime jaxx-runtime-swing/src/main/java/jaxx/runtime/swing jaxx-runtime-swing-widget jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor jaxx-runtime-swing-widget/src/main/resources/i18n
by tchemit@users.labs.libre-entreprise.org 27 Jul '09
by tchemit@users.labs.libre-entreprise.org 27 Jul '09
27 Jul '09
Author: tchemit
Date: 2009-07-27 22:26:02 +0200 (Mon, 27 Jul 2009)
New Revision: 1510
Modified:
trunk/jaxx-runtime-swing-widget/
trunk/jaxx-runtime-swing-widget/pom.xml
trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/AboutPanel.jaxx
trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/ClockWidget.jaxx
trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx
trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java
trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/ErrorDialogUI.jaxx
trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/MemoryStatusWidget.jaxx
trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/StatusMessagePanel.jaxx
trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/StatusMessagePanelHandler.java
trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/I18nEditor.jaxx
trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditor.jaxx
trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java
trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditorPopup.css
trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/TimeEditor.css
trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/TimeEditor.jaxx
trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/TimeEditorHandler.java
trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties
trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties
trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java
trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/I18nTableCellRenderer.java
trunk/pom.xml
Log:
normalize i18n keys in widgets, add ApplicationConfig ui to change preferences, degin of a ColumnSelector (should have a look in swingx...)
Modified: trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java
===================================================================
--- trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java 2009-07-24 08:00:05 UTC (rev 1509)
+++ trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java 2009-07-27 20:26:02 UTC (rev 1510)
@@ -5,6 +5,8 @@
import java.awt.Container;
import java.awt.Desktop;
import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
import java.awt.Rectangle;
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
@@ -184,6 +186,26 @@
combo.setItems(items);
}
+ public static int computeTableColumnWidth(JTable table, Font font, int columnIndex, String suffix) {
+ int width = 0;
+ if (font == null) {
+ font = table.getFont();
+ }
+// if (font == null) {
+// TableColumn column = table.getColumnModel().getColumn(columnIndex);
+// font = ((JComponent) column.getCellRenderer()).getFont();
+// }
+ FontMetrics fontMetrics = table.getFontMetrics(font);
+ for (int i = 0, rowCount = table.getRowCount(); i < rowCount; i++) {
+ String key = (String) table.getModel().getValueAt(i, 0);
+ int w = fontMetrics.stringWidth(key + suffix);
+ if (w > width) {
+ width = w;
+ }
+ }
+ return width;
+ }
+
public static void fixTableColumnWidth(JTable table, int columnIndex, int width) {
TableColumn column = table.getColumnModel().getColumn(columnIndex);
column.setMaxWidth(width);
Modified: trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/I18nTableCellRenderer.java
===================================================================
--- trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/I18nTableCellRenderer.java 2009-07-24 08:00:05 UTC (rev 1509)
+++ trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/I18nTableCellRenderer.java 2009-07-27 20:26:02 UTC (rev 1510)
@@ -42,6 +42,7 @@
}
}
+ @Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasfocus, int row, int column) {
if (column > keys.length) {
throw new IndexOutOfBoundsException("colum can not be greater than " + keys.length);
@@ -53,4 +54,13 @@
rendererComponent.setToolTipText(_(tips[index]));
return rendererComponent;
}
+
+ public String[] getKeys() {
+ return keys;
+ }
+
+ public String[] getTips() {
+ return tips;
+ }
+
}
Property changes on: trunk/jaxx-runtime-swing-widget
___________________________________________________________________
Modified: svn:ignore
- velocity.log
target
nbactions.xml
+ velocity.log
target
nbactions.xml
nbproject
Modified: trunk/jaxx-runtime-swing-widget/pom.xml
===================================================================
--- trunk/jaxx-runtime-swing-widget/pom.xml 2009-07-24 08:00:05 UTC (rev 1509)
+++ trunk/jaxx-runtime-swing-widget/pom.xml 2009-07-27 20:26:02 UTC (rev 1510)
@@ -58,6 +58,7 @@
<properties>
<jaxx.addSourcesToClassPath>true</jaxx.addSourcesToClassPath>
+ <!--jaxx.useUIManagerForIcon>true</jaxx.useUIManagerForIcon-->
</properties>
<build>
@@ -96,6 +97,7 @@
<groupId>org.nuiton.i18n</groupId>
<artifactId>maven-i18n-plugin</artifactId>
<configuration>
+ <silent>true</silent>
<entries>
<entry>
<basedir>${maven.gen.dir}/java/</basedir>
Modified: trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/AboutPanel.jaxx
===================================================================
--- trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/AboutPanel.jaxx 2009-07-24 08:00:05 UTC (rev 1509)
+++ trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/AboutPanel.jaxx 2009-07-27 20:26:02 UTC (rev 1510)
@@ -1,3 +1,25 @@
+<!--
+
+/**
+ * *##% jaxx-runtime-swing-widget
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+-->
<Table insets='1'
background='{getBackgroundColor()}'
border='{BorderFactory.createLineBorder(Color.BLACK, 1)}'>
@@ -133,7 +155,7 @@
void $afterCompleteSetup() {
buildTopPanel();
- close.setText(_("lutinwidget.aboutframe.ok"));
+ close.setText(_("aboutframe.ok"));
}
]]>
@@ -156,7 +178,7 @@
<row>
<cell weighty='1' fill='both'>
<JTabbedPane id='tabs'>
- <tab title="lutinwidget.aboutframe.about">
+ <tab title="aboutframe.about">
<JScrollPane id='aboutContent' border='{null}'>
<JEditorPane contentType='text/html'
editable='false'
@@ -165,7 +187,7 @@
onHyperlinkUpdate='SwingUtil.openLink(event)'/>
</JScrollPane>
</tab>
- <tab title="lutinwidget.aboutframe.license">
+ <tab title="aboutframe.license">
<JScrollPane id='licenseContent' border='{null}'>
<JTextArea id='licenseTextArea'
editable='false'
@@ -174,7 +196,7 @@
text='{SwingUtil.getStringValue(getLicenseText())}'/>
</JScrollPane>
</tab>
- <tab title="lutinwidget.aboutframe.thirdparty">
+ <tab title="aboutframe.thirdparty">
<JScrollPane id='thirdpartyContent' border='{null}'>
<JTextArea id='thirdpartyTextArea'
editable='false'
@@ -199,4 +221,4 @@
</cell>
</row>
-</Table>
\ No newline at end of file
+</Table>
Modified: trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/ClockWidget.jaxx
===================================================================
--- trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/ClockWidget.jaxx 2009-07-24 08:00:05 UTC (rev 1509)
+++ trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/ClockWidget.jaxx 2009-07-27 20:26:02 UTC (rev 1510)
@@ -1,3 +1,25 @@
+<!--
+
+/**
+ * *##% jaxx-runtime-swing-widget
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+-->
<JLabel implements='ActionListener'
foreground='{Color.BLACK}'
background='{Color.WHITE}'>
@@ -30,4 +52,4 @@
}
]]>
</script>
-</JLabel>
\ No newline at end of file
+</JLabel>
Modified: trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx
===================================================================
--- trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx 2009-07-24 08:00:05 UTC (rev 1509)
+++ trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx 2009-07-27 20:26:02 UTC (rev 1510)
@@ -1,3 +1,25 @@
+<!--
+
+/**
+ * *##% jaxx-runtime-swing-widget
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+-->
<Table fill='both' insets='0'
onFocusGained='combobox.requestFocus()'
onFocusLost='hidePopup()'>
@@ -2,3 +24,2 @@
-<!--fill='both' insets='0'-->
<!-- auto complete property -->
@@ -42,7 +63,7 @@
<String id='popupTitleText' javaBean='null'/>
- <String id='i18nPrefix' javaBean='"observe.common."'/>
+ <String id='i18nPrefix' javaBean='"entitycombobox.common."'/>
<!-- popup to change sorted property-->
<JPopupMenu id='popup'
Modified: trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java
===================================================================
--- trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java 2009-07-24 08:00:05 UTC (rev 1509)
+++ trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java 2009-07-27 20:26:02 UTC (rev 1510)
@@ -1,3 +1,21 @@
+/**
+ * *##% jaxx-runtime-swing-widget
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
package jaxx.runtime.swing;
import java.awt.Component;
@@ -306,7 +324,6 @@
//Container container = ui.getIndexesContainer();
for (int i = 0, max = decorator.getNbContext(); i < max; i++) {
String property = ui.getI18nPrefix() + decorator.getProperty(i);
-// String property = "observe.common." + decorator.getProperty(i);
String propertyI18n = _(property);
JRadioButtonMenuItem button = new JRadioButtonMenuItem(propertyI18n);
button.putClientProperty(JAXXButtonGroup.BUTTON8GROUP_CLIENT_PROPERTY, ui.getIndexes());
@@ -332,7 +349,6 @@
beanI18nKey = n_("entitycombobox.unknown.type");
} else {
beanI18nKey = ui.getI18nPrefix() + Introspector.decapitalize(internalClass.getSimpleName());
- //beanI18nKey = "observe.common." + Introspector.decapitalize(internalClass.getSimpleName());
}
String beanI18n = _(beanI18nKey);
title = _(title, beanI18n);
Modified: trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/ErrorDialogUI.jaxx
===================================================================
--- trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/ErrorDialogUI.jaxx 2009-07-24 08:00:05 UTC (rev 1509)
+++ trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/ErrorDialogUI.jaxx 2009-07-27 20:26:02 UTC (rev 1510)
@@ -1,3 +1,25 @@
+<!--
+
+/**
+ * *##% jaxx-runtime-swing-widget
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+-->
<JDialog title='errorUI.title' modal='true'>
<script><![CDATA[
protected static ErrorDialogUI instance;
Modified: trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/MemoryStatusWidget.jaxx
===================================================================
--- trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/MemoryStatusWidget.jaxx 2009-07-24 08:00:05 UTC (rev 1509)
+++ trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/MemoryStatusWidget.jaxx 2009-07-27 20:26:02 UTC (rev 1510)
@@ -1,4 +1,26 @@
+<!--
+/**
+ * *##% jaxx-runtime-swing-widget
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+-->
+
<JComponent implements='ActionListener'
foreground='{Color.BLACK}'
background='{Color.WHITE}'
@@ -56,7 +78,7 @@
g.fillRect(insets.left, insets.top, (int) ((float) width * fraction), height);
// No i18n string was :
// String str = usedMemory / 1024 + "/" + totalMemory / 1024 + "Mb";
- String str = _("lutinwidget.message.statusbar.memory", usedMemory / 1024, totalMemory / 1024);
+ String str = _("memorywidget.memory", usedMemory / 1024, totalMemory / 1024);
//FontRenderContext frc = new FontRenderContext(null, false, false);
Rectangle2D bounds = g.getFont().getStringBounds(str, frc);
Graphics g2 = g.create();
@@ -88,4 +110,4 @@
}
]]>
</script>
-</JComponent>
\ No newline at end of file
+</JComponent>
Modified: trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/StatusMessagePanel.jaxx
===================================================================
--- trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/StatusMessagePanel.jaxx 2009-07-24 08:00:05 UTC (rev 1509)
+++ trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/StatusMessagePanel.jaxx 2009-07-27 20:26:02 UTC (rev 1510)
@@ -1,4 +1,26 @@
+<!--
+/**
+ * *##% jaxx-runtime-swing-widget
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+-->
+
<Table border='{BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED)}'
insets='0'
implements='ActionListener'>
Modified: trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/StatusMessagePanelHandler.java
===================================================================
--- trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/StatusMessagePanelHandler.java 2009-07-24 08:00:05 UTC (rev 1509)
+++ trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/StatusMessagePanelHandler.java 2009-07-27 20:26:02 UTC (rev 1510)
@@ -1,3 +1,21 @@
+/**
+ * *##% jaxx-runtime-swing-widget
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
package jaxx.runtime.swing;
import java.awt.Color;
Modified: trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/I18nEditor.jaxx
===================================================================
--- trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/I18nEditor.jaxx 2009-07-24 08:00:05 UTC (rev 1509)
+++ trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/I18nEditor.jaxx 2009-07-27 20:26:02 UTC (rev 1510)
@@ -1,4 +1,26 @@
+<!--
+/**
+ * *##% jaxx-runtime-swing-widget
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+-->
+
<JPanel implements='PropertyChangeListener, ActionListener'
id='content'
layout='{new BorderLayout()}'
@@ -186,4 +208,4 @@
]]>
</script>
-</JPanel>
\ No newline at end of file
+</JPanel>
Modified: trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditor.jaxx
===================================================================
--- trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditor.jaxx 2009-07-24 08:00:05 UTC (rev 1509)
+++ trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditor.jaxx 2009-07-27 20:26:02 UTC (rev 1510)
@@ -1,4 +1,26 @@
+<!--
+/**
+ * *##% jaxx-runtime-swing-widget
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+-->
+
<JPanel layout='{new BorderLayout()}'
onFocusGained='textField.requestFocus()'
onFocusLost='setPopupVisible(false);popup.setVisible(false);'
@@ -48,33 +70,33 @@
<JPanel layout='{new GridLayout(4,4)}'
border='{BorderFactory.createEmptyBorder(4, 4, 4, 4)}'
background='{Color.WHITE}'>
- <JButton text='7' onActionPerformed='addChar(event)' styleClass='digit'/>
- <JButton text='8' onActionPerformed='addChar(event)' styleClass='digit'/>
- <JButton text='9' onActionPerformed='addChar(event)' styleClass='digit'/>
+ <JButton text='numbereditor.7' onActionPerformed='addChar(event)' styleClass='digit'/>
+ <JButton text='numbereditor.8' onActionPerformed='addChar(event)' styleClass='digit'/>
+ <JButton text='numbereditor.9' onActionPerformed='addChar(event)' styleClass='digit'/>
<JButton text='numbereditor.clearAll' onActionPerformed='setModel(null)' styleClass='clear'
enabled='{!getModelText().isEmpty()}'/>
- <JButton text='4' onActionPerformed='addChar(event)' styleClass='digit'/>
- <JButton text='5' onActionPerformed='addChar(event)' styleClass='digit'/>
- <JButton text='6' onActionPerformed='addChar(event)' styleClass='digit'/>
+ <JButton text='numbereditor.4' onActionPerformed='addChar(event)' styleClass='digit'/>
+ <JButton text='numbereditor.5' onActionPerformed='addChar(event)' styleClass='digit'/>
+ <JButton text='numbereditor.6' onActionPerformed='addChar(event)' styleClass='digit'/>
<JButton text='numbereditor.clearOne' onActionPerformed='getHandler().removeChar()' styleClass='clear'
enabled='{!(getModelText().isEmpty() || textField.getCaretPosition() ==0 )}'/>
- <JButton text='1' onActionPerformed='addChar(event)' styleClass='digit'/>
- <JButton text='2' onActionPerformed='addChar(event)' styleClass='digit'/>
- <JButton text='3' onActionPerformed='addChar(event)' styleClass='digit'/>
+ <JButton text='numbereditor.1' onActionPerformed='addChar(event)' styleClass='digit'/>
+ <JButton text='numbereditor.2' onActionPerformed='addChar(event)' styleClass='digit'/>
+ <JButton text='numbereditor.3' onActionPerformed='addChar(event)' styleClass='digit'/>
<JButton enabled="false"/>
- <JButton text='0' onActionPerformed='addChar(event)' styleClass='digit'
+ <JButton text='numbereditor.0' onActionPerformed='addChar(event)' styleClass='digit'
enabled='{!getEditor().getModelText().equals("0")}'/>
<JButton id='toggleSign' text='numbereditor.toggleSign' styleClass='operator'
onActionPerformed='getHandler().toggleSign()'
enabled='{isUseSign() && !getEditor().getModelText().isEmpty()}'/>
- <JButton id='dot' text='.' styleClass='operator'
+ <JButton id='dot' text='numbereditor..' styleClass='operator'
onActionPerformed='addChar(event)'
enabled='{isUseFloat() && getEditor().getModelText().indexOf(".") == -1 }'/>
@@ -127,13 +149,6 @@
onKeyReleased='getHandler().setModel(textField.getText())'
onFocusGained='showPopup()'/>
- <!--JFormattedTextField id='textField' constraints='BorderLayout.CENTER'
- text='{getModelText()}'
- enabled='{isEnabled()}'
- onKeyReleased='getHandler().setModel(textField.getText())'
- focusLostBehavior='0'
- onFocusGained='showPopup()'/-->
-
<JToolBar constraints='BorderLayout.EAST'
floatable='false'
opaque='false'
@@ -149,4 +164,4 @@
onActionPerformed='getHandler().setPopupVisible(!popup.isVisible())'/>
</JToolBar>
-</JPanel>
\ No newline at end of file
+</JPanel>
Modified: trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java
===================================================================
--- trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java 2009-07-24 08:00:05 UTC (rev 1509)
+++ trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java 2009-07-27 20:26:02 UTC (rev 1510)
@@ -1,3 +1,21 @@
+/**
+ * *##% jaxx-runtime-swing-widget
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
package jaxx.runtime.swing.editor;
import java.awt.Dimension;
Modified: trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditorPopup.css
===================================================================
--- trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditorPopup.css 2009-07-24 08:00:05 UTC (rev 1509)
+++ trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditorPopup.css 2009-07-27 20:26:02 UTC (rev 1510)
@@ -1,3 +1,21 @@
+/**
+ * *##% jaxx-runtime-swing-widget
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
JButton {
font-size: 14;
focusPainted: false;
Modified: trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/TimeEditor.css
===================================================================
--- trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/TimeEditor.css 2009-07-24 08:00:05 UTC (rev 1509)
+++ trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/TimeEditor.css 2009-07-27 20:26:02 UTC (rev 1510)
@@ -1,3 +1,21 @@
+/**
+ * *##% jaxx-runtime-swing-widget
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
#title{
text:{getLabel()};
horizontalAlignment:center;
@@ -10,7 +28,7 @@
}
#labelH {
- text:"H";
+ text:"timeeditor.H";
horizontalAlignment:center;
}
#minute{
Modified: trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/TimeEditor.jaxx
===================================================================
--- trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/TimeEditor.jaxx 2009-07-24 08:00:05 UTC (rev 1509)
+++ trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/TimeEditor.jaxx 2009-07-27 20:26:02 UTC (rev 1510)
@@ -1,4 +1,26 @@
+<!--
+/**
+ * *##% jaxx-runtime-swing-widget
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+-->
+
<JPanel layout='{new BorderLayout()}'>
<style source='TimeEditor.css'/>
Modified: trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/TimeEditorHandler.java
===================================================================
--- trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/TimeEditorHandler.java 2009-07-24 08:00:05 UTC (rev 1509)
+++ trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/TimeEditorHandler.java 2009-07-27 20:26:02 UTC (rev 1510)
@@ -1,3 +1,21 @@
+/**
+ * *##% jaxx-runtime-swing-widget
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
package jaxx.runtime.swing.editor;
import java.awt.event.MouseAdapter;
Modified: trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties
===================================================================
--- trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties 2009-07-24 08:00:05 UTC (rev 1509)
+++ trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties 2009-07-27 20:26:02 UTC (rev 1510)
@@ -1,15 +1,39 @@
-.=.
-0=0
-1=1
-2=2
-3=3
-4=4
-5=5
-6=6
-7=7
-8=8
-9=9
-H=H
+aboutframe.about=About
+aboutframe.license=License
+aboutframe.ok=OK
+aboutframe.thirdparty=Third party
+columnselection.action.tip=
+columnselector.action.tip=
+config.action.quit=Quit
+config.action.quit.tip=Quit the configuration editor
+config.action.reset=Cancel
+config.action.reset.tip=Cancel the modifications for the category
+config.action.save=Save
+config.action.save.tip=Save the modifications for the category
+config.choice.cancel=Cancel
+config.choice.continue=Continue
+config.choice.doNotSave=Do not save
+config.choice.save=Save
+config.defaultValue=Default value
+config.defaultValue.tip=Default value of the option
+config.descrition=Description
+config.error.category.already.exists=category with name '%1$s' does already exist\!
+config.error.category.not.found=category with name '%1$s' does not exist\!
+config.key=Key
+config.key.tip=Key of the option
+config.message.quit.invalid.category=The category '%1$s' is not valid\!
+config.message.quit.valid.and.modified.category=The category '%1$s' has some modified options \:
+config.modified=Option was modified (previous value \: %1$s)
+config.no.option.selected=< No selected option >
+config.option.final=This option can not be modified
+config.option.label=Option '%1$s' (%2$s)
+config.option.modified=Value is modified < original value \: '%1$s' - new value \: '%2$s' >
+config.title=Preferences
+config.title.need.confirm=A confirmation is required
+config.unmodifiable=Can not be modified
+config.unvalid=Option is not valid \! (previous value \: %1$s, required type \: %2$s)
+config.value=Value
+config.value.tip=Value of the option
entitycombobox.action.reset.tip=Reset the selected value
entitycombobox.action.sort.tip=Change the sorted property
entitycombobox.popup.label=Object '%1$s'
@@ -24,13 +48,21 @@
i18neditor.popup.title=Change language
i18neditor.selected=Selected language \: %1$s
i18neditor.unselected=Select this langage \: %1$s
-lutinwidget.aboutframe.about=About
-lutinwidget.aboutframe.license=License
-lutinwidget.aboutframe.ok=OK
-lutinwidget.aboutframe.thirdparty=Third party
-lutinwidget.message.statusbar.memory=%d/%dMb
+memorywidget.memory=%d/%dMb
+numbereditor..=.
+numbereditor.0=0
+numbereditor.1=1
+numbereditor.2=2
+numbereditor.3=3
+numbereditor.4=4
+numbereditor.5=5
+numbereditor.6=6
+numbereditor.7=7
+numbereditor.8=8
+numbereditor.9=9
numbereditor.action.reset.tip=Reset
numbereditor.action.show.tip=Show numeric panel
numbereditor.clearAll=C
numbereditor.clearOne=CE
numbereditor.toggleSign=+/-
+timeeditor.H=H
Modified: trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties
===================================================================
--- trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties 2009-07-24 08:00:05 UTC (rev 1509)
+++ trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties 2009-07-27 20:26:02 UTC (rev 1510)
@@ -1,15 +1,40 @@
-.=.
-0=0
-1=1
-2=2
-3=3
-4=4
-5=5
-6=6
-7=7
-8=8
-9=9
-H=H
+aboutframe.about=\u00C0 propos
+aboutframe.license=Licence
+aboutframe.ok=OK
+aboutframe.thirdparty=Tierce partie
+columnselection.action.tip=
+columnselector.action.tip=
+config.action.quit=Quitter
+config.action.quit.tip=Quitter l'\u00E9diteur de configuration
+config.action.reset=Annuler
+config.action.reset.tip=Annuler les modifications de cette cat\u00E9gorie
+config.action.save=Enregistrer
+config.action.save.tip=Sauver les modifications de cette cat\u00E9gorie
+config.choice.cancel=Annuler
+config.choice.continue=Continuer
+config.choice.doNotSave=Ne pas enregistrer
+config.choice.save=Enregistrer
+config.defaultValue=Valeur par d\u00E9faut
+config.defaultValue.tip=Valeur par d\u00E9faut de l'option
+config.descrition=Description
+config.error.category.already.exists=La cat\u00E9gorie de nom '%1$s' existe d\u00E9j\u00E0\!
+config.error.category.not.found=La cat\u00E9gorie de nom '%1$s' n'existe pas\!
+config.key=Clef
+config.key.tip=Clef de l'option
+config.message.quit.invalid.category=La cat\u00E9gorie '%1$s' n'est pas valide\!
+config.message.quit.valid.and.modified.category=La cat\u00E9gorie '%1$s' poss\u00E8dent des options modifi\u00E9es \:
+config.modified=Option modifi\u00E9e (valeur originale \: %1$s)
+config.no.option.selected=< Pas d'option s\u00E9lectionn\u00E9e >
+config.option.final=Option non modifiable
+config.option.label=Option '%1$s' (%2$s)
+config.option.modified=Valeur modifi\u00E9e < nouvelle valeur \: '%1$s' - ancienne valeur \: '%2$s' >
+config.option.valid=Valeur non valide
+config.title=Pr\u00E9f\u00E9rences
+config.title.need.confirm=Une confirmation de votre part est requise...
+config.unmodifiable=Ne peut pas \u00EAtre modifi\u00E9
+config.unvalid=Option non valide (valeur originale \: %1$s, type requis \: %2$s)
+config.value=Valeur
+config.value.tip=Valeur de l'option
entitycombobox.action.reset.tip=R\u00E9initialiser la valeur de la liste d\u00E9roulante
entitycombobox.action.sort.tip=Modifier le tri de la liste d\u00E9roulante
entitycombobox.popup.label=Objet '%1$s'
@@ -24,13 +49,21 @@
i18neditor.popup.title=Changer de langue
i18neditor.selected=Langue actuellement utilis\u00E9e \: %1$s
i18neditor.unselected=Pour utiliser cette langue \: %1$s
-lutinwidget.aboutframe.about=\u00C0 propos
-lutinwidget.aboutframe.license=Licence
-lutinwidget.aboutframe.ok=OK
-lutinwidget.aboutframe.thirdparty=Tierce partie
-lutinwidget.message.statusbar.memory=%d/%dMo
+memorywidget.memory=%d/%dMo
+numbereditor..=.
+numbereditor.0=0
+numbereditor.1=1
+numbereditor.2=2
+numbereditor.3=3
+numbereditor.4=4
+numbereditor.5=5
+numbereditor.6=6
+numbereditor.7=7
+numbereditor.8=8
+numbereditor.9=9
numbereditor.action.reset.tip=R\u00E9initialiser
numbereditor.action.show.tip=Afficher le pav\u00E9 num\u00E9rique
numbereditor.clearAll=C
numbereditor.clearOne=CE
numbereditor.toggleSign=+/-
+timeeditor.H=H
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-07-24 08:00:05 UTC (rev 1509)
+++ trunk/pom.xml 2009-07-27 20:26:02 UTC (rev 1510)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom</artifactId>
- <version>1.0.0-rc-4</version>
+ <version>1.0.0-rc-5-SNAPSHOT</version>
</parent>
<artifactId>jaxx</artifactId>
@@ -172,8 +172,8 @@
<!-- pour un muli module on doit fixer le projectId -->
<projectId>jaxx</projectId>
- <lutinutil.version>1.1.0-rc-8</lutinutil.version>
- <i18n.version>1.0.0-rc-4</i18n.version>
+ <lutinutil.version>1.1.0-rc-9-SNAPSHOT</lutinutil.version>
+ <i18n.version>1.0.0-rc-5-SNAPSHOT</i18n.version>
</properties>
1
0
r1532 - in trunk/guix-compiler-swing/src: main/java/org/nuiton/guix main/java/org/nuiton/guix/events main/java/org/nuiton/guix/generator test/java test/java/org test/java/org/nuiton test/java/org/nuiton/guix
by kmorin@users.labs.libre-entreprise.org 27 Jul '09
by kmorin@users.labs.libre-entreprise.org 27 Jul '09
27 Jul '09
Author: kmorin
Date: 2009-07-27 14:37:53 +0200 (Mon, 27 Jul 2009)
New Revision: 1532
Added:
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/SwingEventHandler.java
trunk/guix-compiler-swing/src/test/java/org/
trunk/guix-compiler-swing/src/test/java/org/nuiton/
trunk/guix-compiler-swing/src/test/java/org/nuiton/guix/
trunk/guix-compiler-swing/src/test/java/org/nuiton/guix/SwingEventHandlerTest.java
Removed:
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/events/SwingEventHandler.java
Modified:
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingAbstractClassGenerator.java
Log:
add not null parameters condition in SwingEventHandler's addEvent method
+ add test for SwingEventHandler methods
Copied: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/SwingEventHandler.java (from rev 1518, trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/events/SwingEventHandler.java)
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/SwingEventHandler.java (rev 0)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/SwingEventHandler.java 2009-07-27 12:37:53 UTC (rev 1532)
@@ -0,0 +1,157 @@
+/**
+ * *##% guix-compiler-swing
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+package org.nuiton.guix;
+
+import java.beans.BeanInfo;
+import java.beans.EventSetDescriptor;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Handles the Swing events
+ *
+ * @author kmorin
+ */
+public class SwingEventHandler {
+
+ /** log */
+ Log log = LogFactory.getLog(SwingEventHandler.class);
+ /** Maps EventSetDescriptors with a map of the listener method and actions to execute */
+ Map<EventSetDescriptor, Map<Method, String>> map = new HashMap<EventSetDescriptor, Map<Method, String>>();
+
+ /**
+ * Add an event to the map
+ *
+ * @param clazz the class of the object supposed to listen to the event
+ * @param name name of the event
+ * @param value code to execute when the events occurs
+ * @return true if the name corresponds with an event
+ * @throws java.beans.IntrospectionException if the JVM failed while getting the bean infos of the class
+ */
+ public boolean addEvent(Class clazz, String name, String value) throws IntrospectionException {
+ if(clazz == null || name == null || value == null) {
+ return false;
+ }
+
+ //get the bean info of the class
+ BeanInfo bi = Introspector.getBeanInfo(clazz);
+ //get the array of EventSetDescriptor of the class
+ EventSetDescriptor[] esds = bi.getEventSetDescriptors();
+
+ int i = 0;
+ int j = 0;
+ EventSetDescriptor esd = null;
+ Method method = null;
+
+ //while any event with the name "name" has been found, browse the EventSetDescriptors
+ while (i < esds.length && method == null) {
+ j = 0;
+ //get the listener methods of the EventSetDescriptor
+ Method[] methods = esds[i].getListenerMethods();
+ while (j < esds[i].getListenerMethods().length && method == null) {
+ if(methods[j].getName().equals(name)) {
+ method = methods[j];
+ esd = esds[i];
+ }
+ j++;
+ }
+ i++;
+ }
+ //if the event has been found in the bean info
+ if (method != null) {
+ //remove braces
+ while(value.startsWith("{") && value.endsWith("}")) {
+ value = value.substring(1, value.length() - 1);
+ }
+ //add final semicolon
+ if(!value.endsWith(";"))
+ value += ";";
+ //if the EventSetDescriptor has not been yet recorded for another event
+ if (map.get(esd) == null) {
+ Map<Method, String> methods = new HashMap<Method, String>();
+ methods.put(method, value);
+ map.put(esd, methods);
+ }
+ else if(map.get(esd).get(method) != null) {
+ map.get(esd).put(method, map.get(esd).get(method) + value);
+ }
+ else {
+ map.get(esd).put(method, value);
+ }
+ }
+ else
+ if(log.isWarnEnabled())
+ log.warn("Event " + name + " not found.");
+ return method != null;
+ }
+
+ /**
+ * Generates the code for all the events applied to an object
+ *
+ * @param object the objects to add the listeners
+ * @return the generated code
+ */
+ public String generate(String object) {
+ //result
+ StringBuffer result = new StringBuffer();
+ //for every EventSetDescriptor
+ for (EventSetDescriptor e : map.keySet()) {
+ //add new ListenerMethod
+ result.append(object)
+ .append(".")
+ .append(e.getAddListenerMethod().getName())
+ .append("(new ")
+ //if only one event is handled for this EventSetDescriptor then add a listener, else add an adapter
+ .append(e.getListenerMethods().length == 1 ?
+ e.getListenerType().getCanonicalName() :
+ e.getListenerType().getCanonicalName().replace("Listener", "Adapter"))
+ .append("() {\n");
+ //for every event handled for the EventSetDescriptor
+ for(Method m : map.get(e).keySet()) {
+ for(Annotation a : m.getDeclaredAnnotations())
+ result.append(a.toString()).append("\n");
+ //add the method that handles the event
+ result.append("public ")
+ .append(m.getReturnType().getCanonicalName())
+ .append(" ")
+ .append(m.getName())
+ .append("(");
+ for(Class clazz : m.getParameterTypes())
+ result.append(clazz.getCanonicalName())
+ .append(" ")
+ .append(Character.toLowerCase(clazz.getName().charAt(clazz.getName().lastIndexOf('.') + 1)))
+ .append(clazz.getName().substring(clazz.getName().lastIndexOf('.') + 2))
+ .append(", ");
+ result.delete(result.length() - 2, result.length())
+ .append(")")
+ .append("{\n")
+ .append(map.get(e).get(m))
+ .append("\n}\n");
+ }
+ result.append("});\n\n");
+ }
+ return result.toString();
+ }
+}
Property changes on: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/SwingEventHandler.java
___________________________________________________________________
Added: svn:mergeinfo
+
Deleted: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/events/SwingEventHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/events/SwingEventHandler.java 2009-07-27 12:37:18 UTC (rev 1531)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/events/SwingEventHandler.java 2009-07-27 12:37:53 UTC (rev 1532)
@@ -1,152 +0,0 @@
-/**
- * *##% guix-compiler-swing
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-package org.nuiton.guix.events;
-
-import java.beans.BeanInfo;
-import java.beans.EventSetDescriptor;
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Handles the Swing events
- *
- * @author kmorin
- */
-public class SwingEventHandler {
-
- /** log */
- Log log = LogFactory.getLog(SwingEventHandler.class);
- /** Maps EventSetDescriptors with a map of the listener method and actions to execute */
- Map<EventSetDescriptor, Map<Method, String>> map = new HashMap<EventSetDescriptor, Map<Method, String>>();
-
- /**
- * Add an event to the map
- *
- * @param clazz the class of the object...
- * @param name name of the event
- * @param value code to execute when the events occurs
- * @return true if the name corresponds with an event
- * @throws java.beans.IntrospectionException if the JVM failed while getting the bean infos of the class
- */
- public boolean addEvent(Class clazz, String name, String value) throws IntrospectionException {
- //get the bean info of the class
- BeanInfo bi = Introspector.getBeanInfo(clazz);
- //get the array of EventSetDescriptor of the class
- EventSetDescriptor[] esds = bi.getEventSetDescriptors();
-
- int i = 0;
- int j = 0;
- EventSetDescriptor esd = null;
- Method method = null;
-
- //while any event with the name "name" has been found, browse the EventSetDescriptors
- while (i < esds.length && method == null) {
- j = 0;
- //get the listener methods of the EventSetDescriptor
- Method[] methods = esds[i].getListenerMethods();
- while (j < esds[i].getListenerMethods().length && method == null) {
- if(methods[j].getName().equals(name)) {
- method = methods[j];
- esd = esds[i];
- }
- j++;
- }
- i++;
- }
- //if the event has been found in the bean info
- if (method != null) {
- //remove braces
- while(value.startsWith("{") && value.endsWith("}"))
- value = value.substring(1, value.length() - 1);
- //add final semicolon
- if(!value.endsWith(";"))
- value += ";";
- //if the EventSetDescriptor has not been yet recorded for another event
- if (map.get(esd) == null) {
- Map<Method, String> methods = new HashMap<Method, String>();
- methods.put(method, value);
- map.put(esd, methods);
- }
- else if(map.get(esd).get(method) != null) {
- map.get(esd).put(method, map.get(esd).get(method) + value);
- }
- else {
- map.get(esd).put(method, value);
- }
- }
- else
- if(log.isWarnEnabled())
- log.warn("Event " + name + " not found.");
- return method != null;
- }
-
- /**
- * Generates the code for all the events applied to an object
- *
- * @param object the objects to add the listeners
- * @return the generated code
- */
- public String generate(String object) {
- //result
- StringBuffer result = new StringBuffer();
- //for every EventSetDescriptor
- for (EventSetDescriptor e : map.keySet()) {
- //add new ListenerMethod
- result.append(object)
- .append(".")
- .append(e.getAddListenerMethod().getName())
- .append("(new ")
- //if only one event is handled for this EventSetDescriptor then add a listener, else add an adapter
- .append(e.getListenerMethods().length == 1 ?
- e.getListenerType().getCanonicalName() :
- e.getListenerType().getCanonicalName().replace("Listener", "Adapter"))
- .append("() {\n");
- //for every event handled for the EventSetDescriptor
- for(Method m : map.get(e).keySet()) {
- for(Annotation a : m.getDeclaredAnnotations())
- result.append(a.toString()).append("\n");
- //add the method that handles the event
- result.append("public ")
- .append(m.getReturnType().getCanonicalName())
- .append(" ")
- .append(m.getName())
- .append("(");
- for(Class clazz : m.getParameterTypes())
- result.append(clazz.getCanonicalName())
- .append(" ")
- .append(Character.toLowerCase(clazz.getName().charAt(clazz.getName().lastIndexOf('.') + 1)))
- .append(clazz.getName().substring(clazz.getName().lastIndexOf('.') + 2))
- .append(", ");
- result.delete(result.length() - 2, result.length())
- .append(")")
- .append("{\n")
- .append(map.get(e).get(m))
- .append("\n}\n");
- }
- result.append("});\n\n");
- }
- return result.toString();
- }
-}
Modified: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingAbstractClassGenerator.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingAbstractClassGenerator.java 2009-07-27 12:37:18 UTC (rev 1531)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingAbstractClassGenerator.java 2009-07-27 12:37:53 UTC (rev 1532)
@@ -34,7 +34,7 @@
import java.util.Map;
import java.util.Map.Entry;
import org.nuiton.guix.databinding.BindingUtils;
-import org.nuiton.guix.events.SwingEventHandler;
+import org.nuiton.guix.SwingEventHandler;
import org.nuiton.guix.model.AttributeDescriptor;
import org.nuiton.guix.model.ClassDescriptor;
import org.nuiton.guix.model.Rule;
@@ -539,7 +539,7 @@
* Transform the css attributes into AttributeDescriptors
*
* @param gmo the GuixModelObject which has got the css attributes
- * @param seh a SwingEventHandler
+ * @param seh a SwingEventHandlerTest
* @param clazz gmo's class
*/
private void processCSSAttributes(GuixModelObject gmo, SwingEventHandler seh, Class clazz) {
Added: trunk/guix-compiler-swing/src/test/java/org/nuiton/guix/SwingEventHandlerTest.java
===================================================================
--- trunk/guix-compiler-swing/src/test/java/org/nuiton/guix/SwingEventHandlerTest.java (rev 0)
+++ trunk/guix-compiler-swing/src/test/java/org/nuiton/guix/SwingEventHandlerTest.java 2009-07-27 12:37:53 UTC (rev 1532)
@@ -0,0 +1,79 @@
+/**
+ * *##% guix-compiler-swing
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+package org.nuiton.guix;
+
+import java.beans.IntrospectionException;
+import javax.swing.JComponent;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Test;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * Tests the methods of the class SwingEventTestHandler
+ *
+ * @author kmorin
+ */
+public class SwingEventHandlerTest {
+
+ Log log = LogFactory.getLog(SwingEventHandlerTest.class);
+
+ /**
+ * Tests the method addEvent
+ */
+ @Test
+ public void testAddEvent() {
+ SwingEventHandler seh = new SwingEventHandler();
+ try {
+ assertFalse(seh.addEvent(null, "", ""));
+ assertFalse(seh.addEvent(JComponent.class, null, ""));
+ assertFalse(seh.addEvent(JComponent.class, "", null));
+ assertTrue(seh.addEvent(JComponent.class, "propertyChange", "test1"));
+ assertTrue(seh.addEvent(JComponent.class, "propertyChange", "test2"));
+ assertFalse(seh.addEvent(JComponent.class, "azerty", ""));
+ }
+ catch (IntrospectionException eee) {
+ if(log.isErrorEnabled()) {
+ log.error(eee);
+ }
+ }
+ }
+
+ /**
+ * Tests the method generate
+ */
+ @Test
+ public void testGenerate() {
+ SwingEventHandler seh = new SwingEventHandler();
+ try {
+ assertNotNull(seh.generate(""));
+ assertEquals(seh.generate(""), "");
+ seh.addEvent(JComponent.class, "propertyChange", "");
+ assertTrue(seh.generate("").length() > 0);
+ }
+ catch (IntrospectionException eee) {
+ if(log.isErrorEnabled()) {
+ log.error(eee);
+ }
+ }
+ }
+}
1
0
r1531 - in trunk/guix-compiler-gwt/src: main/java/org/nuiton/guix main/java/org/nuiton/guix/events main/java/org/nuiton/guix/generator test/java test/java/org test/java/org/nuiton test/java/org/nuiton/guix
by kmorin@users.labs.libre-entreprise.org 27 Jul '09
by kmorin@users.labs.libre-entreprise.org 27 Jul '09
27 Jul '09
Author: kmorin
Date: 2009-07-27 14:37:18 +0200 (Mon, 27 Jul 2009)
New Revision: 1531
Added:
trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/GwtEventHandler.java
trunk/guix-compiler-gwt/src/test/java/org/
trunk/guix-compiler-gwt/src/test/java/org/nuiton/
trunk/guix-compiler-gwt/src/test/java/org/nuiton/guix/
trunk/guix-compiler-gwt/src/test/java/org/nuiton/guix/GwtEventHandlerTest.java
Removed:
trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/events/GwtEventHandler.java
Modified:
trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtAbstractClassGenerator.java
Log:
add not null parameters condition in GwtEventHandler's addEvent method
+ add test for GwtEventHandler methods
Copied: trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/GwtEventHandler.java (from rev 1518, trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/events/GwtEventHandler.java)
===================================================================
--- trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/GwtEventHandler.java (rev 0)
+++ trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/GwtEventHandler.java 2009-07-27 12:37:18 UTC (rev 1531)
@@ -0,0 +1,150 @@
+/**
+ * *##% guix-compiler-gwt
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+package org.nuiton.guix;
+
+import java.beans.BeanInfo;
+import java.beans.EventSetDescriptor;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Handles the events of GWT
+ *
+ * @author kmorin
+ */
+public class GwtEventHandler {
+ /** log */
+ Log log = LogFactory.getLog(GwtEventHandler.class);
+ /** Maps EventSetDescriptors with a map of the listener method and actions to execute */
+ Map<EventSetDescriptor, Map<Method, String>> map = new HashMap<EventSetDescriptor, Map<Method, String>>();
+
+ /**
+ * Add an event to the map
+ *
+ * @param clazz the class of the object...
+ * @param name name of the event
+ * @param value code to execute when the events occurs
+ * @return true if the name corresponds with an event
+ * @throws java.beans.IntrospectionException if the JVM failed while getting the bean infos of the class
+ */
+ public boolean addEvent(Class clazz, String name, String value) throws IntrospectionException {
+ if(clazz == null || name == null || value == null) {
+ return false;
+ }
+ //get the bean info of the class
+ BeanInfo bi = Introspector.getBeanInfo(clazz);
+ //get the array of EventSetDescriptor of the class
+ EventSetDescriptor[] esds = bi.getEventSetDescriptors();
+
+ int i = 0;
+ int j = 0;
+ EventSetDescriptor esd = null;
+ Method method = null;
+
+ //while any event with the name "name" has been found, browse the EventSetDescriptors
+ while (i < esds.length && method == null) {
+ j = 0;
+ //get the listener methods of the EventSetDescriptor
+ Method[] methods = esds[i].getAddListenerMethod().getParameterTypes()[0].getMethods();
+ while (j < methods.length && method == null) {
+ if(methods[j].getName().equals(name)) {
+ method = methods[j];
+ esd = esds[i];
+ }
+ j++;
+ }
+ i++;
+ }
+ //if the event has been found in the bean info
+ if (method != null) {
+ //remove braces
+ while(value.startsWith("{") && value.endsWith("}"))
+ value = value.substring(1, value.length() - 1);
+ //add final semicolon
+ if(!value.endsWith(";"))
+ value += ";";
+ //if the EventSetDescriptor has not been yet recorded for another event
+ if (map.get(esd) == null) {
+ Map<Method, String> methods = new HashMap<Method, String>();
+ methods.put(method, value);
+ map.put(esd, methods);
+ }
+ else {
+ map.get(esd).put(method, value);
+ }
+ }
+ else if(log.isWarnEnabled()) {
+ log.warn("Event " + name + " not found.");
+ }
+ return method != null;
+ }
+
+ /**
+ * Generates the code for all the events applied to an object
+ *
+ * @param object the objects to add the listeners
+ * @return the generated code
+ */
+ public String generate(String object) {
+ //result
+ StringBuffer result = new StringBuffer();
+ //for each EventSetDescriptor
+ for (EventSetDescriptor e : map.keySet()) {
+ //add new ListenerMethod
+ result.append(object)
+ .append(".")
+ .append(e.getAddListenerMethod().getName())
+ .append("(new ")
+ .append(e.getListenerType().getCanonicalName())
+ //if only one event is handled for this EventSetDescriptor then add a listener, else add an adapter
+ .append(e.getAddListenerMethod().getParameterTypes()[0].getMethods().length == 1 ? "" : "Adapter")
+ .append("() {\n");
+ //for every event handled for the EventSetDescriptor
+ for(Method m : map.get(e).keySet()) {
+ for(Annotation a : m.getDeclaredAnnotations())
+ result.append(a.toString()).append("\n");
+ //add the method that handles the event
+ result.append("public ")
+ .append(m.getReturnType().getCanonicalName())
+ .append(" ")
+ .append(m.getName())
+ .append("(");
+ for(int n = 0 ; n < m.getParameterTypes().length ; n++) {
+ result.append(m.getParameterTypes()[n].getCanonicalName())
+ .append(" arg")
+ .append(n)
+ .append(", ");
+ }
+ result.delete(result.length() - 2, result.length())
+ .append(")")
+ .append("{\n")
+ .append(map.get(e).get(m))
+ .append("\n}\n");
+ }
+ result.append("});\n\n");
+ }
+ return result.toString();
+ }
+}
Property changes on: trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/GwtEventHandler.java
___________________________________________________________________
Added: svn:mergeinfo
+
Deleted: trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/events/GwtEventHandler.java
===================================================================
--- trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/events/GwtEventHandler.java 2009-07-27 07:29:15 UTC (rev 1530)
+++ trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/events/GwtEventHandler.java 2009-07-27 12:37:18 UTC (rev 1531)
@@ -1,147 +0,0 @@
-/**
- * *##% guix-compiler-gwt
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-package org.nuiton.guix.events;
-
-import java.beans.BeanInfo;
-import java.beans.EventSetDescriptor;
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Handles the events of GWT
- *
- * @author kmorin
- */
-public class GwtEventHandler {
- /** log */
- Log log = LogFactory.getLog(GwtEventHandler.class);
- /** Maps EventSetDescriptors with a map of the listener method and actions to execute */
- Map<EventSetDescriptor, Map<Method, String>> map = new HashMap<EventSetDescriptor, Map<Method, String>>();
-
- /**
- * Add an event to the map
- *
- * @param clazz the class of the object...
- * @param name name of the event
- * @param value code to execute when the events occurs
- * @return true if the name corresponds with an event
- * @throws java.beans.IntrospectionException if the JVM failed while getting the bean infos of the class
- */
- public boolean addEvent(Class clazz, String name, String value) throws IntrospectionException {
- //get the bean info of the class
- BeanInfo bi = Introspector.getBeanInfo(clazz);
- //get the array of EventSetDescriptor of the class
- EventSetDescriptor[] esds = bi.getEventSetDescriptors();
-
- int i = 0;
- int j = 0;
- EventSetDescriptor esd = null;
- Method method = null;
-
- //while any event with the name "name" has been found, browse the EventSetDescriptors
- while (i < esds.length && method == null) {
- j = 0;
- //get the listener methods of the EventSetDescriptor
- Method[] methods = esds[i].getAddListenerMethod().getParameterTypes()[0].getMethods();
- while (j < methods.length && method == null) {
- if(methods[j].getName().equals(name)) {
- method = methods[j];
- esd = esds[i];
- }
- j++;
- }
- i++;
- }
- //if the event has been found in the bean info
- if (method != null) {
- //remove braces
- while(value.startsWith("{") && value.endsWith("}"))
- value = value.substring(1, value.length() - 1);
- //add final semicolon
- if(!value.endsWith(";"))
- value += ";";
- //if the EventSetDescriptor has not been yet recorded for another event
- if (map.get(esd) == null) {
- Map<Method, String> methods = new HashMap<Method, String>();
- methods.put(method, value);
- map.put(esd, methods);
- }
- else {
- map.get(esd).put(method, value);
- }
- }
- else
- if(log.isWarnEnabled())
- log.warn("Event " + name + " not found.");
- return method != null;
- }
-
- /**
- * Generates the code for all the events applied to an object
- *
- * @param object the objects to add the listeners
- * @return the generated code
- */
- public String generate(String object) {
- //result
- StringBuffer result = new StringBuffer();
- //for each EventSetDescriptor
- for (EventSetDescriptor e : map.keySet()) {
- //add new ListenerMethod
- result.append(object)
- .append(".")
- .append(e.getAddListenerMethod().getName())
- .append("(new ")
- .append(e.getListenerType().getCanonicalName())
- //if only one event is handled for this EventSetDescriptor then add a listener, else add an adapter
- .append(e.getAddListenerMethod().getParameterTypes()[0].getMethods().length == 1 ? "" : "Adapter")
- .append("() {\n");
- //for every event handled for the EventSetDescriptor
- for(Method m : map.get(e).keySet()) {
- for(Annotation a : m.getDeclaredAnnotations())
- result.append(a.toString()).append("\n");
- //add the method that handles the event
- result.append("public ")
- .append(m.getReturnType().getCanonicalName())
- .append(" ")
- .append(m.getName())
- .append("(");
- for(int n = 0 ; n < m.getParameterTypes().length ; n++) {
- result.append(m.getParameterTypes()[n].getCanonicalName())
- .append(" arg")
- .append(n)
- .append(", ");
- }
- result.delete(result.length() - 2, result.length())
- .append(")")
- .append("{\n")
- .append(map.get(e).get(m))
- .append("\n}\n");
- }
- result.append("});\n\n");
- }
- return result.toString();
- }
-}
Modified: trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtAbstractClassGenerator.java
===================================================================
--- trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtAbstractClassGenerator.java 2009-07-27 07:29:15 UTC (rev 1530)
+++ trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtAbstractClassGenerator.java 2009-07-27 12:37:18 UTC (rev 1531)
@@ -30,7 +30,7 @@
import java.util.List;
import java.util.Map;
import org.nuiton.guix.databinding.BindingUtils;
-import org.nuiton.guix.events.GwtEventHandler;
+import org.nuiton.guix.GwtEventHandler;
import org.nuiton.guix.model.AttributeDescriptor;
import org.nuiton.guix.model.ClassDescriptor;
import org.nuiton.guix.model.StyleSheet;
Added: trunk/guix-compiler-gwt/src/test/java/org/nuiton/guix/GwtEventHandlerTest.java
===================================================================
--- trunk/guix-compiler-gwt/src/test/java/org/nuiton/guix/GwtEventHandlerTest.java (rev 0)
+++ trunk/guix-compiler-gwt/src/test/java/org/nuiton/guix/GwtEventHandlerTest.java 2009-07-27 12:37:18 UTC (rev 1531)
@@ -0,0 +1,80 @@
+/**
+ * *##% guix-compiler-swing
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+package org.nuiton.guix;
+
+import com.google.gwt.user.client.ui.FocusWidget;
+import com.google.gwt.user.client.ui.Widget;
+import java.beans.IntrospectionException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Test;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * Tests the methods of the class SwingEventTestHandler
+ *
+ * @author kmorin
+ */
+public class GwtEventHandlerTest {
+
+ Log log = LogFactory.getLog(GwtEventHandlerTest.class);
+
+ /**
+ * Tests the method addEvent
+ */
+ @Test
+ public void testAddEvent() {
+ GwtEventHandler geh = new GwtEventHandler();
+ try {
+ assertFalse(geh.addEvent(null, "", ""));
+ assertFalse(geh.addEvent(Widget.class, null, ""));
+ assertFalse(geh.addEvent(Widget.class, "", null));
+ assertTrue(geh.addEvent(FocusWidget.class, "onClick", "test1"));
+ assertTrue(geh.addEvent(FocusWidget.class, "onClick", "test2"));
+ assertFalse(geh.addEvent(FocusWidget.class, "azerty", ""));
+ }
+ catch (IntrospectionException eee) {
+ if(log.isErrorEnabled()) {
+ log.error(eee);
+ }
+ }
+ }
+
+ /**
+ * Tests the method generate
+ */
+ @Test
+ public void testGenerate() {
+ GwtEventHandler seh = new GwtEventHandler();
+ try {
+ assertNotNull(seh.generate(""));
+ assertEquals(seh.generate(""), "");
+ seh.addEvent(FocusWidget.class, "onClick", "");
+ assertTrue(seh.generate("").length() > 0);
+ }
+ catch (IntrospectionException eee) {
+ if(log.isErrorEnabled()) {
+ log.error(eee);
+ }
+ }
+ }
+}
1
0
r1530 - trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator
by kmorin@users.labs.libre-entreprise.org 27 Jul '09
by kmorin@users.labs.libre-entreprise.org 27 Jul '09
27 Jul '09
Author: kmorin
Date: 2009-07-27 09:29:15 +0200 (Mon, 27 Jul 2009)
New Revision: 1530
Modified:
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingAbstractClassGenerator.java
Log:
removed the content of the initDataBinding method
Modified: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingAbstractClassGenerator.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingAbstractClassGenerator.java 2009-07-24 15:33:15 UTC (rev 1529)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingAbstractClassGenerator.java 2009-07-27 07:29:15 UTC (rev 1530)
@@ -125,9 +125,7 @@
jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", getMethodName(Method.COMPONENTS_TREE), null, null, methodBodies.get(Method.COMPONENTS_TREE), "components layout"));
//add databinding method
- StringBuffer dataBinding = new StringBuffer();
- dataBinding.append(methodBodies.get(Method.DATABINDING_INIT));
- jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", getMethodName(Method.DATABINDING_INIT), null, null, dataBinding.toString(), "initilization of databinding"));
+ jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", getMethodName(Method.DATABINDING_INIT), null, null, "", "initilization of databinding"));
//add script methods
for (JavaMethod m : (List<JavaMethod>) script.get(ScriptPart.METHODS)) {
1
0
r1529 - in trunk/guix-compiler-swing/src/main/java/org/nuiton/guix: generator tags/swing
by kmorin@users.labs.libre-entreprise.org 24 Jul '09
by kmorin@users.labs.libre-entreprise.org 24 Jul '09
24 Jul '09
Author: kmorin
Date: 2009-07-24 17:33:15 +0200 (Fri, 24 Jul 2009)
New Revision: 1529
Modified:
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingAbstractClassGenerator.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingGenerator.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ApplicationHandler.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ButtonHandler.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ComponentHandler.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/FrameHandler.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/LabelHandler.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/MenuBarHandler.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/MenuHandler.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/MenuItemHandler.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/PanelHandler.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/RowHandler.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/SelectableButtonHandler.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TabPanelHandler.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TableHandler.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TextComponentHandler.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TextFieldHandler.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ToggleButtonHandler.java
Log:
Comments + javadoc
Modified: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingAbstractClassGenerator.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingAbstractClassGenerator.java 2009-07-24 15:20:05 UTC (rev 1528)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingAbstractClassGenerator.java 2009-07-24 15:33:15 UTC (rev 1529)
@@ -80,6 +80,7 @@
script = sh.decomposeScript(gmo.getClassDescriptor().getScript());
}
+ @Override
public JavaFile generate() {
super.addImports(gmo);
@@ -171,7 +172,6 @@
private Map<Method, String> browseModelObjects(GuixModelObject gmo) throws ClassNotFoundException {
StringBuffer componentsCreation = new StringBuffer();
StringBuffer componentsTree = new StringBuffer();
- StringBuffer bindings = new StringBuffer();
SwingEventHandler seh = new SwingEventHandler();
//the class represented by gmo
Class clazz = null;
@@ -198,7 +198,7 @@
creationMethod.append(gmo.getId()).append(" = new ")
.append(clazz.getName()).append("(new java.awt.GridBagLayout());\n");
- constraint = processAttributes(clazz, gmo, bindings, creationMethod, null, seh, null, table);
+ constraint = processAttributes(clazz, gmo, creationMethod, null, seh, null, table);
//add the component to its parent
componentsTree.append(gmo.getParent().getId() == null ? "this" : gmo.getParent().getId()).append(".add(").append(gmo.getId());
@@ -242,7 +242,6 @@
Map<Method, String> methodBodies = browseModelObjects(cell.getChildren().get(0));
componentsCreation.append(methodBodies.get(Method.COMPONENTS_CREATION));
componentsTree.append(methodBodies.get(Method.COMPONENTS_TREE));
- bindings.append(methodBodies.get(Method.DATABINDING_INIT));
}
}
}
@@ -251,7 +250,7 @@
componentsCreation.append("create").append(capitalizedId).append("();\n");
}
- //if gmo represnts a menubar tag
+ //if gmo represents a menubar tag
else if (gmo.getClassDescriptor().getPackageName() == null && gmo.getClassDescriptor().getName().equalsIgnoreCase("MenuBar")) {
String capitalizedId = (gmo.getId().length() > 0) ? Character.toUpperCase(gmo.getId().charAt(0)) + gmo.getId().substring(1) : gmo.getId();
StringBuffer creationMethod = new StringBuffer();
@@ -266,7 +265,7 @@
creationMethod.append(gmo.getId()).append(" = new ")
.append(clazz.getName()).append("();\n");
- constraint = processAttributes(clazz, gmo, bindings, creationMethod, null, seh, null, menuBar);
+ constraint = processAttributes(clazz, gmo, creationMethod, null, seh, null, menuBar);
//add the component to its parent
componentsTree.append(gmo.getParent().getId() == null ? "this" : gmo.getParent().getId()).append(".setJMenuBar(").append(gmo.getId()).append(");\n");
@@ -277,13 +276,15 @@
Map<Method, String> methodBodies = browseModelObjects(child);
componentsCreation.append(methodBodies.get(Method.COMPONENTS_CREATION));
componentsTree.append(methodBodies.get(Method.COMPONENTS_TREE));
- bindings.append(methodBodies.get(Method.DATABINDING_INIT));
}
//create the menu
componentsCreation.append("create").append(capitalizedId).append("();\n");
}
else {
+ //TagHandler of gmo's class
TagHandler th = null;
+
+ //check if gmo's class has a TagHandler and get the class to generate instead
if(TagManager.getGuixClassHandler(gmo.getClassDescriptor().getName()) != null) {
try {
th = (TagHandler)TagManager.getGuixClassHandler(gmo.getClassDescriptor().getName()).newInstance();
@@ -300,6 +301,7 @@
}
}
}
+ //check if gmo's superclass has a TagHandler and get the class to generate instead
else if(gmo.getClassDescriptor().getSuperClass() != null && TagManager.getGuixClassHandler(gmo.getClassDescriptor().getSuperClass().getName()) != null) {
try {
th = (TagHandler)TagManager.getGuixClassHandler(gmo.getClassDescriptor().getSuperClass().getName()).newInstance();
@@ -318,7 +320,7 @@
}
ClassDescriptor cd = gmo.getClassDescriptor();
- //while the class hasn't been found and the classDescriptor is not null
+ //while cd represents a generated class, take cd's superclass
while (clazz == null && cd != null) {
try {
//get the class represented by cd
@@ -340,6 +342,7 @@
}
}
+ //if gmo has a TagHandler, add a field to the JavaFile with this TagHandler (used for the databinding generation)
if(gmo.getClassDescriptor().getPackageName() == null
&& th != null && th.getClassToGenerate() != null) {
jf.addField(new JavaField(Modifier.PRIVATE,
@@ -347,6 +350,7 @@
gmo.getId(), gmo.getJavadoc(), th),
true);
}
+ //if gmo is the root ModelObject, it equals "this"
else if(gmo.getId() == null) {
jf.addField(new JavaField(Modifier.PRIVATE,
(classes != null && classes.contains(gmo.getClassDescriptor().toString())) ? gmo.getClassDescriptor().toString() + "Abstract" : gmo.getClassDescriptor().toString(),
@@ -374,7 +378,7 @@
styleSheets.addAll(gmo.getStyleSheets());
}
- constraint = processAttributes(clazz, gmo, bindings, creationMethod, null, seh, null, th);
+ constraint = processAttributes(clazz, gmo, creationMethod, null, seh, null, th);
//if gmo is the child of a cell
if (!((gmo.getParent().getClassDescriptor().getPackageName() == null || gmo.getParent().getClassDescriptor().getPackageName().equals("org.nuiton.guix.tags.swing")) && gmo.getParent().getClassDescriptor().getName().equalsIgnoreCase("Cell"))) {
@@ -414,20 +418,18 @@
styleSheets.addAll(gmo.getStyleSheets());
}
- constraint = processAttributes(clazz, gmo, bindings, null, componentsTree, seh, layoutDefined, th);
+ constraint = processAttributes(clazz, gmo, null, componentsTree, seh, layoutDefined, th);
}
//browse the children of gmo
for (GuixModelObject child : gmo.getChildren()) {
Map<Method, String> methodBodies = browseModelObjects(child);
componentsCreation.append(methodBodies.get(Method.COMPONENTS_CREATION));
componentsTree.append(methodBodies.get(Method.COMPONENTS_TREE));
- bindings.append(methodBodies.get(Method.DATABINDING_INIT));
}
}
Map<Method, String> result = new HashMap<Method, String>();
result.put(Method.COMPONENTS_CREATION, componentsCreation.toString());
result.put(Method.COMPONENTS_TREE, componentsTree.toString());
- result.put(Method.DATABINDING_INIT, bindings.toString());
return result;
}
@@ -437,14 +439,14 @@
*
* @param clazz class represented by gmo
* @param gmo the GuixModelObject which contains the attribute
- * @param bindings the StringBuffer containing the code of the bindings of the attributes of gmo
* @param creationMethod the StringBuffer containing the code of the creation method for the object represented by gmo (null if gmo represents the first tag)
* @param componentsTree the StringBuffer containing the code of the settings of the attribute of the class (null if gmo does not represent the first tag)
* @param seh the event handler
* @param layoutDefined true if a layout has been defined
- * @return
+ * @param th gmo's TagHandler
+ * @return the value of the layout constraint, if any
*/
- private String processAttributes(Class clazz, GuixModelObject gmo, StringBuffer bindings, StringBuffer creationMethod,
+ private String processAttributes(Class clazz, GuixModelObject gmo, StringBuffer creationMethod,
StringBuffer componentsTree, SwingEventHandler seh, Boolean layoutDefined, TagHandler th) {
String constraint = null;
processCSSAttributes(gmo, seh, clazz);
@@ -535,92 +537,99 @@
return constraint;
}
+ /**
+ * Transform the css attributes into AttributeDescriptors
+ *
+ * @param gmo the GuixModelObject which has got the css attributes
+ * @param seh a SwingEventHandler
+ * @param clazz gmo's class
+ */
private void processCSSAttributes(GuixModelObject gmo, SwingEventHandler seh, Class clazz) {
Map<String, String> cssIds = new HashMap<String, String>();
- Map<String, String> cssStyleClasses = new HashMap<String, String>();
- Map<String, String> cssJavaClasses = new HashMap<String, String>();
- List<AttributeDescriptor> ads = new ArrayList<AttributeDescriptor>();
- for (StyleSheet ss : styleSheets) {
- for (Selector sel : ss.getSelectors()) {
- if((sel.getId() == null || sel.getId().equals(gmo.getId()))
- && (sel.getStyleClass() == null || sel.getStyleClass().equals(gmo.getStyleClass()))
- && (sel.getJavaClassName() == null || sel.getJavaClassName().equals(gmo.getClassDescriptor().getName()))) {
- boolean realAttribute = true;
- if (sel.getPseudoClass() != null && sel.getPseudoClass().startsWith("on") && Character.isUpperCase(sel.getPseudoClass().charAt(2))) {
- //the swing event does not start by "on"
- String lowerCaseAttribute = (sel.getPseudoClass().length() > 2) ? Character.toLowerCase(sel.getPseudoClass().charAt(2)) + sel.getPseudoClass().substring(3) : sel.getPseudoClass();
- StringBuffer eventAction = new StringBuffer();
+ Map<String, String> cssStyleClasses = new HashMap<String, String>();
+ Map<String, String> cssJavaClasses = new HashMap<String, String>();
+ List<AttributeDescriptor> ads = new ArrayList<AttributeDescriptor>();
+ for (StyleSheet ss : styleSheets) {
+ for (Selector sel : ss.getSelectors()) {
+ if((sel.getId() == null || sel.getId().equals(gmo.getId()))
+ && (sel.getStyleClass() == null || sel.getStyleClass().equals(gmo.getStyleClass()))
+ && (sel.getJavaClassName() == null || sel.getJavaClassName().equals(gmo.getClassDescriptor().getName()))) {
+ boolean realAttribute = true;
+ if (sel.getPseudoClass() != null && sel.getPseudoClass().startsWith("on") && Character.isUpperCase(sel.getPseudoClass().charAt(2))) {
+ //the swing event does not start by "on"
+ String lowerCaseAttribute = (sel.getPseudoClass().length() > 2) ? Character.toLowerCase(sel.getPseudoClass().charAt(2)) + sel.getPseudoClass().substring(3) : sel.getPseudoClass();
+ StringBuffer eventAction = new StringBuffer();
- for (Rule rule : sel.getRules()) {
- for (Entry<String, String> entry : rule.getProperties().entrySet()) {
- java.lang.reflect.Method[] methods = clazz.getMethods();
- String capitalizedAttribute = (entry.getKey().length() > 0) ? Character.toUpperCase(entry.getKey().charAt(0)) + entry.getKey().substring(1) : entry.getKey();
- int m = 0;
- //checks if the setter for this attribute exists
- while(m < methods.length && !methods[m].getName().equals("set" + capitalizedAttribute)) {
- m++;
- }
- //if yes
- if(m < methods.length) {
- //checks if the parameter of the setter is a String
- boolean addQuote = methods[m].getParameterTypes()[0].equals(String.class);
- //generates the code to set the attribute to object
- eventAction.append(gmo.getId()).append(".set").append(capitalizedAttribute).append("(").append(addQuote ? "\"" : "").append(entry.getValue()).append(addQuote ? "\"" : "").append(");\n");
- }
- else if(log.isErrorEnabled()) {
- log.error(entry.getKey() + " cannot be set.");
- }
- }
+ for (Rule rule : sel.getRules()) {
+ for (Entry<String, String> entry : rule.getProperties().entrySet()) {
+ java.lang.reflect.Method[] methods = clazz.getMethods();
+ String capitalizedAttribute = (entry.getKey().length() > 0) ? Character.toUpperCase(entry.getKey().charAt(0)) + entry.getKey().substring(1) : entry.getKey();
+ int m = 0;
+ //checks if the setter for this attribute exists
+ while(m < methods.length && !methods[m].getName().equals("set" + capitalizedAttribute)) {
+ m++;
}
- try {
- realAttribute = !seh.addEvent(clazz, lowerCaseAttribute, eventAction.toString());
+ //if yes
+ if(m < methods.length) {
+ //checks if the parameter of the setter is a String
+ boolean addQuote = methods[m].getParameterTypes()[0].equals(String.class);
+ //generates the code to set the attribute to object
+ eventAction.append(gmo.getId()).append(".set").append(capitalizedAttribute).append("(").append(addQuote ? "\"" : "").append(entry.getValue()).append(addQuote ? "\"" : "").append(");\n");
+ }
+ else if(log.isErrorEnabled()) {
+ log.error(entry.getKey() + " cannot be set.");
}
- catch (IntrospectionException ex) {
- if(log.isErrorEnabled()) {
- log.error("Error while adding event " + sel.getPseudoClass());
- }
+ }
+ }
+ try {
+ realAttribute = !seh.addEvent(clazz, lowerCaseAttribute, eventAction.toString());
+ }
+ catch (IntrospectionException ex) {
+ if(log.isErrorEnabled()) {
+ log.error("Error while adding event " + sel.getPseudoClass());
+ }
+ }
+ }
+ if(realAttribute) {
+ if (sel.getId() != null && sel.getId().equals(gmo.getId())) {
+ for (Rule rule : sel.getRules()) {
+ for (Entry<String, String> entry : rule.getProperties().entrySet()) {
+ cssIds.put(entry.getKey(), entry.getValue());
}
}
- if(realAttribute) {
- if (sel.getId() != null && sel.getId().equals(gmo.getId())) {
- for (Rule rule : sel.getRules()) {
- for (Entry<String, String> entry : rule.getProperties().entrySet()) {
- cssIds.put(entry.getKey(), entry.getValue());
- }
- }
+ }
+ else if (sel.getStyleClass() != null && sel.getStyleClass().equals(gmo.getStyleClass())) {
+ for (Rule rule : sel.getRules()) {
+ for (Entry<String, String> entry : rule.getProperties().entrySet()) {
+ cssStyleClasses.put(entry.getKey(), entry.getValue());
}
- else if (sel.getStyleClass() != null && sel.getStyleClass().equals(gmo.getStyleClass())) {
- for (Rule rule : sel.getRules()) {
- for (Entry<String, String> entry : rule.getProperties().entrySet()) {
- cssStyleClasses.put(entry.getKey(), entry.getValue());
- }
- }
+ }
+ }
+ else if (sel.getJavaClassName() != null && sel.getJavaClassName().equals(gmo.getClassDescriptor().getName())) {
+ for (Rule rule : sel.getRules()) {
+ for (Entry<String, String> entry : rule.getProperties().entrySet()) {
+ cssJavaClasses.put(entry.getKey(), entry.getValue());
}
- else if (sel.getJavaClassName() != null && sel.getJavaClassName().equals(gmo.getClassDescriptor().getName())) {
- for (Rule rule : sel.getRules()) {
- for (Entry<String, String> entry : rule.getProperties().entrySet()) {
- cssJavaClasses.put(entry.getKey(), entry.getValue());
- }
- }
- }
}
}
}
}
- for(Entry<String, String> entry : cssIds.entrySet()) {
- ads.add(new AttributeDescriptor(entry.getKey(), entry.getValue()));
- }
- for(Entry<String, String> entry : cssStyleClasses.entrySet()) {
- if(!cssIds.containsKey(entry.getKey())) {
- ads.add(new AttributeDescriptor(entry.getKey(), entry.getValue()));
- }
- }
- for(Entry<String, String> entry : cssJavaClasses.entrySet()) {
- if(!cssIds.containsKey(entry.getKey()) && !cssStyleClasses.containsKey(entry.getKey())) {
- ads.add(new AttributeDescriptor(entry.getKey(), entry.getValue()));
- }
- }
- gmo.getAttributeDescriptors().addAll(ads);
+ }
+ }
+ for(Entry<String, String> entry : cssIds.entrySet()) {
+ ads.add(new AttributeDescriptor(entry.getKey(), entry.getValue()));
+ }
+ for(Entry<String, String> entry : cssStyleClasses.entrySet()) {
+ if(!cssIds.containsKey(entry.getKey())) {
+ ads.add(new AttributeDescriptor(entry.getKey(), entry.getValue()));
+ }
+ }
+ for(Entry<String, String> entry : cssJavaClasses.entrySet()) {
+ if(!cssIds.containsKey(entry.getKey()) && !cssStyleClasses.containsKey(entry.getKey())) {
+ ads.add(new AttributeDescriptor(entry.getKey(), entry.getValue()));
+ }
+ }
+ gmo.getAttributeDescriptors().addAll(ads);
}
public Map<String, Map<String, String>> getBindings2Generate() {
Modified: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingGenerator.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingGenerator.java 2009-07-24 15:20:05 UTC (rev 1528)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingGenerator.java 2009-07-24 15:33:15 UTC (rev 1529)
@@ -22,14 +22,11 @@
import java.io.File;
import java.io.IOException;
import java.lang.annotation.Annotation;
-import java.lang.reflect.Array;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import javax.swing.JComponent;
-import javax.swing.JPanel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.guix.tags.TagHandler;
@@ -44,7 +41,7 @@
/** log */
protected Log log = LogFactory.getLog(SwingGenerator.class);
-
+ /** Maps the different generators with the file to save the generated JavaFile */
Map<SwingJavaFileGenerator, File> generators = new HashMap<SwingJavaFileGenerator, File>();
/**
@@ -124,21 +121,38 @@
@Override
public List<Class> generateBindings(StringBuffer dbCreation, StringBuffer dbDeletion, TagHandler prevTh, JavaFile jf, Class clazz,
String[] binding, int i, List<String> alreadyChecked, String methodToInvoke, Map<GuixGenerator,JavaFile> generatedFiles) {
+ //does the attribute or method to bind exists ?
boolean bindingExists = false;
+ //the return type of the binding
String returnType = null;
+ //the getter method for the binding
String getter = null;
+ //the JavaFile to pass as an argument to the next call of this method
JavaFile nextFile = null;
+ //the Class to pass as an argument to the next call of this method
Class nextClazz = null;
+ //the TagHandler of this binding
TagHandler th = null;
+ //ProxyEventInfo model of this binding
String model = null;
+ //Listener to add to the bound object
Class listener = null;
+ //the name of the listener adding method
String addMethod = null;
+ //the name of the listener removing method
String removeMethod = null;
+ //the Listener list result
List<Class> result = new ArrayList<Class>();
-
+
+ String realMethodName = null;
+ String realAttributename = null;
+
+ //if the part of the binding is a method
if(binding[i].endsWith(")")) {
- String realMethodName = binding[i].substring(0, binding[i].indexOf("("));
- String realAttributename = null;
+ //the method name is all what is before the first open bracket
+ realMethodName = binding[i].substring(0, binding[i].indexOf("("));
+ //if the parent of the method has a TagHandler, then check that the method is the generic method name for all the libraries
+ //or if it is the right name, and then determine the corresponding attribute
if(prevTh != null) {
if(binding[i].startsWith("get")) {
realAttributename = prevTh.getAttrToGenerate(Character.toLowerCase(binding[i].charAt(3)) + binding[i].substring(4, binding[i].indexOf("(")));
@@ -153,6 +167,7 @@
}
}
}
+ //if the method name is the real one, get the corresponding attribute name
if(realAttributename == null) {
if(binding[i].startsWith("get")) {
realAttributename = Character.toLowerCase(binding[i].charAt(3)) + binding[i].substring(4, binding[i].indexOf("("));
@@ -164,6 +179,7 @@
realAttributename = binding[i].substring(0, binding[i].indexOf("("));
}
}
+ //if the parent of the method is an instance of a generated class
if (jf != null) {
bindingExists = jf.getMethod(realMethodName, null) != null;
if (bindingExists) {
@@ -176,8 +192,7 @@
}
else {
try {
- clazz.getMethod(realMethodName, null);
- returnType = clazz.getMethod(realMethodName, null).getReturnType().getName();
+ returnType = clazz.getMethod(realMethodName, (Class[])null).getReturnType().getName();
bindingExists = true;
}
catch (NoSuchMethodException eee) {
@@ -185,15 +200,21 @@
}
}
getter = realMethodName + binding[i].substring(binding[i].indexOf("("));
+ //replace the value of the binding by the getter method
+ binding[i] = getter;
}
+ //if the part of the binding is an attribute
else {
- String realAttributename = null;
+ //if the parent of the attribute has a TagHandler, then check that the attribute is the generic attribute name for all the libraries
+ //or if it is the right name
if(prevTh != null) {
realAttributename = prevTh.getAttrToGenerate(binding[i]);
}
+ //if it is its real name
if(realAttributename == null) {
realAttributename = binding[i];
}
+ //if the parent of the attribute is an instance of a generated class
if (jf != null) {
bindingExists = jf.getMethod("get" + Character.toUpperCase(realAttributename.charAt(0)) + realAttributename.substring(1), null) != null || jf.getMethod("is" + Character.toUpperCase(realAttributename.charAt(0)) + realAttributename.substring(1), null) != null;
if (bindingExists) {
@@ -211,15 +232,13 @@
}
else {
try {
- clazz.getMethod("get" + Character.toUpperCase(realAttributename.charAt(0)) + realAttributename.substring(1), null);
- returnType = clazz.getMethod("get" + Character.toUpperCase(realAttributename.charAt(0)) + realAttributename.substring(1), null).getReturnType().getName();
+ returnType = clazz.getMethod("get" + Character.toUpperCase(realAttributename.charAt(0)) + realAttributename.substring(1), (Class[])null).getReturnType().getName();
getter = "get" + Character.toUpperCase(realAttributename.charAt(0)) + realAttributename.substring(1) + "()";
bindingExists = true;
}
catch (NoSuchMethodException eee) {
try {
- clazz.getMethod("is" + Character.toUpperCase(realAttributename.charAt(0)) + realAttributename.substring(1), null);
- returnType = clazz.getMethod("is" + Character.toUpperCase(realAttributename.charAt(0)) + realAttributename.substring(1), null).getReturnType().getName();
+ returnType = clazz.getMethod("is" + Character.toUpperCase(realAttributename.charAt(0)) + realAttributename.substring(1), (Class[])null).getReturnType().getName();
getter = "is" + Character.toUpperCase(realAttributename.charAt(0)) + realAttributename.substring(1) + "()";
bindingExists = true;
}
@@ -228,8 +247,11 @@
}
}
}
+ binding[i] = getter;
}
+ //if the binding binds an existing attribute or method
if(bindingExists) {
+ //if the object has a TagHandler
if(th != null) {
String getterWoBraces = getter.substring(0, getter.indexOf("("));
if(th.hasEventInfosAboutMethod(getterWoBraces)) {
@@ -244,6 +266,7 @@
removeMethod = "removePropertyChangeListener";
}
}
+ //if it is the last element of the binding and its parent has a taghandler
else if(i == binding.length - 1 && prevTh != null) {
String getterWoBraces = getter.substring(0, getter.indexOf("("));
if(prevTh.hasEventInfosAboutMethod(getterWoBraces)) {
@@ -263,10 +286,12 @@
addMethod = "addPropertyChangeListener";
removeMethod = "removePropertyChangeListener";
}
-
+
+ //starts to generate the code
dbCreation.append("if(");
dbDeletion.append("if(");
if(alreadyChecked != null && !alreadyChecked.isEmpty()) {
+ //add not null parent condition
for(int j = 0 ; j < alreadyChecked.size() ; j++) {
dbCreation.append(alreadyChecked.get(0));
dbDeletion.append(alreadyChecked.get(0));
@@ -368,6 +393,7 @@
alreadyChecked = new ArrayList<String>();
}
alreadyChecked.add(getter);
+ //if it is not the last element of the binding
if(i + 1 < binding.length) {
result.addAll(generateBindings(dbCreation, dbDeletion, th, nextFile, nextClazz, binding, i+1, alreadyChecked, methodToInvoke, generatedFiles));
}
Modified: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ApplicationHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ApplicationHandler.java 2009-07-24 15:20:05 UTC (rev 1528)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ApplicationHandler.java 2009-07-24 15:33:15 UTC (rev 1529)
@@ -1,13 +1,27 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
+/**
+ * *##% guix-compiler-swing
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
*/
-
package org.nuiton.guix.tags.swing;
/**
+ * Handles the Application tag
*
- * @author kevin
+ * @author kmorin
*/
public class ApplicationHandler extends ComponentHandler {
@@ -15,6 +29,7 @@
super();
}
+ @Override
public Class getClassToGenerate() {
return javax.swing.JFrame.class;
}
Modified: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ButtonHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ButtonHandler.java 2009-07-24 15:20:05 UTC (rev 1528)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ButtonHandler.java 2009-07-24 15:33:15 UTC (rev 1529)
@@ -1,13 +1,27 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
+/**
+ * *##% guix-compiler-swing
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
*/
-
package org.nuiton.guix.tags.swing;
/**
+ * Handles the Button tag
*
- * @author kevin
+ * @author kmorin
*/
public class ButtonHandler extends ComponentHandler {
Modified: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ComponentHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ComponentHandler.java 2009-07-24 15:20:05 UTC (rev 1528)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ComponentHandler.java 2009-07-24 15:33:15 UTC (rev 1529)
@@ -1,16 +1,31 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
+/**
+ * *##% guix-compiler-swing
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
*/
+package org.nuiton.guix.tags.swing;
-package org.nuiton.guix.tags.swing;
import java.awt.event.ComponentListener;
import java.awt.event.FocusListener;
import org.nuiton.guix.tags.DefaultTagHandler;
/**
+ * Super class of all the Swing TagHandlers
*
- * @author kevin
+ * @author kmorin
*/
public abstract class ComponentHandler extends DefaultTagHandler {
Modified: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/FrameHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/FrameHandler.java 2009-07-24 15:20:05 UTC (rev 1528)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/FrameHandler.java 2009-07-24 15:33:15 UTC (rev 1529)
@@ -1,13 +1,27 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
+/**
+ * *##% guix-compiler-swing
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
*/
-
package org.nuiton.guix.tags.swing;
/**
+ * Handles the Frame tag
*
- * @author kevin
+ * @author kmorin
*/
public class FrameHandler extends ComponentHandler {
@@ -15,6 +29,7 @@
super();
}
+ @Override
public Class getClassToGenerate() {
return javax.swing.JFrame.class;
}
Modified: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/LabelHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/LabelHandler.java 2009-07-24 15:20:05 UTC (rev 1528)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/LabelHandler.java 2009-07-24 15:33:15 UTC (rev 1529)
@@ -1,13 +1,27 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
+/**
+ * *##% guix-compiler-swing
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
*/
-
package org.nuiton.guix.tags.swing;
/**
+ * Handles the Label tag
*
- * @author kevin
+ * @author kmorin
*/
public class LabelHandler extends ComponentHandler {
Modified: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/MenuBarHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/MenuBarHandler.java 2009-07-24 15:20:05 UTC (rev 1528)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/MenuBarHandler.java 2009-07-24 15:33:15 UTC (rev 1529)
@@ -1,13 +1,27 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
+/**
+ * *##% guix-compiler-swing
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
*/
-
package org.nuiton.guix.tags.swing;
/**
+ * Handles the MenuBar tag
*
- * @author kevin
+ * @author kmorin
*/
public class MenuBarHandler extends ComponentHandler {
Modified: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/MenuHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/MenuHandler.java 2009-07-24 15:20:05 UTC (rev 1528)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/MenuHandler.java 2009-07-24 15:33:15 UTC (rev 1529)
@@ -1,14 +1,29 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
+/**
+ * *##% guix-compiler-swing
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
*/
+package org.nuiton.guix.tags.swing;
-package org.nuiton.guix.tags.swing;
import javax.swing.event.MenuListener;
/**
+ * Handles the Menu tag
*
- * @author kevin
+ * @author kmorin
*/
public class MenuHandler extends ComponentHandler {
Modified: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/MenuItemHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/MenuItemHandler.java 2009-07-24 15:20:05 UTC (rev 1528)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/MenuItemHandler.java 2009-07-24 15:33:15 UTC (rev 1529)
@@ -1,13 +1,27 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
+/**
+ * *##% guix-compiler-swing
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
*/
-
package org.nuiton.guix.tags.swing;
/**
+ * Handles the MenuItem tag
*
- * @author kevin
+ * @author kmorin
*/
public class MenuItemHandler extends ComponentHandler {
Modified: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/PanelHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/PanelHandler.java 2009-07-24 15:20:05 UTC (rev 1528)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/PanelHandler.java 2009-07-24 15:33:15 UTC (rev 1529)
@@ -1,13 +1,27 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
+/**
+ * *##% guix-compiler-swing
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
*/
-
package org.nuiton.guix.tags.swing;
/**
+ * Handles the Panel tag
*
- * @author kevin
+ * @author kmorin
*/
public class PanelHandler extends ComponentHandler {
Modified: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/RowHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/RowHandler.java 2009-07-24 15:20:05 UTC (rev 1528)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/RowHandler.java 2009-07-24 15:33:15 UTC (rev 1529)
@@ -24,7 +24,7 @@
/**
* Represents a row of a table
*
- * @author kevin
+ * @author kmorin
*/
public class RowHandler extends TableHandler {
Modified: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/SelectableButtonHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/SelectableButtonHandler.java 2009-07-24 15:20:05 UTC (rev 1528)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/SelectableButtonHandler.java 2009-07-24 15:33:15 UTC (rev 1529)
@@ -1,14 +1,29 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
+/**
+ * *##% guix-compiler-swing
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
*/
+package org.nuiton.guix.tags.swing;
-package org.nuiton.guix.tags.swing;
import javax.swing.event.ChangeListener;
/**
+ * Superclass of all TagHandlers for the button which can be selected
*
- * @author kevin
+ * @author kmorin
*/
public class SelectableButtonHandler extends ButtonHandler {
Modified: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TabPanelHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TabPanelHandler.java 2009-07-24 15:20:05 UTC (rev 1528)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TabPanelHandler.java 2009-07-24 15:33:15 UTC (rev 1529)
@@ -1,15 +1,30 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
+/**
+ * *##% guix-compiler-swing
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
*/
+package org.nuiton.guix.tags.swing;
-package org.nuiton.guix.tags.swing;
import java.awt.event.ContainerListener;
import javax.swing.event.ChangeListener;
/**
+ * Handles the TabPanel tag
*
- * @author kevin
+ * @author kmorin
*/
public class TabPanelHandler extends ComponentHandler {
Modified: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TableHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TableHandler.java 2009-07-24 15:20:05 UTC (rev 1528)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TableHandler.java 2009-07-24 15:33:15 UTC (rev 1529)
@@ -28,7 +28,7 @@
/**
* Represents a table
*
- * @author kevin
+ * @author kmorin
*/
public class TableHandler extends PanelHandler {
Modified: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TextComponentHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TextComponentHandler.java 2009-07-24 15:20:05 UTC (rev 1528)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TextComponentHandler.java 2009-07-24 15:33:15 UTC (rev 1529)
@@ -1,14 +1,29 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
+/**
+ * *##% guix-compiler-swing
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
*/
+package org.nuiton.guix.tags.swing;
-package org.nuiton.guix.tags.swing;
import javax.swing.event.DocumentListener;
/**
+ * Superclass of all the text component TagHandlers
*
- * @author kevin
+ * @author kmorin
*/
public abstract class TextComponentHandler extends ComponentHandler {
Modified: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TextFieldHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TextFieldHandler.java 2009-07-24 15:20:05 UTC (rev 1528)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TextFieldHandler.java 2009-07-24 15:33:15 UTC (rev 1529)
@@ -1,13 +1,27 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
+/**
+ * *##% guix-compiler-swing
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
*/
-
package org.nuiton.guix.tags.swing;
/**
+ * Handles the Textfield tag
*
- * @author kevin
+ * @author kmorin
*/
public class TextFieldHandler extends TextComponentHandler {
Modified: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ToggleButtonHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ToggleButtonHandler.java 2009-07-24 15:20:05 UTC (rev 1528)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ToggleButtonHandler.java 2009-07-24 15:33:15 UTC (rev 1529)
@@ -1,14 +1,27 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
+/**
+ * *##% guix-compiler-swing
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
*/
-
package org.nuiton.guix.tags.swing;
-import javax.swing.event.ChangeListener;
/**
+ * Handles the ToggleButton tag
*
- * @author kevin
+ * @author kmorin
*/
public class ToggleButtonHandler extends SelectableButtonHandler {
1
0