Guix-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
August 2009
- 3 participants
- 60 discussions
Author: kmorin
Date: 2009-08-26 12:27:48 +0200 (Wed, 26 Aug 2009)
New Revision: 1585
Added:
trunk/maven-guix-swing-archetype/
trunk/maven-guix-swing-archetype/pom.xml
trunk/maven-guix-swing-archetype/src/
trunk/maven-guix-swing-archetype/src/main/
trunk/maven-guix-swing-archetype/src/main/java/
trunk/maven-guix-swing-archetype/src/main/resources/
trunk/maven-guix-swing-archetype/src/main/resources/META-INF/
trunk/maven-guix-swing-archetype/src/main/resources/META-INF/maven/
trunk/maven-guix-swing-archetype/src/main/resources/META-INF/maven/archetype.xml
trunk/maven-guix-swing-archetype/src/main/resources/archetype-resources/
trunk/maven-guix-swing-archetype/src/main/resources/archetype-resources/pom.xml
trunk/maven-guix-swing-archetype/src/main/resources/archetype-resources/src/
trunk/maven-guix-swing-archetype/src/main/resources/archetype-resources/src/main/
trunk/maven-guix-swing-archetype/src/main/resources/archetype-resources/src/main/java/
trunk/maven-guix-swing-archetype/src/main/resources/archetype-resources/src/main/java/myApp.guix
trunk/maven-guix-swing-archetype/src/main/resources/archetype-resources/src/main/resources/
trunk/maven-guix-swing-archetype/src/main/resources/archetype-resources/src/test/
trunk/maven-guix-swing-archetype/src/main/resources/archetype-resources/src/test/java/
trunk/maven-guix-swing-archetype/src/test/
trunk/maven-guix-swing-archetype/src/test/java/
Log:
Create the archetype to generate a new Guix project for swing
Property changes on: trunk/maven-guix-swing-archetype
___________________________________________________________________
Added: svn:ignore
+ target
Added: trunk/maven-guix-swing-archetype/pom.xml
===================================================================
--- trunk/maven-guix-swing-archetype/pom.xml (rev 0)
+++ trunk/maven-guix-swing-archetype/pom.xml 2009-08-26 10:27:48 UTC (rev 1585)
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>guix</artifactId>
+ <groupId>org.nuiton</groupId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+ <name>${artifactId}</name>
+ <groupId>org.nuiton.guix</groupId>
+ <artifactId>maven-guix-swing-archetype</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+</project>
\ No newline at end of file
Added: trunk/maven-guix-swing-archetype/src/main/resources/META-INF/maven/archetype.xml
===================================================================
--- trunk/maven-guix-swing-archetype/src/main/resources/META-INF/maven/archetype.xml (rev 0)
+++ trunk/maven-guix-swing-archetype/src/main/resources/META-INF/maven/archetype.xml 2009-08-26 10:27:48 UTC (rev 1585)
@@ -0,0 +1,6 @@
+<archetype>
+ <id>maven-guix-swing-archetype</id>
+ <sources>
+ <source>src/main/java/myApp.guix</source>
+ </sources>
+</archetype>
Added: trunk/maven-guix-swing-archetype/src/main/resources/archetype-resources/pom.xml
===================================================================
--- trunk/maven-guix-swing-archetype/src/main/resources/archetype-resources/pom.xml (rev 0)
+++ trunk/maven-guix-swing-archetype/src/main/resources/archetype-resources/pom.xml 2009-08-26 10:27:48 UTC (rev 1585)
@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+ <parent>
+ <groupId>org.nuiton</groupId>
+ <artifactId>mavenpom</artifactId>
+ <version>1.0.1</version>
+ </parent>
+
+ <groupId>${groupId}</groupId>
+ <artifactId>${artifactId}</artifactId>
+ <version>${version}</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.nuiton.guix</groupId>
+ <artifactId>maven-guix-plugin</artifactId>
+ <version>${version}</version>
+ </dependency>
+ </dependencies>
+
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+ <name>${artifactId}</name>
+ <description></description>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>jar</packaging>
+
+ <properties>
+ <maven.jar.main.class>${groupId}.Main</maven.jar.main.class>
+ </properties>
+
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Environment ************************************** -->
+ <!-- ************************************************************* -->
+
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*.guix</include>
+ <include>**/*.jaxx</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+
+ <pluginManagement>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ <classpathPrefix>./lib/</classpathPrefix>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ </pluginManagement>
+ <plugins>
+
+ <plugin>
+ <groupId>org.nuiton.guix</groupId>
+ <artifactId>maven-guix-plugin</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <configuration>
+ <targetDirectory>target/generatedFiles/</targetDirectory>
+ <guixFilesBaseDir>src/main/java</guixFilesBaseDir>
+ <guixFilesDir>src/main/java</guixFilesDir>
+ <mainClass>${groupId}.myApp</mainClass>
+ <launcherName>Main</launcherName>
+ <generationLanguage>Swing</generationLanguage>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <configuration>
+ <outputDirectory>${project.build.directory}/lib</outputDirectory>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project>
Added: trunk/maven-guix-swing-archetype/src/main/resources/archetype-resources/src/main/java/myApp.guix
===================================================================
--- trunk/maven-guix-swing-archetype/src/main/resources/archetype-resources/src/main/java/myApp.guix (rev 0)
+++ trunk/maven-guix-swing-archetype/src/main/resources/archetype-resources/src/main/java/myApp.guix 2009-08-26 10:27:48 UTC (rev 1585)
@@ -0,0 +1,3 @@
+<Application title="myApp" size="200,100">
+ <Label text="Hello world" />
+</Application>
\ No newline at end of file
1
0
r1584 - trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator
by kmorin@users.nuiton.org 26 Aug '09
by kmorin@users.nuiton.org 26 Aug '09
26 Aug '09
Author: kmorin
Date: 2009-08-26 12:26:59 +0200 (Wed, 26 Aug 2009)
New Revision: 1584
Modified:
trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtGenerator.java
Log:
Add inherits tags in the .gwt.xml generated file
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-08-26 08:29:18 UTC (rev 1583)
+++ trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtGenerator.java 2009-08-26 10:26:59 UTC (rev 1584)
@@ -237,6 +237,7 @@
serializer.startTag("", "module");
serializer.comment("Inherit the core Web Toolkit stuff.");
+
serializer.startTag("", "inherits");
serializer.attribute("", "name", "com.google.gwt.user.User");
serializer.endTag("","inherits");
@@ -246,6 +247,14 @@
serializer.endTag("","inherits");
serializer.startTag("", "inherits");
+ serializer.attribute("", "name", "com.googlecode.gwt.math.Math");
+ serializer.endTag("","inherits");
+
+ serializer.startTag("", "inherits");
+ serializer.attribute("", "name", "org.gwtwidgets.WidgetLibrary");
+ serializer.endTag("","inherits");
+
+ serializer.startTag("", "inherits");
int i = 0;
while(i < gmo.getAttributeDescriptors().size()
&& !gmo.getAttributeDescriptors().get(i).getName().equals("theme")) {
1
0
26 Aug '09
Author: kmorin
Date: 2009-08-26 10:29:18 +0200 (Wed, 26 Aug 2009)
New Revision: 1583
Modified:
trunk/maven-guix-plugin/src/main/java/org/nuiton/guix/GuixMojo.java
Log:
Add the guixFileBaseDir field to be able to find the package names (ex: "src/main/java" or "src/main/resources").
Modified: trunk/maven-guix-plugin/src/main/java/org/nuiton/guix/GuixMojo.java
===================================================================
--- trunk/maven-guix-plugin/src/main/java/org/nuiton/guix/GuixMojo.java 2009-08-26 08:27:46 UTC (rev 1582)
+++ trunk/maven-guix-plugin/src/main/java/org/nuiton/guix/GuixMojo.java 2009-08-26 08:29:18 UTC (rev 1583)
@@ -48,11 +48,17 @@
protected MavenProject project;
/**
* Directory of the files to compile.
- * @parameter expression="${guix.guixFilesDir}" default-value="${maven.src.dir}/main/java"
+ * @parameter expression="${guix.guixFilesDir}" default-value="${project.basedir}/src/main/java"
* @since 0.0.1
*/
private String guixFilesDir;
/**
+ * Base Directory of the files to compile. Used to determine the package names.
+ * @parameter expression="${guix.guixFilesBaseDir}" default-value="${project.basedir}/src/main/java"
+ * @since 0.0.1
+ */
+ private String guixFilesBaseDir;
+ /**
* Directory of the generated files.
* @parameter expression="${guix.targetDirectory}" default-value="${basedir}/target/generatedFiles"
* @since 0.0.1
@@ -67,7 +73,7 @@
private String mainClass;
/**
* Generation language
- * @parameter expression="${guix.generationLanguage}" default-value="Swing"
+ * @parameter expression="${guix.generationLanguage}"
* @required
* @since 0.0.1
*/
@@ -81,6 +87,7 @@
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
+ File guixFilesBaseDir = new File(this.guixFilesBaseDir);
File guixFilesDir = new File(this.guixFilesDir);
File targetDirectory = new File(this.targetDirectory);
Class generatorClass = null;
@@ -101,8 +108,7 @@
GuixLauncher gcl = new GuixLauncher(guixFiles.toArray(
new File[guixFiles.size()]), targetDirectory,
- new File(project.getBasedir(), "src/main/java"),
- mainClass, generatorClass, generationLanguage, launcherName);
+ guixFilesBaseDir, mainClass, generatorClass, generationLanguage, launcherName);
boolean result = gcl.compile();
if (result) {
getLog().info("Compilation succeeded !");
1
0
r1582 - in trunk/guix-compiler-swing/src/main/java/org/nuiton/guix: generator tags/swing
by kmorin@users.nuiton.org 26 Aug '09
by kmorin@users.nuiton.org 26 Aug '09
26 Aug '09
Author: kmorin
Date: 2009-08-26 10:27:46 +0200 (Wed, 26 Aug 2009)
New Revision: 1582
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/SwingMainClassGenerator.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/CellHandler.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/TableHandler.java
Log:
Improved the binding a little bit.
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-08-26 08:26:37 UTC (rev 1581)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingGenerator.java 2009-08-26 08:27:46 UTC (rev 1582)
@@ -453,9 +453,6 @@
}
}
catch(NullPointerException eee) {
- log.error(i);
- eee.printStackTrace();
- return null;
}
}
}
Modified: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingMainClassGenerator.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingMainClassGenerator.java 2009-08-26 08:26:37 UTC (rev 1581)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingMainClassGenerator.java 2009-08-26 08:27:46 UTC (rev 1582)
@@ -60,15 +60,17 @@
* @param out the file to record the content
*/
public void generate(File out) {
- String gmoClassName = gmo.getClassDescriptor().getName();
+ String gmoClass = gmo.getClassDescriptor().toString();
clazz.addImport("java.io.File");
- clazz.addImport("org.springframework.beans.factory.ListableBeanFactory");
- clazz.addImport("org.springframework.beans.factory.xml.XmlBeanFactory");
- clazz.addImport("org.springframework.core.io.FileSystemResource");
+// clazz.addImport("org.springframework.beans.factory.ListableBeanFactory");
+// clazz.addImport("org.springframework.beans.factory.xml.XmlBeanFactory");
+// clazz.addImport("org.springframework.core.io.FileSystemResource");
StringBuffer mainMethod = new StringBuffer();
- mainMethod.append("javax.swing.SwingUtilities.invokeLater(").append("new Runnable() {").append("public void run() {").append(gmoClassName).append("Impl main = new ").append(gmoClassName).append("Impl();\n").append("main.pack();\n").append("main.setVisible(true);}});");
+ mainMethod.append("javax.swing.SwingUtilities.invokeLater(").append("new Runnable() {\n").append("public void run() {\n")
+ .append(gmoClass).append("Impl main = new ").append(gmoClass).append("Impl();\n")
+ .append("main.setVisible(true);\n}\n});");
clazz.addMethod(new JavaMethod(
Modifier.PUBLIC | Modifier.STATIC,
Modified: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/CellHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/CellHandler.java 2009-08-26 08:26:37 UTC (rev 1581)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/CellHandler.java 2009-08-26 08:27:46 UTC (rev 1582)
@@ -76,10 +76,10 @@
else if (attr.getName().equals("ipady")) {
ipady = Integer.valueOf(attr.getValue());
}
- else if (attr.getName().equals("halign")) {
+ else if (attr.getName().equals("horizontalAlignment")) {
horizontalAlignment = getHalign(attr.getValue());
}
- else if (attr.getName().equals("valign")) {
+ else if (attr.getName().equals("verticalAlignment")) {
verticalAlignment = getValign(attr.getValue());
}
else if (attr.getName().equals("fill")) {
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-08-26 08:26:37 UTC (rev 1581)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/RowHandler.java 2009-08-26 08:27:46 UTC (rev 1582)
@@ -60,10 +60,10 @@
else if (attr.getName().equals("ipady")) {
ipady = Integer.valueOf(attr.getValue());
}
- else if (attr.getName().equals("halign")) {
+ else if (attr.getName().equals("horizontalAlignment")) {
horizontalAlignment = getHalign(attr.getValue());
}
- else if (attr.getName().equals("valign")) {
+ else if (attr.getName().equals("verticalAlignment")) {
verticalAlignment = getValign(attr.getValue());
}
else if (attr.getName().equals("fill")) {
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-08-26 08:26:37 UTC (rev 1581)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TableHandler.java 2009-08-26 08:27:46 UTC (rev 1582)
@@ -47,7 +47,7 @@
public static final String DEFAULT_INSETS = "3, 3, 3, 3";
public static final HorizontalAlignment DEFAULT_HORIZONTAL_ALIGNMENT = HorizontalAlignment.ALIGN_DEFAULT;
public static final VerticalAlignment DEFAULT_VERTICAL_ALIGNMENT = VerticalAlignment.ALIGN_TOP;
- public static final String DEFAULT_FILL = "java.awt.GridBagConstraints.BOTH";
+ public static final String DEFAULT_FILL = "both";
public static final Integer DEFAULT_IPADX = 1;
public static final Integer DEFAULT_IPADY = 1;
public static final Double DEFAULT_WEIGHTX = 0.0;
@@ -75,40 +75,40 @@
public TableHandler(GuixModelObject table) {
for (AttributeDescriptor attr : table.getAttributeDescriptors()) {
- if (attr.getName().equals("weightx")) {
+ if (attr.getName().equalsIgnoreCase("weightx")) {
weightx = Double.valueOf(attr.getValue());
}
- else if (attr.getName().equals("weighty")) {
+ else if (attr.getName().equalsIgnoreCase("weighty")) {
weighty = Double.valueOf(attr.getValue());
}
- else if (attr.getName().equals("ipadx")) {
+ else if (attr.getName().equalsIgnoreCase("ipadx")) {
ipadx = Integer.valueOf(attr.getValue());
}
- else if (attr.getName().equals("ipady")) {
+ else if (attr.getName().equalsIgnoreCase("ipady")) {
ipady = Integer.valueOf(attr.getValue());
}
- else if (attr.getName().equals("halign")) {
+ else if (attr.getName().equalsIgnoreCase("horizontalAlignment")) {
horizontalAlignment = getHalign(attr.getValue());
if (horizontalAlignment == null) {
if (log.isErrorEnabled()) {
- log.error(table.getId() + "'s halign attribute has a wrong value : " + attr.getValue());
+ log.error(table.getId() + "'s horizontalAlignment attribute has a wrong value : " + attr.getValue());
}
- horizontalAlignment = HorizontalAlignment.ALIGN_DEFAULT;
+ horizontalAlignment = DEFAULT_HORIZONTAL_ALIGNMENT;
}
}
- else if (attr.getName().equals("valign")) {
+ else if (attr.getName().equalsIgnoreCase("verticalAlignment")) {
verticalAlignment = getValign(attr.getValue());
if (verticalAlignment == null) {
if (log.isErrorEnabled()) {
- log.error(table.getId() + "'s halign attribute has a wrong value : " + attr.getValue());
+ log.error(table.getId() + "'s verticalAlignment attribute has a wrong value : " + attr.getValue());
}
- verticalAlignment = VerticalAlignment.ALIGN_TOP;
+ verticalAlignment = DEFAULT_VERTICAL_ALIGNMENT;
}
}
- else if (attr.getName().equals("fill")) {
- fill = attr.getValue();
+ else if (attr.getName().equalsIgnoreCase("fill")) {
+ fill = attr.getValue();
}
- else if (attr.getName().equals("insets")) {
+ else if (attr.getName().equalsIgnoreCase("insets")) {
insets = attr.getValue();
}
}
@@ -313,7 +313,7 @@
.append(cl.getWeightx()).append(",")
.append(cl.getWeighty()).append(",")
.append(anchor != null ? anchor : DEFAULT_ANCHOR).append(",")
- .append(cl.getFill()).append(", new java.awt.Insets(")
+ .append("GridBagConstraints.").append(cl.getFill().toUpperCase()).append(", new java.awt.Insets(")
.append(cl.getInsets()).append("),")
.append(cl.getIpadx()).append(",")
.append(cl.getIpady()).append("));\n");
1
0
r1581 - trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt
by kmorin@users.nuiton.org 26 Aug '09
by kmorin@users.nuiton.org 26 Aug '09
26 Aug '09
Author: kmorin
Date: 2009-08-26 10:26:37 +0200 (Wed, 26 Aug 2009)
New Revision: 1581
Modified:
trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/CellHandler.java
trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/CheckBoxHandler.java
trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/ComboBoxHandler.java
trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/RowHandler.java
trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/TableHandler.java
trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/TextFieldHandler.java
trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/ToggleButtonHandler.java
trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/TreeHandler.java
Log:
Reupgrade gwt version to 1.7.0 for better binding
Modified: trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/CellHandler.java
===================================================================
--- trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/CellHandler.java 2009-08-26 08:26:15 UTC (rev 1580)
+++ trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/CellHandler.java 2009-08-26 08:26:37 UTC (rev 1581)
@@ -75,10 +75,10 @@
else if (attr.getName().equals("ipady")) {
ipady = Integer.valueOf(attr.getValue());
}
- else if (attr.getName().equals("halign")) {
+ else if (attr.getName().equals("horizontalAlignment")) {
horizontalAlignment = getHalign(attr.getValue());
}
- else if (attr.getName().equals("valign")) {
+ else if (attr.getName().equals("verticalAlignment")) {
verticalAlignment = getValign(attr.getValue());
}
else if (attr.getName().equals("fill")) {
Modified: trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/CheckBoxHandler.java
===================================================================
--- trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/CheckBoxHandler.java 2009-08-26 08:26:15 UTC (rev 1580)
+++ trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/CheckBoxHandler.java 2009-08-26 08:26:37 UTC (rev 1581)
@@ -1,7 +1,7 @@
package org.nuiton.guix.tags.gwt;
-import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.event.logical.shared.ValueChangeHandler;
/**
* Handles the ChackBox tag
@@ -22,6 +22,7 @@
@Override
protected void configureProxyEventInfo() {
super.configureProxyEventInfo();
- addProxyEventInfo("isChecked", ClickListener.class);
+ addProxyEventInfo("isChecked", ValueChangeHandler.class);
+ addProxyEventInfo("getValue", ValueChangeHandler.class);
}
}
Modified: trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/ComboBoxHandler.java
===================================================================
--- trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/ComboBoxHandler.java 2009-08-26 08:26:15 UTC (rev 1580)
+++ trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/ComboBoxHandler.java 2009-08-26 08:26:37 UTC (rev 1581)
@@ -1,6 +1,6 @@
package org.nuiton.guix.tags.gwt;
-import com.google.gwt.user.client.ui.ChangeListener;
+import com.google.gwt.event.dom.client.ChangeHandler;
/**
* Handles the combobox tag
@@ -21,6 +21,6 @@
@Override
protected void configureProxyEventInfo() {
super.configureProxyEventInfo();
- addProxyEventInfo("getSelectedIndex", ChangeListener.class);
+ addProxyEventInfo("getSelectedIndex", ChangeHandler.class);
}
}
Modified: trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/RowHandler.java
===================================================================
--- trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/RowHandler.java 2009-08-26 08:26:15 UTC (rev 1580)
+++ trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/RowHandler.java 2009-08-26 08:26:37 UTC (rev 1581)
@@ -60,10 +60,10 @@
else if (attr.getName().equals("ipady")) {
ipady = Integer.valueOf(attr.getValue());
}
- else if (attr.getName().equals("halign")) {
+ else if (attr.getName().equals("horizontalAlignment")) {
horizontalAlignment = getHalign(attr.getValue());
}
- else if (attr.getName().equals("valign")) {
+ else if (attr.getName().equals("verticalAlignment")) {
verticalAlignment = getValign(attr.getValue());
}
else if (attr.getName().equals("fill")) {
Modified: trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/TableHandler.java
===================================================================
--- trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/TableHandler.java 2009-08-26 08:26:15 UTC (rev 1580)
+++ trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/TableHandler.java 2009-08-26 08:26:37 UTC (rev 1581)
@@ -45,7 +45,7 @@
public static final String DEFAULT_INSETS = "3, 3, 3, 3";
public static final HorizontalAlignment DEFAULT_HORIZONTAL_ALIGNMENT = HorizontalAlignment.ALIGN_DEFAULT;
public static final VerticalAlignment DEFAULT_VERTICAL_ALIGNMENT = VerticalAlignment.ALIGN_TOP;
- public static final String DEFAULT_FILL = "java.awt.GridBagConstraints.BOTH";
+ public static final String DEFAULT_FILL = "both";
public static final Integer DEFAULT_IPADX = 1;
public static final Integer DEFAULT_IPADY = 1;
public static final Double DEFAULT_WEIGHTX = 0.0;
@@ -73,40 +73,40 @@
*/
public TableHandler(GuixModelObject table) {
for (AttributeDescriptor attr : table.getAttributeDescriptors()) {
- if (attr.getName().equals("weightx")) {
+ if (attr.getName().equalsIgnoreCase("weightx")) {
weightx = Double.valueOf(attr.getValue());
}
- else if (attr.getName().equals("weighty")) {
+ else if (attr.getName().equalsIgnoreCase("weighty")) {
weighty = Double.valueOf(attr.getValue());
}
- else if (attr.getName().equals("ipadx")) {
+ else if (attr.getName().equalsIgnoreCase("ipadx")) {
ipadx = Integer.valueOf(attr.getValue());
}
- else if (attr.getName().equals("ipady")) {
+ else if (attr.getName().equalsIgnoreCase("ipady")) {
ipady = Integer.valueOf(attr.getValue());
}
- else if (attr.getName().equals("halign")) {
+ else if (attr.getName().equalsIgnoreCase("horizontalAlignment")) {
horizontalAlignment = getHalign(attr.getValue());
if (horizontalAlignment == null) {
if (log.isErrorEnabled()) {
- log.error(table.getId() + "'s halign attribute has a wrong value : " + attr.getValue());
+ log.error(table.getId() + "'s horizontalAlignment attribute has a wrong value : " + attr.getValue());
}
horizontalAlignment = HorizontalAlignment.ALIGN_DEFAULT;
}
}
- else if (attr.getName().equals("valign")) {
+ else if (attr.getName().equalsIgnoreCase("verticalAlignment")) {
verticalAlignment = getValign(attr.getValue());
if (verticalAlignment == null) {
if (log.isErrorEnabled()) {
- log.error(table.getId() + "'s halign attribute has a wrong value : " + attr.getValue());
+ log.error(table.getId() + "'s verticalAlignment attribute has a wrong value : " + attr.getValue());
}
verticalAlignment = VerticalAlignment.ALIGN_TOP;
}
}
- else if (attr.getName().equals("fill")) {
+ else if (attr.getName().equalsIgnoreCase("fill")) {
fill = attr.getValue();
}
- else if (attr.getName().equals("insets")) {
+ else if (attr.getName().equalsIgnoreCase("insets")) {
insets = attr.getValue();
}
}
@@ -133,7 +133,7 @@
return fill;
}
- public void setFill(String fill) {
+ public void setFill (String fill) {
this.fill = fill;
}
@@ -202,7 +202,7 @@
}
return null;
}
-
+
/**
* Creates a cell with the right column and generates the code to add it to the table
*
Modified: trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/TextFieldHandler.java
===================================================================
--- trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/TextFieldHandler.java 2009-08-26 08:26:15 UTC (rev 1580)
+++ trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/TextFieldHandler.java 2009-08-26 08:26:37 UTC (rev 1581)
@@ -17,7 +17,7 @@
* <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
*/
package org.nuiton.guix.tags.gwt;
-import com.google.gwt.user.client.ui.KeyboardListener;
+import com.google.gwt.event.dom.client.KeyPressHandler;
/**
* Handles the Textfield tag
@@ -41,6 +41,6 @@
@Override
protected void configureProxyEventInfo() {
super.configureProxyEventInfo();
- addProxyEventInfo("getText", KeyboardListener.class);
+ addProxyEventInfo("getText", KeyPressHandler.class);
}
}
Modified: trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/ToggleButtonHandler.java
===================================================================
--- trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/ToggleButtonHandler.java 2009-08-26 08:26:15 UTC (rev 1580)
+++ trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/ToggleButtonHandler.java 2009-08-26 08:26:37 UTC (rev 1581)
@@ -18,7 +18,7 @@
*/
package org.nuiton.guix.tags.gwt;
-import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.event.dom.client.ClickHandler;
/**
* Handles the ToggleButton tags
@@ -40,6 +40,6 @@
@Override
public void configureProxyEventInfo() {
super.configureProxyEventInfo();
- addProxyEventInfo("isDown", ClickListener.class);
+ addProxyEventInfo("isDown", ClickHandler.class);
}
}
Modified: trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/TreeHandler.java
===================================================================
--- trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/TreeHandler.java 2009-08-26 08:26:15 UTC (rev 1580)
+++ trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/tags/gwt/TreeHandler.java 2009-08-26 08:26:37 UTC (rev 1581)
@@ -1,6 +1,6 @@
package org.nuiton.guix.tags.gwt;
-import com.google.gwt.user.client.ui.TreeListener;
+import com.google.gwt.event.logical.shared.SelectionHandler;
/**
* Handles the tree tag
@@ -21,6 +21,6 @@
@Override
protected void configureProxyEventInfo() {
super.configureProxyEventInfo();
- addProxyEventInfo("getSelectedItem", TreeListener.class);
+ addProxyEventInfo("getSelectedItem", SelectionHandler.class);
}
}
1
0
Author: kmorin
Date: 2009-08-26 10:26:15 +0200 (Wed, 26 Aug 2009)
New Revision: 1580
Modified:
trunk/pom.xml
Log:
Reupgrade gwt version to 1.7.0 for better binding
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-08-25 22:40:16 UTC (rev 1579)
+++ trunk/pom.xml 2009-08-26 08:26:15 UTC (rev 1580)
@@ -203,7 +203,7 @@
<!-- libs version -->
<spring.version>2.0.5</spring.version>
<maven.version>2.0.10</maven.version>
- <gwt.version>1.5.3</gwt.version>
+ <gwt.version>1.7.0</gwt.version>
</properties>
1
0
Author: tchemit
Date: 2009-08-26 00:40:16 +0200 (Wed, 26 Aug 2009)
New Revision: 1579
Modified:
trunk/pom.xml
trunk/src/site/site.xml
Log:
- bump mavenpom and i18n versions
- clean site.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-08-25 10:51:11 UTC (rev 1578)
+++ trunk/pom.xml 2009-08-25 22:40:16 UTC (rev 1579)
@@ -9,7 +9,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom</artifactId>
- <version>1.0.0</version>
+ <version>1.0.1</version>
</parent>
<artifactId>guix</artifactId>
@@ -214,9 +214,9 @@
<!-- plugin i18n -->
<plugin>
- <groupId>org.nuiton</groupId>
+ <groupId>org.nuiton.i18n</groupId>
<artifactId>maven-i18n-plugin</artifactId>
- <version>1.0.0</version>
+ <version>1.0.1-SNAPSHOT</version>
</plugin>
</plugins>
Modified: trunk/src/site/site.xml
===================================================================
--- trunk/src/site/site.xml 2009-08-25 10:51:11 UTC (rev 1578)
+++ trunk/src/site/site.xml 2009-08-25 22:40:16 UTC (rev 1579)
@@ -1,25 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="${project.name}">
- <publishDate format="dd/MM/yyyy"/>
-
- <skin>
- <groupId>org.nuiton</groupId>
- <artifactId>maven-nuiton-skin</artifactId>
- <version>1.0.0</version>
- </skin>
-
<bannerLeft>
<name>${project.name}</name>
<src>guixLogo.png</src>
<href>index.html</href>
</bannerLeft>
- <bannerRight>
- <src>http://www.codelutin.com/images/lutinorange-codelutin.png</src>
- <href>${project.organization.url}</href>
- </bannerRight>
-
<poweredBy>
<logo href="http://maven.apache.org" name="Maven"
img="images/logos/maven-feather.png"/>
1
0
r1578 - in trunk/guix-test-swing: . src/main/java/org/nuiton/guix/demo
by kmorin@users.nuiton.org 25 Aug '09
by kmorin@users.nuiton.org 25 Aug '09
25 Aug '09
Author: kmorin
Date: 2009-08-25 12:51:11 +0200 (Tue, 25 Aug 2009)
New Revision: 1578
Modified:
trunk/guix-test-swing/pom.xml
trunk/guix-test-swing/src/main/java/org/nuiton/guix/demo/Controller.java
trunk/guix-test-swing/src/main/java/org/nuiton/guix/demo/GuixDemo.guix
trunk/guix-test-swing/src/main/java/org/nuiton/guix/demo/GuixDemo5.guix
Log:
Upgrade with new features
Modified: trunk/guix-test-swing/pom.xml
===================================================================
--- trunk/guix-test-swing/pom.xml 2009-08-25 10:51:02 UTC (rev 1577)
+++ trunk/guix-test-swing/pom.xml 2009-08-25 10:51:11 UTC (rev 1578)
@@ -35,14 +35,6 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
-
- <!-- sibiling dependencies -->
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>guix-runtime-swing</artifactId>
- <version>${project.version}</version>
- </dependency>
</dependencies>
Modified: trunk/guix-test-swing/src/main/java/org/nuiton/guix/demo/Controller.java
===================================================================
--- trunk/guix-test-swing/src/main/java/org/nuiton/guix/demo/Controller.java 2009-08-25 10:51:02 UTC (rev 1577)
+++ trunk/guix-test-swing/src/main/java/org/nuiton/guix/demo/Controller.java 2009-08-25 10:51:11 UTC (rev 1578)
@@ -17,12 +17,15 @@
* <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
*/
package org.nuiton.guix.demo;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
public class Controller {
private java.lang.String text = "controller";
private int num = 0;
private java.lang.String cssText = "";
+ private java.beans.PropertyChangeSupport support = new java.beans.PropertyChangeSupport(this);
public Controller() {
System.out.println("Dude, it's bloody raining");
@@ -37,7 +40,9 @@
}
public void setText(java.lang.String text) {
+ String oldValue = this.text;
this.text = text;
+ support.firePropertyChange("text", oldValue, text);
}
public int getNum() {
@@ -45,7 +50,9 @@
}
public void setNum(int num) {
+ int oldValue = this.num;
this.num = num;
+ support.firePropertyChange("num", oldValue, num);
}
public java.lang.String getCssText() {
@@ -53,7 +60,16 @@
}
public void setCssText(java.lang.String cssText) {
+ String oldValue = this.cssText;
this.cssText = cssText;
+ support.firePropertyChange("cssText", oldValue, cssText);
}
+ public void addPropertyChangeListener(java.beans.PropertyChangeListener listener) {
+ support.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String property, java.beans.PropertyChangeListener listener) {
+ support.addPropertyChangeListener(property, listener);
+ }
}
Modified: trunk/guix-test-swing/src/main/java/org/nuiton/guix/demo/GuixDemo.guix
===================================================================
--- trunk/guix-test-swing/src/main/java/org/nuiton/guix/demo/GuixDemo.guix 2009-08-25 10:51:02 UTC (rev 1577)
+++ trunk/guix-test-swing/src/main/java/org/nuiton/guix/demo/GuixDemo.guix 2009-08-25 10:51:11 UTC (rev 1578)
@@ -9,7 +9,7 @@
import java.awt.BorderLayout;
import javax.swing.JFrame;
-private Button b = new Button("test");
+private JButton b = new JButton("test");
public enum Day {
SUNDAY, MONDAY, TUESDAY, WEDNESDAY,
@@ -39,7 +39,7 @@
System.out.println("before Creation");
}
-public void beforeBinding() {
+public void beforeSettings() {
this.add(b, BorderLayout.SOUTH);
}
@@ -50,7 +50,7 @@
<MenuBar border="new javax.swing.border.BevelBorder(javax.swing.border.BevelBorder.RAISED)">
<Menu constructor='"menu 1"'>
<MenuItem id="item1" text="item1" />
- <MenuItem text="item2" action='{System.out.println("Action [" + actionEvent.getActionCommand()
+ <MenuItem text="item2" action='{System.out.println("Action [" + event.getActionCommand()
+ "] performed!");}' />
</Menu>
<Menu constructor='"menu 2"'>
@@ -58,19 +58,19 @@
</Menu>
</MenuBar>
<swing:JToolBar>
- <Button id="bouton1" onActionPerformed='{System.out.println("Action [" + actionEvent.getActionCommand()
+ <JButton id="bouton1" onActionPerformed='{System.out.println("Action [" + event.getActionCommand()
+ "] performed!");}' text="bouton1" />
- <Button onActionPerformed='{System.out.println("Action [" + actionEvent.getActionCommand()
+ <Button onActionPerformed='{System.out.println("Action [" + event.getActionCommand()
+ "] performed!");}' text="bouton2" />
- <Button onActionPerformed='{System.out.println("Action [" + actionEvent.getActionCommand()
+ <Button onActionPerformed='{System.out.println("Action [" + event.getActionCommand()
+ "] performed!");}' text="bouton3" />
</swing:JToolBar>
<gwt:FlowPanel id="gwt">
- <Button id="bouton1" onActionPerformed='{System.out.println("Action [" + actionEvent.getActionCommand()
+ <Button id="bouton1" onClick='{System.out.println("Action [" + event.getActionCommand()
+ "] performed!");}' text="bouton1" />
- <Button onActionPerformed='{System.out.println("Action [" + actionEvent.getActionCommand()
+ <Button onClick='{System.out.println("Action [" + event.getActionCommand()
+ "] performed!");}' text="bouton2" />
- <Button onActionPerformed='{System.out.println("Action [" + actionEvent.getActionCommand()
+ <Button onClick='{System.out.println("Action [" + event.getActionCommand()
+ "] performed!");}' text="bouton3" />
</gwt:FlowPanel>
<TabPanel id="tabPanel">
@@ -81,7 +81,7 @@
<TextField id="textfield" constructor='"test"' enabled="{getGd2().getButton().isSelected() && getGd22().getButton().isSelected()}" onFocus='{System.out.println("dude !")}'/>
</Cell>
<Cell>
- <Label id="label" text="label : {textfield.getText()}" styleClass="bold" />
+ <Label id="label" text="label : {textfield.getText()}" visible="{textfield.enabled}" styleClass="bold" />
</Cell>
<Cell rows='3'>
<Label id="label2" text="color" background="java.awt.Color.BLUE" />
Modified: trunk/guix-test-swing/src/main/java/org/nuiton/guix/demo/GuixDemo5.guix
===================================================================
--- trunk/guix-test-swing/src/main/java/org/nuiton/guix/demo/GuixDemo5.guix 2009-08-25 10:51:02 UTC (rev 1577)
+++ trunk/guix-test-swing/src/main/java/org/nuiton/guix/demo/GuixDemo5.guix 2009-08-25 10:51:11 UTC (rev 1578)
@@ -4,5 +4,5 @@
<Panel id="panel2">
<Label text="GuixDemo5 inherits GuixDemo2" />
</Panel>
- <javax.swing.JCheckBox id="button" text="Push Me again" />
+ <CheckBox id="button" text="Push Me again" />
</org.nuiton.guix.demo.GuixDemo2>
\ No newline at end of file
1
0
r1577 - in trunk/guix-test-gwt: . src/main/java/org/nuiton/guix/client src/main/java/org/nuiton/guix/client/demo
by kmorin@users.nuiton.org 25 Aug '09
by kmorin@users.nuiton.org 25 Aug '09
25 Aug '09
Author: kmorin
Date: 2009-08-25 12:51:02 +0200 (Tue, 25 Aug 2009)
New Revision: 1577
Modified:
trunk/guix-test-gwt/pom.xml
trunk/guix-test-gwt/src/main/java/org/nuiton/guix/client/Controller.java
trunk/guix-test-gwt/src/main/java/org/nuiton/guix/client/demo/GuixDemo.guix
Log:
Upgrade with new features
Modified: trunk/guix-test-gwt/pom.xml
===================================================================
--- trunk/guix-test-gwt/pom.xml 2009-08-25 10:50:31 UTC (rev 1576)
+++ trunk/guix-test-gwt/pom.xml 2009-08-25 10:51:02 UTC (rev 1577)
@@ -40,6 +40,12 @@
</dependency>
<dependency>
+ <groupId>com.google.code.gwtx</groupId>
+ <artifactId>gwtx</artifactId>
+ <version>1.5.0</version>
+</dependency>
+
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
Modified: trunk/guix-test-gwt/src/main/java/org/nuiton/guix/client/Controller.java
===================================================================
--- trunk/guix-test-gwt/src/main/java/org/nuiton/guix/client/Controller.java 2009-08-25 10:50:31 UTC (rev 1576)
+++ trunk/guix-test-gwt/src/main/java/org/nuiton/guix/client/Controller.java 2009-08-25 10:51:02 UTC (rev 1577)
@@ -22,12 +22,15 @@
private java.lang.String text = "controller";
private int num = 0;
+ private java.lang.String cssText = "";
+ private java.beans.PropertyChangeSupport support = new java.beans.PropertyChangeSupport(this);
public Controller() {
System.out.println("Dude, it's bloody raining");
}
public void test() {
+
}
public java.lang.String getText() {
@@ -35,7 +38,9 @@
}
public void setText(java.lang.String text) {
+ String oldValue = this.text;
this.text = text;
+ support.firePropertyChange("text", oldValue, text);
}
public int getNum() {
@@ -43,6 +48,27 @@
}
public void setNum(int num) {
+ int oldValue = this.num;
this.num = num;
+ support.firePropertyChange("num", oldValue, num);
}
+
+ public java.lang.String getCssText() {
+ return cssText;
+ }
+
+ public void setCssText(java.lang.String cssText) {
+ String oldValue = this.cssText;
+ this.cssText = cssText;
+ support.firePropertyChange("cssText", oldValue, cssText);
+ }
+
+ public void addPropertyChangeListener(java.beans.PropertyChangeListener listener) {
+ support.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String property, java.beans.PropertyChangeListener listener) {
+ support.addPropertyChangeListener(property, listener);
+ }
}
+
Modified: trunk/guix-test-gwt/src/main/java/org/nuiton/guix/client/demo/GuixDemo.guix
===================================================================
--- trunk/guix-test-gwt/src/main/java/org/nuiton/guix/client/demo/GuixDemo.guix 2009-08-25 10:50:31 UTC (rev 1576)
+++ trunk/guix-test-gwt/src/main/java/org/nuiton/guix/client/demo/GuixDemo.guix 2009-08-25 10:51:02 UTC (rev 1577)
@@ -6,6 +6,7 @@
import com.google.gwt.user.client.Command;
private Button b = new Button("test");
+int integer = 0;
private Command cmd = new Command() {
public void execute() {
@@ -26,6 +27,7 @@
table1.setSize(String.valueOf(com.google.gwt.user.client.Random.nextInt(800)) + "px",
String.valueOf(com.google.gwt.user.client.Random.nextInt(400)) + "px");
}
+ integer ++;
}
});
@@ -68,49 +70,55 @@
</MenuBar>
<java.util.ArrayList id="list" />
<TabPanel id="tabPanel" width="800px" height="400px">
- <Table id="table1" name="Table">
- <Row>
- <Cell>
- <!-- javadoc textfield -->
- <TextField id="textfield" text='test' enabled="{gd2.getButton().down && gd22.button.isSelected()}" onFocus='{System.out.println("dude !")}'/>
- </Cell>
- <Cell>
- <Label id="label" visible="{textfield.enabled}" text="{textfield.getText()}" styleClass="bold" />
- </Cell>
- <Cell rows='3'>
- <Label id="label2" text="color" style="color: yellow" />
- </Cell>
- </Row>
- <Row insets="0,0,0,0">
- <Cell columns="3">
- <org.nuiton.guix.client.demo.GuixDemo3 id="bt3" text="bt3" onClick='{System.out.println("beau gosse");list.add("test" + list.size())}'/>
- </Cell>
- </Row>
- <Row id="row3" insets="0,0,0,0">
- <Cell columns="2">
- <org.nuiton.guix.client.otherpackage.GuixDemo4 id="bt31" />
- </Cell>
- <Cell insets="2,2,2,2">
- <org.nuiton.guix.client.km.KevinMorinBis />
- </Cell>
- </Row>
- <Row>
- <Cell columns="3">
- <Label text="{c1.getText()} : {c1.getNum()}" />
- </Cell>
- </Row>
- <Row>
- <Cell columns="3">
- <Label text="{c2.getText()} : {c2.getNum()}" />
- </Cell>
- </Row>
- <Row>
- <Cell columns="2">
- <Label id="label3" text="list size : {list.size()}" style="color: yellow" />
- </Cell>
- </Row>
- </Table>
- <org.nuiton.guix.client.demo.GuixDemo2 id="gd2" name="GD2" />
- <org.nuiton.guix.client.demo.GuixDemo2 id="gd22" name="GD22" />
+ <Tab title='"Table"'>
+ <Table id="table1" name="Table">
+ <Row>
+ <Cell>
+ <!-- javadoc textfield -->
+ <TextField id="textfield" text='test' enabled="{gd2.getButton().down && gd22.button.isSelected()}" onFocus='{System.out.println("dude !")}'/>
+ </Cell>
+ <Cell>
+ <Label id="label" visible="{textfield.enabled}" text="{textfield.getText()}" styleClass="bold" />
+ </Cell>
+ <Cell rows='3'>
+ <Label id="label2" text="color" style="color: yellow" />
+ </Cell>
+ </Row>
+ <Row insets="0,0,0,0">
+ <Cell columns="3">
+ <org.nuiton.guix.client.demo.GuixDemo3 id="bt3" text="bt3" onClick='{System.out.println("beau gosse");list.add("test" + list.size())}'/>
+ </Cell>
+ </Row>
+ <Row id="row3" insets="0,0,0,0">
+ <Cell columns="2">
+ <org.nuiton.guix.client.otherpackage.GuixDemo4 id="bt31" />
+ </Cell>
+ <Cell insets="2,2,2,2">
+ <org.nuiton.guix.client.km.KevinMorinBis />
+ </Cell>
+ </Row>
+ <Row>
+ <Cell columns="3">
+ <Label text="{c1.getText()} : {c1.getNum()}" />
+ </Cell>
+ </Row>
+ <Row>
+ <Cell columns="3">
+ <Label text="{c2.getText()} : {c2.getNum()}" />
+ </Cell>
+ </Row>
+ <Row>
+ <Cell columns="2">
+ <Label id="label3" text="list size : {integer}" style="color: yellow" />
+ </Cell>
+ </Row>
+ </Table>
+ </Tab>
+ <Tab title='"GD2"'>
+ <org.nuiton.guix.client.demo.GuixDemo2 id="gd2" />
+ </Tab>
+ <Tab title='"GD22"'>
+ <org.nuiton.guix.client.demo.GuixDemo2 id="gd22" />
+ </Tab>
</TabPanel>
</Application>
1
0
r1576 - in trunk/guix-compiler-swing/src: main/java/org/nuiton/guix main/java/org/nuiton/guix/generator main/java/org/nuiton/guix/tags/swing test/java/org/nuiton/guix/generator
by kmorin@users.nuiton.org 25 Aug '09
by kmorin@users.nuiton.org 25 Aug '09
25 Aug '09
Author: kmorin
Date: 2009-08-25 12:50:31 +0200 (Tue, 25 Aug 2009)
New Revision: 1576
Added:
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/CheckBoxHandler.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ComboBoxHandler.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/DialogBoxHandler.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ListHandler.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/PasswordFieldHandler.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ProgressBarHandler.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/RadioButtonHandler.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ScrollPanelHandler.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/SliderHandler.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/SpinnerHandler.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/SplitPanelHandler.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TabHandler.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TextAreaHandler.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TreeHandler.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TreeNodeHandler.java
Modified:
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/SwingEventHandler.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/SwingGuixInitializer.java
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/generator/SwingImplementationGenerator.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingInterfaceGenerator.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingJavaFileGenerator.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingMainClassGenerator.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/TextComponentHandler.java
trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TextFieldHandler.java
trunk/guix-compiler-swing/src/test/java/org/nuiton/guix/generator/SwingGeneratorTest.java
Log:
Removed unused classes
Imporved the binding
Add Handlers
Modified: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/SwingEventHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/SwingEventHandler.java 2009-08-25 10:50:11 UTC (rev 1575)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/SwingEventHandler.java 2009-08-25 10:50:31 UTC (rev 1576)
@@ -130,22 +130,18 @@
.append("() {\n");
//for every event handled for the EventSetDescriptor
for(Method m : map.get(e).keySet()) {
- for(Annotation a : m.getDeclaredAnnotations())
+ 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(")")
+ Class clazz = m.getParameterTypes()[0];
+ result.append(clazz.getCanonicalName())
+ .append(" event)")
.append("{\n")
.append(map.get(e).get(m))
.append("\n}\n");
Modified: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/SwingGuixInitializer.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/SwingGuixInitializer.java 2009-08-25 10:50:11 UTC (rev 1575)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/SwingGuixInitializer.java 2009-08-25 10:50:31 UTC (rev 1576)
@@ -28,13 +28,28 @@
import org.nuiton.guix.tags.swing.TableHandler;
import org.nuiton.guix.tags.TagManager;
import org.nuiton.guix.tags.swing.ButtonHandler;
+import org.nuiton.guix.tags.swing.CheckBoxHandler;
+import org.nuiton.guix.tags.swing.ComboBoxHandler;
+import org.nuiton.guix.tags.swing.DialogBoxHandler;
import org.nuiton.guix.tags.swing.LabelHandler;
+import org.nuiton.guix.tags.swing.ListHandler;
import org.nuiton.guix.tags.swing.MenuBarHandler;
import org.nuiton.guix.tags.swing.MenuHandler;
import org.nuiton.guix.tags.swing.MenuItemHandler;
+import org.nuiton.guix.tags.swing.PasswordFieldHandler;
+import org.nuiton.guix.tags.swing.ProgressBarHandler;
+import org.nuiton.guix.tags.swing.RadioButtonHandler;
+import org.nuiton.guix.tags.swing.ScrollPanelHandler;
+import org.nuiton.guix.tags.swing.SliderHandler;
+import org.nuiton.guix.tags.swing.SpinnerHandler;
+import org.nuiton.guix.tags.swing.SplitPanelHandler;
+import org.nuiton.guix.tags.swing.TabHandler;
import org.nuiton.guix.tags.swing.TabPanelHandler;
+import org.nuiton.guix.tags.swing.TextAreaHandler;
import org.nuiton.guix.tags.swing.TextFieldHandler;
import org.nuiton.guix.tags.swing.ToggleButtonHandler;
+import org.nuiton.guix.tags.swing.TreeHandler;
+import org.nuiton.guix.tags.swing.TreeNodeHandler;
/**
* Initialize the application
@@ -45,18 +60,35 @@
public static void initialize() {
TagManager.registerGuixClassHandler("Application", FrameHandler.class);
TagManager.registerGuixClassHandler("Frame", FrameHandler.class);
+ TagManager.registerGuixClassHandler("DialogBox", DialogBoxHandler.class);
TagManager.registerGuixClassHandler("Table", TableHandler.class);
TagManager.registerGuixClassHandler("Row", RowHandler.class);
TagManager.registerGuixClassHandler("Cell", CellHandler.class);
TagManager.registerGuixClassHandler("Panel", PanelHandler.class);
+ TagManager.registerGuixClassHandler("HorizontalSplitPanel", SplitPanelHandler.class);
+ TagManager.registerGuixClassHandler("VerticalSplitPanel", SplitPanelHandler.class);
+ TagManager.registerGuixClassHandler("ScrollPanel", ScrollPanelHandler.class);
TagManager.registerGuixClassHandler("Button", ButtonHandler.class);
TagManager.registerGuixClassHandler("TextField", TextFieldHandler.class);
+ TagManager.registerGuixClassHandler("TextArea", TextAreaHandler.class);
TagManager.registerGuixClassHandler("Label", LabelHandler.class);
TagManager.registerGuixClassHandler("ToggleButton", ToggleButtonHandler.class);
+ TagManager.registerGuixClassHandler("CheckBox", CheckBoxHandler.class);
+ TagManager.registerGuixClassHandler("ComboBox", ComboBoxHandler.class);
+ TagManager.registerGuixClassHandler("List", ListHandler.class);
+ TagManager.registerGuixClassHandler("PasswordField", PasswordFieldHandler.class);
+ TagManager.registerGuixClassHandler("ProgressBar", ProgressBarHandler.class);
+ TagManager.registerGuixClassHandler("RadioButton", RadioButtonHandler.class);
+ TagManager.registerGuixClassHandler("Slider", SliderHandler.class);
+ TagManager.registerGuixClassHandler("Spinner", SpinnerHandler.class);
TagManager.registerGuixClassHandler("TabPanel", TabPanelHandler.class);
+ TagManager.registerGuixClassHandler("Tab", TabHandler.class);
+ TagManager.registerGuixClassHandler("Tree", TreeHandler.class);
+ TagManager.registerGuixClassHandler("TreeNode", TreeNodeHandler.class);
TagManager.registerGuixClassHandler("MenuBar", MenuBarHandler.class);
TagManager.registerGuixClassHandler("Menu", MenuHandler.class);
TagManager.registerGuixClassHandler("MenuItem", MenuItemHandler.class);
+
}
}
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-08-25 10:50:11 UTC (rev 1575)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingAbstractClassGenerator.java 2009-08-25 10:50:31 UTC (rev 1576)
@@ -25,7 +25,8 @@
import java.io.InputStreamReader;
import java.io.Reader;
import org.nuiton.guix.tags.swing.MenuBarHandler;
-;
+import org.nuiton.guix.tags.swing.SplitPanelHandler;
+import org.nuiton.guix.tags.swing.TreeHandler;
import org.nuiton.guix.model.GuixModelObject;
//~--- JDK imports ------------------------------------------------------------
@@ -37,7 +38,7 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import org.nuiton.guix.databinding.BindingUtils;
+import org.nuiton.guix.BindingUtils;
import org.nuiton.guix.SwingEventHandler;
import org.nuiton.guix.model.AttributeDescriptor;
import org.nuiton.guix.model.Rule;
@@ -58,6 +59,10 @@
*/
public class SwingAbstractClassGenerator extends SwingJavaFileGenerator {
+ private static final String CONSTRAINT_ATTRIBUTE = "constraints";
+ private static final String SETTER_PATTERN = "%1$s oldValue = this.%2$s;\n%3$s\nfirePropertyChange(\"%2$s\", oldValue, %4$s);";
+ private static final String SWING_DEFAULT_PACKAGE = "javax.swing";
+
/** Stylesheets applied to the objects of the class */
List<StyleSheet> styleSheets = new ArrayList<StyleSheet>();
/** map of the different parts of the script associated with gmo */
@@ -81,8 +86,7 @@
gmo.getClassDescriptor().getName() + "Abstract",
null, gmo.getJavadoc());
- ScriptHandler sh = new ScriptHandler();
- script = sh.decomposeScript(gmo.getClassDescriptor().getScript());
+ script = ScriptHandler.decomposeScript(gmo.getClassDescriptor().getScript());
}
public void setSwingGenerator(SwingGenerator swingGenerator) {
@@ -91,19 +95,26 @@
@Override
public JavaFile generate() {
- super.addImports(gmo);
+ super.addImports();
- //add imports
+ //add script imports
for (String s : (List<String>) script.get(ScriptPart.IMPORTS)) {
jf.addImport(s);
}
- //add bodycode
+ //add script fields
+ for(JavaField field : (List<JavaField>) script.get(ScriptPart.FIELDS)) {
+ jf.addField(field, false);
+ }
+
+ //add script bodycode
jf.addBodyCode((String) script.get(ScriptPart.BODYCODE));
try {
- //get creation, initialization and databinding methods content
+ //get creation, setting and displying methods content
Map<Method, String> methodBodies = browseModelObjects(gmo);
+ // get the script initializers
+ String scriptInitializers = ScriptHandler.postProcessInitializers((String)script.get(ScriptPart.INITIALIZERS), jf.getAllFields());
//add constructor
jf.addMethod(new JavaMethod(Modifier.PUBLIC, null, gmo.getClassDescriptor().getName() + "Abstract",
@@ -112,17 +123,18 @@
//add initialization method
jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", "initialize", null, null,
getMethodName(Method.BEFORE_CREATION) + "();\n" + getMethodName(Method.COMPONENTS_CREATION) + "();\n" +
- getMethodName(Method.COMPONENTS_SETTINGS) + "();\n" +
- (script.get(ScriptPart.INITIALIZERS) != null ? script.get(ScriptPart.INITIALIZERS) + "\n" : "") +
- getMethodName(Method.BEFORE_INITIALIZATION) + "();\n" + getMethodName(Method.COMPONENTS_TREE) + "();\n" +
+ (scriptInitializers != null ? scriptInitializers + "\n" : "") +
+ getMethodName(Method.BEFORE_SETTINGS) + "();\n" + getMethodName(Method.COMPONENTS_SETTINGS) + "();\n" +
+ getMethodName(Method.BEFORE_TREE) + "();\n" + getMethodName(Method.COMPONENTS_TREE) + "();\n" +
getMethodName(Method.BEFORE_BINDING) + "();\n"+ getMethodName(Method.DATABINDING_INIT) + "();\n" + getMethodName(Method.IN_THE_END) + "();",
"initialization"));
//add overridable methods
- jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", getMethodName(Method.BEFORE_CREATION), null, null, jf.isSuperclassIsGuixObject() ? "super." + getMethodName(Method.BEFORE_CREATION) + "();\n" : "", ""));
- jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", getMethodName(Method.BEFORE_INITIALIZATION), null, null, jf.isSuperclassIsGuixObject() ? "super." + getMethodName(Method.BEFORE_INITIALIZATION) + "();\n" : "", ""));
- jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", getMethodName(Method.BEFORE_BINDING), null, null, jf.isSuperclassIsGuixObject() ? "super." + getMethodName(Method.BEFORE_BINDING) + "();\n" : "", ""));
- jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", getMethodName(Method.IN_THE_END), null, null, jf.isSuperclassIsGuixObject() ? "super." + getMethodName(Method.IN_THE_END) + "();\n" : "", ""));
+ jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", getMethodName(Method.BEFORE_CREATION), null, null, jf.isSuperclassIsGuixObject() ? "super." + getMethodName(Method.BEFORE_CREATION) + "();\n" : "", "Method called before the creation of the components"));
+ jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", getMethodName(Method.BEFORE_TREE), null, null, jf.isSuperclassIsGuixObject() ? "super." + getMethodName(Method.BEFORE_TREE) + "();\n" : "", "Method called before the creation of the component tree"));
+ jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", getMethodName(Method.BEFORE_SETTINGS), null, null, jf.isSuperclassIsGuixObject() ? "super." + getMethodName(Method.BEFORE_SETTINGS) + "();\n" : "", "Method called before the settings of the components"));
+ jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", getMethodName(Method.BEFORE_BINDING), null, null, jf.isSuperclassIsGuixObject() ? "super." + getMethodName(Method.BEFORE_BINDING) + "();\n" : "", "Method called before the binding"));
+ jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", getMethodName(Method.IN_THE_END), null, null, jf.isSuperclassIsGuixObject() ? "super." + getMethodName(Method.IN_THE_END) + "();\n" : "", "Method called in the end of the initialization"));
//add creation and initialization methods
jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", getMethodName(Method.COMPONENTS_CREATION), null, null,
@@ -139,11 +151,12 @@
jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", getMethodName(Method.DATABINDING_INIT), null, null,
jf.isSuperclassIsGuixObject() ? "super." + getMethodName(Method.DATABINDING_INIT) + "();\n" :
"", "initilization of databinding"));
-
+
//add script methods
for (JavaMethod m : (List<JavaMethod>) script.get(ScriptPart.METHODS)) {
+ ScriptHandler.postProcessMethodBody(m, jf.getAllFields());
//checks if the method override a generated method
- if ((m.getName().equals(getMethodName(Method.BEFORE_BINDING)) || m.getName().equals(getMethodName(Method.BEFORE_CREATION)) || m.getName().equals(getMethodName(Method.BEFORE_INITIALIZATION)) || m.getName().equals(getMethodName(Method.IN_THE_END))) && m.getReturnType() != null && m.getReturnType().equals("void") && m.getArguments() == null) {
+ if ((m.getName().equals(getMethodName(Method.BEFORE_BINDING)) || m.getName().equals(getMethodName(Method.BEFORE_CREATION)) || m.getName().equals(getMethodName(Method.BEFORE_SETTINGS)) || m.getName().equals(getMethodName(Method.BEFORE_TREE)) || m.getName().equals(getMethodName(Method.IN_THE_END))) && m.getReturnType() != null && m.getReturnType().equals("void") && m.getArguments() == null) {
int i = 0;
boolean methodFound = false;
while (i < jf.getMethods().length && !methodFound) {
@@ -163,6 +176,16 @@
jf.addMethod(m);
}
}
+
+ //Modify the setters by adding the firePropertyChange call
+ for(JavaMethod method : jf.getMethods()) {
+ if(method.getName().startsWith("set") && method.getName().length() > 3
+ && Character.isUpperCase(method.getName().charAt(3)) && method.getArguments() != null) {
+ method.setBodyCode(String.format(SETTER_PATTERN, method.getArguments()[0].getType(),
+ Character.toLowerCase(method.getName().charAt(3)) + method.getName().substring(4),
+ method.getBodyCode(), method.getArguments()[0].getName()));
+ }
+ }
}
catch (ClassNotFoundException eee) {
if (log.isErrorEnabled()) {
@@ -174,6 +197,9 @@
log.error(eee);
}
}
+ catch (NullPointerException eee) {
+ eee.printStackTrace();
+ }
return jf;
}
@@ -194,15 +220,21 @@
String constraint = null;
//do we need to overcharge the field
boolean createField = true;
-
+ //id with the first letter capitalized
+ String capitalizedId = (gmo.getId().length() > 0) ? Character.toUpperCase(gmo.getId().charAt(0)) + gmo.getId().substring(1) : gmo.getId();
+
//if gmo represents a table tag
- if (gmo.getClassDescriptor().getPackageName() == null && gmo.getClassDescriptor().getName().equalsIgnoreCase("Table")) {
+ if ((gmo.getClassDescriptor().getSuperClass() != null
+ && gmo.getClassDescriptor().getSuperClass().getPackageName() == null
+ && gmo.getClassDescriptor().getSuperClass().getName().equalsIgnoreCase("Table"))
+ || (gmo.getClassDescriptor().getPackageName() == null
+ && gmo.getClassDescriptor().getName().equalsIgnoreCase("Table"))) {
//matrix of the gridbaglayout : the free zones are represented by null or false
List<List<Boolean>> layout = new ArrayList<List<Boolean>>();
StringBuffer settingsMethod = new StringBuffer();
//Checks in the table tag if any attribute defines constraints for the children
- TableHandler table = new TableHandler(gmo);
- clazz = table.getClassToGenerate();
+ TableHandler tableHandler = new TableHandler(gmo);
+ clazz = tableHandler.getClassToGenerate();
//if the gmo is the parent or if the field is inherited and has the same class, we don't need to overcharge the field
if(gmo.getParent() == null || (jf.getInheritedField(gmo.getId()) != null && jf.getInheritedField(gmo.getId()).getType().equals(clazz.getName()))) {
createField = false;
@@ -222,26 +254,43 @@
if(createField) {
jf.addField(new JavaField(Modifier.PRIVATE,
clazz.getName(),
- gmo.getId(), gmo.getJavadoc(), table),
- true);
+ gmo.getId(), gmo.getJavadoc(), tableHandler),
+ gmo.isJavaBean());
//the layout of the table is the GridBagLayout
componentsCreation.append(gmo.getId()).append(" = new ")
.append(clazz.getName()).append("(new java.awt.GridBagLayout());\n");
+ if(jf.getInheritedField(gmo.getId()) != null) {
+ componentsCreation.append("super.set").append(capitalizedId).append("(").append(gmo.getId()).append(");\n");
+ }
}
+ else {
+ settingsMethod.append(gmo.getId()).append(".setLayout(new java.awt.GridBagLayout());\n");
+ }
if(jf.isSuperclassIsGuixObject() && jf.getInheritedField(gmo.getId()) != null) {
settingsMethod.insert(0, "super." + gmo.getId() + "Settings();\n");
}
- constraint = processAttributes(clazz, gmo, settingsMethod, seh, table);
+ constraint = processAttributes(clazz, gmo, settingsMethod, seh, tableHandler);
//add the component to its parent
- componentsTree.append(gmo.getParent().getParent() == null ? "this" : gmo.getParent().getId()).append(".add(").append(gmo.getId());
- //if the constraints exists
- if (constraint != null) {
- componentsTree.append(",").append(constraint);
+ if(gmo.getParent().getParent() == null && jf.getInheritedField(gmo.getId()) != null) {
+ componentsTree.append(gmo.getParent().getParent() != null ? gmo.getParent().getId() : "this").append(".set").append(capitalizedId).append("(").append(gmo.getId()).append(");\n");
}
- componentsTree.append(");\n");
+ else if(!ignoreTag(gmo)) {
+ if((gmo.getParent().getClassDescriptor().getPackageName() == null && gmo.getParent().getClassDescriptor().getName().equalsIgnoreCase("ScrollPanel"))
+ || gmo.getParent().getClassDescriptor().toString().equals("javax.swing.JScrollPane")) {
+ componentsTree.append(gmo.getParent().getParent() != null ? gmo.getParent().getId() : "this").append(".setViewportView(").append(gmo.getId()).append(");\n");
+ }
+ else {
+ componentsTree.append(gmo.getParent().getParent() == null ? "this" : gmo.getParent().getId()).append(".add(").append(gmo.getId());
+ //if the constraints exists
+ if (constraint != null) {
+ componentsTree.append(",").append(constraint);
+ }
+ componentsTree.append(");\n");
+ }
+ }
for (int r = 0; r < gmo.getChildren().size(); r++) {
GuixModelObject row = gmo.getChildren().get(r);
@@ -253,7 +302,7 @@
}
else {
//Checks in the row tag if any attribute defines constraints for the children
- RowHandler ro = new RowHandler(row, table);
+ RowHandler rowHandler = new RowHandler(row, tableHandler);
int iC = 0;
for (int c = 0; c < row.getChildren().size(); c++) {
GuixModelObject cell = row.getChildren().get(c);
@@ -270,8 +319,8 @@
}
}
else {
- CellHandler cl = new CellHandler(cell, ro);
- componentsTree.append(TableHandler.createCell(gmo.getId(), cl, layout, iC, r));
+ CellHandler cellHandler = new CellHandler(cell, rowHandler);
+ componentsTree.append(TableHandler.createCell(gmo.getId(), cellHandler, layout, iC, r));
//browse the children of the child of the cell
Map<Method, String> methodBodies = browseModelObjects(cell.getChildren().get(0));
@@ -286,11 +335,50 @@
componentsSettings.append(gmo.getId()).append("Settings();\n");
}
+ else if ((gmo.getClassDescriptor().getSuperClass() != null && gmo.getClassDescriptor().getSuperClass().getPackageName() == null && gmo.getClassDescriptor().getSuperClass().getName().equalsIgnoreCase("Tab"))
+ || (gmo.getClassDescriptor().getPackageName() == null && gmo.getClassDescriptor().getName().equalsIgnoreCase("Tab"))) {
+ //if the parent has a superclass and this superclass is a TabPanel or if the parent is null or if the parent is a TabPanel
+ if(((gmo.getParent().getClassDescriptor().getSuperClass() != null
+ && ((gmo.getParent().getClassDescriptor().getSuperClass().getPackageName() == null
+ && (gmo.getParent().getClassDescriptor().getSuperClass().getName().equals("TabPanel") || gmo.getParent().getClassDescriptor().getSuperClass().getName().equals("JTabbedPane")))
+ || (gmo.getParent().getClassDescriptor().getSuperClass().toString().equals("javax.swing.JTabbedPane"))))
+ ||(gmo.getParent() == null
+ || (gmo.getParent().getClassDescriptor().getPackageName() == null
+ && (gmo.getParent().getClassDescriptor().getName().equals("TabPanel") || gmo.getParent().getClassDescriptor().getName().equals("JTabbedPane")))
+ || (gmo.getParent().getClassDescriptor().toString().equals("javax.swing.JTabbedPane"))))
+ && gmo.getChildren().size() == 1) {
+ String title = null;
+ for(AttributeDescriptor attribute : gmo.getAttributeDescriptors()) {
+ if(attribute.getName().equals("title")) {
+ title = attribute.getValue();
+ break;
+ }
+ }
+
+ //add the component to its parent
+ componentsTree.append(gmo.getParent().getParent() != null ? gmo.getParent().getId() : "this").append(".addTab(")
+ .append(title != null ? title : "\"" + gmo.getId() + "\"").append(",").append(gmo.getChildren().get(0).getId()).append(");\n");
+
+ Map<Method, String> methodBodies = browseModelObjects(gmo.getChildren().get(0));
+ componentsCreation.append(methodBodies.get(Method.COMPONENTS_CREATION));
+ componentsSettings.append(methodBodies.get(Method.COMPONENTS_SETTINGS));
+ componentsTree.append(methodBodies.get(Method.COMPONENTS_TREE));
+ }
+ else if(log.isErrorEnabled()) {
+ log.error("Tab tags can only be children of TabPanel or JTabbedPane tags, and can have only one child.");
+ }
+ }
//if gmo represents a menubar tag
- else if (gmo.getClassDescriptor().getPackageName() == null && gmo.getClassDescriptor().getName().equalsIgnoreCase("MenuBar")) {
+ else if ((gmo.getClassDescriptor().getSuperClass() != null
+ && ((gmo.getClassDescriptor().getSuperClass().getPackageName() == null
+ && (gmo.getClassDescriptor().getSuperClass().getName().equalsIgnoreCase("MenuBar") || gmo.getClassDescriptor().getSuperClass().getName().equalsIgnoreCase("JMenuBar")))
+ || gmo.getClassDescriptor().getSuperClass().toString().equals("javax.swing.JMenuBar")))
+ || ((gmo.getClassDescriptor().getPackageName() == null
+ && (gmo.getClassDescriptor().getName().equalsIgnoreCase("MenuBar") || gmo.getClassDescriptor().getName().equalsIgnoreCase("JMenuBar")))
+ || gmo.getClassDescriptor().toString().equals("javax.swing.JMenuBar"))) {
StringBuffer settingsMethod = new StringBuffer();
- MenuBarHandler menuBar = new MenuBarHandler();
- clazz = menuBar.getClassToGenerate();
+ MenuBarHandler menuBarHandler = new MenuBarHandler();
+ clazz = menuBarHandler.getClassToGenerate();
//if the gmo is the parent or if the field is inherited and has the same class, we don't need to overcharge the field
if(gmo.getParent() == null || (jf.getInheritedField(gmo.getId()) != null && jf.getInheritedField(gmo.getId()).getType().equals(clazz.getName()))) {
createField = false;
@@ -311,21 +399,23 @@
if(createField) {
jf.addField(new JavaField(Modifier.PRIVATE,
clazz.getName(),
- gmo.getId(), gmo.getJavadoc(), menuBar),
- true);
+ gmo.getId(), gmo.getJavadoc(), menuBarHandler),
+ gmo.isJavaBean());
componentsCreation.append(gmo.getId()).append(" = new ")
.append(clazz.getName()).append("();\n");
+ if(jf.getInheritedField(gmo.getId()) != null) {
+ componentsCreation.append("super.set").append(capitalizedId).append("(").append(gmo.getId()).append(");\n");
+ }
}
if(jf.isSuperclassIsGuixObject() && jf.getInheritedField(gmo.getId()) != null) {
settingsMethod.insert(0, "super." + gmo.getId() + "Settings();\n");
}
- constraint = processAttributes(clazz, gmo, settingsMethod, seh, menuBar);
+ constraint = processAttributes(clazz, gmo, settingsMethod, seh, menuBarHandler);
//add the component to its parent
componentsTree.append(gmo.getParent().getParent() == null ? "this" : gmo.getParent().getId()).append(".setJMenuBar(").append(gmo.getId()).append(");\n");
-
-
+
for (GuixModelObject child : gmo.getChildren()) {
//browse the children of the child of the menubar
Map<Method, String> methodBodies = browseModelObjects(child);
@@ -336,6 +426,168 @@
//create the menu
componentsSettings.append(gmo.getId()).append("Settings();\n");
}
+ //if the tag is a SplitPanel (Vertical or Horizontal)
+ else if((gmo.getClassDescriptor().getSuperClass() != null
+ && ((gmo.getClassDescriptor().getSuperClass().getPackageName() == null
+ && (gmo.getClassDescriptor().getSuperClass().getName().equalsIgnoreCase("VerticalSplitPanel")
+ || gmo.getClassDescriptor().getSuperClass().getName().equalsIgnoreCase("HorizontalSplitPanel")
+ || gmo.getClassDescriptor().getSuperClass().getName().equalsIgnoreCase("JSplitPane")))
+ || gmo.getClassDescriptor().getSuperClass().toString().equals("javax.swing.JSplitPane")))
+ || ((gmo.getClassDescriptor().getPackageName() == null
+ && (gmo.getClassDescriptor().getName().equalsIgnoreCase("VerticalSplitPanel")
+ || gmo.getClassDescriptor().getName().equalsIgnoreCase("HorizontalSplitPanel")
+ || gmo.getClassDescriptor().getName().equalsIgnoreCase("JSplitPane")))
+ || gmo.getClassDescriptor().toString().equals("javax.swing.JSplitPane"))) {
+
+ StringBuffer settingsMethod = new StringBuffer();
+ SplitPanelHandler splitPanelHandler = new SplitPanelHandler();
+ clazz = splitPanelHandler.getClassToGenerate();
+
+ //if the gmo is the parent or if the field is inherited and has the same class, we don't need to overcharge the field
+ if(gmo.getParent() == null || (jf.getInheritedField(gmo.getId()) != null && jf.getInheritedField(gmo.getId()).getType().equals(clazz.getName()))) {
+ createField = false;
+ }
+ //if the field is inherited but doesn't hav the same class, check if the types are compatible
+ if(createField && jf.getInheritedField(gmo.getId()) != null) {
+ try {
+ Class inheritedClazz = Class.forName(jf.getInheritedField(gmo.getId()).getType());
+ if(!inheritedClazz.isAssignableFrom(clazz)) {
+ throw new ClassCastException();
+ }
+ }
+ catch(ClassNotFoundException eee) {
+ throw new ClassCastException();
+ }
+ }
+
+ if(createField) {
+ jf.addField(new JavaField(Modifier.PRIVATE,
+ clazz.getName(),
+ gmo.getId(), gmo.getJavadoc(), splitPanelHandler),
+ gmo.isJavaBean());
+
+ componentsCreation.append(gmo.getId()).append(" = new ")
+ .append(clazz.getName()).append("(").append(clazz.getName())
+ .append(gmo.getClassDescriptor().getName().equalsIgnoreCase("VerticalSplitPanel") ? ".VERTICAL_SPLIT" : ".HORIZONTAL_SPLIT").append(");\n");
+ }
+ if(jf.isSuperclassIsGuixObject() && jf.getInheritedField(gmo.getId()) != null) {
+ settingsMethod.insert(0, "super." + gmo.getId() + "Settings();\n");
+ }
+ constraint = processAttributes(clazz, gmo, settingsMethod, seh, splitPanelHandler);
+
+ //add the component to its parent
+ if(gmo.getParent().getParent() == null && jf.getInheritedField(gmo.getId()) != null) {
+ componentsTree.append(gmo.getParent().getParent() != null ? gmo.getParent().getId() : "this").append(".set").append(capitalizedId).append("(").append(gmo.getId()).append(");\n");
+ }
+ else if(!ignoreTag(gmo)) {
+ if((gmo.getParent().getClassDescriptor().getPackageName() == null && gmo.getParent().getClassDescriptor().getName().equalsIgnoreCase("ScrollPanel"))
+ || gmo.getParent().getClassDescriptor().toString().equals("javax.swing.JScrollPane")) {
+ componentsTree.append(gmo.getParent().getParent() != null ? gmo.getParent().getId() : "this").append(".setViewportView(").append(gmo.getId()).append(");\n");
+ }
+ else {
+ componentsTree.append(gmo.getParent().getParent() == null ? "this" : gmo.getParent().getId()).append(".add(").append(gmo.getId());
+ //if the constraints exists
+ if (constraint != null) {
+ componentsTree.append(",").append(constraint);
+ }
+ componentsTree.append(");\n");
+ }
+ }
+
+ for (GuixModelObject child : gmo.getChildren()) {
+ Map<Method, String> methodBodies = browseModelObjects(child);
+ componentsCreation.append(methodBodies.get(Method.COMPONENTS_CREATION));
+ componentsSettings.append(methodBodies.get(Method.COMPONENTS_SETTINGS));
+ componentsTree.append(methodBodies.get(Method.COMPONENTS_TREE));
+ }
+ //create the splitpanel
+ componentsSettings.append(gmo.getId()).append("Settings();\n");
+ }
+ //if the tag represents a tree
+ else if((gmo.getClassDescriptor().getSuperClass() != null
+ && ((gmo.getClassDescriptor().getSuperClass().getPackageName() == null
+ && (gmo.getClassDescriptor().getSuperClass().getName().equalsIgnoreCase("Tree") || gmo.getClassDescriptor().getSuperClass().getName().equalsIgnoreCase("JTree")))
+ || gmo.getClassDescriptor().getSuperClass().toString().equals("javax.swing.JTree")))
+ ||((gmo.getClassDescriptor().getPackageName() == null
+ && (gmo.getClassDescriptor().getName().equalsIgnoreCase("Tree") || gmo.getClassDescriptor().getName().equalsIgnoreCase("JTree")))
+ ||gmo.getClassDescriptor().toString().equals("javax.swing.JTree"))) {
+
+ StringBuffer settingsMethod = new StringBuffer();
+ TreeHandler treeHandler = new TreeHandler();
+ clazz = treeHandler.getClassToGenerate();
+
+ //if the gmo is the parent or if the field is inherited and has the same class, we don't need to overcharge the field
+ if(gmo.getParent() == null || (jf.getInheritedField(gmo.getId()) != null && jf.getInheritedField(gmo.getId()).getType().equals(clazz.getName()))) {
+ createField = false;
+ }
+ //if the field is inherited but doesn't have the same class, check if the types are compatible
+ if(createField && jf.getInheritedField(gmo.getId()) != null) {
+ try {
+ Class inheritedClazz = Class.forName(jf.getInheritedField(gmo.getId()).getType());
+ if(!inheritedClazz.isAssignableFrom(clazz)) {
+ throw new ClassCastException();
+ }
+ }
+ catch(ClassNotFoundException eee) {
+ throw new ClassCastException();
+ }
+ }
+ //browse the children first to be able to ad them to the list after their creation
+ for (GuixModelObject child : gmo.getChildren()) {
+ Map<Method, String> methodBodies = browseModelObjects(child);
+ componentsCreation.append(methodBodies.get(Method.COMPONENTS_CREATION));
+ componentsSettings.append(methodBodies.get(Method.COMPONENTS_SETTINGS));
+ componentsTree.append(methodBodies.get(Method.COMPONENTS_TREE));
+ }
+
+ if(createField) {
+ jf.addField(new JavaField(Modifier.PRIVATE,
+ clazz.getName(),
+ gmo.getId(), gmo.getJavadoc(), treeHandler),
+ gmo.isJavaBean());
+
+ if(gmo.getChildren().size() == 1) {
+ componentsCreation.append(gmo.getId()).append(" = new ")
+ .append(clazz.getName()).append("(").append(gmo.getChildren().get(0).getId()).append(");\n");
+ }
+ else {
+ componentsCreation.append("java.util.Vector<javax.swing.tree.TreeNode> ")
+ .append(gmo.getId()).append("Nodes = new java.util.Vector<javax.swing.tree.TreeNode>();\n");
+ for(GuixModelObject child : gmo.getChildren()) {
+ componentsCreation.append(gmo.getId()).append("Nodes.add(")
+ .append(child.getId()).append(");\n");
+ }
+ componentsCreation.append(gmo.getId()).append(" = new ")
+ .append(clazz.getName()).append("(").append(gmo.getId()).append("Nodes);\n");
+ }
+ }
+ if(jf.isSuperclassIsGuixObject() && jf.getInheritedField(gmo.getId()) != null) {
+ settingsMethod.insert(0, "super." + gmo.getId() + "Settings();\n");
+ }
+ constraint = processAttributes(clazz, gmo, settingsMethod, seh, treeHandler);
+
+ //add the component to its parent
+ if(gmo.getParent().getParent() == null && jf.getInheritedField(gmo.getId()) != null) {
+ componentsTree.append(gmo.getParent().getParent() != null ? gmo.getParent().getId() : "this").append(".set").append(capitalizedId).append("(").append(gmo.getId()).append(");\n");
+ }
+ else if(!ignoreTag(gmo)) {
+ if((gmo.getParent().getClassDescriptor().getPackageName() == null && gmo.getParent().getClassDescriptor().getName().equalsIgnoreCase("ScrollPanel"))
+ || gmo.getParent().getClassDescriptor().toString().equals("javax.swing.JScrollPane")) {
+ componentsTree.append(gmo.getParent().getParent() != null ? gmo.getParent().getId() : "this").append(".setViewportView(").append(gmo.getId()).append(");\n");
+ }
+ else {
+ componentsTree.append(gmo.getParent().getParent() == null ? "this" : gmo.getParent().getId()).append(".add(").append(gmo.getId());
+ //if the constraints exists
+ if (constraint != null) {
+ componentsTree.append(",").append(constraint);
+ }
+ componentsTree.append(");\n");
+ }
+ }
+
+ //create the splitpanel
+ componentsSettings.append(gmo.getId()).append("Settings();\n");
+ }
else {
//TagHandler of gmo's class
TagHandler th = null;
@@ -345,8 +597,6 @@
JavaFile jFile = null;
//gmo's first not generated superclass
Class superClazz = null;
- //id with the first letter capitalized
- String capitalizedId = (gmo.getId().length() > 0) ? Character.toUpperCase(gmo.getId().charAt(0)) + gmo.getId().substring(1) : gmo.getId();
StringBuffer settingsMethod = new StringBuffer();
//List of gmo's generated superclasses
List<String> generatedSuperClasses = new ArrayList<String>();
@@ -358,38 +608,51 @@
clazz = th.getClassToGenerate();
}
}
- //check if gmo's superclass has a TagHandler and get the class to generate instead
- else if(gmo.getParent() == null && gmo.getClassDescriptor().getSuperClass() != null && TagManager.getGuixClassHandler(gmo.getClassDescriptor().getSuperClass().getName()) != null) {
- th = TagManager.getGuixClassHandler(gmo.getClassDescriptor().getSuperClass().getName());
- if(th != null) {
- clazz = th.getClassToGenerate();
- }
- }
- //check if gmo's type is a generated class
- else if(gmo.getClassDescriptor() != null && classes.get(gmo.getClassDescriptor().toString()) != null) {
- jFile = classes.get(gmo.getClassDescriptor().toString());
- }
- //check if gmo is the first tag and its superclass is a generated class
- else if(gmo.getParent() == null && gmo.getClassDescriptor().getSuperClass() != null && classes.get(gmo.getClassDescriptor().getSuperClass().toString()) != null) {
- jFile = classes.get(gmo.getClassDescriptor().getSuperClass().toString());
- }
- //gmo's class is a basic class or an uncompiled class from the source folder
+ //check if gmo's class has a TagHandler and get the class to generate instead
else {
- try{
- //get the class represented by cd
- clazz = Class.forName(gmo.getClassDescriptor().toString());
+ if(gmo.getClassDescriptor().getPackageName() == null) {
+ gmo.getClassDescriptor().setPackageName(SWING_DEFAULT_PACKAGE);
}
- catch (ClassNotFoundException eee) {
- File f = new File(swingGenerator.getSrcDir(), gmo.getClassDescriptor().toString().replace('.', File.separatorChar) + ".java");
- try {
- Reader isr = new InputStreamReader(new FileInputStream(f));
- jFile = JavaFileParser.parseJavaFile(gmo.getClassDescriptor().toString(), isr);
+ if(TagManager.getGuixClassHandler(gmo.getClassDescriptor().toString()) != null) {
+ th = TagManager.getGuixClassHandler(gmo.getClassDescriptor().toString());
+ if(th != null) {
+ clazz = th.getClassToGenerate();
}
- catch (FileNotFoundException eeee) {
- log.error(eeee);
- throw new ClassNotFoundException();
+ }
+ //check if gmo's superclass has a TagHandler and get the class to generate instead
+ else if(gmo.getParent() == null && gmo.getClassDescriptor().getSuperClass() != null && TagManager.getGuixClassHandler(gmo.getClassDescriptor().getSuperClass().getName()) != null) {
+ th = TagManager.getGuixClassHandler(gmo.getClassDescriptor().getSuperClass().getName());
+ if(th != null) {
+ clazz = th.getClassToGenerate();
}
}
+ //check if gmo's type is a generated class
+ else if(gmo.getClassDescriptor() != null && classes.get(gmo.getClassDescriptor().toString()) != null) {
+ jFile = classes.get(gmo.getClassDescriptor().toString());
+ }
+ //check if gmo is the first tag and its superclass is a generated class
+ else if(gmo.getParent() == null && gmo.getClassDescriptor().getSuperClass() != null && classes.get(gmo.getClassDescriptor().getSuperClass().toString()) != null) {
+ jFile = classes.get(gmo.getClassDescriptor().getSuperClass().toString());
+ }
+ //gmo's class is a basic class or an uncompiled class from the source folder
+ else {
+ try{
+ //get the class represented by cd
+ clazz = Class.forName(gmo.getClassDescriptor().toString());
+ }
+ catch (ClassNotFoundException eee) {
+ File f = new File(swingGenerator.getSrcDir(), gmo.getClassDescriptor().toString().replace('.', File.separatorChar) + ".java");
+ try {
+ Reader isr = new InputStreamReader(new FileInputStream(f));
+ jFile = JavaFileParser.parseJavaFile(gmo.getClassDescriptor().toString(), isr);
+ swingGenerator.getPropertyChangeListenerDependencies().add(jFile);
+ }
+ catch (FileNotFoundException eeee) {
+ log.error(eeee);
+ throw new ClassNotFoundException();
+ }
+ }
+ }
}
if(clazz != null) {
@@ -452,13 +715,13 @@
jf.addField(new JavaField(Modifier.PROTECTED,
clazz.getName(),
gmo.getId(), gmo.getJavadoc(), th),
- true);
+ gmo.isJavaBean());
}
- else {
+ else {
jf.addField(new JavaField(Modifier.PROTECTED,
(classes != null && classes.containsKey(gmo.getClassDescriptor().toString())) ? gmo.getClassDescriptor().toString() + "Abstract" : gmo.getClassDescriptor().toString(),
- gmo.getId(), gmo.getJavadoc(), superTh != null ? superTh : th),
- true);
+ gmo.getId(), gmo.getJavadoc(), superTh),
+ gmo.isJavaBean());
}
}
//if gmo does not represents the first tag
@@ -466,7 +729,7 @@
if(jf.isSuperclassIsGuixObject() && jf.getInheritedField(gmo.getId()) != null) {
settingsMethod.insert(0, "super." + gmo.getId() + "Settings();\n");
}
- if(createField) {
+ if(createField || gmo.getConstructor() != null) {
componentsCreation.append(gmo.getId()).append(" = new ");
if(classes != null && classes.containsKey(gmo.getClassDescriptor().toString())) {
componentsCreation.append(gmo.getClassDescriptor().toString() + "Impl");
@@ -495,15 +758,19 @@
constraint = processAttributes(jFile, superClazz, gmo, settingsMethod, seh, superTh);
}
+ if((jFile != null && (jFile.getField(gmo.getId()) != null || jFile.getInheritedField(gmo.getId()) != null))
+ || (gmo.getParent().getParent() == null && jf.getInheritedField(gmo.getId()) != null)) {
+ componentsTree.append(gmo.getParent().getParent() != null ? gmo.getParent().getId() : "this").append(".set").append(capitalizedId).append("(").append(gmo.getId()).append(");\n");
+ }
//if gmo is not the child of a cell
- if (!(gmo.getParent().getClassDescriptor().getPackageName() == null && gmo.getParent().getClassDescriptor().getName().equalsIgnoreCase("Cell")) && !gmo.getClassDescriptor().toString().equals("javax.swing.JMenuBar")) {
- if((jFile != null && (jFile.getField(gmo.getId()) != null || jFile.getInheritedField(gmo.getId()) != null))
- || (gmo.getParent().getParent() == null && jf.getInheritedField(gmo.getId()) != null)) {
- componentsTree.append(gmo.getParent().getParent() != null ? gmo.getParent().getId() : "this").append(".set").append(capitalizedId).append("(").append(gmo.getId()).append(");\n");
+ else if (!ignoreTag(gmo)) {
+ if((gmo.getParent().getClassDescriptor().getPackageName() == null && gmo.getParent().getClassDescriptor().getName().equalsIgnoreCase("ScrollPanel"))
+ || gmo.getParent().getClassDescriptor().toString().equals("javax.swing.JScrollPane")) {
+ componentsTree.append(gmo.getParent().getParent() != null ? gmo.getParent().getId() : "this").append(".setViewportView(").append(gmo.getId()).append(");\n");
}
//add the component to its parent
- else
- if(superClazz != null && java.awt.Component.class.isAssignableFrom(superClazz)) {
+ else if((superClazz != null && java.awt.Component.class.isAssignableFrom(superClazz) && !java.awt.Window.class.isAssignableFrom(superClazz))
+ || (gmo.getParent().getClassDescriptor().getPackageName() == null && gmo.getParent().getClassDescriptor().getName().equalsIgnoreCase("TreeNode"))) {
componentsTree.append(gmo.getParent().getParent() != null ? gmo.getParent().getId() : "this").append(".add(").append(gmo.getId());
//with a constraint if it is not null
if (constraint != null) {
@@ -532,6 +799,12 @@
//get the inherited methods from the not generated superclass
if(clazz != null) {
jf.setSuperclassIsGuixObject(false);
+ if(javax.swing.JComponent.class.isAssignableFrom(clazz)) {
+ jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", "firePropertyChange",
+ new JavaArgument[]{new JavaArgument("String", "propertyName"), new JavaArgument("Object", "oldValue"), new JavaArgument("Object", "newValue")},
+ null, "super.firePropertyChange(propertyName, oldValue, newValue);", null));
+ }
+
for(java.lang.reflect.Method m : clazz.getMethods()) {
if(Modifier.isPublic(m.getModifiers()) || Modifier.isProtected(m.getModifiers())) {
JavaArgument[] args = new JavaArgument[m.getParameterTypes().length];
@@ -566,7 +839,7 @@
jf.addInheritedField(f);
}
}
- processAttributes(jFile, superClazz, gmo, settingsMethod, seh, superTh);
+ processAttributes(jFile, superClazz, gmo, settingsMethod, seh, superTh != null ? superTh: th);
}
else {
log.error("Allo Houston, on a un probleme !");
@@ -590,6 +863,16 @@
}
+ /**
+ *
+ * @return true if the tag does not represent a real object but is just useful to ease the creation of the UI
+ */
+ private boolean ignoreTag(GuixModelObject gmo) {
+ return (gmo.getParent() != null && (gmo.getParent().getClassDescriptor().getPackageName() == null
+ && (gmo.getParent().getClassDescriptor().getName().equalsIgnoreCase("Cell")
+ || gmo.getParent().getClassDescriptor().getName().equalsIgnoreCase("Tab"))));
+ }
+
/**
* Generates the code to set the attributes of the gmo
*
@@ -608,7 +891,7 @@
if(th != null && th.getAttrToGenerate(attr.getName()) != null) {
attr.setName(th.getAttrToGenerate(attr.getName()));
}
- boolean addQuote = false;
+ boolean addQuote = false, addSimpleQuote = false;
//the attribute name with the first letter capitalized
String capitalizedAttribute = (attr.getName().length() > 0) ? Character.toUpperCase(attr.getName().charAt(0)) + attr.getName().substring(1) : attr.getName();
//is the attribute a "real" attribute ? false if it represents an event or a constraint
@@ -622,7 +905,7 @@
realAttribute = !seh.addEvent(clazz, lowerCaseAttribute, attr.getValue());
}
//checks if it is a constraint
- else if (attr.getName().equals("constraint")) {
+ else if (attr.getName().equals(CONSTRAINT_ATTRIBUTE)) {
constraint = attr.getValue();
realAttribute = false;
}
@@ -649,9 +932,19 @@
else {
//checks if the parameter of the setter is a String
addQuote = methods[m].getParameterTypes()[0].equals(String.class);
+ addSimpleQuote = methods[m].getParameterTypes()[0].equals(Character.class) || methods[m].getParameterTypes()[0].equals(char.class);
//generates the code to set the attribute to object
if(settingsMethod != null) {
- settingsMethod.append(gmo.getParent() != null ? gmo.getId() : "this").append(".set").append(capitalizedAttribute).append("(").append(addQuote ? "\"" : "").append(attr.getValue()).append(addQuote ? "\"" : "").append(");\n");
+ settingsMethod.append(gmo.getParent() != null ? gmo.getId() : "this").append(".set").append(capitalizedAttribute).append("(");
+ if(addQuote) {
+ settingsMethod.append("\"").append(attr.getValue()).append("\"").append(");\n");
+ }
+ else if(addSimpleQuote) {
+ settingsMethod.append("'").append(attr.getValue()).append("'").append(");\n");
+ }
+ else {
+ settingsMethod.append(attr.getValue()).append(");\n");
+ }
}
}
}
@@ -696,7 +989,7 @@
if(th != null && th.getAttrToGenerate(attr.getName()) != null) {
attr.setName(th.getAttrToGenerate(attr.getName()));
}
- boolean addQuote = false;
+ boolean addQuote = false, addSimpleQuote = false;
//the attribute name with the first letter capitalized
String capitalizedAttribute = (attr.getName().length() > 0) ? Character.toUpperCase(attr.getName().charAt(0)) + attr.getName().substring(1) : attr.getName();
//is the attribute a "real" attribute ? false if it represents an event or a constraint
@@ -710,7 +1003,7 @@
realAttribute = !seh.addEvent(superClazz, lowerCaseAttribute, attr.getValue());
}
//checks if it is a constraint
- else if (attr.getName().equals("constraint")) {
+ else if (attr.getName().equals(CONSTRAINT_ATTRIBUTE)) {
constraint = attr.getValue();
realAttribute = false;
}
@@ -742,8 +1035,18 @@
else {
//checks if the parameter of the setter is a String
addQuote = method.getArguments()[0].getType().equals(String.class.getName());
+ addSimpleQuote = method.getArguments()[0].getType().equals(Character.class.getName()) || method.getArguments()[0].getType().equals(char.class.getName());
//generates the code to set the attribute to object
- settingsMethod.append(gmo.getParent() != null ? gmo.getId() : "this").append(".set").append(capitalizedAttribute).append("(").append(addQuote ? "\"" : "").append(attr.getValue()).append(addQuote ? "\"" : "").append(");\n");
+ settingsMethod.append(gmo.getParent() != null ? gmo.getId() : "this").append(".set").append(capitalizedAttribute).append("(");
+ if(addQuote) {
+ settingsMethod.append("\"").append(attr.getValue()).append("\"").append(");\n");
+ }
+ else if(addSimpleQuote) {
+ settingsMethod.append("'").append(attr.getValue()).append("'").append(");\n");
+ }
+ else {
+ settingsMethod.append(attr.getValue()).append(");\n");
+ }
}
}
else if(log.isErrorEnabled()) {
@@ -877,10 +1180,8 @@
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()) {
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-08-25 10:50:11 UTC (rev 1575)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingGenerator.java 2009-08-25 10:50:31 UTC (rev 1576)
@@ -169,283 +169,300 @@
String realMethodName = null;
String realAttributename = null;
- //if the part of the binding is a method
- if(binding[i].endsWith(")")) {
- //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("(")));
- if(realAttributename != null) {
- realMethodName = "get" + Character.toUpperCase(realAttributename.charAt(0)) + realAttributename.substring(1);
+ if(Character.isUpperCase(binding[i].charAt(binding[i].lastIndexOf('.') + 1))) {
+ try {
+ Class.forName(binding[i]);
+ }
+ catch (ClassNotFoundException eee) {
+ return null;
+ }
+ bindingExists = false;
+ }
+ else {
+ //if the part of the binding is a method
+ if(binding[i].endsWith(")")) {
+ //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("(")));
+ if(realAttributename != null) {
+ realMethodName = "get" + Character.toUpperCase(realAttributename.charAt(0)) + realAttributename.substring(1);
+ }
}
+ else if(binding[i].startsWith("is")){
+ realAttributename = prevTh.getAttrToGenerate(Character.toLowerCase(binding[i].charAt(2)) + binding[i].substring(3, binding[i].indexOf("(")));
+ if(realAttributename != null) {
+ realMethodName = "is" + Character.toUpperCase(realAttributename.charAt(0)) + realAttributename.substring(1);
+ }
+ }
}
- else if(binding[i].startsWith("is")){
- realAttributename = prevTh.getAttrToGenerate(Character.toLowerCase(binding[i].charAt(2)) + binding[i].substring(3, binding[i].indexOf("(")));
- if(realAttributename != null) {
- realMethodName = "is" + Character.toUpperCase(realAttributename.charAt(0)) + realAttributename.substring(1);
+ //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('('));
}
+ else if(binding[i].startsWith("is")){
+ realAttributename = Character.toLowerCase(binding[i].charAt(2)) + binding[i].substring(3, binding[i].indexOf('('));
+ }
+ else {
+ realAttributename = binding[i].substring(0, binding[i].indexOf('('));
+ }
}
- }
- //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("("));
+ //if the parent of the method is an instance of a generated class
+ if (jf != null) {
+ bindingExists = jf.getMethod(realMethodName, null) != null;
+ if (bindingExists) {
+ returnType = jf.getMethod(realMethodName, null).getReturnType();
+ JavaField f = jf.getField(realAttributename);
+ if (f != null) {
+ th = f.getTagHandler();
+ }
+ }
}
- else if(binding[i].startsWith("is")){
- realAttributename = Character.toLowerCase(binding[i].charAt(2)) + binding[i].substring(3, binding[i].indexOf("("));
- }
else {
- 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) {
- returnType = jf.getMethod(realMethodName, null).getReturnType();
- JavaField f = jf.getField(realAttributename);
- if (f != null) {
- th = f.getTagHandler();
+ try {
+ returnType = clazz.getMethod(realMethodName, (Class[])null).getReturnType().getName();
+ bindingExists = true;
}
+ catch (NoSuchMethodException eee) {
+ bindingExists = false;
+ }
}
+ getter = realMethodName + binding[i].substring(binding[i].indexOf('('));
+
}
+ //if the part of the binding is an attribute
else {
- try {
- returnType = clazz.getMethod(realMethodName, (Class[])null).getReturnType().getName();
- bindingExists = true;
+ //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]);
}
- catch (NoSuchMethodException eee) {
- bindingExists = false;
+ //if it is its real name
+ if(realAttributename == null) {
+ realAttributename = binding[i];
}
- }
- 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 {
- //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) {
- returnType = jf.getMethod("get" + Character.toUpperCase(realAttributename.charAt(0)) + realAttributename.substring(1), null) != null ? jf.getMethod("get" + Character.toUpperCase(realAttributename.charAt(0)) + realAttributename.substring(1), null).getReturnType()
- : jf.getMethod("is" + Character.toUpperCase(realAttributename.charAt(0)) + realAttributename.substring(1), null).getReturnType();
- }
+ //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) {
+ returnType = jf.getMethod("get" + Character.toUpperCase(realAttributename.charAt(0)) + realAttributename.substring(1), null) != null ? jf.getMethod("get" + Character.toUpperCase(realAttributename.charAt(0)) + realAttributename.substring(1), null).getReturnType()
+ : jf.getMethod("is" + Character.toUpperCase(realAttributename.charAt(0)) + realAttributename.substring(1), null).getReturnType();
+ }
- getter = jf.getMethod("get" + Character.toUpperCase(realAttributename.charAt(0)) + realAttributename.substring(1), null) != null ? "get" + Character.toUpperCase(realAttributename.charAt(0)) + realAttributename.substring(1) + "()"
- : "is" + Character.toUpperCase(realAttributename.charAt(0)) + realAttributename.substring(1) + "()";
+ getter = jf.getMethod("get" + Character.toUpperCase(realAttributename.charAt(0)) + realAttributename.substring(1), null) != null ? "get" + Character.toUpperCase(realAttributename.charAt(0)) + realAttributename.substring(1) + "()"
+ : "is" + Character.toUpperCase(realAttributename.charAt(0)) + realAttributename.substring(1) + "()";
- JavaField f = jf.getField(realAttributename);
- if (f != null) {
- th = f.getTagHandler();
+ JavaField f = jf.getField(realAttributename);
+ if (f != null) {
+ th = f.getTagHandler();
+ }
}
- }
- else {
- try {
- 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) {
+ else {
try {
- 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) + "()";
+ 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 eee2) {
- bindingExists = false;
+ catch (NoSuchMethodException eee) {
+ try {
+ 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;
+ }
+ catch (NoSuchMethodException eee2) {
+ bindingExists = false;
+ }
}
}
}
- 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)) {
- model = th.getEventInfosModelName(getterWoBraces);
- listener = th.getEventInfosListenerClass(getterWoBraces);
- addMethod = th.getEventInfosAddListenerMethodName(getterWoBraces);
- removeMethod = th.getEventInfosRemoveListenerMethodName(getterWoBraces);
+ //if the binding binds an existing attribute or method
+ if(bindingExists) {
+ //replace the value of the binding by the getter method
+ binding[i] = getter;
+ //if the previous object has a TagHandler
+ if(prevTh != null) {
+ String getterWoBraces = getter.substring(0, getter.indexOf('('));
+ if(prevTh.hasEventInfosAboutMethod(getterWoBraces)) {
+ model = prevTh.getEventInfosModelName(getterWoBraces);
+ listener = prevTh.getEventInfosListenerClass(getterWoBraces);
+ addMethod = prevTh.getEventInfosAddListenerMethodName(getterWoBraces);
+ removeMethod = prevTh.getEventInfosRemoveListenerMethodName(getterWoBraces);
+ }
+ else {
+ listener = PropertyChangeListener.class;
+ addMethod = "addPropertyChangeListener";
+ removeMethod = "removePropertyChangeListener";
+ }
}
- else {
- listener = PropertyChangeListener.class;
- addMethod = "addPropertyChangeListener";
- removeMethod = "removePropertyChangeListener";
+
+ //get the class of the current token or its JavaFile
+ try {
+ nextClazz = Class.forName(returnType);
}
- }
- //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)) {
- model = prevTh.getEventInfosModelName(getterWoBraces);
- listener = prevTh.getEventInfosListenerClass(getterWoBraces);
- addMethod = prevTh.getEventInfosAddListenerMethodName(getterWoBraces);
- removeMethod = prevTh.getEventInfosRemoveListenerMethodName(getterWoBraces);
- }
- else {
- listener = PropertyChangeListener.class;
- addMethod = "addPropertyChangeListener";
- removeMethod = "removePropertyChangeListener";
- }
- }
- try {
- nextClazz = Class.forName(returnType);
- if(listener == null && nextClazz.isAssignableFrom(java.awt.Container.class)) {
- listener = PropertyChangeListener.class;
- addMethod = "addPropertyChangeListener";
- removeMethod = "removePropertyChangeListener";
- }
- }
- catch (ClassNotFoundException eee) {
- for(JavaFile javaFile : generatedFiles.values()) {
- if(returnType.equals(javaFile.getPackageName() + "." + javaFile.getClassName())) {
- nextFile = javaFile;
- break;
+ catch (ClassNotFoundException eee) {
+ for(JavaFile javaFile : generatedFiles.values()) {
+ if(returnType.equals(javaFile.getPackageName() + "." + javaFile.getClassName())) {
+ nextFile = javaFile;
+ break;
+ }
}
+ if(nextFile == null) {
+ for(JavaFile javaFile : propertyChangeListenerDependencies) {
+ if(returnType.equals(javaFile.getPackageName() + "." + javaFile.getClassName())) {
+ nextFile = javaFile;
+ break;
+ }
+ }
+ }
}
- try {
- Class c = Class.forName(nextFile.getSuperClass());
- if(listener == null && c.isAssignableFrom(java.awt.Container.class)) {
+
+ if(listener == null && clazz != null) {
+ try {
+ clazz.getMethod("addPropertyChangeListener", PropertyChangeListener.class);
listener = PropertyChangeListener.class;
addMethod = "addPropertyChangeListener";
removeMethod = "removePropertyChangeListener";
}
+ catch(NoSuchMethodException eee) {
+ }
}
- catch(ClassNotFoundException eeee) {
+ else if(listener == null && jf != null) {
+ for(JavaMethod method : jf.getAllMethods()) {
+ if(method.getName().equals("addPropertyChangeListener")
+ && ((method.getArguments().length == 1 && method.getArguments()[0].getType().equals("java.beans.PropertyChangeListener"))
+ ||(method.getArguments().length == 2 && method.getArguments()[1].getType().equals("java.beans.PropertyChangeListener")))) {
+ listener = PropertyChangeListener.class;
+ addMethod = "addPropertyChangeListener";
+ removeMethod = "removePropertyChangeListener";
+ }
+ }
}
- catch(NullPointerException eeee) {
- }
- }
- if(listener != null) {
- //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));
- for(int k = 1 ; k <= j ; k++) {
- dbCreation.append(".").append(alreadyChecked.get(k));
- dbDeletion.append(".").append(alreadyChecked.get(k));
+
+ boolean ifAdded = false;
+ if(listener != null) {
+ if(alreadyChecked != null && !alreadyChecked.isEmpty()) {
+ ifAdded = true;
+ //starts to generate the code
+ dbCreation.append("if(");
+ dbDeletion.append("if(");
+ //add not null parent condition
+ for(int j = 0 ; j < alreadyChecked.size() ; j++) {
+ dbCreation.append(alreadyChecked.get(0));
+ dbDeletion.append(alreadyChecked.get(0));
+ for(int k = 1 ; k <= j ; k++) {
+ dbCreation.append(".").append(alreadyChecked.get(k));
+ dbDeletion.append(".").append(alreadyChecked.get(k));
+ }
+ dbCreation.append(" != null && ");
+ dbDeletion.append(" != null && ");
}
- dbCreation.append(" != null && ");
- dbDeletion.append(" != null && ");
+
+ if(binding.length > alreadyChecked.size() + 1 && nextClazz != null && !nextClazz.isPrimitive()) {
+ for(int j = 0 ; j < alreadyChecked.size() ; j++) {
+ dbCreation.append(alreadyChecked.get(j)).append(".");
+ dbDeletion.append(alreadyChecked.get(j)).append(".");
+ }
+ dbCreation.append(getter).append(" != null");
+ dbDeletion.append(getter).append(" != null");
+ }
+ else {
+ dbCreation.delete(dbCreation.length() - 4, dbCreation.length());
+ dbDeletion.delete(dbDeletion.length() - 4, dbDeletion.length());
+ }
+ dbCreation.append(") {\n");
+ dbDeletion.append(") {\n");
}
-
- if(binding.length > alreadyChecked.size() + 1) {
+ else if(nextClazz != null && !nextClazz.isPrimitive()) {
+ ifAdded = true;
+ //starts to generate the code
+ dbCreation.append("if(").append(getter).append(" != null").append(") {\n");
+ dbDeletion.append("if(").append(getter).append(" != null").append(") {\n");
+ }
+ if(alreadyChecked != null) {
for(int j = 0 ; j < alreadyChecked.size() ; j++) {
dbCreation.append(alreadyChecked.get(j)).append(".");
dbDeletion.append(alreadyChecked.get(j)).append(".");
}
- dbCreation.append(getter).append(" != null");
- dbDeletion.append(getter).append(" != null");
}
- else {
- dbCreation.delete(dbCreation.length() - 4, dbCreation.length());
- dbDeletion.delete(dbDeletion.length() - 4, dbDeletion.length());
+ if(model != null && !model.equals("")) {
+ if(alreadyChecked == null) {
+ dbCreation.append(getter).append(".");
+ dbDeletion.append(getter).append(".");
+ }
+ dbCreation.append("get").append(Character.toUpperCase(model.charAt(0)))
+ .append(model.substring(1)).append("()").append(".");
+ dbDeletion.append("get").append(Character.toUpperCase(model.charAt(0)))
+ .append(model.substring(1)).append("()").append(".");
}
- }
- else {
- dbCreation.append(getter).append(" != null");
- dbDeletion.append(getter).append(" != null");
- }
- dbCreation.append(") {\n");
- dbDeletion.append(") {\n");
- if(alreadyChecked != null) {
- for(int j = 0 ; j < alreadyChecked.size() ; j++) {
- dbCreation.append(alreadyChecked.get(j)).append(".");
- dbDeletion.append(alreadyChecked.get(j)).append(".");
+ dbCreation.append(addMethod).append("(");
+ dbDeletion.append(removeMethod).append("(");
+ if(listener == PropertyChangeListener.class) {
+ dbCreation.append("\"").append(realAttributename).append("\", ");
+ dbDeletion.append("\"").append(realAttributename).append("\", ");
}
- }
- if(model != null) {
- dbCreation.append("get").append(Character.toUpperCase(model.charAt(0)))
- .append(model.substring(1)).append("()");
- dbDeletion.append("get").append(Character.toUpperCase(model.charAt(0)))
- .append(model.substring(1)).append("()");
- }
- else {
- dbCreation.append(getter);
- dbDeletion.append(getter);
- }
- // dbCreation.append(".").append(addMethod).append("((")
- // .append(listener.getName()).append(") org.nuiton.guix.runtime.Util.getEventListener(")
- // .append(listener.getName()).append(".class,this,\"onChangeFrom")
- // .append(methodToInvoke).append("\"));\n}\n");
- // dbDeletion.append(".").append(removeMethod).append("((")
- // .append(listener.getName()).append(") org.nuiton.guix.runtime.Util.getEventListener(")
- // .append(listener.getName()).append(".class,this,\"onChangeFrom")
- // .append(methodToInvoke).append("\"));\n}\n");
+ dbCreation.append("new ").append(listener.getName()).append("() {\n");
+ dbDeletion.append("new ").append(listener.getName()).append("() {\n");
+ for(Method m : listener.getMethods()) {
+ StringBuffer sb = new StringBuffer();
+ for(Annotation a : m.getDeclaredAnnotations()) {
+ dbCreation.append(a.toString()).append("\n");
+ }
+ //add the method that handles the event
+ sb.append("public ")
+ .append(m.getReturnType().getCanonicalName())
+ .append(" ")
+ .append(m.getName())
+ .append("(");
+ for(int n = 0 ; n < m.getParameterTypes().length ; n++) {
+ sb.append(m.getParameterTypes()[n].getCanonicalName())
+ .append(" arg")
+ .append(n)
+ .append(", ");
+ }
+ sb.delete(sb.length() - 2, sb.length())
+ .append(")")
+ .append(" {\n")
+ .append("onChangeFrom").append(methodToInvoke)
+ .append("();\n}\n");
+ dbCreation.append(sb);
+ dbDeletion.append(sb);
+ }
+ dbCreation.append("});\n");
+ dbDeletion.append("});\n");
+ if(ifAdded) {
+ dbCreation.append("}\n");
+ dbDeletion.append("}\n");
+ }
- dbCreation.append(".").append(addMethod).append("(new ").append(listener.getName()).append("() {\n");
- dbDeletion.append(".").append(removeMethod).append("(new ").append(listener.getName()).append("() {\n");
- for(Method m : listener.getMethods()) {
- StringBuffer sb = new StringBuffer();
- for(Annotation a : m.getDeclaredAnnotations()) {
- dbCreation.append(a.toString()).append("\n");
+ if(alreadyChecked == null){
+ alreadyChecked = new ArrayList<String>();
}
- //add the method that handles the event
- sb.append("public ")
- .append(m.getReturnType().getCanonicalName())
- .append(" ")
- .append(m.getName())
- .append("(");
- for(int n = 0 ; n < m.getParameterTypes().length ; n++) {
- sb.append(m.getParameterTypes()[n].getCanonicalName())
- .append(" arg")
- .append(n)
- .append(", ");
+ alreadyChecked.add(getter);
+ 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 && !result.contains(listener)) {
+ result.add(listener);
+ }
}
- sb.delete(sb.length() - 2, sb.length())
- .append(")")
- .append(" {\n")
- .append("onChangeFrom").append(methodToInvoke)
- .append("();\n}\n");
- dbCreation.append(sb);
- dbDeletion.append(sb);
- }
- dbCreation.append("});\n}\n");
- dbDeletion.append("});\n}\n");
-
- if(alreadyChecked == null){
- alreadyChecked = new ArrayList<String>();
- }
- alreadyChecked.add(getter);
- 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));
+ catch(NullPointerException eee) {
+ log.error(i);
+ eee.printStackTrace();
+ return null;
}
- if(listener != null && !result.contains(listener)) {
- result.add(listener);
- }
}
- catch(NullPointerException eee) {
- log.error(i);
- eee.printStackTrace();
- return null;
- }
}
+ else if(log.isErrorEnabled()) {
+ log.error("unable to bind " + binding[i]);
+ }
}
- else if(log.isErrorEnabled()) {
- log.error("unable to bind " + binding[i]);
- }
return result;
}
Modified: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingImplementationGenerator.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingImplementationGenerator.java 2009-08-25 10:50:11 UTC (rev 1575)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingImplementationGenerator.java 2009-08-25 10:50:31 UTC (rev 1576)
@@ -47,7 +47,7 @@
@Override
public JavaFile generate() {
- super.addImports(gmo);
+ super.addImports();
//add the constructor
jf.addMethod(new JavaMethod(Modifier.PUBLIC, null, gmo.getClassDescriptor().getName() + "Impl",
Modified: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingInterfaceGenerator.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingInterfaceGenerator.java 2009-08-25 10:50:11 UTC (rev 1575)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingInterfaceGenerator.java 2009-08-25 10:50:31 UTC (rev 1576)
@@ -25,6 +25,8 @@
import java.lang.reflect.Modifier;
import java.util.Map;
+import org.nuiton.guix.tags.TagHandler;
+import org.nuiton.guix.tags.TagManager;
/**
* Generator of interfaces
@@ -51,15 +53,13 @@
@Override
public JavaFile generate() {
- super.addImports(gmo);
+ super.addImports();
addFields(gmo);
jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", "initialize", null, null, null, "initialization"));
jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", getMethodName(Method.BEFORE_CREATION), null, null, null, ""));
- jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", getMethodName(Method.COMPONENTS_CREATION), null, null, null, "Components creation"));
- jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", getMethodName(Method.BEFORE_INITIALIZATION), null, null, null, ""));
- jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", getMethodName(Method.COMPONENTS_TREE), null, null, null, "components layout"));
+ jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", getMethodName(Method.BEFORE_TREE), null, null, null, ""));
+ jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", getMethodName(Method.BEFORE_SETTINGS), null, null, null, ""));
jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", getMethodName(Method.BEFORE_BINDING), null, null, null, ""));
- jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", getMethodName(Method.DATABINDING_INIT), null, null, null, "initilization of databinding"));
jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", getMethodName(Method.IN_THE_END), null, null, null, ""));
return jf;
@@ -73,21 +73,20 @@
private void addFields(GuixModelObject gmo) {
for (GuixModelObject child : gmo.getChildren()) {
//if gmo represents a Guix tag
- if (child.getClassDescriptor().getPackageName() == null || child.getClassDescriptor().getPackageName().equals("org.nuiton.guix.tags.swing")) {
- //if it is a table
- if (child.getClassDescriptor().getName() != null && child.getClassDescriptor().getName().equals("Table")) {
- //the table is represented by a JPanel
+ if (child.getClassDescriptor().getPackageName() == null
+ && TagManager.getGuixClassHandler(child.getClassDescriptor().getName()) != null) {
+ if(TagManager.getGuixClassHandler(child.getClassDescriptor().getName()).getClassToGenerate() != null) {
jf.addField(new JavaField(Modifier.PRIVATE,
- "javax.swing.JPanel",
+ TagManager.getGuixClassHandler(child.getClassDescriptor().getName()).getClassToGenerate().getName(),
child.getId(), child.getJavadoc()),
- true);
+ gmo.isJavaBean());
}
}
else {
jf.addField(new JavaField(Modifier.PRIVATE,
- (classes != null && classes.containsKey(child.getClassDescriptor().toString())) ? child.getClassDescriptor().getName() + "Abstract" : child.getClassDescriptor().getName(),
+ (classes != null && classes.containsKey(child.getClassDescriptor().toString())) ? child.getClassDescriptor().toString() + "Abstract" : child.getClassDescriptor().toString(),
child.getId(), child.getJavadoc()),
- true);
+ gmo.isJavaBean());
}
addFields(child);
}
Modified: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingJavaFileGenerator.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingJavaFileGenerator.java 2009-08-25 10:50:11 UTC (rev 1575)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingJavaFileGenerator.java 2009-08-25 10:50:31 UTC (rev 1576)
@@ -40,29 +40,10 @@
@Override
/**
* Add imports to the generated file
- *
- * @param gmo GuixModelObject which represents the class to generate
*/
- protected void addImports(GuixModelObject gmo) {for (GuixModelObject child : gmo.getChildren()) {
- if (child.getClassDescriptor().getPackageName() == null
- && TagManager.getGuixClassHandler(child.getClassDescriptor().getName()) != null) {
- TagHandler th = TagManager.getGuixClassHandler(child.getClassDescriptor().getName());
- if(th.getClassToGenerate() != null) {
- Class clazz = th.getClassToGenerate();
- if (imports != null && !imports.contains(clazz.getName())) {
- imports.add(clazz.getName());
- jf.addImport(clazz);
- }
- }
- }
- else {
- if (imports != null && !imports.contains(child.getClassDescriptor().toString())) {
- imports.add(child.getClassDescriptor().toString());
- jf.addImport(classes.containsKey(child.getClassDescriptor().toString()) ? child.getClassDescriptor().toString() + "Abstract" : child.getClassDescriptor().toString());
- }
- }
- addImports(child);
- }
+ protected void addImports() {
+ jf.addImport("javax.swing.*");
+ jf.addImport("java.awt.*");
}
}
Modified: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingMainClassGenerator.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingMainClassGenerator.java 2009-08-25 10:50:11 UTC (rev 1575)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingMainClassGenerator.java 2009-08-25 10:50:31 UTC (rev 1576)
@@ -19,7 +19,6 @@
package org.nuiton.guix.generator;
//~--- non-JDK imports --------------------------------------------------------
-import org.nuiton.guix.generator.*;
import org.nuiton.guix.model.GuixModelObject;
//~--- JDK imports ------------------------------------------------------------
@@ -62,8 +61,6 @@
*/
public void generate(File out) {
String gmoClassName = gmo.getClassDescriptor().getName();
- String gmoAttributeName = gmoClassName.replace(gmoClassName.charAt(0),
- Character.toLowerCase(gmoClassName.charAt(0)));
clazz.addImport("java.io.File");
clazz.addImport("org.springframework.beans.factory.ListableBeanFactory");
@@ -71,22 +68,6 @@
clazz.addImport("org.springframework.core.io.FileSystemResource");
StringBuffer mainMethod = new StringBuffer();
- /*mainMethod.append("//usine à beans\n")
- .append("ListableBeanFactory bf = new XmlBeanFactory(")
- .append("new FileSystemResource(new File(\"")
- .append(destDir.getAbsolutePath())
- .append("/config.xml\")));\n")
- .append(gmoClassName)
- .append(" ")
- .append(gmoAttributeName)
- .append(" = (")
- .append(gmoClassName)
- .append(") bf.getBean(\"")
- .append(gmoAttributeName)
- .append("\");\n")
- .append(gmoAttributeName)
- .append(".test();");*/
- //SwingUtilities.invokeLater(new Runnable() { public void run() { new JAXXDemo().setVisible(true); } });
mainMethod.append("javax.swing.SwingUtilities.invokeLater(").append("new Runnable() {").append("public void run() {").append(gmoClassName).append("Impl main = new ").append(gmoClassName).append("Impl();\n").append("main.pack();\n").append("main.setVisible(true);}});");
clazz.addMethod(new JavaMethod(
Added: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/CheckBoxHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/CheckBoxHandler.java (rev 0)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/CheckBoxHandler.java 2009-08-25 10:50:31 UTC (rev 1576)
@@ -0,0 +1,19 @@
+
+package org.nuiton.guix.tags.swing;
+
+/**
+ * Handles the ChackBox tag
+ *
+ * @author kmorin
+ */
+public class CheckBoxHandler extends ToggleButtonHandler {
+
+ public CheckBoxHandler() {
+ super();
+ }
+
+ @Override
+ public Class getClassToGenerate() {
+ return javax.swing.JCheckBox.class;
+ }
+}
Added: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ComboBoxHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ComboBoxHandler.java (rev 0)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ComboBoxHandler.java 2009-08-25 10:50:31 UTC (rev 1576)
@@ -0,0 +1,27 @@
+
+package org.nuiton.guix.tags.swing;
+import java.awt.event.ItemListener;
+
+/**
+ * Handles the combobox tag
+ *
+ * @author kmorin
+ */
+public class ComboBoxHandler extends ComponentHandler {
+
+ public ComboBoxHandler() {
+ super();
+ }
+
+ @Override
+ public Class getClassToGenerate() {
+ return javax.swing.JComboBox.class;
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getSelectedIndex", ItemListener.class, "");
+ addProxyEventInfo("getSelectedItem", ItemListener.class, "");
+ }
+}
Added: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/DialogBoxHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/DialogBoxHandler.java (rev 0)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/DialogBoxHandler.java 2009-08-25 10:50:31 UTC (rev 1576)
@@ -0,0 +1,20 @@
+package org.nuiton.guix.tags.swing;
+
+
+/**
+ * Handles the DialogBoxHandler
+ *
+ * @author kmorin
+ */
+public class DialogBoxHandler extends ComponentHandler {
+
+ public DialogBoxHandler() {
+ super();
+ }
+
+ @Override
+ public Class getClassToGenerate() {
+ return javax.swing.JDialog.class;
+ }
+
+}
Added: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ListHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ListHandler.java (rev 0)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ListHandler.java 2009-08-25 10:50:31 UTC (rev 1576)
@@ -0,0 +1,29 @@
+
+package org.nuiton.guix.tags.swing;
+import javax.swing.event.ListSelectionListener;
+
+/**
+ * Handles the list tag
+ *
+ * @author kmorin
+ */
+public class ListHandler extends ComponentHandler {
+
+ public ListHandler() {
+ super();
+ }
+
+ @Override
+ public Class getClassToGenerate() {
+ return javax.swing.JList.class;
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getSelectedIndex", ListSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectedIndices", ListSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectedValue", ListSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectedValues", ListSelectionListener.class, "selectionModel");
+ }
+}
Added: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/PasswordFieldHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/PasswordFieldHandler.java (rev 0)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/PasswordFieldHandler.java 2009-08-25 10:50:31 UTC (rev 1576)
@@ -0,0 +1,27 @@
+
+package org.nuiton.guix.tags.swing;
+
+import javax.swing.event.DocumentListener;
+
+/**
+ * Handles the PasswordField tag
+ *
+ * @author kmorin
+ */
+public class PasswordFieldHandler extends TextComponentHandler {
+
+ public PasswordFieldHandler() {
+ super();
+ }
+
+ @Override
+ public Class getClassToGenerate() {
+ return javax.swing.JPasswordField.class;
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getPassword", DocumentListener.class, "document");
+ }
+}
Added: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ProgressBarHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ProgressBarHandler.java (rev 0)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ProgressBarHandler.java 2009-08-25 10:50:31 UTC (rev 1576)
@@ -0,0 +1,27 @@
+
+package org.nuiton.guix.tags.swing;
+import javax.swing.event.ChangeListener;
+
+/**
+ * Handles the progressbar tag
+ *
+ * @author kmorin
+ */
+public class ProgressBarHandler extends ComponentHandler {
+
+ public ProgressBarHandler() {
+ super();
+ }
+
+ @Override
+ public Class getClassToGenerate() {
+ return javax.swing.JProgressBar.class;
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getValue", ChangeListener.class, "change");
+ }
+
+}
Added: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/RadioButtonHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/RadioButtonHandler.java (rev 0)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/RadioButtonHandler.java 2009-08-25 10:50:31 UTC (rev 1576)
@@ -0,0 +1,19 @@
+
+package org.nuiton.guix.tags.swing;
+
+/**
+ * Handles the RadioButton tag
+ *
+ * @author kmorin
+ */
+public class RadioButtonHandler extends ToggleButtonHandler {
+
+ public RadioButtonHandler() {
+ super();
+ }
+
+ @Override
+ public Class getClassToGenerate() {
+ return javax.swing.JRadioButton.class;
+ }
+}
Added: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ScrollPanelHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ScrollPanelHandler.java (rev 0)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/ScrollPanelHandler.java 2009-08-25 10:50:31 UTC (rev 1576)
@@ -0,0 +1,16 @@
+
+package org.nuiton.guix.tags.swing;
+
+/**
+ * Handles the ScrollPanel tag
+ *
+ * @author kmorin
+ */
+public class ScrollPanelHandler extends ComponentHandler {
+
+ @Override
+ public Class getClassToGenerate() {
+ return javax.swing.JScrollPane.class;
+ }
+
+}
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-08-25 10:50:11 UTC (rev 1575)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/SelectableButtonHandler.java 2009-08-25 10:50:31 UTC (rev 1576)
@@ -32,7 +32,7 @@
}
@Override
- public void configureProxyEventInfo() {
+ protected void configureProxyEventInfo() {
super.configureProxyEventInfo();
addProxyEventInfo("isSelected", ChangeListener.class, "model");
}
Added: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/SliderHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/SliderHandler.java (rev 0)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/SliderHandler.java 2009-08-25 10:50:31 UTC (rev 1576)
@@ -0,0 +1,27 @@
+
+package org.nuiton.guix.tags.swing;
+
+import javax.swing.event.ChangeListener;
+
+/**
+ * Handles the slider tag
+ *
+ * @author kmorin
+ */
+public class SliderHandler extends ComponentHandler {
+
+ public SliderHandler() {
+ super();
+ }
+
+ @Override
+ public Class getClassToGenerate() {
+ return javax.swing.JSlider.class;
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getValue", ChangeListener.class, "model");
+ }
+}
Added: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/SpinnerHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/SpinnerHandler.java (rev 0)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/SpinnerHandler.java 2009-08-25 10:50:31 UTC (rev 1576)
@@ -0,0 +1,27 @@
+
+package org.nuiton.guix.tags.swing;
+import javax.swing.event.ChangeListener;
+
+/**
+ * Handles the spinner tag
+ *
+ * @author kmorin
+ */
+public class SpinnerHandler extends ComponentHandler {
+
+ public SpinnerHandler() {
+ super();
+ }
+
+ @Override
+ public Class getClassToGenerate() {
+ return javax.swing.JSpinner.class;
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getValue", ChangeListener.class, "model");
+ }
+
+}
Added: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/SplitPanelHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/SplitPanelHandler.java (rev 0)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/SplitPanelHandler.java 2009-08-25 10:50:31 UTC (rev 1576)
@@ -0,0 +1,16 @@
+
+package org.nuiton.guix.tags.swing;
+
+/**
+ * Handles the VerticalSplitPanel and HorizontalSplitPanel tags
+ *
+ * @author kmorin
+ */
+public class SplitPanelHandler extends ComponentHandler {
+
+ @Override
+ public Class getClassToGenerate() {
+ return javax.swing.JSplitPane.class;
+ }
+
+}
Added: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TabHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TabHandler.java (rev 0)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TabHandler.java 2009-08-25 10:50:31 UTC (rev 1576)
@@ -0,0 +1,17 @@
+
+package org.nuiton.guix.tags.swing;
+
+import org.nuiton.guix.tags.DefaultTagHandler;
+
+/**
+ *
+ * @author kmorin
+ */
+public class TabHandler extends DefaultTagHandler {
+
+ @Override
+ public Class getClassToGenerate() {
+ return null;
+ }
+
+}
Added: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TextAreaHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TextAreaHandler.java (rev 0)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TextAreaHandler.java 2009-08-25 10:50:31 UTC (rev 1576)
@@ -0,0 +1,20 @@
+
+package org.nuiton.guix.tags.swing;
+
+/**
+ * Handles the TextArea tag
+ *
+ * @author kmorin
+ */
+public class TextAreaHandler extends TextComponentHandler {
+
+ public TextAreaHandler() {
+ super();
+ }
+
+ @Override
+ public Class getClassToGenerate() {
+ return javax.swing.JTextArea.class;
+ }
+
+}
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-08-25 10:50:11 UTC (rev 1575)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TextComponentHandler.java 2009-08-25 10:50:31 UTC (rev 1576)
@@ -32,7 +32,7 @@
}
@Override
- public void configureProxyEventInfo() {
+ protected void configureProxyEventInfo() {
super.configureProxyEventInfo();
addProxyEventInfo("getText", DocumentListener.class, "document");
}
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-08-25 10:50:11 UTC (rev 1575)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TextFieldHandler.java 2009-08-25 10:50:31 UTC (rev 1576)
@@ -36,5 +36,5 @@
public Class getClassToGenerate() {
return javax.swing.JTextField.class;
}
-
+
}
Added: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TreeHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TreeHandler.java (rev 0)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TreeHandler.java 2009-08-25 10:50:31 UTC (rev 1576)
@@ -0,0 +1,30 @@
+
+package org.nuiton.guix.tags.swing;
+
+import javax.swing.event.TreeSelectionListener;
+
+/**
+ * Handles the tree tag
+ *
+ * @author kmorin
+ */
+public class TreeHandler extends ComponentHandler {
+
+ public TreeHandler() {
+ }
+
+ @Override
+ public Class getClassToGenerate() {
+ return javax.swing.JTree.class;
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getSelectionCount", TreeSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectionPath", TreeSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectionPaths", TreeSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectionRows", TreeSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectionValue", TreeSelectionListener.class, "selectionModel");
+ }
+}
Added: trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TreeNodeHandler.java
===================================================================
--- trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TreeNodeHandler.java (rev 0)
+++ trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/tags/swing/TreeNodeHandler.java 2009-08-25 10:50:31 UTC (rev 1576)
@@ -0,0 +1,20 @@
+
+package org.nuiton.guix.tags.swing;
+
+/**
+ *
+ * @author kmorin
+ */
+public class TreeNodeHandler extends ComponentHandler {
+
+ public TreeNodeHandler() {
+ super();
+ attrMap.put("value", "userObject");
+ }
+
+ @Override
+ public Class getClassToGenerate() {
+ return javax.swing.tree.DefaultMutableTreeNode.class;
+ }
+
+}
Modified: 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 2009-08-25 10:50:11 UTC (rev 1575)
+++ trunk/guix-compiler-swing/src/test/java/org/nuiton/guix/generator/SwingGeneratorTest.java 2009-08-25 10:50:31 UTC (rev 1576)
@@ -43,112 +43,112 @@
@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(), 0);
- //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 empty 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(), 0);
-
- //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 empty 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));
- l = sg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"getTest()","getButton()","isSelected()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>());
- Assert.assertNotNull(l);
- Assert.assertEquals(l.size(), 0);
- //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));
- l = sg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"getTest()","getButton()","isSelected()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>());
- Assert.assertNotNull(l);
- Assert.assertEquals(l.size(), 0);
-
- Map<GuixGenerator,JavaFile> map = new HashMap<GuixGenerator, JavaFile>();
- map.put(sg, jf2);
- //tests an unsuccessful binding generation with a method as a binding because the superclass of j2 is not assignable from java.awt.Container
- 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(), 0);
- //tests a successful generation with a method as a binding
- jf2 = new JavaFile(Modifier.PUBLIC, 0, "test", "Test", "java.awt.Container", 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));
- map = new HashMap<GuixGenerator, JavaFile>();
- map.put(sg, jf2);
- 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);
+// 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(), 0);
+// //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 empty 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(), 0);
+//
+// //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 empty 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));
+// l = sg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"getTest","getButton","isSelected"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>());
+// Assert.assertNotNull(l);
+// Assert.assertEquals(l.size(), 0);
+// //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));
+// l = sg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"getTest","getButton","isSelected"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>());
+// Assert.assertNotNull(l);
+// Assert.assertEquals(l.size(), 0);
+//
+// Map<GuixGenerator,JavaFile> map = new HashMap<GuixGenerator, JavaFile>();
+// map.put(sg, jf2);
+// //tests an unsuccessful binding generation with a method as a binding because the superclass of j2 is not assignable from java.awt.Container
+// 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(), 0);
+// //tests a successful generation with a method as a binding
+// jf2 = new JavaFile(Modifier.PUBLIC, 0, "test", "Test", "java.awt.Container", 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));
+// map = new HashMap<GuixGenerator, JavaFile>();
+// map.put(sg, jf2);
+// 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