Jaxx-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
March 2013
- 3 participants
- 64 discussions
Author: tchemit
Date: 2013-03-03 16:33:39 +0100 (Sun, 03 Mar 2013)
New Revision: 2586
Url: http://nuiton.org/projects/jaxx/repository/revisions/2586
Log:
- add missing stuff on svn (properties, license headers...)
- refs #2557: Introduce a new jaxx-config module
Added:
trunk/jaxx-config/
trunk/jaxx-config/LICENSE.txt
trunk/jaxx-config/README.txt
trunk/jaxx-config/changelog.txt
trunk/jaxx-config/pom.xml
trunk/jaxx-config/src/
trunk/jaxx-config/src/license/
trunk/jaxx-config/src/license/THIRD-PARTY.properties
trunk/jaxx-config/src/main/
trunk/jaxx-config/src/main/java/
trunk/jaxx-config/src/main/java/jaxx/
trunk/jaxx-config/src/main/java/jaxx/runtime/
trunk/jaxx-config/src/main/java/jaxx/runtime/swing/
trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/
trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigCallBackUI.jaxx
trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigCallBackUIHandler.java
trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigCategoryUI.css
trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigCategoryUI.jaxx
trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigCategoryUIHandler.java
trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigTableEditor.java
trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigTableRenderer.java
trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigUI.css
trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigUI.jaxx
trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigUIHandler.java
trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigUIHelper.java
trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/
trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/CallBackEntry.java
trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/CallBackFinalizer.java
trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/CallBackMap.java
trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/CallBacksManager.java
trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/CategoryModel.java
trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/ConfigTableModel.java
trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/ConfigUIModel.java
trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/ConfigUIModelBuilder.java
trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/MainCallBackFinalizer.java
trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/OptionModel.java
trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/package.html
trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/package.html
trunk/jaxx-config/src/main/resources/
trunk/jaxx-config/src/main/resources/i18n/
trunk/jaxx-config/src/main/resources/i18n/jaxx-config_en_GB.properties
trunk/jaxx-config/src/main/resources/i18n/jaxx-config_es_ES.properties
trunk/jaxx-config/src/main/resources/i18n/jaxx-config_fr_FR.properties
trunk/jaxx-config/src/main/resources/icons/
trunk/jaxx-config/src/main/resources/icons/action-add.png
trunk/jaxx-config/src/main/resources/icons/action-config-quit.png
trunk/jaxx-config/src/main/resources/icons/action-config-reset.png
trunk/jaxx-config/src/main/resources/icons/action-config-save.png
trunk/jaxx-config/src/site/
trunk/jaxx-config/src/site/rst/
trunk/jaxx-config/src/site/rst/index.rst
trunk/jaxx-config/src/site/site_fr.xml
trunk/jaxx-config/src/test/
trunk/jaxx-config/src/test/java/
trunk/jaxx-config/src/test/java/jaxx/
trunk/jaxx-config/src/test/java/jaxx/runtime/
trunk/jaxx-config/src/test/java/jaxx/runtime/swing/
trunk/jaxx-config/src/test/java/jaxx/runtime/swing/config/
trunk/jaxx-config/src/test/java/jaxx/runtime/swing/config/model/
trunk/jaxx-config/src/test/java/jaxx/runtime/swing/config/model/MyDelegateConfig.java
trunk/jaxx-config/src/test/java/jaxx/runtime/swing/config/model/MyDelegateConfigTest.java
trunk/jaxx-config/src/test/java/jaxx/runtime/swing/config/model/MyInheritedConfig.java
trunk/jaxx-config/src/test/java/jaxx/runtime/swing/config/model/MyInheritedConfigTest.java
trunk/jaxx-config/src/test/resources/
trunk/jaxx-config/src/test/resources/log4j.properties
Modified:
trunk/jaxx-demo/pom.xml
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java
trunk/jaxx-demo/src/main/resources/jaxx/demo/images/jim.jpg
trunk/jaxx-demo/src/main/resources/jaxx/demo/images/joker.jpg
trunk/jaxx-runtime/pom.xml
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/ComponentMover.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/ComponentResizer.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/model/JaxxFilterableListModel.java
trunk/jaxx-validator/src/main/resources/icons/action-alert-error.png
trunk/jaxx-validator/src/main/resources/icons/action-alert-info.png
trunk/jaxx-validator/src/main/resources/icons/action-alert-none.png
trunk/jaxx-validator/src/main/resources/icons/action-alert-warning.png
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/cell/NumberCellEditor.java
trunk/jaxx-widgets/src/main/resources/icons/action-filter.png
trunk/pom.xml
Property changes on: trunk/jaxx-config
___________________________________________________________________
Added: svn:ignore
+ target
*.ipr
*.iws
*.iml
.idea
.project
.classpath
.settings
*.log
Added: trunk/jaxx-config/LICENSE.txt
===================================================================
--- trunk/jaxx-config/LICENSE.txt (rev 0)
+++ trunk/jaxx-config/LICENSE.txt 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,166 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
+
Property changes on: trunk/jaxx-config/LICENSE.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/README.txt
===================================================================
--- trunk/jaxx-config/README.txt (rev 0)
+++ trunk/jaxx-config/README.txt 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,2 @@
+To deploy new version of pom: mvn deploy
+To install localy: mvn install
Property changes on: trunk/jaxx-config/README.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/changelog.txt
===================================================================
--- trunk/jaxx-config/changelog.txt (rev 0)
+++ trunk/jaxx-config/changelog.txt 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,5 @@
+1.6.0
+ * introduce StatusMessageBar and AboutPanel (fork from nuiton-widgets but in JAXX :))
+
+1.5
+ * 20090404 [chemit] - initial version
Property changes on: trunk/jaxx-config/changelog.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/pom.xml
===================================================================
--- trunk/jaxx-config/pom.xml (rev 0)
+++ trunk/jaxx-config/pom.xml 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,169 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ JAXX :: Widgets
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2008 - 2010 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+
+<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/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.nuiton</groupId>
+ <artifactId>jaxx</artifactId>
+ <version>2.5.11-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.nuiton.jaxx</groupId>
+ <artifactId>jaxx-config</artifactId>
+
+ <name>JAXX :: Config</name>
+ <description>
+ Config UI based on org.nuiton.util.config.ApplicationConfig
+ </description>
+
+ <properties>
+ <jaxx.addSourcesToClassPath>true</jaxx.addSourcesToClassPath>
+ <jaxx.autoImportCss>true</jaxx.autoImportCss>
+ <!--jaxx.useUIManagerForIcon>true</jaxx.useUIManagerForIcon-->
+ </properties>
+
+ <dependencies>
+
+ <!-- sibiling dependencies -->
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-runtime</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-widgets</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.swinglabs.swingx</groupId>
+ <artifactId>swingx-common</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.nuiton.i18n</groupId>
+ <artifactId>nuiton-i18n</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-config</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-utils</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+
+ <plugins>
+
+ <plugin>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.nuiton.i18n</groupId>
+ <artifactId>i18n-maven-plugin</artifactId>
+ <configuration>
+ <entries>
+ <entry>
+ <basedir>${maven.gen.dir}/java</basedir>
+ </entry>
+ </entries>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>parserJava</goal>
+ <goal>gen</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project>
Property changes on: trunk/jaxx-config/pom.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/license/THIRD-PARTY.properties
===================================================================
--- trunk/jaxx-config/src/license/THIRD-PARTY.properties (rev 0)
+++ trunk/jaxx-config/src/license/THIRD-PARTY.properties 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,20 @@
+# Generated by org.codehaus.mojo.license.AddThirdPartyMojo
+#-------------------------------------------------------------------------------
+# Already used licenses in project :
+# - BSD License
+# - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+# - Common Public License Version 1.0
+# - GNU General Public License - Version 2 with the class path exception
+# - Indiana University Extreme! Lab Software License, vesion 1.1.1
+# - Lesser General Public License (LGPL)
+# - Lesser General Public License (LGPL) v 3.0
+# - Lesser General Public License (LPGL)
+# - Lesser General Public License (LPGL) v 2.1
+# - MIT License
+# - The Apache Software License, Version 2.0
+#-------------------------------------------------------------------------------
+# Please fill the missing licenses for dependencies :
+#
+#
+#Thu Aug 18 07:10:57 CEST 2011
+commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
Property changes on: trunk/jaxx-config/src/license/THIRD-PARTY.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigCallBackUI.jaxx
===================================================================
--- trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigCallBackUI.jaxx (rev 0)
+++ trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigCallBackUI.jaxx 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,61 @@
+<!--
+ #%L
+ JAXX :: Config
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2008 - 2013 CodeLutin, Tony Chemit
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+<JPanel layout='{new BorderLayout()}'>
+
+ <script><![CDATA[
+ /**
+ * Init the ui.
+ */
+ public void init() {
+ getHandler().init(this);
+ }
+ ]]>
+ </script>
+
+ <ConfigCallBackUIHandler
+ id='handler'
+ initializer='getContextValue(ConfigCallBackUIHandler.class)'/>
+
+ <JScrollPane constraints='BorderLayout.CENTER'
+ columnHeaderView='{treeHeader}'>
+
+ <JTree id='detectedCallBack'
+ editable='false'
+ rootVisible='false'
+ rowHeight='24'/>
+
+ </JScrollPane>
+
+ <JButton constraints='BorderLayout.SOUTH'
+ id='go'
+ text='config.launch.callBack'
+ toolTipText='config.launch.callBack.tip'
+ actionIcon='config-quit'
+ onActionPerformed='getHandler().doAction(this)'/>
+
+ <JPanel id='treeHeader' constraints='BorderLayout.EAST'>
+ <JLabel text='config.detected.callBack'/>
+ </JPanel>
+
+</JPanel>
Property changes on: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigCallBackUI.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigCallBackUIHandler.java
===================================================================
--- trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigCallBackUIHandler.java (rev 0)
+++ trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigCallBackUIHandler.java 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,193 @@
+package jaxx.runtime.swing.config;
+
+/*
+ * #%L
+ * JAXX :: Config
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2013 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import jaxx.runtime.SwingUtil;
+import jaxx.runtime.swing.config.model.CallBackEntry;
+import jaxx.runtime.swing.config.model.CallBackMap;
+import jaxx.runtime.swing.config.model.OptionModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.JLabel;
+import javax.swing.JTree;
+import javax.swing.SwingUtilities;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeCellRenderer;
+import javax.swing.tree.DefaultTreeModel;
+import java.awt.Component;
+import java.awt.Window;
+import java.util.List;
+import java.util.Map;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * callBackUI handler
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5.11
+ */
+public class ConfigCallBackUIHandler {
+
+ /** Logger */
+ private static final Log log =
+ LogFactory.getLog(ConfigCallBackUIHandler.class);
+
+ public void init(ConfigCallBackUI ui) {
+
+ // build tree model
+ DefaultMutableTreeNode root = new DefaultMutableTreeNode();
+
+ CallBackMap forSaved = ui.getContextValue(
+ CallBackMap.class, ConfigUIHandler.CALLBACKS_WITH_OPTIONS);
+
+ for (Map.Entry<CallBackEntry, List<OptionModel>> e :
+ forSaved.entrySet()) {
+
+ CallBackEntry callBackEntry = e.getKey();
+ List<OptionModel> options = e.getValue();
+
+ DefaultMutableTreeNode callBackNode;
+ callBackNode = new DefaultMutableTreeNode(callBackEntry, true);
+
+ root.add(callBackNode);
+ for (OptionModel o : options) {
+
+ DefaultMutableTreeNode optionkNode;
+ optionkNode = new DefaultMutableTreeNode(o, false);
+
+ callBackNode.add(optionkNode);
+ }
+ }
+
+ JTree tree = ui.getDetectedCallBack();
+
+ tree.setModel(new DefaultTreeModel(root));
+
+ SwingUtil.expandTree(tree);
+
+ tree.setCellRenderer(new DefaultTreeCellRenderer() {
+ @Override
+ public Component getTreeCellRendererComponent(JTree tree,
+ Object value,
+ boolean sel,
+ boolean expanded,
+ boolean leaf,
+ int row,
+ boolean hasFocus) {
+ if (log.isDebugEnabled()) {
+ log.debug("value = " + value.getClass());
+ }
+ if (value == null) {
+ return super.getTreeCellRendererComponent(
+ tree,
+ value,
+ sel,
+ expanded,
+ leaf,
+ row,
+ hasFocus);
+ }
+
+ if (!(value instanceof DefaultMutableTreeNode)) {
+ return super.getTreeCellRendererComponent(
+ tree,
+ value,
+ sel,
+ expanded,
+ leaf,
+ row,
+ hasFocus);
+ }
+
+ DefaultMutableTreeNode n = (DefaultMutableTreeNode) value;
+ value = n.getUserObject();
+
+ if (value instanceof CallBackEntry) {
+ CallBackEntry v = (CallBackEntry) value;
+ if (log.isDebugEnabled()) {
+ log.debug("callBackEntry detected " + v.getName());
+ }
+ value = _(v.getDescription());
+ } else if (value instanceof OptionModel) {
+
+ OptionModel v = (OptionModel) value;
+ if (log.isDebugEnabled()) {
+ log.debug("option detected " + v.getKey());
+ }
+ value = v.getKey() + " (" + _(v.getDescription()) + ")";
+ }
+
+ JLabel rendererComponent;
+ rendererComponent = (JLabel)
+ super.getTreeCellRendererComponent(
+ tree,
+ value,
+ sel,
+ expanded,
+ leaf,
+ row,
+ hasFocus);
+
+ value = n.getUserObject();
+
+ if (value instanceof CallBackEntry) {
+
+ CallBackEntry v = (CallBackEntry) value;
+ rendererComponent.setIcon(v.getIcon());
+ }
+ return rendererComponent;
+ }
+ });
+ }
+
+ public void doAction(final ConfigCallBackUI ui) {
+ log.info("Launch callBacks...");
+ Window parent = ui.getContextValue(Window.class, "parent");
+ if (parent != null) {
+ log.info("dispose parent window...");
+ parent.dispose();
+ }
+
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+
+ List<CallBackEntry> callBacks;
+ callBacks = ui.getContextValue(
+ List.class,
+ ConfigUIHandler.CALLBACKS);
+ for (CallBackEntry e : callBacks) {
+ if (log.isInfoEnabled()) {
+ log.info("launch callBack " + _(e.getDescription()));
+ }
+ e.getAction().run();
+ }
+ }
+ });
+ }
+}
Property changes on: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigCallBackUIHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigCategoryUI.css
===================================================================
--- trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigCategoryUI.css (rev 0)
+++ trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigCategoryUI.css 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,68 @@
+/*
+ * #%L
+ * JAXX :: Widgets
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+
+#categoryLabelPanel {
+ background:{Color.WHITE};
+}
+
+#descriptionPane {
+ columnHeaderView:{new JLabel(_("config.description"), SwingUtil.getUIManagerActionIcon("information"), 10)};
+}
+
+#description {
+ rows:3;
+ editable:false;
+ focusable:false;
+ font-size:10;
+ text:{_("config.no.option.selected")};
+}
+
+#tablePane {
+ columnHeaderView:{table.getTableHeader()};
+ verticalScrollBarPolicy:{ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS};
+ horizontalScrollBarPolicy:{ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER};
+}
+
+#table {
+ rowSelectionAllowed:false;
+ autoCreateRowSorter:true;
+ autoResizeMode:{JTable.AUTO_RESIZE_ALL_COLUMNS};
+ rowHeight:25;
+}
+
+#reset{
+ text:"config.action.reset";
+ toolTipText:"config.action.reset.tip";
+ actionIcon:"config-reset";
+ enabled:{getCategoryModel().isModified()};
+}
+
+#save{
+ text:"config.action.save";
+ toolTipText:"config.action.save.tip";
+ actionIcon:"config-save";
+ enabled:{getCategoryModel().isModified() && getCategoryModel().isValid()};
+}
Property changes on: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigCategoryUI.css
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigCategoryUI.jaxx
===================================================================
--- trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigCategoryUI.jaxx (rev 0)
+++ trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigCategoryUI.jaxx 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,84 @@
+<!--
+ #%L
+ JAXX :: Config
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2008 - 2013 CodeLutin, Tony Chemit
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+<JPanel layout='{new BorderLayout()}'>
+
+ <import>
+ java.awt.Color
+ javax.swing.DefaultListSelectionModel
+ javax.swing.ScrollPaneConstants
+ jaxx.runtime.swing.config.model.CategoryModel
+ jaxx.runtime.swing.config.model.ConfigTableModel
+ jaxx.runtime.swing.config.model.ConfigUIModel
+ </import>
+
+ <ConfigCategoryUIHandler id='handler' constructorParams='this'/>
+
+ <script><![CDATA[
+
+void $afterCompleteSetup() {
+ getHandler().init();
+}
+]]>
+ </script>
+
+ <!-- le modele de l'ui -->
+ <ConfigUIModel id='model'
+ initializer='getContextValue(ConfigUIModel.class)'/>
+
+ <CategoryModel id='categoryModel'
+ javaBean='getContextValue(CategoryModel.class)'/>
+
+ <ConfigTableModel id='tableModel' constructorParams='categoryModel'
+ onTableChanged='handler.updateDescriptionText()'/>
+
+ <ListSelectionModel id='selectionModel'
+ javaBean='new DefaultListSelectionModel()'
+ onValueChanged='if (!event.getValueIsAdjusting()) {handler.updateDescriptionText(); }'/>
+
+ <!-- categorie label -->
+ <JPanel id="categoryLabelPanel" constraints='BorderLayout.NORTH'>
+ <JLabel id='categoryLabel'/>
+ </JPanel>
+
+ <!-- table of options -->
+ <JScrollPane id='tablePane' constraints='BorderLayout.CENTER'>
+ <JTable id="table" constructorParams='tableModel'
+ selectionModel='{selectionModel}'/>
+ </JScrollPane>
+
+ <JPanel layout='{new BorderLayout()}' constraints='BorderLayout.SOUTH'>
+
+ <!-- description of selected option in table -->
+ <JScrollPane id="descriptionPane" constraints='BorderLayout.CENTER'>
+ <JTextArea id='description'/>
+ </JScrollPane>
+
+ <!-- actions of the category -->
+ <JPanel layout='{new GridLayout(1,0)}'
+ constraints='BorderLayout.SOUTH'>
+ <JButton id='reset' onActionPerformed='model.reset()'/>
+ <JButton id='save' onActionPerformed='model.saveModified()'/>
+ </JPanel>
+ </JPanel>
+</JPanel>
Property changes on: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigCategoryUI.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigCategoryUIHandler.java
===================================================================
--- trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigCategoryUIHandler.java (rev 0)
+++ trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigCategoryUIHandler.java 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,118 @@
+package jaxx.runtime.swing.config;
+
+/*
+ * #%L
+ * JAXX :: Config
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2013 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import jaxx.runtime.SwingUtil;
+import jaxx.runtime.swing.config.model.ConfigTableModel;
+import jaxx.runtime.swing.config.model.OptionModel;
+import jaxx.runtime.swing.renderer.ClassTableCellRenderer;
+import jaxx.runtime.swing.renderer.ColorCellRenderer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.JTable;
+import javax.swing.JTextArea;
+import javax.swing.ListSelectionModel;
+import java.awt.Color;
+import java.awt.Font;
+
+import static org.nuiton.i18n.I18n._;
+import static org.nuiton.i18n.I18n.n_;
+
+/**
+ * Handler of {@link ConfigCategoryUI}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5.11
+ */
+public class ConfigCategoryUIHandler {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ConfigCategoryUIHandler.class);
+
+ private final ConfigCategoryUI ui;
+
+ public ConfigCategoryUIHandler(ConfigCategoryUI ui) {
+ this.ui = ui;
+ }
+
+ public void init() {
+
+ JTable table = ui.getTable();
+
+ // prepare table
+ SwingUtil.setI18nTableHeaderRenderer(
+ table,
+ n_("config.key"),
+ n_("config.key.tip"),
+ n_("config.value"),
+ n_("config.value.tip"),
+ n_("config.defaultValue"),
+ n_("config.defaultValue.tip"));
+
+ ConfigTableRenderer renderer = new ConfigTableRenderer();
+ SwingUtil.setTableColumnRenderer(table, 0, renderer);
+ SwingUtil.setTableColumnRenderer(table, 1, renderer);
+ SwingUtil.setTableColumnRenderer(table, 2, renderer);
+ Font f = table.getFont().deriveFont(Font.ITALIC | Font.BOLD);
+ int width = SwingUtil.computeTableColumnWidth(table, f, 0, "___*");
+ SwingUtil.fixTableColumnWidth(table, 0, width);
+ SwingUtil.setTableColumnEditor(table, 1, new ConfigTableEditor((ConfigTableModel) table.getModel()));
+ table.setDefaultRenderer(Color.class, new ColorCellRenderer());
+ table.setDefaultRenderer(Class.class, new ClassTableCellRenderer());
+ }
+
+ public void updateDescriptionText() {
+ OptionModel option;
+ JTable table = ui.getTable();
+ JTextArea description = ui.getDescription();
+ ListSelectionModel selectionModel = ui.getSelectionModel();
+
+ if (selectionModel.isSelectionEmpty()) {
+ option = null;
+ } else {
+ int row = selectionModel.getAnchorSelectionIndex();
+ ConfigTableModel m = (ConfigTableModel) table.getModel();
+ option = m.getEntry(row);
+ if (log.isDebugEnabled()) {
+ log.debug(row + " : " + option);
+ }
+ }
+ StringBuilder buffer = new StringBuilder();
+ if (option == null) {
+ buffer.append(_("config.no.option.selected"));
+ } else {
+ buffer.append(_("config.option.label", option.getKey(), _(option.getDescription()))).append('\n');
+ if (option.isModified()) {
+ buffer.append(_("config.option.modified", option.getOriginalValue(), option.getValue())).append('\n');
+ }
+ if (option.isFinal()) {
+ buffer.append(_("config.option.final")).append('\n');
+ }
+ }
+ description.setText(buffer.toString());
+ }
+}
Property changes on: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigCategoryUIHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigTableEditor.java
===================================================================
--- trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigTableEditor.java (rev 0)
+++ trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigTableEditor.java 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,167 @@
+package jaxx.runtime.swing.config;
+
+/*
+ * #%L
+ * JAXX :: Config
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2013 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.io.Files;
+import jaxx.runtime.swing.JAXXWidgetUtil;
+import jaxx.runtime.swing.editor.ClassCellEditor;
+import jaxx.runtime.swing.editor.ColorCellEditor;
+import jaxx.runtime.swing.editor.EnumEditor;
+import jaxx.runtime.swing.editor.LocaleEditor;
+import jaxx.runtime.swing.editor.cell.FileCellEditor;
+import jaxx.runtime.swing.config.model.ConfigTableModel;
+import jaxx.runtime.swing.config.model.OptionModel;
+import org.apache.commons.lang3.StringUtils;
+
+import javax.swing.DefaultCellEditor;
+import javax.swing.JTable;
+import javax.swing.KeyStroke;
+import javax.swing.event.CellEditorListener;
+import javax.swing.table.TableCellEditor;
+import java.awt.Color;
+import java.awt.Component;
+import java.io.File;
+import java.util.EventObject;
+import java.util.Locale;
+
+/**
+ * L'éditeur des valeurs des propriétés d'une configuration
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5.11
+ */
+public class ConfigTableEditor implements TableCellEditor {
+
+ protected TableCellEditor delegate;
+ protected ConfigTableModel model;
+
+ public ConfigTableEditor(ConfigTableModel model) {
+ this.model = model;
+ }
+
+ @Override
+ public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
+ delegate = findDelegate(table, model.getEntry(row));
+ return delegate.getTableCellEditorComponent(table, value, isSelected, row, column);
+ }
+
+ @Override
+ public Object getCellEditorValue() {
+ return !hasDelegate() ? null : delegate.getCellEditorValue();
+ }
+
+ @Override
+ public boolean isCellEditable(EventObject anEvent) {
+ return !hasDelegate() || delegate.isCellEditable(anEvent);
+ }
+
+ @Override
+ public boolean shouldSelectCell(EventObject anEvent) {
+ return hasDelegate() && delegate.shouldSelectCell(anEvent);
+ }
+
+ @Override
+ public boolean stopCellEditing() {
+ return !hasDelegate() || delegate.stopCellEditing();
+ }
+
+ @Override
+ public void cancelCellEditing() {
+ if (hasDelegate()) {
+ delegate.cancelCellEditing();
+ }
+ }
+
+ @Override
+ public void addCellEditorListener(CellEditorListener l) {
+ if (hasDelegate()) {
+ delegate.addCellEditorListener(l);
+ }
+ }
+
+ @Override
+ public void removeCellEditorListener(CellEditorListener l) {
+ if (hasDelegate()) {
+ delegate.removeCellEditorListener(l);
+ }
+ }
+
+ protected TableCellEditor findDelegate(JTable table, OptionModel option) {
+ Class<?> type = option.getType();
+ TableCellEditor editor = table.getDefaultEditor(type);
+ TableCellEditor defaultEditor = table.getDefaultEditor(Object.class);
+ //TODO always Search from option.getEditor() and store editor as cache
+ if (editor.equals(defaultEditor)) {
+ // find not a specialized editor for the type
+ if (type.isEnum()) {
+ // add a EnumEditor to table
+ editor = new DefaultCellEditor(EnumEditor.newEditor((Class<Enum>) type));
+
+ } else if (type.equals(Class.class)) {
+ editor = new ClassCellEditor();
+
+ } else if (type.equals(File.class)){
+ editor = new FileCellEditorWithExtDetector();
+
+ } else if (type.equals(KeyStroke.class)){
+ editor = JAXXWidgetUtil.newKeyStrokeTableCellEditor();
+
+ } else if (type.equals(Locale.class)) {
+ editor = new DefaultCellEditor(LocaleEditor.newEditor());
+
+ } else if (type.equals(Color.class)) {
+ editor = new ColorCellEditor();
+
+ } else {
+ editor = table.getDefaultEditor(String.class);
+ }
+ table.setDefaultEditor(type, editor);
+ }
+ if (editor == null) {
+ throw new IllegalStateException("could not find a editor for type +" + type);
+ }
+ return editor;
+ }
+
+ protected static class FileCellEditorWithExtDetector extends FileCellEditor {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
+
+ String fileExtension = value == null ? null : Files.getFileExtension(((File) value).getName());
+ if (StringUtils.isNotEmpty(fileExtension)) {
+ fileEditor.setExts(fileExtension);
+ fileEditor.setAcceptAllFileFilterUsed(true);
+ }
+ return super.getTableCellEditorComponent(table, value, isSelected, row, column);
+ }
+ }
+
+ protected boolean hasDelegate() {
+ return delegate != null;
+ }
+}
Property changes on: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigTableEditor.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigTableRenderer.java
===================================================================
--- trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigTableRenderer.java (rev 0)
+++ trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigTableRenderer.java 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,121 @@
+package jaxx.runtime.swing.config;
+
+/*
+ * #%L
+ * JAXX :: Config
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2013 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import jaxx.runtime.swing.config.model.ConfigTableModel;
+import jaxx.runtime.swing.config.model.OptionModel;
+
+import javax.swing.JComponent;
+import javax.swing.JTable;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.TableCellRenderer;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Font;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Pour le rendu du tableau des options d'une categorie
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @see ConfigTableModel
+ * @since 2.5.11
+ */
+public class ConfigTableRenderer extends DefaultTableCellRenderer {
+
+ private static final long serialVersionUID = 1L;
+ protected static Color col;
+ protected static Font font;
+ protected static Font font2;
+
+ public ConfigTableRenderer() {
+ col = getForeground();
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+ int modelRow = table.convertRowIndexToModel(row);
+ int modelColumn = table.convertColumnIndexToModel(column);
+ ConfigTableModel model = (ConfigTableModel) table.getModel();
+ OptionModel key = model.getEntry(modelRow);
+ boolean isModified = key.isModified();
+
+ boolean isValid = key.isValid();
+
+ if (font == null) {
+ font = getFont();
+ font2 = font.deriveFont(Font.ITALIC | Font.BOLD);
+ }
+ Component cellRenderer;
+ switch (modelColumn) {
+ case 0:
+ cellRenderer = getKeyCellRenderer(table, value, isSelected, hasFocus, modelRow, modelColumn, key, isValid, isModified);
+ break;
+ case 1:
+ cellRenderer = getValueCellRenderer(table, value, isSelected, hasFocus, modelRow, modelColumn, key, isValid, isModified);
+ break;
+ case 2:
+ cellRenderer = getValueCellRenderer(table, value, isSelected, hasFocus, modelRow, modelColumn, key, isValid, isModified);
+ break;
+ default:
+ throw new IllegalStateException("no renderer find for column " + modelColumn);
+ }
+ return cellRenderer;
+ }
+
+ protected Component getKeyCellRenderer(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column, OptionModel key, boolean isValid, boolean isModified) {
+ String tooltip = _(key.getDescription());
+ Object originalValue = key.getOriginalValue();
+ boolean isFinal = key.isFinal();
+ if (isFinal) {
+ tooltip += " [" + _("config.unmodifiable") + ']';
+ }
+ if (isModified) {
+ String s = _("config.modified", originalValue);
+ value = value + " *";
+ tooltip += " [" + s + ']';
+ }
+ if (!isValid) {
+ String s2 = _("config.unvalid", originalValue, key.getType());
+ tooltip += " (" + s2 + ")";
+ value = value + " !";
+ }
+ JComponent result = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ result.setToolTipText(tooltip);
+ result.setForeground(isValid ? col : Color.RED);
+ result.setFont(isModified || !isValid ? font2 : font);
+ result.setEnabled(!isFinal);
+ return result;
+ }
+
+ protected Component getValueCellRenderer(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column, OptionModel key, boolean isValid, boolean isModified) {
+ TableCellRenderer defaultRenderer = table.getDefaultRenderer(key.getType());
+
+ Component result;
+ result = defaultRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ return result;
+ }
+}
Property changes on: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigTableRenderer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigUI.css
===================================================================
--- trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigUI.css (rev 0)
+++ trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigUI.css 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,34 @@
+/*
+ * #%L
+ * JAXX :: Widgets
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+#quit{
+ text:"config.action.quit";
+ toolTipText:"config.action.quit.tip";
+ actionIcon:"config-quit";
+}
+
+#categories{
+ tabPlacement:{JTabbedPane.LEFT};
+}
Property changes on: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigUI.css
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigUI.jaxx
===================================================================
--- trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigUI.jaxx (rev 0)
+++ trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigUI.jaxx 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,58 @@
+<!--
+ #%L
+ JAXX :: Config
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2008 - 2013 CodeLutin, Tony Chemit
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+<JPanel layout='{new BorderLayout()}'>
+
+ <import>
+ jaxx.runtime.swing.config.model.ConfigUIModel
+ </import>
+
+ <script><![CDATA[
+
+public void init(String defaultCategory) {
+ getHandler().initUI(defaultCategory);
+}
+
+@Override
+protected void finalize() throws Throwable {
+ super.finalize();
+ getHandler().destroy();
+}
+ ]]>
+ </script>
+
+ <ConfigUIHandler id='handler' constructorParams='this'/>
+
+ <!-- le modele de l'ui -->
+ <ConfigUIModel id='model'
+ initializer='getContextValue(ConfigUIModel.class)'/>
+
+ <!-- les differentes categories de la configuration -->
+ <JTabbedPane id='categories' constraints='BorderLayout.CENTER'
+ onStateChanged='getHandler().changeCategory(event)'/>
+
+ <!-- pour quitter l'ui -->
+ <JPanel layout='{new GridLayout(1,0)}' constraints='BorderLayout.SOUTH'>
+ <JButton id='quit'/>
+ </JPanel>
+</JPanel>
Property changes on: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigUI.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigUIHandler.java
===================================================================
--- trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigUIHandler.java (rev 0)
+++ trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigUIHandler.java 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,357 @@
+package jaxx.runtime.swing.config;
+
+/*
+ * #%L
+ * JAXX :: Config
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2013 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import jaxx.runtime.JAXXUtil;
+import jaxx.runtime.SwingUtil;
+import jaxx.runtime.context.JAXXInitialContext;
+import jaxx.runtime.swing.config.model.CallBackEntry;
+import jaxx.runtime.swing.config.model.CallBackMap;
+import jaxx.runtime.swing.config.model.CategoryModel;
+import jaxx.runtime.swing.config.model.ConfigUIModel;
+import jaxx.runtime.swing.config.model.OptionModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.DefaultSingleSelectionModel;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JDialog;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JRootPane;
+import javax.swing.JTabbedPane;
+import javax.swing.KeyStroke;
+import javax.swing.SwingUtilities;
+import javax.swing.event.ChangeEvent;
+import java.awt.Frame;
+import java.awt.Window;
+import java.awt.event.ActionEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.util.ArrayList;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Handler of the {@link ConfigUI} ui.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5.11
+ */
+public class ConfigUIHandler {
+
+ public static final Log log = LogFactory.getLog(ConfigUIHandler.class);
+
+ public static final String CALLBACKS_WITH_OPTIONS = "callbacksWithOptions";
+
+ public static final String CALLBACKS = "callbacks";
+
+ private final ConfigUI ui;
+
+ public ConfigUIHandler(ConfigUI ui) {
+ this.ui = ui;
+ }
+
+ public void initUI(String defaultCategory) {
+
+ ConfigUIModel model = ui.getModel();
+
+ JTabbedPane categories = ui.getCategories();
+
+ categories.setModel(new DefaultSingleSelectionModel() {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void setSelectedIndex(int index) {
+ // check if catgeory can be quit
+ boolean canContinue = !isSelected() || canQuitCategory();
+ if (canContinue) {
+ if (log.isDebugEnabled()) {
+ log.debug("new index : " + index);
+ }
+ // was authorized to continue
+ super.setSelectedIndex(index);
+ }
+ }
+ });
+
+ JButton quitButton = ui.getQuit();
+
+ // prepare quit action
+ Action quitAction = createQuitAction();
+
+ String tip = quitButton.getToolTipText();
+ quitButton.setAction(quitAction);
+ quitButton.setToolTipText(tip);
+
+ // build categories tabs
+ for (CategoryModel categoryModel : model) {
+ String category = categoryModel.getCategory();
+ String categoryLabel = _(categoryModel.getCategoryLabel());
+ ConfigCategoryUI p = new ConfigCategoryUI(new
+ JAXXInitialContext().add(ui).add(categoryModel));
+ p.getCategoryLabel().setText(categoryLabel);
+ p.setName(category);
+ categories.addTab(_(category), null, p, categoryLabel);
+ }
+
+ model.setCategory(defaultCategory);
+ int categoryIndex = model.getCategoryIndex(defaultCategory);
+ if (log.isDebugEnabled()) {
+ log.debug("index of default category (" + defaultCategory + ") : "
+ + categoryIndex);
+ }
+ categories.setSelectedIndex(categoryIndex);
+ }
+
+ public void destroy() {
+ if (log.isDebugEnabled() ) {
+ log.debug("destroy ui " + ui.getName());
+ }
+ JAXXUtil.destroy(ui);
+ ui.getModel().destroy();
+ }
+
+ public void changeCategory(ChangeEvent e) {
+ JPanel p = (JPanel) ui.getCategories().getSelectedComponent();
+ if (p == null) {
+ // pas de selection
+ return;
+ }
+ ui.getModel().setCategory(p.getName());
+ ui.getCategories().invalidate();
+ }
+
+ public void displayUI(Frame parentUI, boolean undecorated) {
+ JDialog f = new JDialog(parentUI, true);
+ f.setTitle(_("config.title"));
+ f.add(ui);
+ if (parentUI != null) {
+ f.setIconImage(parentUI.getIconImage());
+ }
+ // pour savoir si l'ui est autonome
+ ui.getModel().setStandalone(parentUI == null);
+
+ f.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
+ f.addWindowListener(new WindowAdapter() {
+
+ @Override
+ public void windowClosing(WindowEvent e) {
+ ActionEvent myEvent = new ActionEvent(e.getSource(), 1, "quit");
+ ui.getQuit().getAction().actionPerformed(myEvent);
+ }
+ });
+ f.setUndecorated(undecorated);
+ JRootPane rootPane = f.getRootPane();
+ rootPane.setDefaultButton(ui.getQuit());
+ rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
+ KeyStroke.getKeyStroke("ESCAPE"), "quit");
+ rootPane.getActionMap().put("quit", ui.getQuit().getAction());
+ f.pack();
+ SwingUtil.center(ui, f);
+ f.setVisible(true);
+ }
+
+ protected Action createQuitAction() {
+
+ JButton button = ui.getQuit();
+
+ Action quitAction = new AbstractAction(button.getText(),
+ button.getIcon()) {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (!canQuitCategory()) {
+ return;
+ }
+
+ final Window parentWindow = ui.getParentContainer(Window.class);
+
+
+ ConfigUIModel model = ui.getModel();
+ if (!model.isSaved() || model.isStandalone()) {
+
+ // just quit, no callBack can be apply here
+ closeUI(parentWindow, model);
+ return;
+ }
+
+ CallBackMap forSaved = model.getCallBacksForSaved();
+
+ if (forSaved.isEmpty()) {
+
+ // just quit, no callBack to call
+ closeUI(parentWindow, model);
+ return;
+ }
+
+ forSaved = model.getCallBacksForSaved();
+
+ // init callBackUI
+
+ JAXXInitialContext context = new JAXXInitialContext().
+ add("parent", parentWindow).
+ add(ui).
+ add(CALLBACKS_WITH_OPTIONS, forSaved).
+ add(CALLBACKS,
+ new ArrayList<CallBackEntry>(forSaved.keySet())).
+ add(new ConfigCallBackUIHandler());
+
+ ConfigCallBackUI lastUI = new ConfigCallBackUI(context);
+
+ lastUI.init();
+ ui.setVisible(false);
+ parentWindow.remove(ui);
+ parentWindow.add(lastUI);
+
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ parentWindow.validate();
+ }
+ });
+ }
+ };
+ return quitAction;
+ }
+
+ protected void closeUI(Window parentWindow, ConfigUIModel model) {
+
+ destroy();
+
+ // close the config ui
+ parentWindow.dispose();
+
+ Runnable runnable = model.getCloseAction();
+ if (runnable != null) {
+ log.info("execute close action");
+ runnable.run();
+ }
+ }
+
+ protected boolean canQuitCategory() {
+ boolean canContinue = true;
+ ConfigUIModel model = ui.getModel();
+ CategoryModel categoryModel = model.getCategoryModel();
+ String categoryName = _(categoryModel.getCategory());
+ if (!categoryModel.isValid()) {
+
+ // the category is not valid
+ // get all the invalid options
+
+ StringBuilder buffer = new StringBuilder();
+ buffer.append(_("config.message.quit.invalid.category",
+ categoryName));
+ buffer.append('\n');
+ for (OptionModel m : categoryModel.getInvalidOptions()) {
+ buffer.append("\n- ").append(m.getKey());
+ }
+ buffer.append('\n');
+ int reponse = askUser(_("config.title.need.confirm"),
+ buffer.toString(),
+ JOptionPane.ERROR_MESSAGE,
+ new Object[]{
+ _("config.choice.continue"),
+ _("config.choice.cancel")},
+ 0);
+
+ switch (reponse) {
+ case JOptionPane.CLOSED_OPTION:
+ case 1:
+ canContinue = false;
+ break;
+ case 0:
+ if (categoryModel.isModified()) {
+ // wil reset category
+ model.reset();
+ }
+ break;
+ }
+ } else if (categoryModel.isModified()) {
+
+ // category was modified, ask user if wants to save
+
+ StringBuilder buffer = new StringBuilder();
+ buffer.append(_("config.message.quit.valid.and.modified.category",
+ categoryName)).append('\n');
+ for (OptionModel m : categoryModel.getModifiedOptions()) {
+ buffer.append("\n- ").append(m.getKey());
+ }
+ buffer.append('\n');
+
+ int reponse = askUser(_("config.title.need.confirm"),
+ buffer.toString(),
+ JOptionPane.WARNING_MESSAGE,
+ new Object[]{
+ _("config.choice.save"),
+ _("config.choice.doNotSave"),
+ _("config.choice.cancel")},
+ 0);
+
+ switch (reponse) {
+ case JOptionPane.CLOSED_OPTION:
+ case 2:
+ canContinue = false;
+ break;
+ case 0:
+ // will save ui
+ model.saveModified();
+ break;
+ case 1:
+ // wil reset ui
+ model.reset();
+ break;
+ }
+ }
+ return canContinue;
+ }
+
+ public int askUser(String title,
+ String message,
+ int typeMessage,
+ Object[] options,
+ int defaultOption) {
+
+ int response = JOptionPane.showOptionDialog(
+ ui,
+ message,
+ title,
+ JOptionPane.DEFAULT_OPTION,
+ typeMessage,
+ null,
+ options,
+ options[defaultOption]
+ );
+
+ return response;
+ }
+}
Property changes on: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigUIHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigUIHelper.java
===================================================================
--- trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigUIHelper.java (rev 0)
+++ trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigUIHelper.java 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,183 @@
+package jaxx.runtime.swing.config;
+
+/*
+ * #%L
+ * JAXX :: Config
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2013 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import com.google.common.base.Supplier;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.context.JAXXInitialContext;
+import jaxx.runtime.swing.config.model.CallBackFinalizer;
+import jaxx.runtime.swing.config.model.CategoryModel;
+import jaxx.runtime.swing.config.model.ConfigUIModel;
+import jaxx.runtime.swing.config.model.ConfigUIModelBuilder;
+import jaxx.runtime.swing.config.model.OptionModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.config.ApplicationConfig;
+import org.nuiton.util.config.ConfigOptionDef;
+
+import javax.swing.Icon;
+import javax.swing.table.TableCellEditor;
+import java.awt.Frame;
+
+/**
+ * A helper to build a config ui.
+ * <p/>
+ * contains all states as method to build model, then ui and finally display it.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5.11
+ */
+public class ConfigUIHelper {
+
+ public static final Log log = LogFactory.getLog(ConfigUIHelper.class);
+
+ /** internal model builder */
+ protected final ConfigUIModelBuilder modelBuilder;
+
+ /** internal model after builder flush */
+ protected ConfigUIModel model;
+
+ protected ConfigUI ui;
+
+ public ConfigUIHelper(Supplier<ApplicationConfig> config) {
+ modelBuilder = new ConfigUIModelBuilder();
+ modelBuilder.createModel(config);
+ }
+
+ public ConfigUIHelper(ApplicationConfig config) {
+ modelBuilder = new ConfigUIModelBuilder();
+ modelBuilder.createModel(config);
+ }
+
+ public ConfigUIModel getModel() {
+ if (model == null) {
+ model = modelBuilder.flushModel();
+ }
+ return model;
+ }
+
+ public ConfigUIModelBuilder addCategory(String categoryName, String categoryLabel)
+ throws IllegalStateException, NullPointerException {
+ modelBuilder.addCategory(categoryName, categoryLabel);
+ return modelBuilder;
+ }
+
+ public ConfigUIModelBuilder addCategory(String categoryName, String categoryLabel, String categoryCallback)
+ throws IllegalStateException, NullPointerException {
+ modelBuilder.addCategory(categoryName, categoryLabel, categoryCallback);
+ return modelBuilder;
+ }
+
+ public ConfigUIModelBuilder addOption(ConfigOptionDef def)
+ throws IllegalStateException, NullPointerException {
+ modelBuilder.addOption(def);
+ return modelBuilder;
+ }
+
+ public ConfigUIModelBuilder addOption(ConfigOptionDef def, String propertyName)
+ throws IllegalStateException, NullPointerException {
+ modelBuilder.addOption(def, propertyName);
+ return modelBuilder;
+ }
+
+ public ConfigUIModelBuilder setOptionPropertyName(String propertyName)
+ throws IllegalStateException, NullPointerException {
+ modelBuilder.setOptionPropertyName(propertyName);
+ return modelBuilder;
+ }
+
+ public ConfigUIModelBuilder setOptionEditor(TableCellEditor editor)
+ throws IllegalStateException, NullPointerException {
+ modelBuilder.setOptionEditor(editor);
+ return modelBuilder;
+ }
+
+ public ConfigUIModelBuilder registerCallBack(String name,
+ String description,
+ Icon icon,
+ Runnable action) {
+ modelBuilder.registerCallBack(name, description, icon, action);
+ return modelBuilder;
+ }
+
+ public ConfigUIModelBuilder setOptionCallBack(String name) {
+ modelBuilder.setOptionCallBack(name);
+ return modelBuilder;
+ }
+
+ public ConfigUIModelBuilder setModel(ConfigUIModel model) throws IllegalStateException {
+ modelBuilder.setModel(model);
+ return modelBuilder;
+ }
+
+ public ConfigUIModelBuilder setCategory(CategoryModel categoryModel)
+ throws IllegalStateException {
+ modelBuilder.setCategory(categoryModel);
+ return modelBuilder;
+ }
+
+ public ConfigUIModelBuilder setOption(OptionModel optionModel)
+ throws IllegalStateException {
+ modelBuilder.setOption(optionModel);
+ return modelBuilder;
+ }
+
+ public ConfigUIModelBuilder setFinalizer(CallBackFinalizer finalizer) {
+ modelBuilder.setFinalizer(finalizer);
+ return modelBuilder;
+ }
+
+ public ConfigUIModelBuilder setCloseAction(Runnable runnable) {
+ modelBuilder.setCloseAction(runnable);
+ return modelBuilder;
+ }
+
+ /**
+ * Construire l'ui de configuration (sous forme de panel)
+ *
+ * @param parentContext le context applicatif
+ * @param defaultCategory la categorie a selectionner
+ * @return l'ui instanciate
+ */
+ public ConfigUI buildUI(JAXXContext parentContext,
+ String defaultCategory) {
+
+ ConfigUIModel model = getModel();
+
+ JAXXContext tx = new JAXXInitialContext().add(parentContext).add(model);
+
+ ui = new ConfigUI(tx);
+
+ ui.init(defaultCategory);
+
+ return ui;
+ }
+
+ public void displayUI(Frame parentUI, boolean undecorated) {
+ Preconditions.checkNotNull(ui, "UI was not build, use before the *buildUI* method");
+ ui.getHandler().displayUI(parentUI, undecorated);
+ }
+}
Property changes on: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigUIHelper.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/CallBackEntry.java
===================================================================
--- trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/CallBackEntry.java (rev 0)
+++ trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/CallBackEntry.java 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,81 @@
+package jaxx.runtime.swing.config.model;
+
+/*
+ * #%L
+ * JAXX :: Config
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2013 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import javax.swing.*;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * A call back with his attached options.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5.11
+ */
+public class CallBackEntry {
+
+ protected final String name;
+ protected final String description;
+ protected final Icon icon;
+ protected final Runnable action;
+ protected List<OptionModel> options;
+
+ public CallBackEntry(String name,
+ String description,
+ Icon icon,
+ Runnable action) {
+ this.description = description;
+ this.icon = icon;
+ options = new ArrayList<OptionModel>();
+ this.name = name;
+ this.action = action;
+ }
+
+ public Runnable getAction() {
+ return action;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public Icon getIcon() {
+ return icon;
+ }
+
+ public List<OptionModel> getOptions() {
+ // always send a copy
+ return new ArrayList<OptionModel>(options);
+ }
+
+ protected void addOption(OptionModel option) {
+ options.add(option);
+
+ }
+}
Property changes on: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/CallBackEntry.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/CallBackFinalizer.java
===================================================================
--- trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/CallBackFinalizer.java (rev 0)
+++ trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/CallBackFinalizer.java 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,42 @@
+package jaxx.runtime.swing.config.model;
+
+/*
+ * #%L
+ * JAXX :: Config
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2013 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+/**
+ * Contract to finalize the callbacks to launch.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5.11
+ */
+public interface CallBackFinalizer {
+
+ /**
+ * Do finalize the result.
+ *
+ * @param result unfinalized result
+ * @return the finalized result
+ */
+ CallBackMap finalize(CallBackMap result);
+}
Property changes on: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/CallBackFinalizer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/CallBackMap.java
===================================================================
--- trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/CallBackMap.java (rev 0)
+++ trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/CallBackMap.java 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,58 @@
+package jaxx.runtime.swing.config.model;
+
+/*
+ * #%L
+ * JAXX :: Config
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2013 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import java.util.LinkedHashMap;
+import java.util.List;
+
+/**
+ * A convient map of callback entry for a list of option.
+ * <p/>
+ * This model is used to store callbacks to use before a saving action.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5.11
+ */
+public class CallBackMap extends LinkedHashMap<CallBackEntry, List<OptionModel>> {
+ private static final long serialVersionUID = 1L;
+
+ public boolean containsCallBack(String callBackName) {
+ for (CallBackEntry entry : keySet()) {
+ if (callBackName.equals(entry.getName())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public CallBackEntry getCallBack(String callBackName) {
+ for (CallBackEntry entry : keySet()) {
+ if (callBackName.equals(entry.getName())) {
+ return entry;
+ }
+ }
+ return null;
+ }
+}
Property changes on: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/CallBackMap.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/CallBacksManager.java
===================================================================
--- trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/CallBacksManager.java (rev 0)
+++ trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/CallBacksManager.java 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,252 @@
+package jaxx.runtime.swing.config.model;
+
+/*
+ * #%L
+ * JAXX :: Config
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2013 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import javax.swing.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * CallBack manager.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5.11
+ */
+public class CallBacksManager {
+
+ /** lists of registred callback. */
+ protected List<CallBackEntry> callbacks;
+
+ /** optional callbacks finalizer */
+ protected CallBackFinalizer finalizer;
+
+ public CallBacksManager() {
+ callbacks = new ArrayList<CallBackEntry>();
+ }
+
+ /**
+ * Obtain the finalizer to use.
+ *
+ * @return the finalizer (can be {@code null}).
+ * @see CallBackFinalizer
+ */
+ public CallBackFinalizer getFinalizer() {
+ return finalizer;
+ }
+
+ /**
+ * Sets the finalizer.
+ *
+ * @param finalizer the new finalizer
+ * @see CallBackFinalizer
+ */
+ public void setFinalizer(CallBackFinalizer finalizer) {
+ this.finalizer = finalizer;
+ }
+
+ /**
+ * Registers a new callback.
+ * <p/>
+ * <b>Note:</b> the order of registred callback is used to determine
+ * the higher priority of callback to launch if required.
+ *
+ * @param name the unique name of a callback
+ * @param description the i18n key to describe the action
+ * @param icon icon of callBack (used in ui)
+ * @param action the action of the callback
+ */
+ public void registerCallBack(String name,
+ String description,
+ Icon icon,
+ Runnable action) {
+ if (name == null) {
+ throw new NullPointerException(
+ "parameter 'name' can not be null");
+ }
+ if (action == null) {
+ throw new NullPointerException(
+ "parameter 'action' can not be null");
+ }
+ if (description == null) {
+ throw new NullPointerException(
+ "parameter 'description' can not be null");
+ }
+ if (icon == null) {
+ throw new NullPointerException("parameter 'icon' can not be null");
+ }
+ if (getCallBack(name) != null) {
+ throw new IllegalArgumentException(
+ "there is already a callback with name '" + name + "'");
+ }
+ callbacks.add(new CallBackEntry(name, description, icon, action));
+ }
+
+ /**
+ * Registers a option into a known callback.
+ *
+ * @param name the name of the callback
+ * @param option the option to register for the given callback
+ */
+ public void registerOption(String name, OptionModel option) {
+ if (name == null) {
+ throw new NullPointerException("parameter 'name' can not be null");
+ }
+ if (option == null) {
+ throw new NullPointerException(
+ "parameter 'option' can not be null");
+ }
+ CallBackEntry callback = getCallBack(name);
+ if (callback == null) {
+ throw new IllegalArgumentException(
+ "could not find a callback with name '" + name + "'");
+ }
+ callback.addOption(option);
+ }
+
+ /**
+ * Scan a model and grab per callBack the options saved.
+ *
+ * @param model the model to scan
+ * @return the dictionnary of options for each callback to launch
+ */
+ public CallBackMap getCallBacksForSaved(ConfigUIModel model) {
+
+ CallBackMap result = getCallBacks(model,true,false);
+ return result;
+ }
+
+ /**
+ * Scan a category and grab per callBack the options saved.
+ *
+ * @param category the category to scan
+ * @return the dictionnary of options for each callBack to launch
+ */
+ public CallBackMap getCallBacksForSaved(CategoryModel category) {
+
+ CallBackMap result = getCallBacks(category,true,false);
+ return result;
+ }
+
+ /**
+ * Scan a model and grab per callBack the options.
+ *
+ * @param model the model to scan
+ * @param modified {@code true} to include modified options
+ * @param saved {@code true} to include saved options
+ * @return the dictionnary of options for each callback to launch
+ */
+ public CallBackMap getCallBacks(ConfigUIModel model,
+ boolean saved,
+ boolean modified) {
+
+ CallBackMap result = new CallBackMap();
+
+ for (CategoryModel categoryModel : model) {
+ CallBackMap callBacks =
+ getCallBacks(categoryModel, saved, modified);
+ for (Map.Entry<CallBackEntry, List<OptionModel>> entry :
+ callBacks.entrySet()) {
+ CallBackEntry key = entry.getKey();
+ List<OptionModel> value = entry.getValue();
+ if (result.containsKey(key)) {
+ result.get(key).addAll(value);
+ } else {
+ result.put(key, value);
+ }
+ }
+ callBacks.clear();
+ }
+
+ CallBackFinalizer finalizer = getFinalizer();
+ if (finalizer != null) {
+ result = finalizer.finalize(result);
+ }
+ return result;
+ }
+
+ /**
+ * Scan a category and grab per callBack the options.
+ *
+ * @param category the category to scan
+ * @param modified {@code true} to include modified options
+ * @param saved {@code true} to include saved options
+ * @return the dictionnary of options for each callBack to launch
+ */
+ public CallBackMap getCallBacks(CategoryModel category,
+ boolean saved,
+ boolean modified) {
+
+ CallBackMap result = new CallBackMap();
+
+ for (OptionModel optionModel : category) {
+ if (modified && optionModel.isModified() ||
+ saved && optionModel.isSaved()) {
+ CallBackEntry callBackEntry = getCallBack(optionModel);
+ if (callBackEntry != null) {
+ List<OptionModel> models = result.get(callBackEntry);
+ if (models == null) {
+ models = new ArrayList<OptionModel>();
+ result.put(callBackEntry, models);
+ }
+ models.add(optionModel);
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Get the first callBack for a given option.
+ *
+ * @param option the option
+ * @return the first callBack (so the most important) on which the given
+ * option is attacjed. (can be null)
+ */
+ protected CallBackEntry getCallBack(OptionModel option) {
+ for (CallBackEntry callback : callbacks) {
+ if (callback.getOptions().contains(option)) {
+ return callback;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Obtain a registred callBack from his name.
+ *
+ * @param name the name of the searched callBack
+ * @return the callBack for the given name (or {@code null} if not found).
+ */
+ protected CallBackEntry getCallBack(String name) {
+ for (CallBackEntry callback : callbacks) {
+ if (callback.getName().equals(name)) {
+ return callback;
+ }
+ }
+ return null;
+ }
+
+}
Property changes on: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/CallBacksManager.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/CategoryModel.java
===================================================================
--- trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/CategoryModel.java (rev 0)
+++ trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/CategoryModel.java 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,225 @@
+package jaxx.runtime.swing.config.model;
+
+/*
+ * #%L
+ * JAXX :: Config
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2013 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import jaxx.runtime.JAXXUtil;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * le modele d'une categorie d'options.
+ * <p/>
+ * Une categorie est un ensemble d'options.
+ *
+ * @author tchemit
+ * @since 2.5.11
+ */
+public class CategoryModel implements Iterable<OptionModel>, Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String RELOAD_PROPERTY_NAME = "reload";
+
+ public static final String MODIFIED_PROPERTY_NAME = "modified";
+
+ public static final String VALID_PROPERTY_NAME = "valid";
+
+ /** category short name (i18n key) */
+ protected String category;
+
+ /** category long name (i18n key) */
+ protected String categoryLabel;
+
+ /** options of the category */
+ protected List<OptionModel> entries;
+
+ /** suport of modification */
+ protected PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+
+ protected CategoryModel(String category, String categoryLabel) {
+ this.category = category;
+ this.categoryLabel = categoryLabel;
+ entries = new ArrayList<OptionModel>();
+ }
+
+ protected void addOption(OptionModel option) {
+ entries.add(option);
+ }
+
+ @Deprecated
+ public CategoryModel(String category,
+ String categoryLabel,
+ OptionModel[] entries) {
+ this.category = category;
+ this.categoryLabel = categoryLabel;
+ this.entries = Collections.unmodifiableList(Arrays.asList(entries));
+ }
+
+ public String getCategory() {
+ return category;
+ }
+
+ public String getCategoryLabel() {
+ return categoryLabel;
+ }
+
+ public List<OptionModel> getEntries() {
+ return entries;
+ }
+
+ public boolean isModified() {
+ boolean modified = false;
+ for (OptionModel m : this) {
+ if (m.isModified()) {
+ modified = true;
+ break;
+ }
+ }
+ return modified;
+ }
+
+ public boolean isValid() {
+ boolean valid = true;
+ for (OptionModel m : this) {
+ if (!m.isValid()) {
+ valid = false;
+ break;
+ }
+ }
+ return valid;
+ }
+
+ public OptionModel getOptionModel(String optionModelKey) {
+ OptionModel result = null;
+ for (OptionModel optionModel : this) {
+ if (optionModelKey.endsWith(optionModel.getKey())) {
+ result = optionModel;
+ break;
+ }
+ }
+ return result;
+ }
+ public void setValue(OptionModel key, Object val) {
+ boolean wasModified = isModified();
+ boolean wasValid = isValid();
+ key.setValue(val);
+ boolean modified = isModified();
+ boolean valid = isValid();
+ if (wasModified != modified) {
+ // change modified state
+ firePropertyChange(MODIFIED_PROPERTY_NAME, wasModified, modified);
+ }
+ if (wasValid != valid) {
+ // change valid state
+ firePropertyChange(VALID_PROPERTY_NAME, wasValid, valid);
+ }
+ }
+
+ @Override
+ public Iterator<OptionModel> iterator() {
+ return entries.iterator();
+ }
+
+ public List<OptionModel> getInvalidOptions() {
+
+ List<OptionModel> result = new ArrayList<OptionModel>();
+ for (OptionModel m : this) {
+ if (!m.isValid()) {
+ result.add(m);
+ }
+ }
+ return result;
+ }
+
+ public List<OptionModel> getModifiedOptions() {
+
+ List<OptionModel> result = new ArrayList<OptionModel>();
+ for (OptionModel m : this) {
+ if (m.isModified()) {
+ result.add(m);
+ }
+ }
+ return result;
+ }
+
+ public List<OptionModel> getSavedOptions() {
+ List<OptionModel> result = new ArrayList<OptionModel>();
+ for (OptionModel option : this) {
+ if (option.isSaved()) {
+ result.add(option);
+ }
+ }
+ return result;
+ }
+
+ public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
+ pcs.firePropertyChange(propertyName, oldValue, newValue);
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(propertyName, listener);
+ }
+
+ public boolean hasListeners(String propertyName) {
+ return pcs.hasListeners(propertyName);
+ }
+
+ public PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
+ return pcs.getPropertyChangeListeners(propertyName);
+ }
+
+ public PropertyChangeListener[] getPropertyChangeListeners() {
+ return pcs.getPropertyChangeListeners();
+ }
+
+ public void destroy() {
+ JAXXUtil.destroy(pcs);
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ super.finalize();
+ destroy();
+ }
+}
Property changes on: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/CategoryModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/ConfigTableModel.java
===================================================================
--- trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/ConfigTableModel.java (rev 0)
+++ trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/ConfigTableModel.java 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,156 @@
+package jaxx.runtime.swing.config.model;
+
+/*
+ * #%L
+ * JAXX :: Config
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2013 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import org.nuiton.util.converter.ConverterUtil;
+
+import javax.swing.table.AbstractTableModel;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+/**
+ * le modele du tableau d'options pour une categorie donnee.
+ * <p/>
+ * Le modele se base sur le modele d'une categorie d'option.
+ *
+ * @author tchemit
+ * @see CategoryModel
+ * @since 2.5.11
+ */
+public class ConfigTableModel extends AbstractTableModel {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final Class<?>[] columnClass = {String.class, Object.class, String.class};
+
+ /** le modele d'une categorie */
+ protected final CategoryModel categoryModel;
+
+ public ConfigTableModel(CategoryModel categoryModel) {
+ this.categoryModel = categoryModel;
+ // listen of property reload of the category model
+ // to known when to refresh table
+ this.categoryModel.addPropertyChangeListener(CategoryModel.RELOAD_PROPERTY_NAME, new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ fireTableDataChanged();
+ }
+ });
+ }
+
+ public CategoryModel getCategoryModel() {
+ return categoryModel;
+ }
+
+ public OptionModel getEntry(int rowIndex) {
+ return categoryModel.getEntries().get(rowIndex);
+ }
+
+ @Override
+ public int getRowCount() {
+ return categoryModel.getEntries().size();
+ }
+
+ @Override
+ public int getColumnCount() {
+ return columnClass.length;
+ }
+
+ @Override
+ public Class<?> getColumnClass(int columnIndex) {
+ return columnClass[columnIndex];
+ }
+
+ @Override
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ return columnIndex == 1 && !getEntry(rowIndex).isFinal();
+ }
+
+ @Override
+ public Object getValueAt(int row, int column) {
+ OptionModel key = getEntry(row);
+ Object value = null;
+ switch (column) {
+ case 0:
+ value = key.getKey();
+ break;
+ case 1:
+ value = key.getValue();
+ break;
+ case 2:
+ value = key.getDefaultValue();
+ if (value != null) {
+ value = ConverterUtil.convert(key.getType(), value);
+ }
+ break;
+ }
+ return value;
+// if (column == 0) {
+// return key.getKey();
+// }
+// return key.getValue();
+ }
+
+ @Override
+ public void setValueAt(Object aValue, int row, int column) {
+ if (column != 1) {
+ // seul la colonne 1 est editable (valeur de l'option)
+ throw new IllegalArgumentException("can not edit column " + column);
+ }
+ OptionModel key = getEntry(row);
+ Object val;
+ if (aValue == null || key.getType().equals(aValue.getClass())) {
+ val = aValue;
+ } else {
+ String valStr = String.valueOf(aValue).trim();
+ try {
+ val = ConverterUtil.convert(key.getType(), valStr);
+ if (val != null && val instanceof Integer) {
+ if (new Integer(0).equals(val) && !valStr.equals("0")) {
+ val = null;
+ }
+ }
+ } catch (Exception e) {
+ val = null;
+ }
+ }
+ categoryModel.setValue(key, val);
+ fireTableRowsUpdated(row, row);
+ }
+
+
+ public void destroy() {
+ if (categoryModel != null) {
+ categoryModel.destroy();
+ }
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ super.finalize();
+ destroy();
+ }
+}
Property changes on: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/ConfigTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/ConfigUIModel.java
===================================================================
--- trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/ConfigUIModel.java (rev 0)
+++ trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/ConfigUIModel.java 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,381 @@
+package jaxx.runtime.swing.config.model;
+
+/*
+ * #%L
+ * JAXX :: Config
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2013 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Supplier;
+import jaxx.runtime.JAXXUtil;
+import org.apache.commons.beanutils.PropertyUtils;
+import org.nuiton.util.config.ApplicationConfig;
+
+import javax.swing.Icon;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Le modele de l'ui des preferences.
+ * <p/>
+ * Ce modele contient les catégories des options.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5.11
+ */
+public class ConfigUIModel implements Iterable<CategoryModel> {
+
+ public static final String CATEGORY_MODEL_PROPERTY_NAME = "categoryModel";
+
+ /** le dictionnaire des options disponibles par categorie */
+ protected final Map<String, CategoryModel> categories;
+
+ /** La configuration de l'application */
+ protected final Object configBean;
+
+ /** La configuration de l'application */
+ protected final ApplicationConfig applicationConfig;
+
+ /** la cateogrie en cours d'utilisation */
+ protected CategoryModel categoryModel;
+
+ /**
+ * un drapeau pour savoir si la configuration a été modifiée au moins une
+ * fois.
+ * <p/>
+ * On utilise ce drapeau lors de la sortie pour verifier s'il faut ou non
+ * redemarer l'application (si non en mode standalone)
+ */
+ protected boolean saved;
+
+ /**
+ * un drapeau pour savoir si l'ui de configuration a été lancée en mode
+ * standalone ou pas.
+ * <p/>
+ * Si pas lancée en mode standalone, et si la confi a été sauvé on vérifie
+ * s'il ne faut pas relancer l'application.
+ */
+ protected boolean standalone;
+
+ /** Callbacks manager */
+ protected CallBacksManager callBacksManager;
+
+ /**
+ * optional action to execute (if not null) if no call backs fits.
+ *
+ * @since 1.4.2
+ */
+ protected Runnable closeAction;
+
+ /** support of modification notifications */
+ protected final PropertyChangeSupport pcs;
+
+ public ConfigUIModel(Supplier<ApplicationConfig> config) {
+ this(config, config.get());
+ }
+
+ public ConfigUIModel(ApplicationConfig applicationConfig) {
+ this(applicationConfig, applicationConfig);
+ }
+
+ public ConfigUIModel(Object configBean, ApplicationConfig applicationConfig) {
+ this.configBean = configBean;
+ this.applicationConfig = applicationConfig;
+ categories = new LinkedHashMap<String, CategoryModel>();
+ callBacksManager = new CallBacksManager();
+ pcs = new PropertyChangeSupport(this);
+ }
+
+ /**
+ * Ajoute une categorie dans le modele.
+ *
+ * @param category la categorie a ajouter au modèle.
+ */
+ public void addCategory(CategoryModel category) {
+ if (categories.containsKey(category.getCategory())) {
+ throw new IllegalArgumentException(
+ _("config.error.category.already.exists",
+ category.getCategory()));
+ }
+ categories.put(category.getCategory(), category);
+ }
+
+ /**
+ * Change la categorie en cours d'édition.
+ *
+ * @param category l'id de la categorie courante
+ */
+ public void setCategory(String category) {
+ if (!categories.containsKey(category)) {
+ throw new IllegalArgumentException(
+ _("config.error.category.not.found", category));
+ }
+ CategoryModel newCategoryModel = categories.get(category);
+ setCategoryModel(newCategoryModel);
+ newCategoryModel.firePropertyChange(
+ CategoryModel.MODIFIED_PROPERTY_NAME, false,
+ getCategoryModel().isModified());
+ newCategoryModel.firePropertyChange(
+ CategoryModel.VALID_PROPERTY_NAME, false,
+ getCategoryModel().isValid());
+ }
+
+ /**
+ * Registers a new callback.
+ * <p/>
+ * <b>Note:</b> the order of registred callback is used to determine
+ * the higher priority of callback to launch if required.
+ *
+ * @param name the unique name of a callback
+ * @param description the i18n key to describe the action
+ * @param icon the icon of the callBack (used in ui)
+ * @param action the action of the callback
+ */
+ public void registerCallBack(String name,
+ String description,
+ Icon icon,
+ Runnable action) {
+ callBacksManager.registerCallBack(name, description, icon, action);
+ }
+
+ /**
+ * Registers a option into a known callback.
+ *
+ * @param name the name of the callback
+ * @param option the option to register for the given callback
+ */
+ public void registerOptionCallBack(String name, OptionModel option) {
+ callBacksManager.registerOption(name, option);
+ }
+
+ public void setFinalizer(CallBackFinalizer finalizer) {
+ callBacksManager.setFinalizer(finalizer);
+ }
+
+ public Runnable getCloseAction() {
+ return closeAction;
+ }
+
+ public void setCloseAction(Runnable closeAction) {
+ this.closeAction = closeAction;
+ }
+
+ /**
+ * Obtain the dictionnary of callback for all to saved modified options.
+ *
+ * @return the dictonnary
+ */
+ public CallBackMap getCallBacksForSaved() {
+ return callBacksManager.getCallBacksForSaved(this);
+ }
+
+ @Override
+ public Iterator<CategoryModel> iterator() {
+ return categories.values().iterator();
+ }
+
+ public CategoryModel getCategoryModel() {
+ return categoryModel;
+ }
+
+ public void setCategoryModel(CategoryModel categoryModel) {
+ CategoryModel old = this.categoryModel;
+ this.categoryModel = categoryModel;
+ firePropertyChange(CATEGORY_MODEL_PROPERTY_NAME, old, categoryModel);
+ }
+
+ public boolean isSaved() {
+ return saved;
+ }
+
+ public void setSaved(boolean saved) {
+ this.saved = saved;
+ }
+
+ public boolean isStandalone() {
+ return standalone;
+ }
+
+ public void setStandalone(boolean standalone) {
+ this.standalone = standalone;
+ }
+
+ public void saveModified() {
+ // compute transients keys (to never be saved)
+ List<String> transients = new ArrayList<String>();
+
+ applicationConfig.setAdjusting(true);
+
+ try {
+ for (OptionModel option : categoryModel) {
+ if (option.isModified()) {
+ Object value = option.getValue();
+ if (option.getPropertyName() != null) {
+
+ // this is a javaBean option, push value via mutator
+ try {
+ PropertyUtils.setProperty(configBean,
+ option.getPropertyName(), value);
+ } catch (Exception e) {
+ throw new RuntimeException(
+ "could not set property [" +
+ option.getPropertyName() +
+ "] with value = " + value, e);
+ }
+ } else {
+
+ // simple option with no javabeans, just push the option
+ // value
+ applicationConfig.setOption(option.getKey(),
+ value == null ?
+ null : value.toString());
+ }
+ // l'option a été sauvegardée, on la marque
+ option.setSaved(true);
+ // this is the new original value
+ option.initValue(value);
+ }
+ if (option.isTransient()) {
+ transients.add(option.getKey());
+ }
+ }
+ } finally {
+ applicationConfig.setAdjusting(false);
+ }
+
+ setSaved(true);
+ // save config
+ applicationConfig.saveForUser(transients.toArray(new String[transients.size()]));
+ // notify data has changed
+ categoryModel.firePropertyChange(
+ CategoryModel.MODIFIED_PROPERTY_NAME,
+ categoryModel.isModified(), true);
+ categoryModel.firePropertyChange(
+ CategoryModel.VALID_PROPERTY_NAME,
+ false, categoryModel.isValid());
+ categoryModel.firePropertyChange(
+ CategoryModel.RELOAD_PROPERTY_NAME, false, true);
+ }
+
+ public void reset() {
+ // reset all modified options of the current category
+ for (OptionModel key : categoryModel) {
+ if (key.isModified()) {
+ key.initValue(key.getOriginalValue());
+ }
+ }
+ // notify data has changed
+ categoryModel.firePropertyChange(
+ CategoryModel.MODIFIED_PROPERTY_NAME,
+ categoryModel.isModified(), true);
+ categoryModel.firePropertyChange(
+ CategoryModel.VALID_PROPERTY_NAME,
+ false, categoryModel.isValid());
+ categoryModel.firePropertyChange(
+ CategoryModel.RELOAD_PROPERTY_NAME, false, true);
+ }
+
+ public int getCategoryIndex(String category) {
+ int i = 0;
+ for (CategoryModel m : this) {
+ if (category.equals(m.getCategory())) {
+ return i;
+ }
+ i++;
+ }
+ // not found
+ return -1;
+ }
+
+ public void firePropertyChange(String propertyName,
+ Object oldValue,
+ Object newValue) {
+ pcs.firePropertyChange(propertyName, oldValue, newValue);
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName,
+ PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName,
+ PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(propertyName, listener);
+ }
+
+ public boolean hasListeners(String propertyName) {
+ return pcs.hasListeners(propertyName);
+ }
+
+ public PropertyChangeListener[] getPropertyChangeListeners(
+ String propertyName) {
+ return pcs.getPropertyChangeListeners(propertyName);
+ }
+
+ public PropertyChangeListener[] getPropertyChangeListeners() {
+ return pcs.getPropertyChangeListeners();
+ }
+
+ public void destroy() {
+ JAXXUtil.destroy(pcs);
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ super.finalize();
+ destroy();
+ }
+
+ /**
+ * @return the underlined application config
+ * @deprecated since 2.5.4 use now {@link #getApplicationConfig()}.
+ */
+ protected ApplicationConfig getConfig() {
+ return applicationConfig;
+ }
+
+ /**
+ * @return the underlined application config
+ * @since 2.5.4
+ */
+ protected ApplicationConfig getApplicationConfig() {
+ return applicationConfig;
+ }
+
+ protected CallBacksManager getCallBacksManager() {
+ return callBacksManager;
+ }
+}
Property changes on: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/ConfigUIModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/ConfigUIModelBuilder.java
===================================================================
--- trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/ConfigUIModelBuilder.java (rev 0)
+++ trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/ConfigUIModelBuilder.java 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,449 @@
+package jaxx.runtime.swing.config.model;
+
+/*
+ * #%L
+ * JAXX :: Config
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2013 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import com.google.common.base.Supplier;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.config.ApplicationConfig;
+import org.nuiton.util.config.ConfigOptionDef;
+
+import javax.swing.Icon;
+import javax.swing.table.TableCellEditor;
+
+/**
+ * A builder of {@link ConfigUIModel}
+ * Created: 22 déc. 2009
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5.11
+ */
+public class ConfigUIModelBuilder {
+
+ /** Logger */
+ private static final Log log =
+ LogFactory.getLog(ConfigUIModelBuilder.class);
+
+ /** current model used */
+ ConfigUIModel model;
+
+ /** current category used */
+ CategoryModel category;
+
+ /** Current default callback used by a category. */
+ String categoryDefaultCallBack;
+
+ /** current option used */
+ OptionModel option;
+
+ /**
+ * Create a new model and set it as current model.
+ *
+ * @param config the configuration used in model
+ * @return the builder
+ * @throws IllegalStateException if there is already a current model
+ * @throws NullPointerException if config is {@code null}
+ */
+ public ConfigUIModelBuilder createModel(Supplier<ApplicationConfig> config)
+ throws IllegalStateException, NullPointerException {
+ checkNoCurrent(model, "model");
+ checkNotNull(config, "createModel", "config");
+ model = new ConfigUIModel(config);
+ if (log.isDebugEnabled()) {
+ log.debug("model created : " + model);
+ }
+ return this;
+ }
+
+ /**
+ * Create a new model and set it as current model.
+ *
+ * @param config the configuration used in model
+ * @return the builder
+ * @throws IllegalStateException if there is already a current model
+ * @throws NullPointerException if config is {@code null}
+ */
+ public ConfigUIModelBuilder createModel(ApplicationConfig config)
+ throws IllegalStateException, NullPointerException {
+ checkNoCurrent(model, "model");
+ checkNotNull(config, "createModel", "config");
+ model = new ConfigUIModel(config);
+ if (log.isDebugEnabled()) {
+ log.debug("model created : " + model);
+ }
+ return this;
+ }
+
+ /**
+ * Add a new category, and set it as current.
+ * <p/>
+ * <b>Note:</b> As side effets, if a previous category, then store it to
+ * the model.
+ *
+ * @param categoryName the name of the new category
+ * (can not to be {@code null})
+ * @param categoryLabel the label of the new category
+ * (can not to be {@code null})
+ * @return the builder
+ * @throws IllegalStateException if there is not a current model,
+ * nor category
+ * @throws NullPointerException if any of parameter is {@code null}
+ */
+ public ConfigUIModelBuilder addCategory(String categoryName, String categoryLabel)
+ throws IllegalStateException, NullPointerException {
+ checkCurrent(model, "model");
+ checkNotNull(categoryName, "addCategory", "categoryName");
+ checkNotNull(categoryLabel, "addCategory", "categoryLabel");
+ flushCategory();
+ category = new CategoryModel(categoryName, categoryLabel);
+ if (log.isDebugEnabled()) {
+ log.debug("category created : " + category);
+ }
+ return this;
+ }
+
+ /**
+ * Add a new category, and set it as current.
+ * <p/>
+ * <b>Note:</b> As side effets, if a previous category, then store it to
+ * the model.
+ *
+ * @param categoryName the name of the new category
+ * (can not to be {@code null})
+ * @param categoryLabel the label of the new category
+ * (can not to be {@code null})
+ * @return the builder
+ * @throws IllegalStateException if there is not a current model,
+ * nor category
+ * @throws NullPointerException if any of parameter is {@code null}
+ */
+ public ConfigUIModelBuilder addCategory(String categoryName, String categoryLabel, String defaultCallback)
+ throws IllegalStateException, NullPointerException {
+ checkCurrent(model, "model");
+ checkNotNull(categoryName, "addCategory", "categoryName");
+ checkNotNull(categoryLabel, "addCategory", "categoryLabel");
+ flushCategory();
+ categoryDefaultCallBack = defaultCallback;
+ category = new CategoryModel(categoryName, categoryLabel);
+ if (log.isDebugEnabled()) {
+ log.debug("category created : " + category);
+ }
+ return this;
+ }
+
+ /**
+ * Add a new option, and set it as current.
+ * <p/>
+ * <b>Note:</b> As side effets, if a previous option, then store it to
+ * the model.
+ *
+ * @param def the def ot the new option
+ * @return the builder
+ * @throws IllegalStateException if there is not a current model,
+ * nor category
+ * @throws NullPointerException if any of parameter is {@code null}
+ */
+ public ConfigUIModelBuilder addOption(ConfigOptionDef def)
+ throws IllegalStateException, NullPointerException {
+ checkCurrent(model, "model");
+ checkCurrent(category, "category");
+ checkNotNull(def, "addOption", "def");
+ flushOption();
+ Object value = model.getApplicationConfig().getOption(def);
+ option = new OptionModel(def, value);
+ if (categoryDefaultCallBack != null) {
+
+ // use default callback
+ model.registerOptionCallBack(categoryDefaultCallBack, option);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("option created : " + option);
+ }
+ return this;
+ }
+
+ /**
+ * Add a new option with a propertyName, and set it as current.
+ * <p/>
+ * <b>Note:</b> As side effets, if a previous option, then store it to
+ * the model.
+ * <p/>
+ * <b>Note:</b> This method is a short-cut for
+ * {@link #addOption(ConfigOptionDef)} then
+ * {@link #setOptionPropertyName(String)}.
+ *
+ * @param def the def ot the new option
+ * @param propertyName the propertyName to set on the option
+ * @return the builder
+ * @throws IllegalStateException if there is not a current model, nor
+ * category
+ * @throws NullPointerException if any of parameter is {@code null}
+ */
+ public ConfigUIModelBuilder addOption(ConfigOptionDef def,
+ String propertyName)
+ throws IllegalStateException, NullPointerException {
+ addOption(def);
+ checkNotNull(propertyName, "setOptionPropertyName", "propertyName");
+ option.setPropertyName(propertyName);
+ return this;
+ }
+
+ /**
+ * Set the propertyName on the current option.
+ *
+ * @param propertyName the propertyName to set in the current option.
+ * @return the builder
+ * @throws IllegalStateException if there is not a current option set.
+ * @throws NullPointerException if any of parameter is {@code null}
+ * @see OptionModel#setPropertyName(String)
+ */
+ public ConfigUIModelBuilder setOptionPropertyName(String propertyName)
+ throws IllegalStateException, NullPointerException {
+ checkCurrent(option, "option");
+ checkNotNull(propertyName, "setOptionPropertyName", "propertyName");
+ option.setPropertyName(propertyName);
+ return this;
+ }
+
+ /**
+ * Set the editor on the current option.
+ *
+ * @param editor the editor to set in the current option.
+ * @return the builder
+ * @throws IllegalStateException if there is not a current option set.
+ * @throws NullPointerException if any of parameter is {@code null}
+ * @see OptionModel#setEditor(TableCellEditor)
+ */
+ public ConfigUIModelBuilder setOptionEditor(TableCellEditor editor)
+ throws IllegalStateException, NullPointerException {
+ checkCurrent(option, "option");
+ checkNotNull(editor, "setOptionEditor", "editor");
+ option.setEditor(editor);
+ return this;
+ }
+
+ /**
+ * Registers a new callback.
+ * <p/>
+ * <b>Note:</b> the order of registred callback is used to determine
+ * the higher priority of callback to launch if required.
+ *
+ * @param name the unique name of a callback
+ * @param description the i18n key to describe the action
+ * @param icon the icon of the callBack (used in ui)
+ * @param action the action of the callback
+ * @return the builder
+ */
+ public ConfigUIModelBuilder registerCallBack(String name,
+ String description,
+ Icon icon,
+ Runnable action) {
+ checkCurrent(model, "model");
+ checkNotNull(name, "registerCallBack", "name");
+ checkNotNull(description, "registerCallBack", "description");
+ checkNotNull(action, "registerCallBack", "action");
+ model.registerCallBack(name, description, icon, action);
+ return this;
+ }
+
+ /**
+ * Registers the current option into a known callback.
+ *
+ * @param name the name of the callback
+ * @return the builder
+ */
+ public ConfigUIModelBuilder setOptionCallBack(String name) {
+ checkCurrent(option, "option");
+ checkNotNull(name, "setOptionCallBack", "name");
+ Preconditions.checkArgument(
+ categoryDefaultCallBack == null,
+ "You can not use the method *setOptionCallBack* when " +
+ "a default callback has been assigned to a category");
+
+ model.registerOptionCallBack(name, option);
+ return this;
+ }
+
+ /**
+ * Sets the callback finalizet
+ *
+ * @param finalizer callback finalize
+ * @return the builder
+ * @see CallBackFinalizer
+ */
+ public ConfigUIModelBuilder setFinalizer(CallBackFinalizer finalizer) {
+ model.setFinalizer(finalizer);
+ return this;
+ }
+
+ /**
+ * Sets the default callback to use for this category (the call back
+ * will be add to all options of this category until you set another one or
+ * nullify it).
+ *
+ * @param categoryDefaultCallBack default callbakc name for the category
+ * @return the buider
+ */
+ public ConfigUIModelBuilder setCategoryDefaultCallBack(String categoryDefaultCallBack) {
+ checkCurrent(model, "model");
+ checkCurrent(category, "category");
+ this.categoryDefaultCallBack = categoryDefaultCallBack;
+ return this;
+ }
+
+
+ /**
+ * Flush the model and return it.
+ * <p/>
+ * <b>Note:</b> As a side effect, nothing is available in the builder
+ * after this operation.
+ * To reuse the builder on a model, use the dedicated setter.
+ *
+ * @return the final model
+ * @throws IllegalStateException if there is not a current model set.
+ */
+ public ConfigUIModel flushModel() throws IllegalStateException {
+ checkCurrent(model, "model");
+ flushCategory();
+ ConfigUIModel result = model;
+ model = null;
+ return result;
+ }
+
+ /**
+ * Set the given model as current model.
+ * <p/>
+ * <b>Note:</b> As side effets, il will clean current category and option.
+ *
+ * @param model the model to use
+ * @return the buider
+ * @throws IllegalStateException if there is already a current model
+ */
+ public ConfigUIModelBuilder setModel(ConfigUIModel model) throws IllegalStateException {
+ checkNoCurrent(model, "model");
+ this.model = model;
+ if (log.isDebugEnabled()) {
+ log.debug("new current model : " + this.model);
+ }
+ category = null;
+ categoryDefaultCallBack = null;
+ option = null;
+ return this;
+ }
+
+ /**
+ * Set the given category as current category.
+ * <p/>
+ * <b>Note:</b> As side effets, il will clean current option.
+ *
+ * @param categoryModel the category to use
+ * @return the buider
+ * @throws IllegalStateException if there is not a current model or a
+ * current category
+ */
+ public ConfigUIModelBuilder setCategory(CategoryModel categoryModel)
+ throws IllegalStateException {
+ checkCurrent(model, "model");
+ checkNoCurrent(category, "category");
+ category = categoryModel;
+ categoryDefaultCallBack = null;
+ if (log.isDebugEnabled()) {
+ log.debug("new current category : " + category);
+ }
+ option = null;
+ return this;
+ }
+
+ /**
+ * Sets the given option as current option.
+ *
+ * @param optionModel the option to use
+ * @return the buider
+ * @throws IllegalStateException if there is not a current model, nor
+ * category, or a current option
+ */
+ public ConfigUIModelBuilder setOption(OptionModel optionModel)
+ throws IllegalStateException {
+ checkCurrent(model, "model");
+ checkCurrent(category, "category");
+ checkNoCurrent(option, "option");
+ option = optionModel;
+ if (log.isDebugEnabled()) {
+ log.debug("new current option : " + option);
+ }
+ return this;
+ }
+
+ public ConfigUIModelBuilder setCloseAction(Runnable runnable) {
+ checkNotNull(runnable, "setCloseAction", "runnable");
+ checkCurrent(model, "model");
+ model.setCloseAction(runnable);
+ return this;
+ }
+
+ protected CategoryModel flushCategory() {
+ CategoryModel result = category;
+ if (category != null) {
+ flushOption();
+ // add the previous category to the model
+ model.addCategory(category);
+ category = null;
+ categoryDefaultCallBack = null;
+ }
+ return result;
+ }
+
+ protected OptionModel flushOption() {
+ OptionModel result = option;
+ if (option != null) {
+ // add the previous option to the category
+ category.addOption(option);
+ option = null;
+ }
+ return result;
+ }
+
+ protected void checkCurrent(Object o, String type) {
+ if (o == null) {
+ throw new IllegalStateException("no current " + type + "!");
+ }
+ }
+
+ protected void checkNoCurrent(Object o, String type) {
+ if (o != null) {
+ throw new IllegalStateException(
+ "there is already a current " + type + "!");
+ }
+ }
+
+ protected void checkNotNull(Object o, String method, String parameter) {
+ if (o == null) {
+ throw new NullPointerException(
+ "method " + method + " does not support null parameter " +
+ parameter + "!");
+ }
+ }
+}
Property changes on: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/ConfigUIModelBuilder.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/MainCallBackFinalizer.java
===================================================================
--- trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/MainCallBackFinalizer.java (rev 0)
+++ trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/MainCallBackFinalizer.java 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,65 @@
+package jaxx.runtime.swing.config.model;
+
+/*
+ * #%L
+ * JAXX :: Config
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2013 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * A finalizer to mark a special category to eat every others categories
+ * when finalizing.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5.11
+ */
+public class MainCallBackFinalizer implements CallBackFinalizer {
+
+ /** name of call back which eats everybody */
+ protected final String mainCallBack;
+
+ public MainCallBackFinalizer(String mainCallBack) {
+ this.mainCallBack = mainCallBack;
+ }
+
+ @Override
+ public CallBackMap finalize(CallBackMap result) {
+ CallBackEntry applicationEntry = result.getCallBack(mainCallBack);
+ CallBackMap newResult;
+ if (applicationEntry == null) {
+ // rien n'a change
+ newResult = result;
+ } else {
+ newResult = new CallBackMap();
+ // on passe toutes les options sur ce callback
+ List<OptionModel> options = new ArrayList<OptionModel>();
+
+ for (List<OptionModel> optionModels : result.values()) {
+ options.addAll(optionModels);
+ }
+ newResult.put(applicationEntry, options);
+ }
+ return newResult;
+ }
+}
Property changes on: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/MainCallBackFinalizer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/OptionModel.java
===================================================================
--- trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/OptionModel.java (rev 0)
+++ trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/OptionModel.java 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,165 @@
+package jaxx.runtime.swing.config.model;
+
+/*
+ * #%L
+ * JAXX :: Config
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2013 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import org.apache.commons.lang3.ObjectUtils;
+import org.nuiton.util.config.ConfigOptionDef;
+
+import javax.swing.table.TableCellEditor;
+
+/**
+ * le modele d'une option de la configuration a editer.
+ *
+ * @author tchemit
+ * @since 2.5.11
+ */
+public class OptionModel implements ConfigOptionDef {
+
+ private static final long serialVersionUID = 1L;
+
+ /** la definition de l'option (venant de la config) */
+ protected final ConfigOptionDef def;
+
+ /** un drapeau pour savoir si l'option est valide (n'est pas utilisé actuellement) */
+ protected boolean valid = true;
+
+ /** un drapeau pour savoir si l'option a été sauvée */
+ protected boolean saved;
+
+ /** la valeur non modifié de l'option */
+ protected Object originalValue;
+
+ /** la valeur actuelle de l'option (peut être la valeur orignal si non modifée) */
+ protected Object value;
+
+ /** le nom de la propriété javaBean (peut etre null, si option sans support javaBean) */
+ protected String propertyName;
+
+ /** l'editeur utilise pour modifier graphiquement l'option */
+ protected TableCellEditor editor;
+
+ protected OptionModel(ConfigOptionDef def, Object value) {
+ this.def = def;
+ initValue(value);
+ }
+
+ @Override
+ public String getKey() {
+ return def.getKey();
+ }
+
+ @Override
+ public Class<?> getType() {
+ return def.getType();
+ }
+
+ @Override
+ public String getDescription() {
+ return def.getDescription();
+ }
+
+ @Override
+ public String getDefaultValue() {
+ return def.getDefaultValue();
+ }
+
+ @Override
+ public boolean isTransient() {
+ return def.isTransient();
+ }
+
+ @Override
+ public boolean isFinal() {
+ return def.isFinal();
+ }
+
+ public Object getOriginalValue() {
+ return originalValue;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ @Override
+ public void setDefaultValue(String defaultValue) {
+ def.setDefaultValue(defaultValue);
+ }
+
+ @Override
+ public void setTransient(boolean isTransient) {
+ def.setTransient(isTransient);
+ }
+
+ @Override
+ public void setFinal(boolean isFinal) {
+ def.setFinal(isFinal);
+ }
+
+ public void setValue(Object value) {
+ this.value = value;
+ }
+
+ public boolean isModified() {
+ return ObjectUtils.notEqual(originalValue, value);
+ }
+
+ public boolean isValid() {
+ return valid;
+ }
+
+ public void setValid(boolean valid) {
+ this.valid = valid;
+ }
+
+ public boolean isSaved() {
+ return saved;
+ }
+
+ public void setSaved(boolean saved) {
+ this.saved = saved;
+ }
+
+ public void initValue(Object originalValue) {
+ this.originalValue = originalValue;
+ value = originalValue;
+ }
+
+ public String getPropertyName() {
+ return propertyName;
+ }
+
+ public TableCellEditor getEditor() {
+ return editor;
+ }
+
+ protected void setEditor(TableCellEditor editor) {
+ this.editor = editor;
+ }
+
+ protected void setPropertyName(String propertyName) {
+ this.propertyName = propertyName;
+ }
+}
Property changes on: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/OptionModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/package.html
===================================================================
--- trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/package.html (rev 0)
+++ trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/package.html 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,30 @@
+<!--
+ #%L
+ JAXX :: Config
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2008 - 2013 CodeLutin, Tony Chemit
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+<html>
+<body>
+<h1>Package jaxx.runtime.swing.config.model</h1>
+
+the package contains the models of the Config UI.
+</body>
+</html>
Property changes on: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/package.html
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/package.html
===================================================================
--- trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/package.html (rev 0)
+++ trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/package.html 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,41 @@
+<!--
+ #%L
+ JAXX :: Config
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2008 - 2013 CodeLutin, Tony Chemit
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+<html>
+<body>
+<h1>Package jaxx.runtime.swing.config</h1>
+
+This package contains the Config ui, based on org.nuiton.util.config.ApplicationConfig.
+
+The config ui is categorized and offers possibility to add callbacks to run
+when configuration was saved.
+
+<hr/>
+<ul>
+ <li>
+ ConfigUIBuilder offers you a simple way to build the ConfigUI (and his
+ model).
+ </li>
+</ul>
+</body>
+</html>
Property changes on: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/package.html
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/main/resources/i18n/jaxx-config_en_GB.properties
===================================================================
--- trunk/jaxx-config/src/main/resources/i18n/jaxx-config_en_GB.properties (rev 0)
+++ trunk/jaxx-config/src/main/resources/i18n/jaxx-config_en_GB.properties 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,33 @@
+config.action.quit=Quit
+config.action.quit.tip=Quit the configuration editor
+config.action.reset=Cancel
+config.action.reset.tip=Cancel the modifications for the category
+config.action.save=Save
+config.action.save.tip=Save the modifications for the category
+config.choice.cancel=Cancel
+config.choice.continue=Continue
+config.choice.doNotSave=Do not save
+config.choice.save=Save
+config.defaultValue=Default value
+config.defaultValue.tip=Default value of the option
+config.description=Description
+config.detected.callBack=Detected actions
+config.error.category.already.exists=category with name '%1$s' does already exist\!
+config.error.category.not.found=category with name '%1$s' does not exist\!
+config.key=Key
+config.key.tip=Key of the option
+config.launch.callBack=Perform
+config.launch.callBack.tip=Perform necessary actions
+config.message.quit.invalid.category=The category '%1$s' is not valid\!
+config.message.quit.valid.and.modified.category=The category '%1$s' has some modified options \:
+config.modified=Option was modified (previous value \: %1$s)
+config.no.option.selected=< No selected option >
+config.option.final=This option can not be modified
+config.option.label=Option '%1$s' (%2$s)
+config.option.modified=Value is modified < original value \: '%1$s' - new value \: '%2$s' >
+config.title=Preferences
+config.title.need.confirm=A confirmation is required
+config.unmodifiable=Can not be modified
+config.unvalid=Option is not valid \! (previous value \: %1$s, required type \: %2$s)
+config.value=Value
+config.value.tip=Value of the option
Property changes on: trunk/jaxx-config/src/main/resources/i18n/jaxx-config_en_GB.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/main/resources/i18n/jaxx-config_es_ES.properties
===================================================================
--- trunk/jaxx-config/src/main/resources/i18n/jaxx-config_es_ES.properties (rev 0)
+++ trunk/jaxx-config/src/main/resources/i18n/jaxx-config_es_ES.properties 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,33 @@
+config.action.quit=Salir
+config.action.quit.tip=Salir del editor de configuración
+config.action.reset=Cancelar
+config.action.reset.tip=Cancelar las modificaciones de esta categoría
+config.action.save=Guardar
+config.action.save.tip=Guardar las modificaciones de esta categoría
+config.choice.cancel=Cancelar
+config.choice.continue=Continuar
+config.choice.doNotSave=No guardar
+config.choice.save=Guardar
+config.defaultValue=Valor por defecto
+config.defaultValue.tip=Valor por defecto de la opción
+config.description=Descripción
+config.detected.callBack=Acciones detectadas para las opciones modificadas
+config.error.category.already.exists=la categoría '%1$s' ya existe\!
+config.error.category.not.found=La categoria '%1$s' no existe\!
+config.key=Clave
+config.key.tip=Calve de la opcion
+config.launch.callBack=Lanzar
+config.launch.callBack.tip=Lanzar las acciones necesarias
+config.message.quit.invalid.category=La categoría '%1$s' no es valida\!
+config.message.quit.valid.and.modified.category=La categoria '%1$s' tiene opciones modificadas \:
+config.modified=Opción modificada (valor original \: %1$s)
+config.no.option.selected=< No hay opciones seleccionadas >
+config.option.final=Opción no modificable
+config.option.label=Opción '%1$s' (%2$s)
+config.option.modified=Valor modificado < valor anterior \: '%1$s' - nuevo valor \: '%2$s' >
+config.title=Preferencias
+config.title.need.confirm=Se requiere confirmación del usuario...
+config.unmodifiable=No puede ser modificado
+config.unvalid=Opción no valida (valor original \: %1$s, tipo requerido \: %2$s)
+config.value=Valor
+config.value.tip=Valor de la opción
Property changes on: trunk/jaxx-config/src/main/resources/i18n/jaxx-config_es_ES.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/main/resources/i18n/jaxx-config_fr_FR.properties
===================================================================
--- trunk/jaxx-config/src/main/resources/i18n/jaxx-config_fr_FR.properties (rev 0)
+++ trunk/jaxx-config/src/main/resources/i18n/jaxx-config_fr_FR.properties 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,33 @@
+config.action.quit=Quitter
+config.action.quit.tip=Quitter l'éditeur de configuration
+config.action.reset=Annuler
+config.action.reset.tip=Annuler les modifications de cette catégorie
+config.action.save=Enregistrer
+config.action.save.tip=Sauver les modifications de cette catégorie
+config.choice.cancel=Annuler
+config.choice.continue=Continuer
+config.choice.doNotSave=Ne pas enregistrer
+config.choice.save=Enregistrer
+config.defaultValue=Valeur par défaut
+config.defaultValue.tip=Valeur par défaut de l'option
+config.description=Description
+config.detected.callBack=Actions détectées pour les options modifiées
+config.error.category.already.exists=La catégorie de nom '%1$s' existe déjà\!
+config.error.category.not.found=La catégorie de nom '%1$s' n'existe pas\!
+config.key=Clef
+config.key.tip=Clef de l'option
+config.launch.callBack=Lancer
+config.launch.callBack.tip=Lancer les actions nécessaires
+config.message.quit.invalid.category=La catégorie '%1$s' n'est pas valide\!
+config.message.quit.valid.and.modified.category=La catégorie '%1$s' possèdent des options modifiées \:
+config.modified=Option modifiée (valeur originale \: %1$s)
+config.no.option.selected=< Pas d'option sélectionnée >
+config.option.final=Option non modifiable
+config.option.label=Option '%1$s' (%2$s)
+config.option.modified=Valeur modifiée < ancienne valeur \: '%1$s' - nouvelle valeur \: '%2$s' >
+config.title=Préférences
+config.title.need.confirm=Une confirmation de votre part est requise...
+config.unmodifiable=Ne peut pas être modifié
+config.unvalid=Option non valide (valeur originale \: %1$s, type requis \: %2$s)
+config.value=Valeur
+config.value.tip=Valeur de l'option
Property changes on: trunk/jaxx-config/src/main/resources/i18n/jaxx-config_fr_FR.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/main/resources/icons/action-add.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-config/src/main/resources/icons/action-add.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/jaxx-config/src/main/resources/icons/action-config-quit.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-config/src/main/resources/icons/action-config-quit.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/jaxx-config/src/main/resources/icons/action-config-reset.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-config/src/main/resources/icons/action-config-reset.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/jaxx-config/src/main/resources/icons/action-config-save.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-config/src/main/resources/icons/action-config-save.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/jaxx-config/src/site/rst/index.rst
===================================================================
--- trunk/jaxx-config/src/site/rst/index.rst (rev 0)
+++ trunk/jaxx-config/src/site/rst/index.rst 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,30 @@
+.. -
+.. * #%L
+.. * JAXX :: Config
+.. * $Id$
+.. * $HeadURL$
+.. * %%
+.. * Copyright (C) 2008 - 2013 CodeLutin
+.. * %%
+.. * This program is free software: you can redistribute it and/or modify
+.. * it under the terms of the GNU Lesser General Public License as
+.. * published by the Free Software Foundation, either version 3 of the
+.. * License, or (at your option) any later version.
+.. *
+.. * This program is distributed in the hope that it will be useful,
+.. * but WITHOUT ANY WARRANTY; without even the implied warranty of
+.. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+.. * GNU General Lesser Public License for more details.
+.. *
+.. * You should have received a copy of the GNU General Lesser Public
+.. * License along with this program. If not, see
+.. * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+.. * #L%
+.. -
+===========
+JAXX Config
+===========
+
+configuration editor based on applicationconfig and designed in jaxx.
+
+TODO
\ No newline at end of file
Property changes on: trunk/jaxx-config/src/site/rst/index.rst
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/site/site_fr.xml
===================================================================
--- trunk/jaxx-config/src/site/site_fr.xml (rev 0)
+++ trunk/jaxx-config/src/site/site_fr.xml 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ JAXX :: Widgets
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2008 - 2010 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+
+<project name="${project.name}">
+
+ <bannerLeft>
+ <name>${project.name}</name>
+ <src>http://maven-site.chorem.org/public/images/logos/jaxx-logo.png</src>
+ <href>index.html</href>
+ </bannerLeft>
+
+ <body>
+
+ <head>
+ <script type="text/javascript"
+ src="http://maven-site.nuiton.org/public/js/mavenpom-site.js">
+ </script>
+
+ <link rel="stylesheet" type="text/css"
+ href="http://maven-site.nuiton.org/public/css/mavenpom-site.css"/>
+ </head>
+
+ <breadcrumbs>
+ <item name="${project.name}" href="index.html"/>
+ </breadcrumbs>
+
+ <menu ref="parent"/>
+
+ <menu name="Utilisateur"/>
+
+ <menu ref="reports"/>
+
+ <menu ref="modules"/>
+
+ <footer>
+
+ <div id='projectMetas'
+ projectversion='${project.version}'
+ platform='${project.platform}'
+ projectid='${project.projectId}'
+ scm='${project.scm.developerConnection}'
+ scmwebeditorenabled='${project.scmwebeditorEnabled}'
+ scmwebeditorurl='${project.scmwebeditorUrl}'
+ siteSourcesType='${project.siteSourcesType}'
+ piwikEnabled='${project.piwikEnabled}'
+ piwikId='${project.piwikId}'>
+ </div>
+ </footer>
+
+ </body>
+</project>
Property changes on: trunk/jaxx-config/src/site/site_fr.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/test/java/jaxx/runtime/swing/config/model/MyDelegateConfig.java
===================================================================
--- trunk/jaxx-config/src/test/java/jaxx/runtime/swing/config/model/MyDelegateConfig.java (rev 0)
+++ trunk/jaxx-config/src/test/java/jaxx/runtime/swing/config/model/MyDelegateConfig.java 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,273 @@
+package jaxx.runtime.swing.config.model;
+
+/*
+ * #%L
+ * JAXX :: Config
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2013 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Supplier;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.beans.AbstractBean;
+import org.nuiton.util.config.ApplicationConfig;
+import org.nuiton.util.config.ConfigOptionDef;
+
+import java.awt.Color;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Date;
+import java.util.Locale;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * A config to test config ui api when using a delegation
+ * on {@link ApplicationConfig}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5.11
+ */
+public class MyDelegateConfig extends AbstractBean implements Supplier<ApplicationConfig> {
+
+ /** Logger */
+ private static final Log log = LogFactory.getLog(MyDelegateConfig.class);
+
+ public static final String PROPERTY_FULLSCREEN = "fullscreen";
+
+ public static final String PROPERTY_LOCALE = "locale";
+
+ public static final String PROPERTY_FONT_SIZE = "fontSize";
+
+ public static final String PROPERTY_ADJUSTING = "adjusting";
+
+ public static final String PROPERTY_DEMO_COLOR = "demoColor";
+
+ public static final String PROPERTY_DEMO_CLASS = "demoClass";
+
+ protected final ApplicationConfig applicationConfig;
+
+ public MyDelegateConfig() {
+ this.applicationConfig = new ApplicationConfig();
+
+ applicationConfig.setConfigFileName(Option.CONFIG_FILE.defaultValue);
+
+ // chargement de la configuration interne
+
+ for (Option o : Option.values()) {
+ applicationConfig.setDefaultOption(o.key, o.defaultValue);
+ }
+
+ applicationConfig.setAdjusting(true);
+ try {
+ addPropertyChangeListener(PROPERTY_FULLSCREEN, saveAction);
+ addPropertyChangeListener(PROPERTY_FONT_SIZE, saveAction);
+ addPropertyChangeListener(PROPERTY_LOCALE, saveAction);
+ addPropertyChangeListener(PROPERTY_DEMO_COLOR, saveAction);
+ addPropertyChangeListener(PROPERTY_DEMO_CLASS, saveAction);
+ } finally {
+ applicationConfig.setAdjusting(false);
+ }
+ }
+
+ protected final PropertyChangeListener saveAction = new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (isAdjusting()) {
+ if (log.isDebugEnabled()) {
+ log.debug("skip save while adjusting");
+ }
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("Saving configuration at " + new Date());
+ }
+ saveForUser();
+ }
+ }
+ };
+
+ public void saveForUser(String... excludeKeys) {
+ // never save anything :)
+ }
+
+ public boolean isFullScreen() {
+ Boolean result = applicationConfig.getOptionAsBoolean(Option.FULL_SCREEN.key);
+ return result != null && result;
+ }
+
+ public Locale getLocale() {
+ Locale result = applicationConfig.getOption(Locale.class, Option.LOCALE.key);
+ return result;
+ }
+
+ public Float getFontSize() {
+ Float result = applicationConfig.getOption(Float.class, Option.FONT_SIZE.key);
+ return result;
+ }
+
+ public Color getDemoColor() {
+ Color result = applicationConfig.getOptionAsColor(Option.DEMO_COLOR.key);
+ return result;
+ }
+
+ public Class<?> getDemoClass() {
+ Class<?> result = applicationConfig.getOptionAsClass(Option.DEMO_CLASS.key);
+ return result;
+ }
+
+ public void setFullscreen(boolean fullscreen) {
+ Object oldValue = null;
+ applicationConfig.setOption(Option.FULL_SCREEN.key, fullscreen + "");
+ firePropertyChange(PROPERTY_FULLSCREEN, oldValue, fullscreen);
+ }
+
+ public void setLocale(Locale newLocale) {
+ applicationConfig.setOption(Option.LOCALE.key, newLocale.toString());
+ firePropertyChange(PROPERTY_LOCALE, null, newLocale);
+ }
+
+ public void setFontSize(Float newFontSize) {
+ Float oldValue = getFontSize();
+ if (log.isDebugEnabled()) {
+ log.debug("changing font-size to " + newFontSize);
+ }
+ applicationConfig.setOption(Option.FONT_SIZE.key, newFontSize.toString());
+ firePropertyChange(PROPERTY_FONT_SIZE, oldValue, newFontSize);
+ }
+
+ public void setDemoColor(Color color) {
+ Color oldValue = getDemoColor();
+ if (log.isDebugEnabled()) {
+ log.debug("changing demo-color to " + color);
+ }
+ applicationConfig.setOption(Option.DEMO_COLOR.key, color.toString());
+ firePropertyChange(PROPERTY_DEMO_COLOR, oldValue, color);
+ }
+
+ public void setDemoClass(Class<?> newClass) {
+ Class<?> oldValue = getDemoClass();
+ if (log.isDebugEnabled()) {
+ log.debug("changing demo-class to " + newClass);
+ }
+ applicationConfig.setOption(Option.DEMO_CLASS.key, newClass.getName());
+ firePropertyChange(PROPERTY_DEMO_CLASS, oldValue, newClass);
+ }
+
+ public boolean isAdjusting() {
+ return applicationConfig.isAdjusting();
+ }
+
+ public void setAdjusting(boolean adjusting) {
+ applicationConfig.setAdjusting(adjusting);
+ }
+
+ @Override
+ public ApplicationConfig get() {
+ return applicationConfig;
+ }
+
+ //////////////////////////////////////////////////
+ // Toutes les options disponibles
+ //////////////////////////////////////////////////
+
+ public enum Option implements ConfigOptionDef {
+
+ CONFIG_FILE(ApplicationConfig.CONFIG_FILE_NAME, _("jaxxdemo.config.configFileName.description"), "jaxxdemo", String.class, true, true),
+ FULL_SCREEN("ui.fullscreen", _("jaxxdemo.config.ui.fullscreen"), "false", Boolean.class, false, false),
+ LOCALE("ui." + PROPERTY_LOCALE, _("jaxxdemo.config.ui." + PROPERTY_LOCALE), Locale.FRANCE.toString(), Locale.class, false, false),
+ FONT_SIZE("ui." + PROPERTY_FONT_SIZE, _("jaxxdemo.config.ui." + PROPERTY_FONT_SIZE), "10f", Float.class, false, false),
+ DEMO_COLOR("ui." + PROPERTY_DEMO_COLOR, _("jaxxdemo.config.ui.demoColor"), "#ffffff", Color.class, false, false),
+ DEMO_CLASS("ui." + PROPERTY_DEMO_CLASS, _("jaxxdemo.config.ui.demoClass"), "java.io.File", Class.class, false, false);
+
+ public final String key;
+
+ public final String description;
+
+ public String defaultValue;
+
+ public final Class<?> type;
+
+ public boolean _transient;
+
+ public boolean _final;
+
+ Option(String key,
+ String description,
+ String defaultValue,
+ Class<?> type,
+ boolean _transient,
+ boolean _final) {
+ this.key = key;
+ this.description = description;
+ this.defaultValue = defaultValue;
+ this.type = type;
+ this._final = _final;
+ this._transient = _transient;
+ }
+
+ @Override
+ public boolean isFinal() {
+ return _final;
+ }
+
+ @Override
+ public void setDefaultValue(String defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ @Override
+ public void setTransient(boolean _transient) {
+ this._transient = _transient;
+ }
+
+ @Override
+ public void setFinal(boolean _final) {
+ this._final = _final;
+ }
+
+ @Override
+ public boolean isTransient() {
+ return _transient;
+ }
+
+ @Override
+ public String getDefaultValue() {
+ return defaultValue;
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public String getKey() {
+ return key;
+ }
+
+ @Override
+ public Class<?> getType() {
+ return type;
+ }
+ }
+}
+
Property changes on: trunk/jaxx-config/src/test/java/jaxx/runtime/swing/config/model/MyDelegateConfig.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/test/java/jaxx/runtime/swing/config/model/MyDelegateConfigTest.java
===================================================================
--- trunk/jaxx-config/src/test/java/jaxx/runtime/swing/config/model/MyDelegateConfigTest.java (rev 0)
+++ trunk/jaxx-config/src/test/java/jaxx/runtime/swing/config/model/MyDelegateConfigTest.java 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,331 @@
+package jaxx.runtime.swing.config.model;
+
+/*
+ * #%L
+ * JAXX :: Config
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2013 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import jaxx.runtime.SwingUtil;
+import jaxx.runtime.swing.editor.MyDefaultCellEditor;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.nuiton.util.config.ApplicationConfig;
+
+import javax.swing.ImageIcon;
+import javax.swing.table.TableCellEditor;
+import java.awt.Color;
+import java.io.File;
+import java.util.Collection;
+
+/**
+ * To test ConfigUI api on {@link MyDelegateConfig}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5.11
+ */
+public class MyDelegateConfigTest {
+
+
+ public static final String CATEGORY = "cat0";
+
+ protected ConfigUIModelBuilder builder;
+
+ protected MyDelegateConfig config;
+
+ @Before
+ public void setup() {
+ config = new MyDelegateConfig();
+ builder = new ConfigUIModelBuilder();
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testCreateModelLimitCase0() throws Exception {
+ builder.createModel((ApplicationConfig) null);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testFlushModelLimitCase0() throws Exception {
+ builder.flushModel();
+ }
+
+ @Test
+ public void testCreateModel() throws Exception {
+ builder.createModel(config);
+ ConfigUIModel configModel = builder.flushModel();
+ Assert.assertNotNull(configModel);
+ Assert.assertNotNull(configModel.getApplicationConfig());
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testRegisterCallbackLimitCase() throws Exception {
+ builder.registerCallBack(null, null, null, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testRegisterCallbackLimitCase0() throws Exception {
+ builder.createModel(config);
+ builder.registerCallBack(null, null, null, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testRegisterCallbackLimitCase1() throws Exception {
+ builder.createModel(config);
+ builder.registerCallBack("yo", null, null, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testRegisterCallbackLimitCase2() throws Exception {
+ builder.createModel(config);
+ builder.registerCallBack("yo", "yo description", null, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testRegisterCallbackLimitCase4() throws Exception {
+ builder.createModel(config);
+ Runnable callback = new Runnable() {
+
+ @Override
+ public void run() {
+ }
+ };
+ builder.registerCallBack("yo", "yo description", null, callback);
+ }
+
+ @Test
+ public void testRegisterCallback() throws Exception {
+ builder.createModel(config);
+ Runnable callback = new Runnable() {
+
+ @Override
+ public void run() {
+ }
+ };
+ ImageIcon icon = SwingUtil.createActionIcon("add");
+ builder.registerCallBack("yo", "yo description", icon, callback);
+ ConfigUIModel configModel = builder.flushModel();
+ Assert.assertNotNull(configModel);
+ Assert.assertNotNull(configModel.getApplicationConfig());
+ CallBackEntry callBackEntry =
+ configModel.getCallBacksManager().getCallBack("yo");
+ Assert.assertNotNull(callBackEntry);
+
+ Assert.assertEquals(callback, callBackEntry.getAction());
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testAddCategoryLimitCase0() throws Exception {
+ builder.addCategory(null, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testAddCategoryLimitCase1() throws Exception {
+ builder.createModel(config);
+ builder.addCategory(null, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testAddCategoryLimitCase2() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("", null);
+ }
+
+ @Test
+ public void testAddCategory() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ CategoryModel categoryModel = builder.flushCategory();
+ Assert.assertNotNull(categoryModel);
+ Assert.assertEquals("cat0", categoryModel.category);
+ Assert.assertEquals("cat0 label", categoryModel.categoryLabel);
+ Assert.assertEquals(0, categoryModel.entries.size());
+
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testAddOptionLimitCase0() throws Exception {
+ builder.addOption(null);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testAddOptionLimitCase1() throws Exception {
+ builder.createModel(config);
+ builder.addOption(null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testAddOptionLimitCase2() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.addOption(null);
+ }
+
+ @Test
+ public void testAddOption() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.addOption(MyDelegateConfig.Option.LOCALE);
+ OptionModel optionModel = builder.flushOption();
+ Assert.assertNotNull(optionModel);
+ Assert.assertEquals(MyDelegateConfig.Option.LOCALE, optionModel.def);
+
+ CategoryModel categoryModel = builder.flushCategory();
+ Assert.assertNotNull(categoryModel);
+ Assert.assertEquals("cat0", categoryModel.category);
+ Assert.assertEquals("cat0 label", categoryModel.categoryLabel);
+ Assert.assertEquals(1, categoryModel.entries.size());
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionPropertyNameLimitCase0() throws Exception {
+ builder.setOptionPropertyName(null);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionPropertyNameLimitCase1() throws Exception {
+ builder.createModel(config);
+ builder.setOptionPropertyName(null);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionPropertyNameLimitCase2() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.setOptionPropertyName(null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testSetOptionPropertyNameLimitCase3() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.addOption(MyDelegateConfig.Option.LOCALE);
+ builder.setOptionPropertyName(null);
+ }
+
+ @Test
+ public void testSetOptionPropertyName() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.addOption(MyDelegateConfig.Option.LOCALE);
+ builder.setOptionPropertyName(MyDelegateConfig.PROPERTY_LOCALE);
+ OptionModel optionModel = builder.flushOption();
+ Assert.assertNotNull(optionModel);
+ Assert.assertEquals(MyDelegateConfig.Option.LOCALE, optionModel.def);
+ Assert.assertEquals(MyDelegateConfig.PROPERTY_LOCALE, optionModel.propertyName);
+ Assert.assertNull(optionModel.editor);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionEditorLimitCase0() throws Exception {
+ builder.setOptionEditor(null);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionEditorLimitCase1() throws Exception {
+ builder.createModel(config);
+ builder.setOptionEditor(null);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionEditorLimitCase2() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.setOptionEditor(null);
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void testSetOptionEditorLimitCase3() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.addOption(MyDelegateConfig.Option.LOCALE);
+ builder.setOptionEditor(null);
+ }
+
+ @Test
+ public void testSetOptionEditor() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.addOption(MyDelegateConfig.Option.LOCALE);
+ TableCellEditor cellEditor = MyDefaultCellEditor.newBooleanEditor();
+ builder.setOptionEditor(cellEditor);
+ OptionModel optionModel = builder.flushOption();
+ Assert.assertNotNull(optionModel);
+ Assert.assertEquals(MyDelegateConfig.Option.LOCALE, optionModel.def);
+ Assert.assertNull(optionModel.propertyName);
+ Assert.assertEquals(cellEditor, optionModel.editor);
+ }
+
+ @Test
+ public void testFlushModel() throws Exception {
+ builder.createModel(config);
+ ConfigUIModel configModel = builder.flushModel();
+ Assert.assertNotNull(configModel);
+ Assert.assertNull(builder.model);
+ }
+
+ @Test
+ public void testSaveClassOption() throws Exception {
+ builder.createModel(config);
+ builder.addCategory(CATEGORY, "cat0 label");
+ builder.addOption(MyDelegateConfig.Option.DEMO_CLASS, MyDelegateConfig.PROPERTY_DEMO_CLASS);
+ ConfigUIModel configModel = builder.flushModel();
+ configModel.setCategory(CATEGORY);
+
+ CategoryModel categoryModel = configModel.getCategoryModel();
+ Assert.assertNotNull(categoryModel);
+
+ OptionModel optionModel = categoryModel.getOptionModel(MyDelegateConfig.Option.DEMO_CLASS.getKey());
+ Assert.assertNotNull(optionModel);
+
+ categoryModel.setValue(optionModel, Collection.class);
+
+ Assert.assertEquals(File.class, config.getDemoClass());
+
+ configModel.saveModified();
+
+ Assert.assertEquals(Collection.class, config.getDemoClass());
+ }
+
+ @Test
+ public void testSaveColorOption() throws Exception {
+ builder.createModel(config);
+ builder.addCategory(CATEGORY, "cat0 label");
+ builder.addOption(MyDelegateConfig.Option.DEMO_COLOR);
+ ConfigUIModel configModel = builder.flushModel();
+ configModel.setCategory(CATEGORY);
+
+ CategoryModel categoryModel = configModel.getCategoryModel();
+ Assert.assertNotNull(categoryModel);
+
+ OptionModel optionModel = categoryModel.getOptionModel(MyDelegateConfig.Option.DEMO_COLOR.getKey());
+ Assert.assertNotNull(optionModel);
+
+ Color newColor = new Color(0, 0, 0);
+ categoryModel.setValue(optionModel, newColor);
+
+ Assert.assertFalse(newColor.equals(config.getDemoColor()));
+
+ configModel.saveModified();
+ Assert.assertEquals(newColor, config.getDemoColor());
+ }
+}
Property changes on: trunk/jaxx-config/src/test/java/jaxx/runtime/swing/config/model/MyDelegateConfigTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/test/java/jaxx/runtime/swing/config/model/MyInheritedConfig.java
===================================================================
--- trunk/jaxx-config/src/test/java/jaxx/runtime/swing/config/model/MyInheritedConfig.java (rev 0)
+++ trunk/jaxx-config/src/test/java/jaxx/runtime/swing/config/model/MyInheritedConfig.java 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,284 @@
+package jaxx.runtime.swing.config.model;
+
+/*
+ * #%L
+ * JAXX :: Config
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2013 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.config.ApplicationConfig;
+import org.nuiton.util.config.ConfigOptionDef;
+
+import java.awt.Color;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Date;
+import java.util.Locale;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * A config to test config ui api when using a delegation
+ * on {@link ApplicationConfig}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5.11
+ */
+public class MyInheritedConfig extends ApplicationConfig {
+
+ /** Logger */
+ private static final Log log = LogFactory.getLog(MyInheritedConfig.class);
+
+ public static final String PROPERTY_FULLSCREEN = "fullscreen";
+
+ public static final String PROPERTY_LOCALE = "locale";
+
+ public static final String PROPERTY_FONT_SIZE = "fontSize";
+
+ public static final String PROPERTY_ADJUSTING = "adjusting";
+
+ public static final String PROPERTY_DEMO_COLOR = "demoColor";
+
+ public static final String PROPERTY_DEMO_CLASS = "demoClass";
+
+// /**
+// * un drapeau pour bloquer la sauvegarde lors de la modification en masse des options
+// * via les setter.
+// */
+// protected boolean adjusting;
+
+ protected final PropertyChangeListener saveAction = new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (isAdjusting()) {
+ if (log.isDebugEnabled()) {
+ log.debug("skip save while adjusting");
+ }
+ return;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Saving configuration at " + new Date());
+ }
+ saveForUser();
+ }
+ };
+
+ @Override
+ public void saveForUser(String... excludeKeys) {
+ // never save anything :)
+ }
+
+ public MyInheritedConfig() {
+
+ setConfigFileName(Option.CONFIG_FILE.defaultValue);
+
+ // chargement de la configuration interne
+
+ for (Option o : Option.values()) {
+ setDefaultOption(o.key, o.defaultValue);
+ }
+
+ setAdjusting(true);
+ try {
+ addPropertyChangeListener(PROPERTY_FULLSCREEN, saveAction);
+ addPropertyChangeListener(PROPERTY_FONT_SIZE, saveAction);
+ addPropertyChangeListener(PROPERTY_LOCALE, saveAction);
+ addPropertyChangeListener(PROPERTY_DEMO_COLOR, saveAction);
+ addPropertyChangeListener(PROPERTY_DEMO_CLASS, saveAction);
+ } finally {
+ setAdjusting(false);
+ }
+ }
+
+ @Override
+ public void setOption(String key, String value) {
+ if (key.equals(PROPERTY_ADJUSTING)) {
+ setAdjusting(Boolean.valueOf(value));
+ return;
+ }
+ super.setOption(key, value);
+ }
+
+
+ public boolean isFullScreen() {
+ Boolean result = getOptionAsBoolean(Option.FULL_SCREEN.key);
+ return result != null && result;
+ }
+
+ public Locale getLocale() {
+ Locale result = getOption(Locale.class, Option.LOCALE.key);
+ return result;
+ }
+
+ public Float getFontSize() {
+ Float result = getOption(Float.class, Option.FONT_SIZE.key);
+ return result;
+ }
+
+ public Color getDemoColor() {
+ Color result = getOptionAsColor(Option.DEMO_COLOR.key);
+ return result;
+ }
+
+ public Class<?> getDemoClass() {
+ Class<?> result = getOptionAsClass(Option.DEMO_CLASS.key);
+ return result;
+ }
+
+ public void setFullscreen(boolean fullscreen) {
+ Object oldValue = null;
+ setOption(Option.FULL_SCREEN.key, fullscreen + "");
+ firePropertyChange(PROPERTY_FULLSCREEN, oldValue, fullscreen);
+ }
+
+ public void setLocale(Locale newLocale) {
+ setOption(Option.LOCALE.key, newLocale.toString());
+ firePropertyChange(PROPERTY_LOCALE, null, newLocale);
+ }
+
+ public void setFontSize(Float newFontSize) {
+ Float oldValue = getFontSize();
+ if (log.isDebugEnabled()) {
+ log.debug("changing font-size to " + newFontSize);
+ }
+ setOption(Option.FONT_SIZE.key, newFontSize.toString());
+ firePropertyChange(PROPERTY_FONT_SIZE, oldValue, newFontSize);
+ }
+
+ public void setDemoColor(Color color) {
+ Color oldValue = getDemoColor();
+ if (log.isDebugEnabled()) {
+ log.debug("changing demo-color to " + color);
+ }
+ setOption(Option.DEMO_COLOR.key, color.toString());
+ firePropertyChange(PROPERTY_DEMO_COLOR, oldValue, color);
+ }
+
+ public void setDemoClass(Class<?> newClass) {
+ Class<?> oldValue = getDemoClass();
+ if (log.isDebugEnabled()) {
+ log.debug("changing demo-class to " + newClass);
+ }
+ setOption(Option.DEMO_CLASS.key, newClass.getName());
+ firePropertyChange(PROPERTY_DEMO_CLASS, oldValue, newClass);
+ }
+
+// public boolean isAdjusting() {
+// return adjusting;
+// }
+//
+// public void setAdjusting(boolean adjusting) {
+// if (log.isDebugEnabled()) {
+// log.debug("changing adjusting to " + adjusting);
+// }
+// boolean oldValue = this.adjusting;
+// this.adjusting = adjusting;
+// firePropertyChange(PROPERTY_ADJUSTING, oldValue, adjusting);
+// }
+
+ //////////////////////////////////////////////////
+ // Toutes les options disponibles
+ //////////////////////////////////////////////////
+
+ public enum Option implements ConfigOptionDef {
+
+ CONFIG_FILE(CONFIG_FILE_NAME, _("jaxxdemo.config.configFileName.description"), "jaxxdemo", String.class, true, true),
+ FULL_SCREEN("ui.fullscreen", _("jaxxdemo.config.ui.fullscreen"), "false", Boolean.class, false, false),
+ LOCALE("ui." + PROPERTY_LOCALE, _("jaxxdemo.config.ui." + PROPERTY_LOCALE), Locale.FRANCE.toString(), Locale.class, false, false),
+ FONT_SIZE("ui." + PROPERTY_FONT_SIZE, _("jaxxdemo.config.ui." + PROPERTY_FONT_SIZE), "10f", Float.class, false, false),
+ DEMO_COLOR("ui." + PROPERTY_DEMO_COLOR, _("jaxxdemo.config.ui.demoColor"), "#ffffff", Color.class, false, false),
+ DEMO_CLASS("ui." + PROPERTY_DEMO_CLASS, _("jaxxdemo.config.ui.demoClass"), "java.io.File", Class.class, false, false);
+
+ public final String key;
+
+ public final String description;
+
+ public String defaultValue;
+
+ public final Class<?> type;
+
+ public boolean _transient;
+
+ public boolean _final;
+
+ Option(String key,
+ String description,
+ String defaultValue,
+ Class<?> type,
+ boolean _transient,
+ boolean _final) {
+ this.key = key;
+ this.description = description;
+ this.defaultValue = defaultValue;
+ this.type = type;
+ this._final = _final;
+ this._transient = _transient;
+ }
+
+ @Override
+ public boolean isFinal() {
+ return _final;
+ }
+
+ @Override
+ public void setDefaultValue(String defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ @Override
+ public void setTransient(boolean _transient) {
+ this._transient = _transient;
+ }
+
+ @Override
+ public void setFinal(boolean _final) {
+ this._final = _final;
+ }
+
+ @Override
+ public boolean isTransient() {
+ return _transient;
+ }
+
+ @Override
+ public String getDefaultValue() {
+ return defaultValue;
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public String getKey() {
+ return key;
+ }
+
+ @Override
+ public Class<?> getType() {
+ return type;
+ }
+ }
+}
Property changes on: trunk/jaxx-config/src/test/java/jaxx/runtime/swing/config/model/MyInheritedConfig.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/test/java/jaxx/runtime/swing/config/model/MyInheritedConfigTest.java
===================================================================
--- trunk/jaxx-config/src/test/java/jaxx/runtime/swing/config/model/MyInheritedConfigTest.java (rev 0)
+++ trunk/jaxx-config/src/test/java/jaxx/runtime/swing/config/model/MyInheritedConfigTest.java 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,341 @@
+package jaxx.runtime.swing.config.model;
+
+/*
+ * #%L
+ * JAXX :: Config
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2013 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import jaxx.runtime.SwingUtil;
+import jaxx.runtime.swing.editor.MyDefaultCellEditor;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.nuiton.util.config.ApplicationConfig;
+
+import javax.swing.ImageIcon;
+import javax.swing.table.TableCellEditor;
+import java.awt.Color;
+import java.io.File;
+import java.util.Collection;
+
+/**
+ * To test ConfigUI api on {@link MyInheritedConfig}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5.11
+ */
+public class MyInheritedConfigTest {
+
+ public static final String CATEGORY = "cat0";
+
+ protected ConfigUIModelBuilder builder;
+
+ protected MyInheritedConfig config;
+
+ @Before
+ public void setup() {
+ config = new MyInheritedConfig();
+ builder = new ConfigUIModelBuilder();
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testCreateModelLimitCase0() throws Exception {
+ builder.createModel((ApplicationConfig) null);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testFlushModelLimitCase0() throws Exception {
+ builder.flushModel();
+ }
+
+ @Test
+ public void testCreateModel() throws Exception {
+ builder.createModel(config);
+ ConfigUIModel configModel = builder.flushModel();
+ Assert.assertNotNull(configModel);
+ Assert.assertNotNull(configModel.getApplicationConfig());
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testRegisterCallbackLimitCase() throws Exception {
+ builder.registerCallBack(null, null, null, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testRegisterCallbackLimitCase0() throws Exception {
+ builder.createModel(config);
+ builder.registerCallBack(null, null, null, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testRegisterCallbackLimitCase1() throws Exception {
+ builder.createModel(config);
+ builder.registerCallBack("yo", null, null, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testRegisterCallbackLimitCase2() throws Exception {
+ builder.createModel(config);
+ builder.registerCallBack("yo", "yo description", null, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testRegisterCallbackLimitCase4() throws Exception {
+ builder.createModel(config);
+ Runnable callback = new Runnable() {
+
+ @Override
+ public void run() {
+ }
+ };
+ builder.registerCallBack("yo", "yo description", null, callback);
+ }
+
+ @Test
+ public void testRegisterCallback() throws Exception {
+ builder.createModel(config);
+ Runnable callback = new Runnable() {
+
+ @Override
+ public void run() {
+ }
+ };
+ ImageIcon icon = SwingUtil.createActionIcon("add");
+ builder.registerCallBack("yo", "yo description", icon, callback);
+ ConfigUIModel configModel = builder.flushModel();
+ Assert.assertNotNull(configModel);
+ Assert.assertNotNull(configModel.getApplicationConfig());
+ CallBackEntry callBackEntry =
+ configModel.getCallBacksManager().getCallBack("yo");
+ Assert.assertNotNull(callBackEntry);
+
+ Assert.assertEquals(callback, callBackEntry.getAction());
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testAddCategoryLimitCase0() throws Exception {
+ builder.addCategory(null, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testAddCategoryLimitCase1() throws Exception {
+ builder.createModel(config);
+ builder.addCategory(null, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testAddCategoryLimitCase2() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("", null);
+ }
+
+ @Test
+ public void testAddCategory() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ CategoryModel categoryModel = builder.flushCategory();
+ Assert.assertNotNull(categoryModel);
+ Assert.assertEquals("cat0", categoryModel.category);
+ Assert.assertEquals("cat0 label", categoryModel.categoryLabel);
+ Assert.assertEquals(0, categoryModel.entries.size());
+
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testAddOptionLimitCase0() throws Exception {
+ builder.addOption(null);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testAddOptionLimitCase1() throws Exception {
+ builder.createModel(config);
+ builder.addOption(null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testAddOptionLimitCase2() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.addOption(null);
+ }
+
+ @Test
+ public void testAddOption() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.addOption(MyInheritedConfig.Option.LOCALE);
+ OptionModel optionModel = builder.flushOption();
+ Assert.assertNotNull(optionModel);
+ Assert.assertEquals(MyInheritedConfig.Option.LOCALE, optionModel.def);
+
+ CategoryModel categoryModel = builder.flushCategory();
+ Assert.assertNotNull(categoryModel);
+ Assert.assertEquals("cat0", categoryModel.category);
+ Assert.assertEquals("cat0 label", categoryModel.categoryLabel);
+ Assert.assertEquals(1, categoryModel.entries.size());
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionPropertyNameLimitCase0() throws Exception {
+ builder.setOptionPropertyName(null);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionPropertyNameLimitCase1() throws Exception {
+ builder.createModel(config);
+ builder.setOptionPropertyName(null);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionPropertyNameLimitCase2() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.setOptionPropertyName(null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testSetOptionPropertyNameLimitCase3() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.addOption(MyInheritedConfig.Option.LOCALE);
+ builder.setOptionPropertyName(null);
+ }
+
+ @Test
+ public void testSetOptionPropertyName() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.addOption(MyInheritedConfig.Option.LOCALE);
+ builder.setOptionPropertyName(MyInheritedConfig.PROPERTY_LOCALE);
+ OptionModel optionModel = builder.flushOption();
+ Assert.assertNotNull(optionModel);
+ Assert.assertEquals(MyInheritedConfig.Option.LOCALE, optionModel.def);
+ Assert.assertEquals(MyInheritedConfig.PROPERTY_LOCALE, optionModel.propertyName);
+ Assert.assertNull(optionModel.editor);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionEditorLimitCase0() throws Exception {
+ builder.setOptionEditor(null);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionEditorLimitCase1() throws Exception {
+ builder.createModel(config);
+ builder.setOptionEditor(null);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionEditorLimitCase2() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.setOptionEditor(null);
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void testSetOptionEditorLimitCase3() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.addOption(MyInheritedConfig.Option.LOCALE);
+ builder.setOptionEditor(null);
+ }
+
+ @Test
+ public void testSetOptionEditor() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.addOption(MyInheritedConfig.Option.LOCALE);
+ TableCellEditor cellEditor = MyDefaultCellEditor.newBooleanEditor();
+ builder.setOptionEditor(cellEditor);
+ OptionModel optionModel = builder.flushOption();
+ Assert.assertNotNull(optionModel);
+ Assert.assertEquals(MyInheritedConfig.Option.LOCALE, optionModel.def);
+ Assert.assertNull(optionModel.propertyName);
+ Assert.assertEquals(cellEditor, optionModel.editor);
+ }
+
+ @Test
+ public void testFlushModel() throws Exception {
+ builder.createModel(config);
+ ConfigUIModel configModel = builder.flushModel();
+ Assert.assertNotNull(configModel);
+ Assert.assertNull(builder.model);
+ }
+
+ @Test
+ public void testSetModel() throws Exception {
+
+ }
+
+ @Test
+ public void testSetCategory() throws Exception {
+ }
+
+ @Test
+ public void testSetOption() throws Exception {
+ }
+
+ @Test
+ public void testSaveClassOption() throws Exception {
+ builder.createModel(config);
+ builder.addCategory(CATEGORY, "cat0 label");
+ builder.addOption(MyDelegateConfig.Option.DEMO_CLASS, MyDelegateConfig.PROPERTY_DEMO_CLASS);
+ ConfigUIModel configModel = builder.flushModel();
+ configModel.setCategory(CATEGORY);
+ CategoryModel categoryModel = configModel.getCategoryModel();
+ Assert.assertNotNull(categoryModel);
+
+ OptionModel optionModel = categoryModel.getOptionModel(MyDelegateConfig.Option.DEMO_CLASS.getKey());
+ Assert.assertNotNull(optionModel);
+
+ categoryModel.setValue(optionModel, Collection.class);
+
+ Assert.assertEquals(File.class, config.getDemoClass());
+
+ configModel.saveModified();
+ Assert.assertEquals(Collection.class, config.getDemoClass());
+ }
+
+ @Test
+ public void testSaveColorOption() throws Exception {
+ builder.createModel(config);
+ builder.addCategory(CATEGORY, "cat0 label");
+ builder.addOption(MyDelegateConfig.Option.DEMO_COLOR);
+ ConfigUIModel configModel = builder.flushModel();
+ configModel.setCategory(CATEGORY);
+
+ CategoryModel categoryModel = configModel.getCategoryModel();
+ Assert.assertNotNull(categoryModel);
+
+ OptionModel optionModel = categoryModel.getOptionModel(MyDelegateConfig.Option.DEMO_COLOR.getKey());
+ Assert.assertNotNull(optionModel);
+
+ Color newColor = new Color(0, 0, 0);
+ categoryModel.setValue(optionModel, newColor);
+
+ Assert.assertFalse(newColor.equals(config.getDemoColor()));
+
+ configModel.saveModified();
+ Assert.assertEquals(newColor, config.getDemoColor());
+ }
+}
Property changes on: trunk/jaxx-config/src/test/java/jaxx/runtime/swing/config/model/MyInheritedConfigTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-config/src/test/resources/log4j.properties
===================================================================
--- trunk/jaxx-config/src/test/resources/log4j.properties (rev 0)
+++ trunk/jaxx-config/src/test/resources/log4j.properties 2013-03-03 15:33:39 UTC (rev 2586)
@@ -0,0 +1,34 @@
+###
+# #%L
+# JAXX :: Widgets
+#
+# $Id$
+# $HeadURL$
+# %%
+# Copyright (C) 2008 - 2010 CodeLutin
+# %%
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Lesser Public License for more details.
+#
+# You should have received a copy of the GNU General Lesser Public
+# License along with this program. If not, see
+# <http://www.gnu.org/licenses/lgpl-3.0.html>.
+# #L%
+###
+# Global logging configuration
+log4j.rootLogger=ERROR, 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.jaxx.swing=INFO
+#log4j.logger.jaxx.runtime.swing.editor.config.model.ConfigUIModelBuilder=DEBUG
+log4j.logger.org.nuiton=WARN
Property changes on: trunk/jaxx-config/src/test/resources/log4j.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/jaxx-demo/pom.xml
===================================================================
--- trunk/jaxx-demo/pom.xml 2013-03-03 15:21:26 UTC (rev 2585)
+++ trunk/jaxx-demo/pom.xml 2013-03-03 15:33:39 UTC (rev 2586)
@@ -64,6 +64,12 @@
</dependency>
<dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-config</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.nuiton.i18n</groupId>
<artifactId>nuiton-i18n</artifactId>
</dependency>
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java 2013-03-03 15:21:26 UTC (rev 2585)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java 2013-03-03 15:33:39 UTC (rev 2586)
@@ -31,10 +31,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.beans.AbstractBean;
-import org.nuiton.util.ApplicationConfig;
-import org.nuiton.util.ArgumentsParserException;
+import org.nuiton.util.config.ApplicationConfig;
+import org.nuiton.util.config.ArgumentsParserException;
import org.nuiton.util.Version;
import org.nuiton.util.VersionUtil;
+import org.nuiton.util.config.ConfigOptionDef;
import javax.swing.KeyStroke;
import java.awt.Color;
@@ -361,7 +362,7 @@
// Toutes les options disponibles
//////////////////////////////////////////////////
- public enum Option implements ApplicationConfig.OptionDef {
+ public enum Option implements ConfigOptionDef {
CONFIG_FILE(
ApplicationConfig.CONFIG_FILE_NAME,
@@ -506,6 +507,5 @@
return type;
}
-
}
}
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2013-03-03 15:21:26 UTC (rev 2585)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2013-03-03 15:33:39 UTC (rev 2586)
@@ -1,33 +1,15 @@
+package jaxx.demo;
+
/*
* #%L
* JAXX :: Demo
- *
+ *
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2010 CodeLutin
+ * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-/**
- * *##%
- * JAXX Demo
- * Copyright (C) 2008 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
@@ -40,9 +22,8 @@
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%*
+ * #L%
*/
-package jaxx.demo;
import jaxx.demo.tree.DemoNode;
import jaxx.demo.tree.DemoTreeHelper;
@@ -54,7 +35,7 @@
import jaxx.runtime.context.JAXXInitialContext;
import jaxx.runtime.swing.AboutPanel;
import jaxx.runtime.swing.ErrorDialogUI;
-import jaxx.runtime.swing.editor.config.ConfigUIHelper;
+import jaxx.runtime.swing.config.ConfigUIHelper;
import jaxx.runtime.swing.log.JAXXLog4jUI;
import jaxx.runtime.swing.renderer.DecoratorProviderListCellRenderer;
import org.apache.commons.logging.Log;
Property changes on: trunk/jaxx-demo/src/main/resources/jaxx/demo/images/jim.jpg
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/jaxx-demo/src/main/resources/jaxx/demo/images/joker.jpg
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/jaxx-runtime/pom.xml
===================================================================
--- trunk/jaxx-runtime/pom.xml 2013-03-03 15:21:26 UTC (rev 2585)
+++ trunk/jaxx-runtime/pom.xml 2013-03-03 15:33:39 UTC (rev 2586)
@@ -51,6 +51,11 @@
</dependency>
<dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</dependency>
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/ComponentMover.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/ComponentMover.java 2013-03-03 15:21:26 UTC (rev 2585)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/ComponentMover.java 2013-03-03 15:33:39 UTC (rev 2586)
@@ -3,8 +3,8 @@
/*
* #%L
* Tutti :: UI
- * $Id: ComponentMover.java 70 2012-12-14 23:13:54Z tchemit $
- * $HeadURL: http://svn.forge.codelutin.com/svn/tutti/trunk/tutti-ui-swing/src/main/java… $
+ * $Id$
+ * $HeadURL$
* %%
* Copyright (C) 2012 Ifremer
* %%
Property changes on: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/ComponentMover.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/ComponentResizer.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/ComponentResizer.java 2013-03-03 15:21:26 UTC (rev 2585)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/ComponentResizer.java 2013-03-03 15:33:39 UTC (rev 2586)
@@ -3,8 +3,8 @@
/*
* #%L
* Tutti :: UI
- * $Id: ComponentResizer.java 70 2012-12-14 23:13:54Z tchemit $
- * $HeadURL: http://svn.forge.codelutin.com/svn/tutti/trunk/tutti-ui-swing/src/main/java… $
+ * $Id$
+ * $HeadURL$
* %%
* Copyright (C) 2012 Ifremer
* %%
Property changes on: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/ComponentResizer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/model/JaxxFilterableListModel.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/model/JaxxFilterableListModel.java 2013-03-03 15:21:26 UTC (rev 2585)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/model/JaxxFilterableListModel.java 2013-03-03 15:33:39 UTC (rev 2586)
@@ -1,5 +1,29 @@
package jaxx.runtime.swing.model;
+/*
+ * #%L
+ * JAXX :: Runtime
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2013 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
import com.google.common.base.Predicate;
import com.google.common.collect.Lists;
import java.util.ArrayList;
Property changes on: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/model/JaxxFilterableListModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Property changes on: trunk/jaxx-validator/src/main/resources/icons/action-alert-error.png
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/jaxx-validator/src/main/resources/icons/action-alert-info.png
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/jaxx-validator/src/main/resources/icons/action-alert-none.png
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/jaxx-validator/src/main/resources/icons/action-alert-warning.png
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/cell/NumberCellEditor.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/cell/NumberCellEditor.java 2013-03-03 15:21:26 UTC (rev 2585)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/cell/NumberCellEditor.java 2013-03-03 15:33:39 UTC (rev 2586)
@@ -7,16 +7,16 @@
* Copyright (C) 2008 - 2012 CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
+ *
+ * You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* #L%
Property changes on: trunk/jaxx-widgets/src/main/resources/icons/action-filter.png
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-03-03 15:21:26 UTC (rev 2585)
+++ trunk/pom.xml 2013-03-03 15:33:39 UTC (rev 2586)
@@ -42,6 +42,7 @@
<module>jaxx-compiler</module>
<module>jaxx-maven-plugin</module>
<module>jaxx-widgets</module>
+ <module>jaxx-config</module>
</modules>
<developers>
@@ -111,7 +112,7 @@
<!-- pour un muli module on doit fixer le projectId -->
<projectId>jaxx</projectId>
- <nuitonUtilsVersion>2.6.9</nuitonUtilsVersion>
+ <nuitonUtilsVersion>2.6.10-SNAPSHOT</nuitonUtilsVersion>
<nuitonI18nVersion>2.5</nuitonI18nVersion>
<eugeneVersion>2.6</eugeneVersion>
<jxLayerVersion>3.0.4</jxLayerVersion>
@@ -156,6 +157,12 @@
<dependency>
<groupId>org.nuiton</groupId>
+ <artifactId>nuiton-config</artifactId>
+ <version>${nuitonUtilsVersion}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.nuiton</groupId>
<artifactId>nuiton-validator</artifactId>
<version>${nuitonUtilsVersion}</version>
</dependency>
1
0
r2585 - in trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config: . model
by tchemit@users.nuiton.org 03 Mar '13
by tchemit@users.nuiton.org 03 Mar '13
03 Mar '13
Author: tchemit
Date: 2013-03-03 16:21:26 +0100 (Sun, 03 Mar 2013)
New Revision: 2585
Url: http://nuiton.org/projects/jaxx/repository/revisions/2585
Log:
fixes #2556: Deprecates ConfigUI (using old applicationconfig api)
Modified:
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCallBackUIHandler.java
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUIHandler.java
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableEditor.java
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableRenderer.java
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIHandler.java
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIHelper.java
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CallBackEntry.java
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CallBackFinalizer.java
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CallBackMap.java
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CallBacksManager.java
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigTableModel.java
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilder.java
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/MainCallBackFinalizer.java
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCallBackUIHandler.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCallBackUIHandler.java 2013-03-01 15:55:12 UTC (rev 2584)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCallBackUIHandler.java 2013-03-03 15:21:26 UTC (rev 2585)
@@ -46,7 +46,9 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0
+ * @deprecated since 2.5.11, use now jaxx-config API.
*/
+@Deprecated
public class ConfigCallBackUIHandler {
/** Logger */
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUIHandler.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUIHandler.java 2013-03-01 15:55:12 UTC (rev 2584)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUIHandler.java 2013-03-03 15:21:26 UTC (rev 2585)
@@ -45,7 +45,9 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @since 2.5.4
+ * @deprecated since 2.5.11, use now jaxx-config API.
*/
+@Deprecated
public class ConfigCategoryUIHandler {
/** Logger. */
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableEditor.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableEditor.java 2013-03-01 15:55:12 UTC (rev 2584)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableEditor.java 2013-03-03 15:21:26 UTC (rev 2585)
@@ -51,7 +51,9 @@
* L'éditeur des valeurs des propriétés d'une configuration
*
* @author tchemit <chemit(a)codelutin.com>
+ * @deprecated since 2.5.11, use now jaxx-config API.
*/
+@Deprecated
public class ConfigTableEditor implements TableCellEditor {
protected TableCellEditor delegate;
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableRenderer.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableRenderer.java 2013-03-01 15:55:12 UTC (rev 2584)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableRenderer.java 2013-03-03 15:21:26 UTC (rev 2585)
@@ -61,7 +61,9 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @see ConfigTableModel
+ * @deprecated since 2.5.11, use now jaxx-config API.
*/
+@Deprecated
public class ConfigTableRenderer extends DefaultTableCellRenderer {
private static final long serialVersionUID = 1L;
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIHandler.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIHandler.java 2013-03-01 15:55:12 UTC (rev 2584)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIHandler.java 2013-03-03 15:21:26 UTC (rev 2585)
@@ -63,7 +63,9 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0.2
+ * @deprecated since 2.5.11, use now jaxx-config API.
*/
+@Deprecated
public class ConfigUIHandler {
public static final Log log = LogFactory.getLog(ConfigUIHandler.class);
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIHelper.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIHelper.java 2013-03-01 15:55:12 UTC (rev 2584)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIHelper.java 2013-03-03 15:21:26 UTC (rev 2585)
@@ -49,7 +49,9 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0.2
+ * @deprecated since 2.5.11, use now jaxx-config API.
*/
+@Deprecated
public class ConfigUIHelper {
public static final Log log = LogFactory.getLog(ConfigUIHelper.class);
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CallBackEntry.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CallBackEntry.java 2013-03-01 15:55:12 UTC (rev 2584)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CallBackEntry.java 2013-03-03 15:21:26 UTC (rev 2585)
@@ -33,7 +33,9 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0
+ * @deprecated since 2.5.11, use now jaxx-config API.
*/
+@Deprecated
public class CallBackEntry {
protected final String name;
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CallBackFinalizer.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CallBackFinalizer.java 2013-03-01 15:55:12 UTC (rev 2584)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CallBackFinalizer.java 2013-03-03 15:21:26 UTC (rev 2585)
@@ -30,7 +30,9 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0.2
+ * @deprecated since 2.5.11, use now jaxx-config API.
*/
+@Deprecated
public interface CallBackFinalizer {
/**
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CallBackMap.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CallBackMap.java 2013-03-01 15:55:12 UTC (rev 2584)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CallBackMap.java 2013-03-03 15:21:26 UTC (rev 2585)
@@ -35,7 +35,9 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0.2
+ * @deprecated since 2.5.11, use now jaxx-config API.
*/
+@Deprecated
public class CallBackMap extends LinkedHashMap<CallBackEntry, List<OptionModel>> {
private static final long serialVersionUID = 1L;
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CallBacksManager.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CallBacksManager.java 2013-03-01 15:55:12 UTC (rev 2584)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CallBacksManager.java 2013-03-03 15:21:26 UTC (rev 2585)
@@ -34,7 +34,9 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0
+ * @deprecated since 2.5.11, use now jaxx-config API.
*/
+@Deprecated
public class CallBacksManager {
/** lists of registred callback. */
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java 2013-03-01 15:55:12 UTC (rev 2584)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java 2013-03-03 15:21:26 UTC (rev 2585)
@@ -42,7 +42,9 @@
* Une categorie est un ensemble d'options.
*
* @author tchemit
+ * @deprecated since 2.5.11, use now jaxx-config API.
*/
+@Deprecated
public class CategoryModel implements Iterable<OptionModel>, Serializable {
private static final long serialVersionUID = 1L;
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigTableModel.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigTableModel.java 2013-03-01 15:55:12 UTC (rev 2584)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigTableModel.java 2013-03-03 15:21:26 UTC (rev 2585)
@@ -38,7 +38,9 @@
*
* @author tchemit
* @see CategoryModel
+ * @deprecated since 2.5.11, use now jaxx-config API.
*/
+@Deprecated
public class ConfigTableModel extends AbstractTableModel {
private static final long serialVersionUID = 1L;
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java 2013-03-01 15:55:12 UTC (rev 2584)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java 2013-03-03 15:21:26 UTC (rev 2585)
@@ -47,7 +47,9 @@
* Ce modele contient les catégories des options.
*
* @author tchemit <chemit(a)codelutin.com>
+ * @deprecated since 2.5.11, use now jaxx-config API.
*/
+@Deprecated
public class ConfigUIModel implements Iterable<CategoryModel> {
public static final String CATEGORY_MODEL_PROPERTY_NAME = "categoryModel";
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilder.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilder.java 2013-03-01 15:55:12 UTC (rev 2584)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilder.java 2013-03-03 15:21:26 UTC (rev 2585)
@@ -39,7 +39,9 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0.0
+ * @deprecated since 2.5.11, use now jaxx-config API.
*/
+@Deprecated
public class ConfigUIModelBuilder {
/** Logger */
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/MainCallBackFinalizer.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/MainCallBackFinalizer.java 2013-03-01 15:55:12 UTC (rev 2584)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/MainCallBackFinalizer.java 2013-03-03 15:21:26 UTC (rev 2585)
@@ -34,7 +34,9 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0.2
+ * @deprecated since 2.5.11, use now jaxx-config API.
*/
+@Deprecated
public class MainCallBackFinalizer implements CallBackFinalizer {
/** name of call back which eats everybody */
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java 2013-03-01 15:55:12 UTC (rev 2584)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java 2013-03-03 15:21:26 UTC (rev 2585)
@@ -34,7 +34,9 @@
* le modele d'une option de la configuration a editer.
*
* @author tchemit
+ * @deprecated since 2.5.11, use now jaxx-config API.
*/
+@Deprecated
public class OptionModel implements OptionDef {
private static final long serialVersionUID = 1L;
1
0
r2584 - trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/cell
by kmorin@users.nuiton.org 01 Mar '13
by kmorin@users.nuiton.org 01 Mar '13
01 Mar '13
Author: kmorin
Date: 2013-03-01 16:55:12 +0100 (Fri, 01 Mar 2013)
New Revision: 2584
Url: http://nuiton.org/projects/jaxx/repository/revisions/2584
Log:
fixes #2551 NumberCellEditor - the textfield is not emptied when we change to an empty cell
Modified:
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/cell/NumberCellEditor.java
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/cell/NumberCellEditor.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/cell/NumberCellEditor.java 2013-03-01 11:19:52 UTC (rev 2583)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/cell/NumberCellEditor.java 2013-03-01 15:55:12 UTC (rev 2584)
@@ -7,16 +7,16 @@
* Copyright (C) 2008 - 2012 CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
+ *
+ * You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* #L%
@@ -34,6 +34,7 @@
import javax.swing.event.AncestorEvent;
import javax.swing.event.AncestorListener;
import javax.swing.table.TableCellEditor;
+import jaxx.runtime.JAXXUtil;
import jaxx.runtime.swing.editor.NumberEditor;
/**
@@ -66,11 +67,7 @@
E number = (E) value;
numberEditor.setModel(number);
-
- // Check nullity and set the text that will be selected with the current value
- if (number != null) {
- numberEditor.setModelText(String.valueOf(number));
- }
+ numberEditor.setModelText(JAXXUtil.getStringValue(number));
return numberEditor;
}
@@ -123,7 +120,11 @@
numberEditor.setModel(null);
// Use empty string, otherwise there is a NPE in NumberEditorHandler
numberEditor.setModelText("");
+ // force binding, I do not know why the textfield text is not emptied
+ // if we do not force it
+ numberEditor.applyDataBinding(NumberEditor.BINDING_TEXT_FIELD_TEXT);
}
return result;
}
+
}
1
0
r2583 - trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/model
by kmorin@users.nuiton.org 01 Mar '13
by kmorin@users.nuiton.org 01 Mar '13
01 Mar '13
Author: kmorin
Date: 2013-03-01 12:19:52 +0100 (Fri, 01 Mar 2013)
New Revision: 2583
Url: http://nuiton.org/projects/jaxx/repository/revisions/2583
Log:
escape the special characters
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/model/JaxxFilterableListModel.java
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/model/JaxxFilterableListModel.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/model/JaxxFilterableListModel.java 2013-02-27 13:57:45 UTC (rev 2582)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/model/JaxxFilterableListModel.java 2013-03-01 11:19:52 UTC (rev 2583)
@@ -7,6 +7,7 @@
import java.util.List;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.LogFactory;
import org.nuiton.util.decorator.JXPathDecorator;
/**
@@ -18,16 +19,16 @@
public class JaxxFilterableListModel<E> extends JaxxDefaultListModel<E> {
private static final long serialVersionUID = 1L;
-
+
protected ArrayList<E> filteredItems = Lists.newArrayList();
-
+
protected String filterText;
-
+
/** the decorator of data */
protected JXPathDecorator<E> decorator;
-
+
protected List<Predicate<E>> filters = Lists.newArrayList();
-
+
@Override
public E getElementAt(int index) {
if (index < filteredItems.size()) {
@@ -36,7 +37,7 @@
return null;
}
}
-
+
@Override
public E elementAt(int index) {
return getElementAt(index);
@@ -54,17 +55,17 @@
refilter();
return result;
}
-
+
@Override
public int getSize() {
return filteredItems.size();
}
-
+
@Override
public int size() {
return filteredItems.size();
}
-
+
@Override
public void trimToSize() {
super.trimToSize();
@@ -82,19 +83,19 @@
super.setSize(newSize);
filteredItems.ensureCapacity(newSize);
}
-
+
@Override
public void setElementAt(E element, int index) {
super.setElementAt(element, index);
refilter();
}
-
+
@Override
public void removeElementAt(int index) {
super.removeElementAt(index);
refilter();
}
-
+
@Override
public void insertElementAt(E element, int index) {
super.insertElementAt(element, index);
@@ -106,14 +107,14 @@
super.removeAllElements();
refilter();
}
-
+
@Override
public E set(int index, E element) {
E rv = super.set(index, element);
refilter();
return rv;
}
-
+
@Override
public void add(int index, E element) {
super.add(index, element);
@@ -150,7 +151,7 @@
super.removeRange(fromIndex, toIndex);
refilter();
}
-
+
public String getFilterText() {
return filterText;
}
@@ -167,34 +168,34 @@
public void setDecorator(JXPathDecorator<E> decorator) {
this.decorator = decorator;
}
-
+
public void addFilter(Predicate<E> filter) {
filters.add(filter);
refilter();
}
-
+
public void removeFilter(Predicate<E> filter) {
filters.remove(filter);
refilter();
}
-
+
public void clearFilters() {
filters.clear();
refilter();
}
-
+
protected void refilter() {
filteredItems.clear();
-
- if (StringUtils.isEmpty(StringUtils.remove(filterText, '*'))
+
+ if (StringUtils.isEmpty(StringUtils.remove(filterText, '*'))
&& filters.isEmpty()) {
filteredItems.addAll(delegate);
-
+
} else {
int itemNumber = delegate.size();
Pattern pattern = null;
if (!StringUtils.isBlank(filterText)) {
- String patternText = filterText.replace("*", ".*") + ".*";
+ String patternText = Pattern.quote(filterText).replace("*", "\\E.*\\Q") + ".*";
pattern = Pattern.compile(patternText, Pattern.CASE_INSENSITIVE);
}
for (int i = 0 ; i < itemNumber ; i++) {
@@ -209,14 +210,14 @@
} else {
decoratedElement = String.valueOf(element);
}
- boolean matches = pattern == null
+ boolean matches = pattern == null
|| pattern.matcher(decoratedElement).matches();
if (matches && addElement) {
filteredItems.add(element);
}
}
}
-
+
fireContentsChanged(this, 0, getSize());
}
}
1
0