Nuiton-utils-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- 3157 discussions
[Lutinutil-commits] r882 - trunk/maven-genclean-plugin
by tchemit@users.labs.libre-entreprise.org 23 Jul '08
by tchemit@users.labs.libre-entreprise.org 23 Jul '08
23 Jul '08
Author: tchemit
Date: 2008-07-23 00:11:14 +0000 (Wed, 23 Jul 2008)
New Revision: 882
Modified:
trunk/maven-genclean-plugin/pom.xml
Log:
change name
Modified: trunk/maven-genclean-plugin/pom.xml
===================================================================
--- trunk/maven-genclean-plugin/pom.xml 2008-07-22 23:32:42 UTC (rev 881)
+++ trunk/maven-genclean-plugin/pom.xml 2008-07-23 00:11:14 UTC (rev 882)
@@ -19,7 +19,7 @@
<groupId>org.codelutin.maven.plugins</groupId>
<artifactId>maven-genclean-plugin</artifactId>
- <name>maven plugin</name>
+ <name>maven-genclean-plugin</name>
<dependencies>
1
0
[Lutinutil-commits] r881 - in trunk/commandline: . commandline-ui
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
22 Jul '08
Author: tchemit
Date: 2008-07-22 23:32:42 +0000 (Tue, 22 Jul 2008)
New Revision: 881
Modified:
trunk/commandline/commandline-ui/pom.xml
trunk/commandline/pom.xml
Log:
utilisation de maven-genclean-plugin
Modified: trunk/commandline/commandline-ui/pom.xml
===================================================================
--- trunk/commandline/commandline-ui/pom.xml 2008-07-22 23:27:18 UTC (rev 880)
+++ trunk/commandline/commandline-ui/pom.xml 2008-07-22 23:32:42 UTC (rev 881)
@@ -59,6 +59,18 @@
</resources>
<plugins>
+ <plugin>
+ <groupId>org.codelutin.maven.plugins</groupId>
+ <artifactId>maven-genclean-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>clean</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
<!-- jaxx -->
<plugin>
<groupId>org.codelutin.jaxx</groupId>
@@ -106,28 +118,6 @@
</execution>
</executions>
</plugin>
- <!-- ant -->
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>clean</id>
- <phase>clean</phase>
- <configuration>
- <tasks>
- <mkdir dir="${basedir}/gen/java"/>
- <delete includeemptydirs="true">
- <fileset dir="${basedir}/gen/java" includes="**/*"/>
- </delete>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
</plugins>
</build>
Modified: trunk/commandline/pom.xml
===================================================================
--- trunk/commandline/pom.xml 2008-07-22 23:27:18 UTC (rev 880)
+++ trunk/commandline/pom.xml 2008-07-22 23:32:42 UTC (rev 881)
@@ -276,7 +276,7 @@
</dependency>
<dependency>
- <groupId>org.codelutin.maven.plugin</groupId>
+ <groupId>org.codelutin.maven.plugins</groupId>
<artifactId>maven-genclean-plugin</artifactId>
<version>0.1-SNAPSHOT</version>
</dependency>
1
0
[Lutinutil-commits] r880 - trunk/maven-genclean-plugin
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
22 Jul '08
Author: tchemit
Date: 2008-07-22 23:27:18 +0000 (Tue, 22 Jul 2008)
New Revision: 880
Modified:
trunk/maven-genclean-plugin/pom.xml
Log:
changement du groupId
Modified: trunk/maven-genclean-plugin/pom.xml
===================================================================
--- trunk/maven-genclean-plugin/pom.xml 2008-07-22 23:26:28 UTC (rev 879)
+++ trunk/maven-genclean-plugin/pom.xml 2008-07-22 23:27:18 UTC (rev 880)
@@ -17,7 +17,7 @@
<version>2.3</version>
</parent>
- <groupId>org.codelutin.maven.plugin</groupId>
+ <groupId>org.codelutin.maven.plugins</groupId>
<artifactId>maven-genclean-plugin</artifactId>
<name>maven plugin</name>
1
0
22 Jul '08
Author: tchemit
Date: 2008-07-22 23:26:28 +0000 (Tue, 22 Jul 2008)
New Revision: 879
Modified:
trunk/commandline/pom.xml
Log:
changement du groupId
Modified: trunk/commandline/pom.xml
===================================================================
--- trunk/commandline/pom.xml 2008-07-22 23:23:54 UTC (rev 878)
+++ trunk/commandline/pom.xml 2008-07-22 23:26:28 UTC (rev 879)
@@ -274,6 +274,12 @@
<artifactId>maven-jaxx-plugin</artifactId>
<version>0.2-SNAPHOT</version>
</dependency>
+
+ <dependency>
+ <groupId>org.codelutin.maven.plugin</groupId>
+ <artifactId>maven-genclean-plugin</artifactId>
+ <version>0.1-SNAPSHOT</version>
+ </dependency>
</dependencies>
</dependencyManagement>
1
0
[Lutinutil-commits] r878 - in trunk/maven-genclean-plugin: . src/main/java/org/codelutin/maven/plugin
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
22 Jul '08
Author: tchemit
Date: 2008-07-22 23:23:54 +0000 (Tue, 22 Jul 2008)
New Revision: 878
Modified:
trunk/maven-genclean-plugin/
trunk/maven-genclean-plugin/pom.xml
trunk/maven-genclean-plugin/src/main/java/org/codelutin/maven/plugin/GenCleanMojo.java
Log:
first import of maven-genclean-plugin
Property changes on: trunk/maven-genclean-plugin
___________________________________________________________________
Name: svn:ignore
+ target
Modified: trunk/maven-genclean-plugin/pom.xml
===================================================================
--- trunk/maven-genclean-plugin/pom.xml 2008-07-22 23:06:39 UTC (rev 877)
+++ trunk/maven-genclean-plugin/pom.xml 2008-07-22 23:23:54 UTC (rev 878)
@@ -23,6 +23,12 @@
<dependencies>
+ <dependency>
+ <groupId>org.codelutin</groupId>
+ <artifactId>lutinutil</artifactId>
+ <version>0.30-SNAPSHOT</version>
+ </dependency>
+
<!-- maven plugin project dependencies -->
<dependency>
Modified: trunk/maven-genclean-plugin/src/main/java/org/codelutin/maven/plugin/GenCleanMojo.java
===================================================================
--- trunk/maven-genclean-plugin/src/main/java/org/codelutin/maven/plugin/GenCleanMojo.java 2008-07-22 23:06:39 UTC (rev 877)
+++ trunk/maven-genclean-plugin/src/main/java/org/codelutin/maven/plugin/GenCleanMojo.java 2008-07-22 23:23:54 UTC (rev 878)
@@ -18,7 +18,6 @@
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
-import static org.codelutin.i18n.I18n._;
import java.io.File;
@@ -30,7 +29,7 @@
* @goal clean
* @phase clean
*/
-public abstract class GenCleanMojo extends AbstractMojo {
+public class GenCleanMojo extends AbstractMojo {
/**
* @description D�pendance du projet.
@@ -51,24 +50,22 @@
*/
protected boolean verbose;
-
- protected abstract void doExecute() throws Exception;
-
public void execute() throws MojoExecutionException, MojoFailureException {
try {
- if (genDirectory.exists()) {
+ if (!genDirectory.exists()) {
if (verbose) {
- getLog().info("delete gen directory " + genDirectory);
+ getLog().warn("could not find gen directory " + genDirectory);
}
- genDirectory.delete();
- } else {
- if (verbose) {
- getLog().info("could not find gen directory " + genDirectory);
- }
+ return;
}
+ if (verbose) {
+ getLog().info("delete gen directory " + genDirectory);
+ }
+ org.codelutin.util.FileUtil.deleteRecursively(genDirectory);
+
} catch (Exception e) {
getLog().error(e);
Throwable e2 = e;
1
0
[Lutinutil-commits] r877 - in trunk: . maven-genclean-plugin maven-genclean-plugin/src maven-genclean-plugin/src/main maven-genclean-plugin/src/main/java maven-genclean-plugin/src/main/java/org maven-genclean-plugin/src/main/java/org/codelutin maven-genclean-plugin/src/main/java/org/codelutin/maven maven-genclean-plugin/src/main/java/org/codelutin/maven/plugin maven-genclean-plugin/src/main/resources maven-genclean-plugin/src/test
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
22 Jul '08
Author: tchemit
Date: 2008-07-22 23:06:39 +0000 (Tue, 22 Jul 2008)
New Revision: 877
Added:
trunk/maven-genclean-plugin/
trunk/maven-genclean-plugin/pom.xml
trunk/maven-genclean-plugin/src/
trunk/maven-genclean-plugin/src/main/
trunk/maven-genclean-plugin/src/main/java/
trunk/maven-genclean-plugin/src/main/java/org/
trunk/maven-genclean-plugin/src/main/java/org/codelutin/
trunk/maven-genclean-plugin/src/main/java/org/codelutin/maven/
trunk/maven-genclean-plugin/src/main/java/org/codelutin/maven/plugin/
trunk/maven-genclean-plugin/src/main/java/org/codelutin/maven/plugin/GenCleanMojo.java
trunk/maven-genclean-plugin/src/main/resources/
trunk/maven-genclean-plugin/src/main/resources/log4j.properties
trunk/maven-genclean-plugin/src/test/
trunk/maven-genclean-plugin/src/test/java/
trunk/maven-genclean-plugin/src/test/resources/
Log:
first import of maven-genclean-plugin
Added: trunk/maven-genclean-plugin/pom.xml
===================================================================
--- trunk/maven-genclean-plugin/pom.xml (rev 0)
+++ trunk/maven-genclean-plugin/pom.xml 2008-07-22 23:06:39 UTC (rev 877)
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<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>lutinlib</groupId>
+ <artifactId>lutinproject</artifactId>
+ <version>2.3</version>
+ </parent>
+
+ <groupId>org.codelutin.maven.plugin</groupId>
+ <artifactId>maven-genclean-plugin</artifactId>
+ <name>maven plugin</name>
+
+ <dependencies>
+
+ <!-- maven plugin project dependencies -->
+
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>2.0.4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-model</artifactId>
+ <version>2.0.4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>2.0.4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>1.0.5</version>
+ </dependency>
+
+ </dependencies>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <version>0.1-SNAPSHOT</version>
+
+ <description>Maven 2 plugin to clean generate stuff.</description>
+
+ <inceptionYear>2008</inceptionYear>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>maven-plugin</packaging>
+
+ <properties> <!-- id du projet du labs (lutinutil) -->
+
+ <labs.id>41</labs.id>
+ <!-- nom du projet du labs -->
+
+ <labs.project>lutinutil</labs.project>
+
+ <!-- compile with ? -->
+
+ <maven.compile.source>1.6</maven.compile.source>
+
+ <maven.compile.target>1.6</maven.compile.target>
+ <!-- compilation encondig -->
+
+ <maven.compile.encoding>ISO-8859-15</maven.compile.encoding>
+ <!-- Lists URL -->
+ <labs.lists>
+
+ http://lists.labs.libre-entreprise.org/mailman/listinfo/lutinutil
+
+ </labs.lists>
+ <!-- maven will suffix with /${pom.artifactId} /-->
+ <maven.scm.developerConnection>scm:svn:svn+ssh://${username}@${labs.host}/svnroot/lutinutil/trunk
+
+ </maven.scm.developerConnection>
+ <!--maven will suffix with /${pom.artifactId} /-->
+ <maven.scm.connection>scm:svn:svn:anonymous@${labs.host}/svnroot/lutinutil/trunk</maven.scm.connection>
+ </properties>
+ <prerequisites>
+
+ <maven>2.0.9</maven>
+
+ </prerequisites>
+
+ <!-- ************************************************************* -->
+ <!-- **** Build Environment ************************************** -->
+ <!-- ************************************************************* -->
+
+ <!-- the plugin is a module in a labs project (lutinutil), so we have to override
+ this property (see in the parent pom for more explanation) -->
+ <scm>
+ <url>${maven.scm.url}</url>
+ </scm>
+
+</project>
Added: trunk/maven-genclean-plugin/src/main/java/org/codelutin/maven/plugin/GenCleanMojo.java
===================================================================
--- trunk/maven-genclean-plugin/src/main/java/org/codelutin/maven/plugin/GenCleanMojo.java (rev 0)
+++ trunk/maven-genclean-plugin/src/main/java/org/codelutin/maven/plugin/GenCleanMojo.java 2008-07-22 23:06:39 UTC (rev 877)
@@ -0,0 +1,101 @@
+/**
+ * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * This program is free software; you
+ * can redistribute it and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. This program is
+ * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
+ * should have received a copy of the GNU General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place
+ * - Suite 330, Boston, MA 02111-1307, USA.
+ * # #%
+ */
+package org.codelutin.maven.plugin;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import static org.codelutin.i18n.I18n._;
+
+import java.io.File;
+
+
+/**
+ * Classe permettant de nettoyer les fichiers g�n�r�s.
+ *
+ * @author chemit
+ * @goal clean
+ * @phase clean
+ */
+public abstract class GenCleanMojo extends AbstractMojo {
+
+ /**
+ * @description D�pendance du projet.
+ * @parameter default-value="${project}"
+ * @readonly
+ */
+ protected MavenProject project;
+
+ /**
+ * @description R�pertoire de destination des fichiers java � g�n�rer.
+ * @parameter expression="${genclean.genDirectory}" default-value="${basedir}/gen/java"
+ */
+ protected File genDirectory;
+
+ /**
+ * @description verbose
+ * @parameter expression="${genclean.verbose}" default-value="${maven.verbose}"
+ */
+ protected boolean verbose;
+
+
+ protected abstract void doExecute() throws Exception;
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+
+ try {
+
+ if (genDirectory.exists()) {
+ if (verbose) {
+ getLog().info("delete gen directory " + genDirectory);
+ }
+ genDirectory.delete();
+ } else {
+ if (verbose) {
+ getLog().info("could not find gen directory " + genDirectory);
+ }
+ }
+
+ } catch (Exception e) {
+ getLog().error(e);
+ Throwable e2 = e;
+ while (e2.getCause() != null) {
+ e2 = e.getCause();
+ }
+ getLog().error(e2);
+
+ throw new MojoExecutionException(e.getMessage(), e);
+ }
+
+ }
+
+
+ public File getGenDirectory() {
+ return genDirectory;
+ }
+
+ public void setGenDirectory(File genDirectory) {
+ this.genDirectory = genDirectory;
+ }
+
+ public boolean isVerbose() {
+ return verbose;
+ }
+
+ public void setVerbose(boolean verbose) {
+ this.verbose = verbose;
+ }
+}
\ No newline at end of file
Added: trunk/maven-genclean-plugin/src/main/resources/log4j.properties
===================================================================
--- trunk/maven-genclean-plugin/src/main/resources/log4j.properties (rev 0)
+++ trunk/maven-genclean-plugin/src/main/resources/log4j.properties 2008-07-22 23:06:39 UTC (rev 877)
@@ -0,0 +1,9 @@
+# Global logging configuration
+log4j.rootLogger=INFO, stdout
+# Console output...
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
+
+#log4j.logger.org.codelutin.jaxx=DEBUG
+#log4j.logger.jaxx=DEBUG
1
0
[Lutinutil-commits] r876 - in trunk/commandline: . commandline-ui
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
22 Jul '08
Author: tchemit
Date: 2008-07-22 20:24:54 +0000 (Tue, 22 Jul 2008)
New Revision: 876
Modified:
trunk/commandline/
trunk/commandline/commandline-ui/
trunk/commandline/commandline-ui/pom.xml
Log:
utilisation du r?\195?\169pertoire gen non dans target car les ide ignore ce r?\195?\169pertoire
Property changes on: trunk/commandline
___________________________________________________________________
Name: svn:ignore
+ *.iws
*.ipr
Property changes on: trunk/commandline/commandline-ui
___________________________________________________________________
Name: svn:ignore
- target
+ target
gen
Modified: trunk/commandline/commandline-ui/pom.xml
===================================================================
--- trunk/commandline/commandline-ui/pom.xml 2008-07-22 20:06:39 UTC (rev 875)
+++ trunk/commandline/commandline-ui/pom.xml 2008-07-22 20:24:54 UTC (rev 876)
@@ -51,12 +51,13 @@
<!-- where to generate jaxx java files -->
<resources>
<resource>
- <directory>${basedir}/target/gen/java</directory>
+ <directory>${basedir}/gen/java</directory>
</resource>
<resource>
<directory>${maven.src.dir}/main/resources</directory>
</resource>
</resources>
+
<plugins>
<!-- jaxx -->
<plugin>
@@ -65,8 +66,7 @@
<version>0.2-SNAPSHOT</version>
<configuration>
<src>${maven.src.dir}/main/uimodel</src>
- <out>${basedir}/target/gen/java</out>
- <!--out>${maven.src.dir}/main/java</out-->
+ <out>${basedir}/gen/java</out>
</configuration>
<executions>
<execution>
@@ -80,7 +80,6 @@
<groupId>org.codelutin.jaxx</groupId>
<artifactId>jaxx-swing</artifactId>
<scope>compile</scope>
- <!--version>${jaxx.version}</version-->
<version>0.2-SNAPSHOT</version>
</dependency>
</dependencies>
@@ -96,9 +95,7 @@
<configuration>
<entries>
<entry>
- <basedir>
- ${basedir}/target/gen/java
- </basedir>
+ <basedir>${basedir}/gen/java</basedir>
</entry>
</entries>
</configuration>
@@ -113,36 +110,21 @@
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
- <!--execution>
+ <execution>
<id>clean</id>
<phase>clean</phase>
<configuration>
<tasks>
+ <mkdir dir="${basedir}/gen/java"/>
<delete includeemptydirs="true">
- <fileset dir="${maven.src.dir}/main/java" includes="**/*"/>
+ <fileset dir="${basedir}/gen/java" includes="**/*"/>
</delete>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
- </execution-->
- <!--execution>
- <id>generate-sources</id>
- <phase>generate-sources</phase>
- <configuration>
- <tasks>
- <copy todir="${maven.src.dir}/main/java" verbose="${maven.verbose}" overwrite="true">
- <fileset dir="${maven.src.dir}/main/uimodel">
- <include name="**/*.java"/>
- </fileset>
- </copy>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution-->
+ </execution>
</executions>
</plugin>
1
0
[Lutinutil-commits] r875 - in trunk/commandline/commandline-ui: . src/main/java src/main/java/org src/main/java/org/codelutin src/main/java/org/codelutin/option src/main/java/org/codelutin/option/ui src/main/uimodel/org/codelutin/option/ui
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
22 Jul '08
Author: tchemit
Date: 2008-07-22 20:06:39 +0000 (Tue, 22 Jul 2008)
New Revision: 875
Added:
trunk/commandline/commandline-ui/src/main/java/org/
trunk/commandline/commandline-ui/src/main/java/org/codelutin/
trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/
trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/
trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ClassCellEditor.java
trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableEditor.java
trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableModel.java
trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableRenderer.java
trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigUI.java
trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigUIHandler.java
trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/LoginUIHandler.java
Removed:
trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ClassCellEditor.java
trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTableEditor.java
trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTableModel.java
trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTableRenderer.java
trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigUI.java
trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigUIHandler.java
trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/LoginUIHandler.java
Modified:
trunk/commandline/commandline-ui/pom.xml
trunk/commandline/commandline-ui/src/main/java/
Log:
utilisation d'un r?\195?\169pertoire de compilation dans le projet
Modified: trunk/commandline/commandline-ui/pom.xml
===================================================================
--- trunk/commandline/commandline-ui/pom.xml 2008-07-21 00:34:57 UTC (rev 874)
+++ trunk/commandline/commandline-ui/pom.xml 2008-07-22 20:06:39 UTC (rev 875)
@@ -48,7 +48,15 @@
<packaging>jar</packaging>
<build>
-
+ <!-- where to generate jaxx java files -->
+ <resources>
+ <resource>
+ <directory>${basedir}/target/gen/java</directory>
+ </resource>
+ <resource>
+ <directory>${maven.src.dir}/main/resources</directory>
+ </resource>
+ </resources>
<plugins>
<!-- jaxx -->
<plugin>
@@ -57,7 +65,8 @@
<version>0.2-SNAPSHOT</version>
<configuration>
<src>${maven.src.dir}/main/uimodel</src>
- <out>${maven.src.dir}/main/java</out>
+ <out>${basedir}/target/gen/java</out>
+ <!--out>${maven.src.dir}/main/java</out-->
</configuration>
<executions>
<execution>
@@ -71,8 +80,9 @@
<groupId>org.codelutin.jaxx</groupId>
<artifactId>jaxx-swing</artifactId>
<scope>compile</scope>
+ <!--version>${jaxx.version}</version-->
<version>0.2-SNAPSHOT</version>
- </dependency>
+ </dependency>
</dependencies>
</plugin>
@@ -83,6 +93,15 @@
<executions>
<execution>
<phase>compile</phase>
+ <configuration>
+ <entries>
+ <entry>
+ <basedir>
+ ${basedir}/target/gen/java
+ </basedir>
+ </entry>
+ </entries>
+ </configuration>
<goals>
<goal>parserJava</goal>
<goal>gen</goal>
@@ -94,7 +113,7 @@
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
- <execution>
+ <!--execution>
<id>clean</id>
<phase>clean</phase>
<configuration>
@@ -107,8 +126,8 @@
<goals>
<goal>run</goal>
</goals>
- </execution>
- <execution>
+ </execution-->
+ <!--execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
@@ -123,7 +142,7 @@
<goals>
<goal>run</goal>
</goals>
- </execution>
+ </execution-->
</executions>
</plugin>
Property changes on: trunk/commandline/commandline-ui/src/main/java
___________________________________________________________________
Name: svn:ignore
- org
Copied: trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ClassCellEditor.java (from rev 872, trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ClassCellEditor.java)
===================================================================
--- trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ClassCellEditor.java (rev 0)
+++ trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ClassCellEditor.java 2008-07-22 20:06:39 UTC (rev 875)
@@ -0,0 +1,112 @@
+/*
+* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
+* Tony Chemit
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package org.codelutin.option.ui;
+
+import org.apache.commons.beanutils.Converter;
+import org.codelutin.util.ConverterUtil;
+
+import javax.swing.DefaultCellEditor;
+import javax.swing.JTable;
+import javax.swing.JTextField;
+import javax.swing.event.CellEditorListener;
+import javax.swing.table.TableCellEditor;
+import java.awt.Component;
+import java.util.EventObject;
+
+/**
+ * L'�diteur des valeurs des propri�t�s d'une configuration
+ *
+ * @author chemit
+ */
+public class ClassCellEditor implements TableCellEditor {
+
+ protected TableCellEditor delegate;
+
+ public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
+
+ String valStr = (value + "").trim();
+ if (valStr.equals("null")) {
+ valStr = "";
+ } else if (valStr.startsWith("class ")) {
+ valStr = valStr.substring(6);
+ }
+ Component comp;
+ comp = getDelegate().getTableCellEditorComponent(table, valStr, isSelected, row, column);
+ return comp;
+ }
+
+ public Object getCellEditorValue() {
+ Object o = !hasDelegate() ? null : delegate.getCellEditorValue();
+ if (o == null) {
+ return null;
+ }
+ Converter converter = ConverterUtil.getConverter(Class.class);
+
+ try {
+ if (converter != null) {
+ return converter.convert(Class.class, o);
+ }
+ o =Class.forName(o+"");
+ } catch (Exception e) {
+ o=null;
+ }
+ return o;
+ }
+
+ public boolean isCellEditable(EventObject anEvent) {
+ return !hasDelegate() || delegate.isCellEditable(anEvent);
+ }
+
+ public boolean shouldSelectCell(EventObject anEvent) {
+ return hasDelegate() && delegate.shouldSelectCell(anEvent);
+ }
+
+ public boolean stopCellEditing() {
+ return !hasDelegate() || delegate.stopCellEditing();
+ }
+
+ public void cancelCellEditing() {
+ if (hasDelegate()) {
+ delegate.cancelCellEditing();
+ }
+ }
+
+ public void addCellEditorListener(CellEditorListener l) {
+ if (hasDelegate()) {
+ delegate.addCellEditorListener(l);
+ }
+ }
+
+ public void removeCellEditorListener(CellEditorListener l) {
+ if (hasDelegate()) {
+ delegate.removeCellEditorListener(l);
+ }
+ }
+
+ protected TableCellEditor getDelegate() {
+ if (delegate == null) {
+ delegate = new DefaultCellEditor(new JTextField());
+ }
+ return delegate;
+ }
+
+ protected boolean hasDelegate() {
+ return delegate != null;
+ }
+}
\ No newline at end of file
Property changes on: trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ClassCellEditor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableEditor.java (from rev 872, trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTableEditor.java)
===================================================================
--- trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableEditor.java (rev 0)
+++ trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableEditor.java 2008-07-22 20:06:39 UTC (rev 875)
@@ -0,0 +1,114 @@
+/*
+* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
+* Tony Chemit
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package org.codelutin.option.ui;
+
+import javax.swing.DefaultCellEditor;
+import javax.swing.JTable;
+import javax.swing.event.CellEditorListener;
+import javax.swing.table.TableCellEditor;
+import java.awt.Component;
+import java.util.EventObject;
+import java.util.Locale;
+
+/**
+ * L'�diteur des valeurs des propri�t�s d'une configuration
+ *
+ * @author chemit
+ */
+public class ConfigTableEditor implements TableCellEditor {
+
+ protected TableCellEditor delegate;
+ protected ConfigTableModel model;
+
+ public ConfigTableEditor(ConfigTableModel model) {
+ this.model = model;
+ }
+
+ public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
+ delegate = findDelegate(table, model.getKey(row).getType());
+ return delegate.getTableCellEditorComponent(table, value, isSelected, row, column);
+ }
+
+ public Object getCellEditorValue() {
+ return !hasDelegate() ? null : delegate.getCellEditorValue();
+ }
+
+ public boolean isCellEditable(EventObject anEvent) {
+ return !hasDelegate() || delegate.isCellEditable(anEvent);
+ }
+
+ public boolean shouldSelectCell(EventObject anEvent) {
+ return hasDelegate() && delegate.shouldSelectCell(anEvent);
+ }
+
+ public boolean stopCellEditing() {
+ return !hasDelegate() || delegate.stopCellEditing();
+ }
+
+ public void cancelCellEditing() {
+ if (hasDelegate()) {
+ delegate.cancelCellEditing();
+ }
+ }
+
+ public void addCellEditorListener(CellEditorListener l) {
+ if (hasDelegate()) {
+ delegate.addCellEditorListener(l);
+ }
+ }
+
+ public void removeCellEditorListener(CellEditorListener l) {
+ if (hasDelegate()) {
+ delegate.removeCellEditorListener(l);
+ }
+ }
+
+ protected TableCellEditor findDelegate(JTable table, Class<?> type) {
+ TableCellEditor delegate = table.getDefaultEditor(type);
+ TableCellEditor defaultEditor = table.getDefaultEditor(Object.class);
+ if (delegate == defaultEditor) {
+ // find not a specialized editor for the type
+ if (type.isEnum()) {
+ // add a EnumEditor to table
+ delegate = new DefaultCellEditor(org.codelutin.util.EnumEditor.newEditor(type));
+ table.setDefaultEditor(type, delegate);
+ } else if (type == Class.class) {
+ delegate = new ClassCellEditor();
+ table.setDefaultEditor(type, delegate);
+ } //else if (type == File.class){
+ // TODO a FileEditor
+ // table.setDefaultEditor(type, delegate);
+ //}
+ else if (type.equals(Locale.class)) {
+ delegate = new DefaultCellEditor(org.codelutin.i18n.LocaleEditor.newEditor());
+ table.setDefaultEditor(Locale.class, delegate);
+ } else {
+ delegate = table.getDefaultEditor(String.class);
+ }
+ }
+ if (delegate == null) {
+ throw new IllegalStateException("could not find a editor for type +" + type);
+ }
+ return delegate;
+ }
+
+ protected boolean hasDelegate() {
+ return delegate != null;
+ }
+}
Property changes on: trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableEditor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableModel.java (from rev 872, trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTableModel.java)
===================================================================
--- trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableModel.java (rev 0)
+++ trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableModel.java 2008-07-22 20:06:39 UTC (rev 875)
@@ -0,0 +1,235 @@
+/*
+* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
+* Tony Chemit
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package org.codelutin.option.ui;
+
+import static org.codelutin.i18n.I18n._;
+import org.codelutin.option.Config;
+import org.codelutin.option.ConfigPropertyKey;
+import org.codelutin.util.ArrayUtil;
+
+import javax.swing.table.AbstractTableModel;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * Un mod�le g�n�rique pour une configuration g�n�rique
+ *
+ * @author chemit
+ */
+public class ConfigTableModel extends AbstractTableModel {
+
+ private static final long serialVersionUID = -1457510439292016551L;
+
+ /**
+ * Une enum pour d�finir les types de donn�es � ajouter au model
+ *
+ * @author chemit
+ */
+ public enum TypeModel {
+ all {
+ protected boolean accept(ConfigPropertyKey<?> key) {
+ return true;
+ }},
+ nontech {
+ protected boolean accept(ConfigPropertyKey<?> key) {
+ return !(tech.accept(key) || key.isTransient());
+ }},
+ tech {
+ protected boolean accept(ConfigPropertyKey<?> key) {
+ return key.isFinal();
+ //return key.isFinal() && key.isTransient() && key.isStatic();
+ }};
+
+ abstract boolean accept(ConfigPropertyKey<?> key);
+ }
+
+ // par d�faut on affiche uniquement les propri�t�s non techniques
+ private static final TypeModel DEFAULT_TYPE = TypeModel.nontech;
+
+ private final String[] columnNames = {_("lutinutil.common.key"), _("lutinutil.common.value")};
+
+ private final Class[] columnClass = {String.class, Object.class};
+
+ protected ConfigPropertyKey<?>[] keys;
+ protected Map<ConfigPropertyKey<?>, Object> props;
+ protected TypeModel type;
+
+ protected Config config;
+
+ public ConfigTableModel(Config config) {
+ this(config, null);
+ }
+
+ public ConfigTableModel(Config config, TypeModel type) {
+ this.config = config;
+ setType(type);
+ }
+
+ public TypeModel getType() {
+ return type;
+ }
+
+ public void setType(TypeModel type) {
+ this.type = type;
+ // rebuild model
+ if (props == null) {
+ props = new LinkedHashMap<ConfigPropertyKey<?>, Object>();
+ } else {
+ props.clear();
+ }
+ if (type == null) {
+ type = DEFAULT_TYPE;
+ }
+ if (type == TypeModel.all) {
+ for (ConfigPropertyKey<?> key : config.getUniverse()) {
+ if (TypeModel.nontech.accept(key)) {
+ props.put(key, key.getCurrentValue());
+ }
+ }
+ for (ConfigPropertyKey<?> key : config.getUniverse()) {
+ if (TypeModel.tech.accept(key)) {
+ props.put(key, key.getCurrentValue());
+ }
+ }
+ } else {
+ for (ConfigPropertyKey<?> key : config.getUniverse()) {
+ if (type.accept(key)) {
+ props.put(key, key.getCurrentValue());
+ }
+ }
+ }
+ keys = ArrayUtil.toArray(props.keySet(), ConfigPropertyKey.class);
+ fireTableDataChanged();
+ }
+
+ public ConfigPropertyKey<?> getKey(int rowIndex) {
+ return keys[rowIndex];
+ }
+
+ public boolean isModified(int rowIndex) {
+ ConfigPropertyKey key = getKey(rowIndex);
+ return !key.equals(key.getCurrentValue(), props.get(key));
+ }
+
+ public boolean isValid(int rowIndex) {
+ ConfigPropertyKey<?> key = getKey(rowIndex);
+ Object value = props.get(key);
+ return !key.isMandatory() || value != null && !"".equals(value);
+ }
+
+ public boolean isModified() {
+ for (int i = 0; i < keys.length; i++) {
+ if (isModified(i)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean isValid() {
+ for (int i = 0; i < keys.length; i++) {
+ if (!isValid(i)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public void transfertModified(Config config) {
+ for (int i = 0; i < getRowCount(); i++) {
+ if (isModified(i)) {
+ ConfigPropertyKey<Object> key = (ConfigPropertyKey<Object>) getKey(i);
+ Object value = props.get(key);
+ //System.out.println("transfert property {0} value {1}", key.getKey(), value);
+ config.addProperty(key, value);
+ }
+ }
+ }
+
+ public void reset() {
+ for (int i = 0; i < getRowCount(); i++) {
+ if (isModified(i)) {
+ ConfigPropertyKey key = getKey(i);
+ props.put(key, key.getCurrentValue());
+ }
+ }
+ fireTableDataChanged();
+ }
+
+ public int getRowCount() {
+ return keys.length;
+ }
+
+ public int getColumnCount() {
+ return 2;
+ }
+
+ public Object getValueAt(int row, int column) {
+ ConfigPropertyKey key = getKey(row);
+ if (column == 0) {
+ return key.getKey();
+ }
+ return props.get(key);
+ }
+
+ @Override
+ public String getColumnName(int columnIndex) {
+ return columnNames[columnIndex];
+ }
+
+ @Override
+ public Class<?> getColumnClass(int columnIndex) {
+ return columnClass[columnIndex];
+ }
+
+ @Override
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ return columnIndex == 1 && !keys[rowIndex].isFinal();
+ }
+
+ @Override
+ public void setValueAt(Object aValue, int row, int column) {
+ if (column == 0) {
+ return;
+ }
+ ConfigPropertyKey<?> key = getKey(row);
+ Object val;
+
+ if (aValue==null || key.getType() ==aValue.getClass()) {
+ // we have directly the value, no conversion need
+ val = aValue;
+ } else {
+ String valStr = String.valueOf(aValue).trim();
+ try {
+ val = key.convert(key.getType(), valStr);
+ if (val != null && val instanceof Integer) {
+ if (new Integer(0).equals(val) && !valStr.equals("0")) {
+ val = null;
+ }
+ }
+ } catch (Exception e) {
+ val = null;
+ }
+ }
+ props.put(key, val);
+ fireTableRowsUpdated(row, row);
+ }
+
+}
Property changes on: trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableModel.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableRenderer.java (from rev 872, trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTableRenderer.java)
===================================================================
--- trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableRenderer.java (rev 0)
+++ trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableRenderer.java 2008-07-22 20:06:39 UTC (rev 875)
@@ -0,0 +1,108 @@
+/*
+* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
+* Tony Chemit
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package org.codelutin.option.ui;
+
+import static org.codelutin.i18n.I18n._;
+import org.codelutin.option.ConfigPropertyKey;
+
+import javax.swing.JComponent;
+import javax.swing.JTable;
+import javax.swing.border.LineBorder;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.TableCellRenderer;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Font;
+
+/**
+ * le renderer pour l'ui de config
+ *
+ * @author chemit
+ */
+public class ConfigTableRenderer extends DefaultTableCellRenderer {
+
+ protected static Color col;
+ protected static Font font;
+ protected static Font font2;
+
+ protected ConfigTableModel model;
+
+ public ConfigTableRenderer(ConfigTableModel config) {
+ this.model = config;
+ col = getForeground();
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+ //System.out.println(">>> ConfigColumnRenderer.getTableCellRendererComponent " + row + "/" + column);
+ ConfigPropertyKey key = model.getKey(row);
+ boolean isModified = model.isModified(row);
+ boolean isValid = model.isValid(row);
+
+ boolean isFinal = key.isFinal();
+ if (font == null) {
+ font = table.getFont();
+ font2 = getFont().deriveFont(Font.ITALIC | Font.BOLD);
+ }
+ Component cellRenderer = null;
+ // modified lines are selected
+ if (column == 0) {
+ cellRenderer = getKeyCellRenderer(table, value, isModified, hasFocus, row, column, key, isValid);
+ } else if (column == 1) {
+ cellRenderer = getValueCellRenderer(table, value, isModified, hasFocus, row, column, key, isValid);
+ }
+ if (cellRenderer == null) {
+ throw new IllegalStateException("no renderer find for column " + column);
+ }
+ cellRenderer.setEnabled(!isFinal);
+ cellRenderer.setFont(isModified ? font2 : font);
+ return cellRenderer;
+ }
+
+ protected Component getKeyCellRenderer(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column, ConfigPropertyKey key, boolean valid) {
+ String tooltip = key.getDescription();
+ String s = _("lutinutil.config.modified", key.getCurrentValue());
+
+ if (isSelected) {
+ value = value + " *";
+ tooltip += " [" + s + ']';
+ }
+ if (!valid) {
+ String s2 = _("lutinutil.config.unvalid", key.getCurrentValue(), key.getType());
+ tooltip += " (" + s2 + ")";
+ }
+ JComponent result = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ result.setToolTipText(tooltip);
+ result.setForeground(valid ? col : Color.RED);
+ return result;
+ }
+
+ protected Component getValueCellRenderer(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column, ConfigPropertyKey key, boolean valid) {
+ TableCellRenderer defaultRenderer = table.getDefaultRenderer(key.getType());
+
+ JComponent result;
+ result = (JComponent) defaultRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ if (!valid) {
+ result.setBorder(new LineBorder(Color.red));
+ } else {
+ result.setBorder(null);
+ }
+ return result;
+ }
+}
Property changes on: trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableRenderer.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigUI.java (from rev 872, trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigUI.java)
===================================================================
--- trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigUI.java (rev 0)
+++ trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigUI.java 2008-07-22 20:06:39 UTC (rev 875)
@@ -0,0 +1,103 @@
+/*
+* ##% Copyright (C) 2007, 2008 Code Lutin, Tony Chemit
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package org.codelutin.option.ui;
+
+import org.codelutin.option.AbstractContext;
+import org.codelutin.option.Config;
+
+import javax.swing.*;
+import java.awt.*;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * TODO javadoc
+ *
+ * @author chemit
+ */
+public class ConfigUI extends JConfigUI {
+
+ protected List<Config> configs;
+
+ public List<Config> getConfigs() {
+ if (configs == null) {
+ configs = new ArrayList<Config>();
+ }
+ return configs;
+ }
+
+ public ListCellRenderer getListener() {
+ return new DefaultListCellRenderer() {
+ @Override
+ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
+ if (value instanceof Config) {
+ Config config = (Config) value;
+ JComponent listCellRendererComponent = (JComponent) super.getListCellRendererComponent(list, config.getCategory(), index, isSelected, cellHasFocus);
+ listCellRendererComponent.setToolTipText(config.getCategory());
+ return listCellRendererComponent;
+ }
+ return this;
+ }
+ };
+ }
+
+ public void onValueChanged() {
+ Object value = list.getSelectedValue();
+ if (value instanceof Config) {
+ Config config = (Config) value;
+ cardLayout.show(preview, config.getCategory());
+ }
+ }
+
+ public ConfigUI init(AbstractContext context, Config... configs) {
+ for (Config config : configs) {
+ add(context, config);
+ }
+ if (list.getModel().getSize() > 0) {
+ list.setSelectedIndex(0);
+ }
+ return this;
+ }
+
+ public boolean add(AbstractContext context, Config config) {
+ int index = getConfigs().indexOf(config);
+ if (index > -1) {
+ return false;
+ }
+ configs.add(config);
+ ConfigTab ui = new ConfigTab();
+ ui.getHandler().init(context, config);
+ listModel.addElement(config);
+ preview.add(ui, config.getCategory());
+ return true;
+ }
+
+ public boolean remove(Config o) {
+ if (configs == null) {
+ return false;
+ }
+ int index = configs.indexOf(o);
+ if (index == -1) {
+ return false;
+ }
+ listModel.remove(index);
+ preview.remove(index);
+ configs.remove(index);
+ return true;
+ }
+}
Property changes on: trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigUI.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigUIHandler.java (from rev 872, trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigUIHandler.java)
===================================================================
--- trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigUIHandler.java (rev 0)
+++ trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigUIHandler.java 2008-07-22 20:06:39 UTC (rev 875)
@@ -0,0 +1,115 @@
+/*
+* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
+* Tony Chemit
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package org.codelutin.option.ui;
+
+import org.codelutin.option.AbstractContext;
+import org.codelutin.option.Config;
+
+import javax.swing.*;
+import javax.swing.event.TableModelEvent;
+import javax.swing.event.TableModelListener;
+
+/**
+ * Le controleur de l'ui de modification de configuration.
+ *
+ * @author chemit
+ */
+public class ConfigUIHandler {
+
+ protected ConfigTab ui;
+ protected Config config;
+ protected ConfigTableModel tableModel;
+ protected TableModelListener tableModelListener;
+
+ protected AbstractContext context;
+
+ public ConfigUIHandler(ConfigTab ui) {
+ this.ui = ui;
+ }
+
+ public void init(AbstractContext context, Config config) {
+ this.config = config;
+ this.context = context;
+ tableModel = new ConfigTableModel(config);
+
+ tableModel.addTableModelListener(getTableModelListener());
+ JTable table = ui.getMain();
+ table.setModel(tableModel);
+
+ ConfigTableRenderer renderer = new ConfigTableRenderer(tableModel);
+ table.getColumnModel().getColumn(0).setCellRenderer(renderer);
+ table.getColumnModel().getColumn(1).setCellRenderer(renderer);
+ table.getColumnModel().getColumn(1).setCellEditor(new ConfigTableEditor(getTableModel()));
+
+ tableModel.fireTableDataChanged();
+ }
+
+ public void doSave() {
+ if (!isEmpty() && getTableModel().isModified()) {
+ getTableModel().transfertModified(getConfig());
+ context.saveSafely();
+ }
+ doReset();
+ }
+
+ public void doReset() {
+ getTableModel().reset();
+ }
+
+ public void doSelectTechnical(boolean showTechnical) {
+ tableModel.setType(showTechnical ? ConfigTableModel.TypeModel.all : ConfigTableModel.TypeModel.nontech);
+ }
+
+ protected boolean isSaveEnabled() {
+ return isResetEnabled() && tableModel.isValid();
+ }
+
+ protected boolean isResetEnabled() {
+ return !isEmpty() && tableModel.isModified();
+ }
+
+ protected boolean isEmpty() {
+ return tableModel == null || config == null || config.getUniverse().isEmpty();
+ }
+
+ protected Config getConfig() {
+ return config;
+ }
+
+ protected ConfigTableModel getTableModel() {
+ return tableModel;
+ }
+
+ protected TableModelListener getTableModelListener() {
+ if (tableModelListener == null) {
+ tableModelListener = new TableModelListener() {
+ public void tableChanged(TableModelEvent e) {
+ ui.getSave().setEnabled(isSaveEnabled());
+ ui.getReset().setEnabled(isResetEnabled());
+ }
+ };
+ }
+ return tableModelListener;
+ }
+
+ protected void dispose() {
+ getTableModel().reset();
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigUIHandler.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/LoginUIHandler.java (from rev 872, trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/LoginUIHandler.java)
===================================================================
--- trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/LoginUIHandler.java (rev 0)
+++ trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/LoginUIHandler.java 2008-07-22 20:06:39 UTC (rev 875)
@@ -0,0 +1,28 @@
+package org.codelutin.option.ui;
+
+public abstract class LoginUIHandler {
+
+ boolean cancel;
+
+ JLoginUI ui;
+
+ protected abstract boolean connect(String login, char[] password);
+
+ protected abstract boolean failedToConnect();
+
+ public abstract void doConnect();
+
+ public abstract void doCancel();
+
+ protected void setUi(JLoginUI ui) {
+ this.ui = ui;
+ }
+
+ public void setCancel(boolean cancel) {
+ this.cancel = cancel;
+ }
+
+ public boolean isCancel() {
+ return cancel;
+ }
+}
\ No newline at end of file
Deleted: trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ClassCellEditor.java
===================================================================
--- trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ClassCellEditor.java 2008-07-21 00:34:57 UTC (rev 874)
+++ trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ClassCellEditor.java 2008-07-22 20:06:39 UTC (rev 875)
@@ -1,112 +0,0 @@
-/*
-* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
-* Tony Chemit
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-* ##% */
-package org.codelutin.option.ui;
-
-import org.apache.commons.beanutils.Converter;
-import org.codelutin.util.ConverterUtil;
-
-import javax.swing.DefaultCellEditor;
-import javax.swing.JTable;
-import javax.swing.JTextField;
-import javax.swing.event.CellEditorListener;
-import javax.swing.table.TableCellEditor;
-import java.awt.Component;
-import java.util.EventObject;
-
-/**
- * L'�diteur des valeurs des propri�t�s d'une configuration
- *
- * @author chemit
- */
-public class ClassCellEditor implements TableCellEditor {
-
- protected TableCellEditor delegate;
-
- public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
-
- String valStr = (value + "").trim();
- if (valStr.equals("null")) {
- valStr = "";
- } else if (valStr.startsWith("class ")) {
- valStr = valStr.substring(6);
- }
- Component comp;
- comp = getDelegate().getTableCellEditorComponent(table, valStr, isSelected, row, column);
- return comp;
- }
-
- public Object getCellEditorValue() {
- Object o = !hasDelegate() ? null : delegate.getCellEditorValue();
- if (o == null) {
- return null;
- }
- Converter converter = ConverterUtil.getConverter(Class.class);
-
- try {
- if (converter != null) {
- return converter.convert(Class.class, o);
- }
- o =Class.forName(o+"");
- } catch (Exception e) {
- o=null;
- }
- return o;
- }
-
- public boolean isCellEditable(EventObject anEvent) {
- return !hasDelegate() || delegate.isCellEditable(anEvent);
- }
-
- public boolean shouldSelectCell(EventObject anEvent) {
- return hasDelegate() && delegate.shouldSelectCell(anEvent);
- }
-
- public boolean stopCellEditing() {
- return !hasDelegate() || delegate.stopCellEditing();
- }
-
- public void cancelCellEditing() {
- if (hasDelegate()) {
- delegate.cancelCellEditing();
- }
- }
-
- public void addCellEditorListener(CellEditorListener l) {
- if (hasDelegate()) {
- delegate.addCellEditorListener(l);
- }
- }
-
- public void removeCellEditorListener(CellEditorListener l) {
- if (hasDelegate()) {
- delegate.removeCellEditorListener(l);
- }
- }
-
- protected TableCellEditor getDelegate() {
- if (delegate == null) {
- delegate = new DefaultCellEditor(new JTextField());
- }
- return delegate;
- }
-
- protected boolean hasDelegate() {
- return delegate != null;
- }
-}
\ No newline at end of file
Deleted: trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTableEditor.java
===================================================================
--- trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTableEditor.java 2008-07-21 00:34:57 UTC (rev 874)
+++ trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTableEditor.java 2008-07-22 20:06:39 UTC (rev 875)
@@ -1,114 +0,0 @@
-/*
-* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
-* Tony Chemit
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-* ##% */
-package org.codelutin.option.ui;
-
-import javax.swing.DefaultCellEditor;
-import javax.swing.JTable;
-import javax.swing.event.CellEditorListener;
-import javax.swing.table.TableCellEditor;
-import java.awt.Component;
-import java.util.EventObject;
-import java.util.Locale;
-
-/**
- * L'�diteur des valeurs des propri�t�s d'une configuration
- *
- * @author chemit
- */
-public class ConfigTableEditor implements TableCellEditor {
-
- protected TableCellEditor delegate;
- protected ConfigTableModel model;
-
- public ConfigTableEditor(ConfigTableModel model) {
- this.model = model;
- }
-
- public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
- delegate = findDelegate(table, model.getKey(row).getType());
- return delegate.getTableCellEditorComponent(table, value, isSelected, row, column);
- }
-
- public Object getCellEditorValue() {
- return !hasDelegate() ? null : delegate.getCellEditorValue();
- }
-
- public boolean isCellEditable(EventObject anEvent) {
- return !hasDelegate() || delegate.isCellEditable(anEvent);
- }
-
- public boolean shouldSelectCell(EventObject anEvent) {
- return hasDelegate() && delegate.shouldSelectCell(anEvent);
- }
-
- public boolean stopCellEditing() {
- return !hasDelegate() || delegate.stopCellEditing();
- }
-
- public void cancelCellEditing() {
- if (hasDelegate()) {
- delegate.cancelCellEditing();
- }
- }
-
- public void addCellEditorListener(CellEditorListener l) {
- if (hasDelegate()) {
- delegate.addCellEditorListener(l);
- }
- }
-
- public void removeCellEditorListener(CellEditorListener l) {
- if (hasDelegate()) {
- delegate.removeCellEditorListener(l);
- }
- }
-
- protected TableCellEditor findDelegate(JTable table, Class<?> type) {
- TableCellEditor delegate = table.getDefaultEditor(type);
- TableCellEditor defaultEditor = table.getDefaultEditor(Object.class);
- if (delegate == defaultEditor) {
- // find not a specialized editor for the type
- if (type.isEnum()) {
- // add a EnumEditor to table
- delegate = new DefaultCellEditor(org.codelutin.util.EnumEditor.newEditor(type));
- table.setDefaultEditor(type, delegate);
- } else if (type == Class.class) {
- delegate = new ClassCellEditor();
- table.setDefaultEditor(type, delegate);
- } //else if (type == File.class){
- // TODO a FileEditor
- // table.setDefaultEditor(type, delegate);
- //}
- else if (type.equals(Locale.class)) {
- delegate = new DefaultCellEditor(org.codelutin.i18n.LocaleEditor.newEditor());
- table.setDefaultEditor(Locale.class, delegate);
- } else {
- delegate = table.getDefaultEditor(String.class);
- }
- }
- if (delegate == null) {
- throw new IllegalStateException("could not find a editor for type +" + type);
- }
- return delegate;
- }
-
- protected boolean hasDelegate() {
- return delegate != null;
- }
-}
Deleted: trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTableModel.java
===================================================================
--- trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTableModel.java 2008-07-21 00:34:57 UTC (rev 874)
+++ trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTableModel.java 2008-07-22 20:06:39 UTC (rev 875)
@@ -1,235 +0,0 @@
-/*
-* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
-* Tony Chemit
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-* ##% */
-package org.codelutin.option.ui;
-
-import static org.codelutin.i18n.I18n._;
-import org.codelutin.option.Config;
-import org.codelutin.option.ConfigPropertyKey;
-import org.codelutin.util.ArrayUtil;
-
-import javax.swing.table.AbstractTableModel;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * Un mod�le g�n�rique pour une configuration g�n�rique
- *
- * @author chemit
- */
-public class ConfigTableModel extends AbstractTableModel {
-
- private static final long serialVersionUID = -1457510439292016551L;
-
- /**
- * Une enum pour d�finir les types de donn�es � ajouter au model
- *
- * @author chemit
- */
- public enum TypeModel {
- all {
- protected boolean accept(ConfigPropertyKey<?> key) {
- return true;
- }},
- nontech {
- protected boolean accept(ConfigPropertyKey<?> key) {
- return !(tech.accept(key) || key.isTransient());
- }},
- tech {
- protected boolean accept(ConfigPropertyKey<?> key) {
- return key.isFinal();
- //return key.isFinal() && key.isTransient() && key.isStatic();
- }};
-
- abstract boolean accept(ConfigPropertyKey<?> key);
- }
-
- // par d�faut on affiche uniquement les propri�t�s non techniques
- private static final TypeModel DEFAULT_TYPE = TypeModel.nontech;
-
- private final String[] columnNames = {_("lutinutil.common.key"), _("lutinutil.common.value")};
-
- private final Class[] columnClass = {String.class, Object.class};
-
- protected ConfigPropertyKey<?>[] keys;
- protected Map<ConfigPropertyKey<?>, Object> props;
- protected TypeModel type;
-
- protected Config config;
-
- public ConfigTableModel(Config config) {
- this(config, null);
- }
-
- public ConfigTableModel(Config config, TypeModel type) {
- this.config = config;
- setType(type);
- }
-
- public TypeModel getType() {
- return type;
- }
-
- public void setType(TypeModel type) {
- this.type = type;
- // rebuild model
- if (props == null) {
- props = new LinkedHashMap<ConfigPropertyKey<?>, Object>();
- } else {
- props.clear();
- }
- if (type == null) {
- type = DEFAULT_TYPE;
- }
- if (type == TypeModel.all) {
- for (ConfigPropertyKey<?> key : config.getUniverse()) {
- if (TypeModel.nontech.accept(key)) {
- props.put(key, key.getCurrentValue());
- }
- }
- for (ConfigPropertyKey<?> key : config.getUniverse()) {
- if (TypeModel.tech.accept(key)) {
- props.put(key, key.getCurrentValue());
- }
- }
- } else {
- for (ConfigPropertyKey<?> key : config.getUniverse()) {
- if (type.accept(key)) {
- props.put(key, key.getCurrentValue());
- }
- }
- }
- keys = ArrayUtil.toArray(props.keySet(), ConfigPropertyKey.class);
- fireTableDataChanged();
- }
-
- public ConfigPropertyKey<?> getKey(int rowIndex) {
- return keys[rowIndex];
- }
-
- public boolean isModified(int rowIndex) {
- ConfigPropertyKey key = getKey(rowIndex);
- return !key.equals(key.getCurrentValue(), props.get(key));
- }
-
- public boolean isValid(int rowIndex) {
- ConfigPropertyKey<?> key = getKey(rowIndex);
- Object value = props.get(key);
- return !key.isMandatory() || value != null && !"".equals(value);
- }
-
- public boolean isModified() {
- for (int i = 0; i < keys.length; i++) {
- if (isModified(i)) {
- return true;
- }
- }
- return false;
- }
-
- public boolean isValid() {
- for (int i = 0; i < keys.length; i++) {
- if (!isValid(i)) {
- return false;
- }
- }
- return true;
- }
-
- @SuppressWarnings({"unchecked"})
- public void transfertModified(Config config) {
- for (int i = 0; i < getRowCount(); i++) {
- if (isModified(i)) {
- ConfigPropertyKey<Object> key = (ConfigPropertyKey<Object>) getKey(i);
- Object value = props.get(key);
- //System.out.println("transfert property {0} value {1}", key.getKey(), value);
- config.addProperty(key, value);
- }
- }
- }
-
- public void reset() {
- for (int i = 0; i < getRowCount(); i++) {
- if (isModified(i)) {
- ConfigPropertyKey key = getKey(i);
- props.put(key, key.getCurrentValue());
- }
- }
- fireTableDataChanged();
- }
-
- public int getRowCount() {
- return keys.length;
- }
-
- public int getColumnCount() {
- return 2;
- }
-
- public Object getValueAt(int row, int column) {
- ConfigPropertyKey key = getKey(row);
- if (column == 0) {
- return key.getKey();
- }
- return props.get(key);
- }
-
- @Override
- public String getColumnName(int columnIndex) {
- return columnNames[columnIndex];
- }
-
- @Override
- public Class<?> getColumnClass(int columnIndex) {
- return columnClass[columnIndex];
- }
-
- @Override
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- return columnIndex == 1 && !keys[rowIndex].isFinal();
- }
-
- @Override
- public void setValueAt(Object aValue, int row, int column) {
- if (column == 0) {
- return;
- }
- ConfigPropertyKey<?> key = getKey(row);
- Object val;
-
- if (aValue==null || key.getType() ==aValue.getClass()) {
- // we have directly the value, no conversion need
- val = aValue;
- } else {
- String valStr = String.valueOf(aValue).trim();
- try {
- val = key.convert(key.getType(), valStr);
- if (val != null && val instanceof Integer) {
- if (new Integer(0).equals(val) && !valStr.equals("0")) {
- val = null;
- }
- }
- } catch (Exception e) {
- val = null;
- }
- }
- props.put(key, val);
- fireTableRowsUpdated(row, row);
- }
-
-}
Deleted: trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTableRenderer.java
===================================================================
--- trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTableRenderer.java 2008-07-21 00:34:57 UTC (rev 874)
+++ trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTableRenderer.java 2008-07-22 20:06:39 UTC (rev 875)
@@ -1,108 +0,0 @@
-/*
-* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
-* Tony Chemit
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-* ##% */
-package org.codelutin.option.ui;
-
-import static org.codelutin.i18n.I18n._;
-import org.codelutin.option.ConfigPropertyKey;
-
-import javax.swing.JComponent;
-import javax.swing.JTable;
-import javax.swing.border.LineBorder;
-import javax.swing.table.DefaultTableCellRenderer;
-import javax.swing.table.TableCellRenderer;
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Font;
-
-/**
- * le renderer pour l'ui de config
- *
- * @author chemit
- */
-public class ConfigTableRenderer extends DefaultTableCellRenderer {
-
- protected static Color col;
- protected static Font font;
- protected static Font font2;
-
- protected ConfigTableModel model;
-
- public ConfigTableRenderer(ConfigTableModel config) {
- this.model = config;
- col = getForeground();
- }
-
- @Override
- public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
- //System.out.println(">>> ConfigColumnRenderer.getTableCellRendererComponent " + row + "/" + column);
- ConfigPropertyKey key = model.getKey(row);
- boolean isModified = model.isModified(row);
- boolean isValid = model.isValid(row);
-
- boolean isFinal = key.isFinal();
- if (font == null) {
- font = table.getFont();
- font2 = getFont().deriveFont(Font.ITALIC | Font.BOLD);
- }
- Component cellRenderer = null;
- // modified lines are selected
- if (column == 0) {
- cellRenderer = getKeyCellRenderer(table, value, isModified, hasFocus, row, column, key, isValid);
- } else if (column == 1) {
- cellRenderer = getValueCellRenderer(table, value, isModified, hasFocus, row, column, key, isValid);
- }
- if (cellRenderer == null) {
- throw new IllegalStateException("no renderer find for column " + column);
- }
- cellRenderer.setEnabled(!isFinal);
- cellRenderer.setFont(isModified ? font2 : font);
- return cellRenderer;
- }
-
- protected Component getKeyCellRenderer(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column, ConfigPropertyKey key, boolean valid) {
- String tooltip = key.getDescription();
- String s = _("lutinutil.config.modified", key.getCurrentValue());
-
- if (isSelected) {
- value = value + " *";
- tooltip += " [" + s + ']';
- }
- if (!valid) {
- String s2 = _("lutinutil.config.unvalid", key.getCurrentValue(), key.getType());
- tooltip += " (" + s2 + ")";
- }
- JComponent result = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
- result.setToolTipText(tooltip);
- result.setForeground(valid ? col : Color.RED);
- return result;
- }
-
- protected Component getValueCellRenderer(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column, ConfigPropertyKey key, boolean valid) {
- TableCellRenderer defaultRenderer = table.getDefaultRenderer(key.getType());
-
- JComponent result;
- result = (JComponent) defaultRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
- if (!valid) {
- result.setBorder(new LineBorder(Color.red));
- } else {
- result.setBorder(null);
- }
- return result;
- }
-}
Deleted: trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigUI.java
===================================================================
--- trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigUI.java 2008-07-21 00:34:57 UTC (rev 874)
+++ trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigUI.java 2008-07-22 20:06:39 UTC (rev 875)
@@ -1,103 +0,0 @@
-/*
-* ##% Copyright (C) 2007, 2008 Code Lutin, Tony Chemit
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-* ##% */
-package org.codelutin.option.ui;
-
-import org.codelutin.option.AbstractContext;
-import org.codelutin.option.Config;
-
-import javax.swing.*;
-import java.awt.*;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * TODO javadoc
- *
- * @author chemit
- */
-public class ConfigUI extends JConfigUI {
-
- protected List<Config> configs;
-
- public List<Config> getConfigs() {
- if (configs == null) {
- configs = new ArrayList<Config>();
- }
- return configs;
- }
-
- public ListCellRenderer getListener() {
- return new DefaultListCellRenderer() {
- @Override
- public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
- if (value instanceof Config) {
- Config config = (Config) value;
- JComponent listCellRendererComponent = (JComponent) super.getListCellRendererComponent(list, config.getCategory(), index, isSelected, cellHasFocus);
- listCellRendererComponent.setToolTipText(config.getCategory());
- return listCellRendererComponent;
- }
- return this;
- }
- };
- }
-
- public void onValueChanged() {
- Object value = list.getSelectedValue();
- if (value instanceof Config) {
- Config config = (Config) value;
- cardLayout.show(preview, config.getCategory());
- }
- }
-
- public ConfigUI init(AbstractContext context, Config... configs) {
- for (Config config : configs) {
- add(context, config);
- }
- if (list.getModel().getSize() > 0) {
- list.setSelectedIndex(0);
- }
- return this;
- }
-
- public boolean add(AbstractContext context, Config config) {
- int index = getConfigs().indexOf(config);
- if (index > -1) {
- return false;
- }
- configs.add(config);
- ConfigTab ui = new ConfigTab();
- ui.getHandler().init(context, config);
- listModel.addElement(config);
- preview.add(ui, config.getCategory());
- return true;
- }
-
- public boolean remove(Config o) {
- if (configs == null) {
- return false;
- }
- int index = configs.indexOf(o);
- if (index == -1) {
- return false;
- }
- listModel.remove(index);
- preview.remove(index);
- configs.remove(index);
- return true;
- }
-}
Deleted: trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigUIHandler.java
===================================================================
--- trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigUIHandler.java 2008-07-21 00:34:57 UTC (rev 874)
+++ trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigUIHandler.java 2008-07-22 20:06:39 UTC (rev 875)
@@ -1,115 +0,0 @@
-/*
-* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
-* Tony Chemit
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-* ##% */
-package org.codelutin.option.ui;
-
-import org.codelutin.option.AbstractContext;
-import org.codelutin.option.Config;
-
-import javax.swing.*;
-import javax.swing.event.TableModelEvent;
-import javax.swing.event.TableModelListener;
-
-/**
- * Le controleur de l'ui de modification de configuration.
- *
- * @author chemit
- */
-public class ConfigUIHandler {
-
- protected ConfigTab ui;
- protected Config config;
- protected ConfigTableModel tableModel;
- protected TableModelListener tableModelListener;
-
- protected AbstractContext context;
-
- public ConfigUIHandler(ConfigTab ui) {
- this.ui = ui;
- }
-
- public void init(AbstractContext context, Config config) {
- this.config = config;
- this.context = context;
- tableModel = new ConfigTableModel(config);
-
- tableModel.addTableModelListener(getTableModelListener());
- JTable table = ui.getMain();
- table.setModel(tableModel);
-
- ConfigTableRenderer renderer = new ConfigTableRenderer(tableModel);
- table.getColumnModel().getColumn(0).setCellRenderer(renderer);
- table.getColumnModel().getColumn(1).setCellRenderer(renderer);
- table.getColumnModel().getColumn(1).setCellEditor(new ConfigTableEditor(getTableModel()));
-
- tableModel.fireTableDataChanged();
- }
-
- public void doSave() {
- if (!isEmpty() && getTableModel().isModified()) {
- getTableModel().transfertModified(getConfig());
- context.saveSafely();
- }
- doReset();
- }
-
- public void doReset() {
- getTableModel().reset();
- }
-
- public void doSelectTechnical(boolean showTechnical) {
- tableModel.setType(showTechnical ? ConfigTableModel.TypeModel.all : ConfigTableModel.TypeModel.nontech);
- }
-
- protected boolean isSaveEnabled() {
- return isResetEnabled() && tableModel.isValid();
- }
-
- protected boolean isResetEnabled() {
- return !isEmpty() && tableModel.isModified();
- }
-
- protected boolean isEmpty() {
- return tableModel == null || config == null || config.getUniverse().isEmpty();
- }
-
- protected Config getConfig() {
- return config;
- }
-
- protected ConfigTableModel getTableModel() {
- return tableModel;
- }
-
- protected TableModelListener getTableModelListener() {
- if (tableModelListener == null) {
- tableModelListener = new TableModelListener() {
- public void tableChanged(TableModelEvent e) {
- ui.getSave().setEnabled(isSaveEnabled());
- ui.getReset().setEnabled(isResetEnabled());
- }
- };
- }
- return tableModelListener;
- }
-
- protected void dispose() {
- getTableModel().reset();
- }
-
-}
\ No newline at end of file
Deleted: trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/LoginUIHandler.java
===================================================================
--- trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/LoginUIHandler.java 2008-07-21 00:34:57 UTC (rev 874)
+++ trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/LoginUIHandler.java 2008-07-22 20:06:39 UTC (rev 875)
@@ -1,28 +0,0 @@
-package org.codelutin.option.ui;
-
-public abstract class LoginUIHandler {
-
- boolean cancel;
-
- JLoginUI ui;
-
- protected abstract boolean connect(String login, char[] password);
-
- protected abstract boolean failedToConnect();
-
- public abstract void doConnect();
-
- public abstract void doCancel();
-
- protected void setUi(JLoginUI ui) {
- this.ui = ui;
- }
-
- public void setCancel(boolean cancel) {
- this.cancel = cancel;
- }
-
- public boolean isCancel() {
- return cancel;
- }
-}
\ No newline at end of file
1
0
21 Jul '08
Author: tchemit
Date: 2008-07-21 00:34:57 +0000 (Mon, 21 Jul 2008)
New Revision: 874
Modified:
trunk/commandline/pom.xml
Log:
utilisation org.codelutin:lutinutil:0.30-SNAPSHOT
Modified: trunk/commandline/pom.xml
===================================================================
--- trunk/commandline/pom.xml 2008-07-20 23:52:25 UTC (rev 873)
+++ trunk/commandline/pom.xml 2008-07-21 00:34:57 UTC (rev 874)
@@ -26,7 +26,7 @@
<dependencies>
<dependency>
- <groupId>lutinlib</groupId>
+ <groupId>org.codelutin</groupId>
<artifactId>lutinutil</artifactId>
</dependency>
</dependencies>
@@ -212,9 +212,9 @@
</dependency>
<dependency>
- <groupId>lutinlib</groupId>
+ <groupId>org.codelutin</groupId>
<artifactId>lutinutil</artifactId>
- <version>0.29</version>
+ <version>0.30-SNAPSHOT</version>
</dependency>
<dependency>
1
0
[Lutinutil-commits] r873 - trunk/lutinutil/src/main/java/org/codelutin/util
by tchemit@users.labs.libre-entreprise.org 20 Jul '08
by tchemit@users.labs.libre-entreprise.org 20 Jul '08
20 Jul '08
Author: tchemit
Date: 2008-07-20 23:52:25 +0000 (Sun, 20 Jul 2008)
New Revision: 873
Added:
trunk/lutinutil/src/main/java/org/codelutin/util/PropertiesDateRemoveFilterStream.java
Log:
get from maven-i18n-plugin
Added: trunk/lutinutil/src/main/java/org/codelutin/util/PropertiesDateRemoveFilterStream.java
===================================================================
--- trunk/lutinutil/src/main/java/org/codelutin/util/PropertiesDateRemoveFilterStream.java (rev 0)
+++ trunk/lutinutil/src/main/java/org/codelutin/util/PropertiesDateRemoveFilterStream.java 2008-07-20 23:52:25 UTC (rev 873)
@@ -0,0 +1,50 @@
+/*
+* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package org.codelutin.util;
+
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+public class PropertiesDateRemoveFilterStream extends FilterOutputStream {
+
+ private boolean firstLineOver;
+ char endChar;
+
+ public PropertiesDateRemoveFilterStream(OutputStream out) {
+ super(out);
+ firstLineOver = false;
+ String lineSeparator = java.security.AccessController
+ .doPrivileged(new sun.security.action.GetPropertyAction(
+ "line.separator"));
+ endChar = lineSeparator.charAt(lineSeparator.length() - 1);
+ }
+
+ @Override
+ public void write(int b) throws IOException {
+ if (!firstLineOver) {
+ char c = (char) b;
+ if (c == endChar) {
+ firstLineOver = true;
+ }
+ } else {
+ out.write(b);
+ }
+ }
+
+}
\ No newline at end of file
1
0