Nuiton-utils-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
July 2008
- 3 participants
- 152 discussions
[Lutinutil-commits] r876 - in trunk/commandline: . commandline-ui
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
22 Jul '08
Author: tchemit
Date: 2008-07-22 20:24:54 +0000 (Tue, 22 Jul 2008)
New Revision: 876
Modified:
trunk/commandline/
trunk/commandline/commandline-ui/
trunk/commandline/commandline-ui/pom.xml
Log:
utilisation du r?\195?\169pertoire gen non dans target car les ide ignore ce r?\195?\169pertoire
Property changes on: trunk/commandline
___________________________________________________________________
Name: svn:ignore
+ *.iws
*.ipr
Property changes on: trunk/commandline/commandline-ui
___________________________________________________________________
Name: svn:ignore
- target
+ target
gen
Modified: trunk/commandline/commandline-ui/pom.xml
===================================================================
--- trunk/commandline/commandline-ui/pom.xml 2008-07-22 20:06:39 UTC (rev 875)
+++ trunk/commandline/commandline-ui/pom.xml 2008-07-22 20:24:54 UTC (rev 876)
@@ -51,12 +51,13 @@
<!-- where to generate jaxx java files -->
<resources>
<resource>
- <directory>${basedir}/target/gen/java</directory>
+ <directory>${basedir}/gen/java</directory>
</resource>
<resource>
<directory>${maven.src.dir}/main/resources</directory>
</resource>
</resources>
+
<plugins>
<!-- jaxx -->
<plugin>
@@ -65,8 +66,7 @@
<version>0.2-SNAPSHOT</version>
<configuration>
<src>${maven.src.dir}/main/uimodel</src>
- <out>${basedir}/target/gen/java</out>
- <!--out>${maven.src.dir}/main/java</out-->
+ <out>${basedir}/gen/java</out>
</configuration>
<executions>
<execution>
@@ -80,7 +80,6 @@
<groupId>org.codelutin.jaxx</groupId>
<artifactId>jaxx-swing</artifactId>
<scope>compile</scope>
- <!--version>${jaxx.version}</version-->
<version>0.2-SNAPSHOT</version>
</dependency>
</dependencies>
@@ -96,9 +95,7 @@
<configuration>
<entries>
<entry>
- <basedir>
- ${basedir}/target/gen/java
- </basedir>
+ <basedir>${basedir}/gen/java</basedir>
</entry>
</entries>
</configuration>
@@ -113,36 +110,21 @@
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
- <!--execution>
+ <execution>
<id>clean</id>
<phase>clean</phase>
<configuration>
<tasks>
+ <mkdir dir="${basedir}/gen/java"/>
<delete includeemptydirs="true">
- <fileset dir="${maven.src.dir}/main/java" includes="**/*"/>
+ <fileset dir="${basedir}/gen/java" includes="**/*"/>
</delete>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
- </execution-->
- <!--execution>
- <id>generate-sources</id>
- <phase>generate-sources</phase>
- <configuration>
- <tasks>
- <copy todir="${maven.src.dir}/main/java" verbose="${maven.verbose}" overwrite="true">
- <fileset dir="${maven.src.dir}/main/uimodel">
- <include name="**/*.java"/>
- </fileset>
- </copy>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution-->
+ </execution>
</executions>
</plugin>
1
0
[Lutinutil-commits] r875 - in trunk/commandline/commandline-ui: . src/main/java src/main/java/org src/main/java/org/codelutin src/main/java/org/codelutin/option src/main/java/org/codelutin/option/ui src/main/uimodel/org/codelutin/option/ui
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
22 Jul '08
Author: tchemit
Date: 2008-07-22 20:06:39 +0000 (Tue, 22 Jul 2008)
New Revision: 875
Added:
trunk/commandline/commandline-ui/src/main/java/org/
trunk/commandline/commandline-ui/src/main/java/org/codelutin/
trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/
trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/
trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ClassCellEditor.java
trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableEditor.java
trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableModel.java
trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableRenderer.java
trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigUI.java
trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigUIHandler.java
trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/LoginUIHandler.java
Removed:
trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ClassCellEditor.java
trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTableEditor.java
trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTableModel.java
trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTableRenderer.java
trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigUI.java
trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigUIHandler.java
trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/LoginUIHandler.java
Modified:
trunk/commandline/commandline-ui/pom.xml
trunk/commandline/commandline-ui/src/main/java/
Log:
utilisation d'un r?\195?\169pertoire de compilation dans le projet
Modified: trunk/commandline/commandline-ui/pom.xml
===================================================================
--- trunk/commandline/commandline-ui/pom.xml 2008-07-21 00:34:57 UTC (rev 874)
+++ trunk/commandline/commandline-ui/pom.xml 2008-07-22 20:06:39 UTC (rev 875)
@@ -48,7 +48,15 @@
<packaging>jar</packaging>
<build>
-
+ <!-- where to generate jaxx java files -->
+ <resources>
+ <resource>
+ <directory>${basedir}/target/gen/java</directory>
+ </resource>
+ <resource>
+ <directory>${maven.src.dir}/main/resources</directory>
+ </resource>
+ </resources>
<plugins>
<!-- jaxx -->
<plugin>
@@ -57,7 +65,8 @@
<version>0.2-SNAPSHOT</version>
<configuration>
<src>${maven.src.dir}/main/uimodel</src>
- <out>${maven.src.dir}/main/java</out>
+ <out>${basedir}/target/gen/java</out>
+ <!--out>${maven.src.dir}/main/java</out-->
</configuration>
<executions>
<execution>
@@ -71,8 +80,9 @@
<groupId>org.codelutin.jaxx</groupId>
<artifactId>jaxx-swing</artifactId>
<scope>compile</scope>
+ <!--version>${jaxx.version}</version-->
<version>0.2-SNAPSHOT</version>
- </dependency>
+ </dependency>
</dependencies>
</plugin>
@@ -83,6 +93,15 @@
<executions>
<execution>
<phase>compile</phase>
+ <configuration>
+ <entries>
+ <entry>
+ <basedir>
+ ${basedir}/target/gen/java
+ </basedir>
+ </entry>
+ </entries>
+ </configuration>
<goals>
<goal>parserJava</goal>
<goal>gen</goal>
@@ -94,7 +113,7 @@
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
- <execution>
+ <!--execution>
<id>clean</id>
<phase>clean</phase>
<configuration>
@@ -107,8 +126,8 @@
<goals>
<goal>run</goal>
</goals>
- </execution>
- <execution>
+ </execution-->
+ <!--execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
@@ -123,7 +142,7 @@
<goals>
<goal>run</goal>
</goals>
- </execution>
+ </execution-->
</executions>
</plugin>
Property changes on: trunk/commandline/commandline-ui/src/main/java
___________________________________________________________________
Name: svn:ignore
- org
Copied: trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ClassCellEditor.java (from rev 872, trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ClassCellEditor.java)
===================================================================
--- trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ClassCellEditor.java (rev 0)
+++ trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ClassCellEditor.java 2008-07-22 20:06:39 UTC (rev 875)
@@ -0,0 +1,112 @@
+/*
+* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
+* Tony Chemit
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package org.codelutin.option.ui;
+
+import org.apache.commons.beanutils.Converter;
+import org.codelutin.util.ConverterUtil;
+
+import javax.swing.DefaultCellEditor;
+import javax.swing.JTable;
+import javax.swing.JTextField;
+import javax.swing.event.CellEditorListener;
+import javax.swing.table.TableCellEditor;
+import java.awt.Component;
+import java.util.EventObject;
+
+/**
+ * L'�diteur des valeurs des propri�t�s d'une configuration
+ *
+ * @author chemit
+ */
+public class ClassCellEditor implements TableCellEditor {
+
+ protected TableCellEditor delegate;
+
+ public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
+
+ String valStr = (value + "").trim();
+ if (valStr.equals("null")) {
+ valStr = "";
+ } else if (valStr.startsWith("class ")) {
+ valStr = valStr.substring(6);
+ }
+ Component comp;
+ comp = getDelegate().getTableCellEditorComponent(table, valStr, isSelected, row, column);
+ return comp;
+ }
+
+ public Object getCellEditorValue() {
+ Object o = !hasDelegate() ? null : delegate.getCellEditorValue();
+ if (o == null) {
+ return null;
+ }
+ Converter converter = ConverterUtil.getConverter(Class.class);
+
+ try {
+ if (converter != null) {
+ return converter.convert(Class.class, o);
+ }
+ o =Class.forName(o+"");
+ } catch (Exception e) {
+ o=null;
+ }
+ return o;
+ }
+
+ public boolean isCellEditable(EventObject anEvent) {
+ return !hasDelegate() || delegate.isCellEditable(anEvent);
+ }
+
+ public boolean shouldSelectCell(EventObject anEvent) {
+ return hasDelegate() && delegate.shouldSelectCell(anEvent);
+ }
+
+ public boolean stopCellEditing() {
+ return !hasDelegate() || delegate.stopCellEditing();
+ }
+
+ public void cancelCellEditing() {
+ if (hasDelegate()) {
+ delegate.cancelCellEditing();
+ }
+ }
+
+ public void addCellEditorListener(CellEditorListener l) {
+ if (hasDelegate()) {
+ delegate.addCellEditorListener(l);
+ }
+ }
+
+ public void removeCellEditorListener(CellEditorListener l) {
+ if (hasDelegate()) {
+ delegate.removeCellEditorListener(l);
+ }
+ }
+
+ protected TableCellEditor getDelegate() {
+ if (delegate == null) {
+ delegate = new DefaultCellEditor(new JTextField());
+ }
+ return delegate;
+ }
+
+ protected boolean hasDelegate() {
+ return delegate != null;
+ }
+}
\ No newline at end of file
Property changes on: trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ClassCellEditor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableEditor.java (from rev 872, trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTableEditor.java)
===================================================================
--- trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableEditor.java (rev 0)
+++ trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableEditor.java 2008-07-22 20:06:39 UTC (rev 875)
@@ -0,0 +1,114 @@
+/*
+* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
+* Tony Chemit
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package org.codelutin.option.ui;
+
+import javax.swing.DefaultCellEditor;
+import javax.swing.JTable;
+import javax.swing.event.CellEditorListener;
+import javax.swing.table.TableCellEditor;
+import java.awt.Component;
+import java.util.EventObject;
+import java.util.Locale;
+
+/**
+ * L'�diteur des valeurs des propri�t�s d'une configuration
+ *
+ * @author chemit
+ */
+public class ConfigTableEditor implements TableCellEditor {
+
+ protected TableCellEditor delegate;
+ protected ConfigTableModel model;
+
+ public ConfigTableEditor(ConfigTableModel model) {
+ this.model = model;
+ }
+
+ public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
+ delegate = findDelegate(table, model.getKey(row).getType());
+ return delegate.getTableCellEditorComponent(table, value, isSelected, row, column);
+ }
+
+ public Object getCellEditorValue() {
+ return !hasDelegate() ? null : delegate.getCellEditorValue();
+ }
+
+ public boolean isCellEditable(EventObject anEvent) {
+ return !hasDelegate() || delegate.isCellEditable(anEvent);
+ }
+
+ public boolean shouldSelectCell(EventObject anEvent) {
+ return hasDelegate() && delegate.shouldSelectCell(anEvent);
+ }
+
+ public boolean stopCellEditing() {
+ return !hasDelegate() || delegate.stopCellEditing();
+ }
+
+ public void cancelCellEditing() {
+ if (hasDelegate()) {
+ delegate.cancelCellEditing();
+ }
+ }
+
+ public void addCellEditorListener(CellEditorListener l) {
+ if (hasDelegate()) {
+ delegate.addCellEditorListener(l);
+ }
+ }
+
+ public void removeCellEditorListener(CellEditorListener l) {
+ if (hasDelegate()) {
+ delegate.removeCellEditorListener(l);
+ }
+ }
+
+ protected TableCellEditor findDelegate(JTable table, Class<?> type) {
+ TableCellEditor delegate = table.getDefaultEditor(type);
+ TableCellEditor defaultEditor = table.getDefaultEditor(Object.class);
+ if (delegate == defaultEditor) {
+ // find not a specialized editor for the type
+ if (type.isEnum()) {
+ // add a EnumEditor to table
+ delegate = new DefaultCellEditor(org.codelutin.util.EnumEditor.newEditor(type));
+ table.setDefaultEditor(type, delegate);
+ } else if (type == Class.class) {
+ delegate = new ClassCellEditor();
+ table.setDefaultEditor(type, delegate);
+ } //else if (type == File.class){
+ // TODO a FileEditor
+ // table.setDefaultEditor(type, delegate);
+ //}
+ else if (type.equals(Locale.class)) {
+ delegate = new DefaultCellEditor(org.codelutin.i18n.LocaleEditor.newEditor());
+ table.setDefaultEditor(Locale.class, delegate);
+ } else {
+ delegate = table.getDefaultEditor(String.class);
+ }
+ }
+ if (delegate == null) {
+ throw new IllegalStateException("could not find a editor for type +" + type);
+ }
+ return delegate;
+ }
+
+ protected boolean hasDelegate() {
+ return delegate != null;
+ }
+}
Property changes on: trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableEditor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableModel.java (from rev 872, trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTableModel.java)
===================================================================
--- trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableModel.java (rev 0)
+++ trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableModel.java 2008-07-22 20:06:39 UTC (rev 875)
@@ -0,0 +1,235 @@
+/*
+* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
+* Tony Chemit
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package org.codelutin.option.ui;
+
+import static org.codelutin.i18n.I18n._;
+import org.codelutin.option.Config;
+import org.codelutin.option.ConfigPropertyKey;
+import org.codelutin.util.ArrayUtil;
+
+import javax.swing.table.AbstractTableModel;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * Un mod�le g�n�rique pour une configuration g�n�rique
+ *
+ * @author chemit
+ */
+public class ConfigTableModel extends AbstractTableModel {
+
+ private static final long serialVersionUID = -1457510439292016551L;
+
+ /**
+ * Une enum pour d�finir les types de donn�es � ajouter au model
+ *
+ * @author chemit
+ */
+ public enum TypeModel {
+ all {
+ protected boolean accept(ConfigPropertyKey<?> key) {
+ return true;
+ }},
+ nontech {
+ protected boolean accept(ConfigPropertyKey<?> key) {
+ return !(tech.accept(key) || key.isTransient());
+ }},
+ tech {
+ protected boolean accept(ConfigPropertyKey<?> key) {
+ return key.isFinal();
+ //return key.isFinal() && key.isTransient() && key.isStatic();
+ }};
+
+ abstract boolean accept(ConfigPropertyKey<?> key);
+ }
+
+ // par d�faut on affiche uniquement les propri�t�s non techniques
+ private static final TypeModel DEFAULT_TYPE = TypeModel.nontech;
+
+ private final String[] columnNames = {_("lutinutil.common.key"), _("lutinutil.common.value")};
+
+ private final Class[] columnClass = {String.class, Object.class};
+
+ protected ConfigPropertyKey<?>[] keys;
+ protected Map<ConfigPropertyKey<?>, Object> props;
+ protected TypeModel type;
+
+ protected Config config;
+
+ public ConfigTableModel(Config config) {
+ this(config, null);
+ }
+
+ public ConfigTableModel(Config config, TypeModel type) {
+ this.config = config;
+ setType(type);
+ }
+
+ public TypeModel getType() {
+ return type;
+ }
+
+ public void setType(TypeModel type) {
+ this.type = type;
+ // rebuild model
+ if (props == null) {
+ props = new LinkedHashMap<ConfigPropertyKey<?>, Object>();
+ } else {
+ props.clear();
+ }
+ if (type == null) {
+ type = DEFAULT_TYPE;
+ }
+ if (type == TypeModel.all) {
+ for (ConfigPropertyKey<?> key : config.getUniverse()) {
+ if (TypeModel.nontech.accept(key)) {
+ props.put(key, key.getCurrentValue());
+ }
+ }
+ for (ConfigPropertyKey<?> key : config.getUniverse()) {
+ if (TypeModel.tech.accept(key)) {
+ props.put(key, key.getCurrentValue());
+ }
+ }
+ } else {
+ for (ConfigPropertyKey<?> key : config.getUniverse()) {
+ if (type.accept(key)) {
+ props.put(key, key.getCurrentValue());
+ }
+ }
+ }
+ keys = ArrayUtil.toArray(props.keySet(), ConfigPropertyKey.class);
+ fireTableDataChanged();
+ }
+
+ public ConfigPropertyKey<?> getKey(int rowIndex) {
+ return keys[rowIndex];
+ }
+
+ public boolean isModified(int rowIndex) {
+ ConfigPropertyKey key = getKey(rowIndex);
+ return !key.equals(key.getCurrentValue(), props.get(key));
+ }
+
+ public boolean isValid(int rowIndex) {
+ ConfigPropertyKey<?> key = getKey(rowIndex);
+ Object value = props.get(key);
+ return !key.isMandatory() || value != null && !"".equals(value);
+ }
+
+ public boolean isModified() {
+ for (int i = 0; i < keys.length; i++) {
+ if (isModified(i)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean isValid() {
+ for (int i = 0; i < keys.length; i++) {
+ if (!isValid(i)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public void transfertModified(Config config) {
+ for (int i = 0; i < getRowCount(); i++) {
+ if (isModified(i)) {
+ ConfigPropertyKey<Object> key = (ConfigPropertyKey<Object>) getKey(i);
+ Object value = props.get(key);
+ //System.out.println("transfert property {0} value {1}", key.getKey(), value);
+ config.addProperty(key, value);
+ }
+ }
+ }
+
+ public void reset() {
+ for (int i = 0; i < getRowCount(); i++) {
+ if (isModified(i)) {
+ ConfigPropertyKey key = getKey(i);
+ props.put(key, key.getCurrentValue());
+ }
+ }
+ fireTableDataChanged();
+ }
+
+ public int getRowCount() {
+ return keys.length;
+ }
+
+ public int getColumnCount() {
+ return 2;
+ }
+
+ public Object getValueAt(int row, int column) {
+ ConfigPropertyKey key = getKey(row);
+ if (column == 0) {
+ return key.getKey();
+ }
+ return props.get(key);
+ }
+
+ @Override
+ public String getColumnName(int columnIndex) {
+ return columnNames[columnIndex];
+ }
+
+ @Override
+ public Class<?> getColumnClass(int columnIndex) {
+ return columnClass[columnIndex];
+ }
+
+ @Override
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ return columnIndex == 1 && !keys[rowIndex].isFinal();
+ }
+
+ @Override
+ public void setValueAt(Object aValue, int row, int column) {
+ if (column == 0) {
+ return;
+ }
+ ConfigPropertyKey<?> key = getKey(row);
+ Object val;
+
+ if (aValue==null || key.getType() ==aValue.getClass()) {
+ // we have directly the value, no conversion need
+ val = aValue;
+ } else {
+ String valStr = String.valueOf(aValue).trim();
+ try {
+ val = key.convert(key.getType(), valStr);
+ if (val != null && val instanceof Integer) {
+ if (new Integer(0).equals(val) && !valStr.equals("0")) {
+ val = null;
+ }
+ }
+ } catch (Exception e) {
+ val = null;
+ }
+ }
+ props.put(key, val);
+ fireTableRowsUpdated(row, row);
+ }
+
+}
Property changes on: trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableModel.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableRenderer.java (from rev 872, trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTableRenderer.java)
===================================================================
--- trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableRenderer.java (rev 0)
+++ trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableRenderer.java 2008-07-22 20:06:39 UTC (rev 875)
@@ -0,0 +1,108 @@
+/*
+* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
+* Tony Chemit
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package org.codelutin.option.ui;
+
+import static org.codelutin.i18n.I18n._;
+import org.codelutin.option.ConfigPropertyKey;
+
+import javax.swing.JComponent;
+import javax.swing.JTable;
+import javax.swing.border.LineBorder;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.TableCellRenderer;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Font;
+
+/**
+ * le renderer pour l'ui de config
+ *
+ * @author chemit
+ */
+public class ConfigTableRenderer extends DefaultTableCellRenderer {
+
+ protected static Color col;
+ protected static Font font;
+ protected static Font font2;
+
+ protected ConfigTableModel model;
+
+ public ConfigTableRenderer(ConfigTableModel config) {
+ this.model = config;
+ col = getForeground();
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+ //System.out.println(">>> ConfigColumnRenderer.getTableCellRendererComponent " + row + "/" + column);
+ ConfigPropertyKey key = model.getKey(row);
+ boolean isModified = model.isModified(row);
+ boolean isValid = model.isValid(row);
+
+ boolean isFinal = key.isFinal();
+ if (font == null) {
+ font = table.getFont();
+ font2 = getFont().deriveFont(Font.ITALIC | Font.BOLD);
+ }
+ Component cellRenderer = null;
+ // modified lines are selected
+ if (column == 0) {
+ cellRenderer = getKeyCellRenderer(table, value, isModified, hasFocus, row, column, key, isValid);
+ } else if (column == 1) {
+ cellRenderer = getValueCellRenderer(table, value, isModified, hasFocus, row, column, key, isValid);
+ }
+ if (cellRenderer == null) {
+ throw new IllegalStateException("no renderer find for column " + column);
+ }
+ cellRenderer.setEnabled(!isFinal);
+ cellRenderer.setFont(isModified ? font2 : font);
+ return cellRenderer;
+ }
+
+ protected Component getKeyCellRenderer(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column, ConfigPropertyKey key, boolean valid) {
+ String tooltip = key.getDescription();
+ String s = _("lutinutil.config.modified", key.getCurrentValue());
+
+ if (isSelected) {
+ value = value + " *";
+ tooltip += " [" + s + ']';
+ }
+ if (!valid) {
+ String s2 = _("lutinutil.config.unvalid", key.getCurrentValue(), key.getType());
+ tooltip += " (" + s2 + ")";
+ }
+ JComponent result = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ result.setToolTipText(tooltip);
+ result.setForeground(valid ? col : Color.RED);
+ return result;
+ }
+
+ protected Component getValueCellRenderer(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column, ConfigPropertyKey key, boolean valid) {
+ TableCellRenderer defaultRenderer = table.getDefaultRenderer(key.getType());
+
+ JComponent result;
+ result = (JComponent) defaultRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ if (!valid) {
+ result.setBorder(new LineBorder(Color.red));
+ } else {
+ result.setBorder(null);
+ }
+ return result;
+ }
+}
Property changes on: trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableRenderer.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigUI.java (from rev 872, trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigUI.java)
===================================================================
--- trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigUI.java (rev 0)
+++ trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigUI.java 2008-07-22 20:06:39 UTC (rev 875)
@@ -0,0 +1,103 @@
+/*
+* ##% Copyright (C) 2007, 2008 Code Lutin, Tony Chemit
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package org.codelutin.option.ui;
+
+import org.codelutin.option.AbstractContext;
+import org.codelutin.option.Config;
+
+import javax.swing.*;
+import java.awt.*;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * TODO javadoc
+ *
+ * @author chemit
+ */
+public class ConfigUI extends JConfigUI {
+
+ protected List<Config> configs;
+
+ public List<Config> getConfigs() {
+ if (configs == null) {
+ configs = new ArrayList<Config>();
+ }
+ return configs;
+ }
+
+ public ListCellRenderer getListener() {
+ return new DefaultListCellRenderer() {
+ @Override
+ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
+ if (value instanceof Config) {
+ Config config = (Config) value;
+ JComponent listCellRendererComponent = (JComponent) super.getListCellRendererComponent(list, config.getCategory(), index, isSelected, cellHasFocus);
+ listCellRendererComponent.setToolTipText(config.getCategory());
+ return listCellRendererComponent;
+ }
+ return this;
+ }
+ };
+ }
+
+ public void onValueChanged() {
+ Object value = list.getSelectedValue();
+ if (value instanceof Config) {
+ Config config = (Config) value;
+ cardLayout.show(preview, config.getCategory());
+ }
+ }
+
+ public ConfigUI init(AbstractContext context, Config... configs) {
+ for (Config config : configs) {
+ add(context, config);
+ }
+ if (list.getModel().getSize() > 0) {
+ list.setSelectedIndex(0);
+ }
+ return this;
+ }
+
+ public boolean add(AbstractContext context, Config config) {
+ int index = getConfigs().indexOf(config);
+ if (index > -1) {
+ return false;
+ }
+ configs.add(config);
+ ConfigTab ui = new ConfigTab();
+ ui.getHandler().init(context, config);
+ listModel.addElement(config);
+ preview.add(ui, config.getCategory());
+ return true;
+ }
+
+ public boolean remove(Config o) {
+ if (configs == null) {
+ return false;
+ }
+ int index = configs.indexOf(o);
+ if (index == -1) {
+ return false;
+ }
+ listModel.remove(index);
+ preview.remove(index);
+ configs.remove(index);
+ return true;
+ }
+}
Property changes on: trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigUI.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigUIHandler.java (from rev 872, trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigUIHandler.java)
===================================================================
--- trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigUIHandler.java (rev 0)
+++ trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigUIHandler.java 2008-07-22 20:06:39 UTC (rev 875)
@@ -0,0 +1,115 @@
+/*
+* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
+* Tony Chemit
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package org.codelutin.option.ui;
+
+import org.codelutin.option.AbstractContext;
+import org.codelutin.option.Config;
+
+import javax.swing.*;
+import javax.swing.event.TableModelEvent;
+import javax.swing.event.TableModelListener;
+
+/**
+ * Le controleur de l'ui de modification de configuration.
+ *
+ * @author chemit
+ */
+public class ConfigUIHandler {
+
+ protected ConfigTab ui;
+ protected Config config;
+ protected ConfigTableModel tableModel;
+ protected TableModelListener tableModelListener;
+
+ protected AbstractContext context;
+
+ public ConfigUIHandler(ConfigTab ui) {
+ this.ui = ui;
+ }
+
+ public void init(AbstractContext context, Config config) {
+ this.config = config;
+ this.context = context;
+ tableModel = new ConfigTableModel(config);
+
+ tableModel.addTableModelListener(getTableModelListener());
+ JTable table = ui.getMain();
+ table.setModel(tableModel);
+
+ ConfigTableRenderer renderer = new ConfigTableRenderer(tableModel);
+ table.getColumnModel().getColumn(0).setCellRenderer(renderer);
+ table.getColumnModel().getColumn(1).setCellRenderer(renderer);
+ table.getColumnModel().getColumn(1).setCellEditor(new ConfigTableEditor(getTableModel()));
+
+ tableModel.fireTableDataChanged();
+ }
+
+ public void doSave() {
+ if (!isEmpty() && getTableModel().isModified()) {
+ getTableModel().transfertModified(getConfig());
+ context.saveSafely();
+ }
+ doReset();
+ }
+
+ public void doReset() {
+ getTableModel().reset();
+ }
+
+ public void doSelectTechnical(boolean showTechnical) {
+ tableModel.setType(showTechnical ? ConfigTableModel.TypeModel.all : ConfigTableModel.TypeModel.nontech);
+ }
+
+ protected boolean isSaveEnabled() {
+ return isResetEnabled() && tableModel.isValid();
+ }
+
+ protected boolean isResetEnabled() {
+ return !isEmpty() && tableModel.isModified();
+ }
+
+ protected boolean isEmpty() {
+ return tableModel == null || config == null || config.getUniverse().isEmpty();
+ }
+
+ protected Config getConfig() {
+ return config;
+ }
+
+ protected ConfigTableModel getTableModel() {
+ return tableModel;
+ }
+
+ protected TableModelListener getTableModelListener() {
+ if (tableModelListener == null) {
+ tableModelListener = new TableModelListener() {
+ public void tableChanged(TableModelEvent e) {
+ ui.getSave().setEnabled(isSaveEnabled());
+ ui.getReset().setEnabled(isResetEnabled());
+ }
+ };
+ }
+ return tableModelListener;
+ }
+
+ protected void dispose() {
+ getTableModel().reset();
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigUIHandler.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/LoginUIHandler.java (from rev 872, trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/LoginUIHandler.java)
===================================================================
--- trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/LoginUIHandler.java (rev 0)
+++ trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/LoginUIHandler.java 2008-07-22 20:06:39 UTC (rev 875)
@@ -0,0 +1,28 @@
+package org.codelutin.option.ui;
+
+public abstract class LoginUIHandler {
+
+ boolean cancel;
+
+ JLoginUI ui;
+
+ protected abstract boolean connect(String login, char[] password);
+
+ protected abstract boolean failedToConnect();
+
+ public abstract void doConnect();
+
+ public abstract void doCancel();
+
+ protected void setUi(JLoginUI ui) {
+ this.ui = ui;
+ }
+
+ public void setCancel(boolean cancel) {
+ this.cancel = cancel;
+ }
+
+ public boolean isCancel() {
+ return cancel;
+ }
+}
\ No newline at end of file
Deleted: trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ClassCellEditor.java
===================================================================
--- trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ClassCellEditor.java 2008-07-21 00:34:57 UTC (rev 874)
+++ trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ClassCellEditor.java 2008-07-22 20:06:39 UTC (rev 875)
@@ -1,112 +0,0 @@
-/*
-* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
-* Tony Chemit
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-* ##% */
-package org.codelutin.option.ui;
-
-import org.apache.commons.beanutils.Converter;
-import org.codelutin.util.ConverterUtil;
-
-import javax.swing.DefaultCellEditor;
-import javax.swing.JTable;
-import javax.swing.JTextField;
-import javax.swing.event.CellEditorListener;
-import javax.swing.table.TableCellEditor;
-import java.awt.Component;
-import java.util.EventObject;
-
-/**
- * L'�diteur des valeurs des propri�t�s d'une configuration
- *
- * @author chemit
- */
-public class ClassCellEditor implements TableCellEditor {
-
- protected TableCellEditor delegate;
-
- public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
-
- String valStr = (value + "").trim();
- if (valStr.equals("null")) {
- valStr = "";
- } else if (valStr.startsWith("class ")) {
- valStr = valStr.substring(6);
- }
- Component comp;
- comp = getDelegate().getTableCellEditorComponent(table, valStr, isSelected, row, column);
- return comp;
- }
-
- public Object getCellEditorValue() {
- Object o = !hasDelegate() ? null : delegate.getCellEditorValue();
- if (o == null) {
- return null;
- }
- Converter converter = ConverterUtil.getConverter(Class.class);
-
- try {
- if (converter != null) {
- return converter.convert(Class.class, o);
- }
- o =Class.forName(o+"");
- } catch (Exception e) {
- o=null;
- }
- return o;
- }
-
- public boolean isCellEditable(EventObject anEvent) {
- return !hasDelegate() || delegate.isCellEditable(anEvent);
- }
-
- public boolean shouldSelectCell(EventObject anEvent) {
- return hasDelegate() && delegate.shouldSelectCell(anEvent);
- }
-
- public boolean stopCellEditing() {
- return !hasDelegate() || delegate.stopCellEditing();
- }
-
- public void cancelCellEditing() {
- if (hasDelegate()) {
- delegate.cancelCellEditing();
- }
- }
-
- public void addCellEditorListener(CellEditorListener l) {
- if (hasDelegate()) {
- delegate.addCellEditorListener(l);
- }
- }
-
- public void removeCellEditorListener(CellEditorListener l) {
- if (hasDelegate()) {
- delegate.removeCellEditorListener(l);
- }
- }
-
- protected TableCellEditor getDelegate() {
- if (delegate == null) {
- delegate = new DefaultCellEditor(new JTextField());
- }
- return delegate;
- }
-
- protected boolean hasDelegate() {
- return delegate != null;
- }
-}
\ No newline at end of file
Deleted: trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTableEditor.java
===================================================================
--- trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTableEditor.java 2008-07-21 00:34:57 UTC (rev 874)
+++ trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTableEditor.java 2008-07-22 20:06:39 UTC (rev 875)
@@ -1,114 +0,0 @@
-/*
-* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
-* Tony Chemit
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-* ##% */
-package org.codelutin.option.ui;
-
-import javax.swing.DefaultCellEditor;
-import javax.swing.JTable;
-import javax.swing.event.CellEditorListener;
-import javax.swing.table.TableCellEditor;
-import java.awt.Component;
-import java.util.EventObject;
-import java.util.Locale;
-
-/**
- * L'�diteur des valeurs des propri�t�s d'une configuration
- *
- * @author chemit
- */
-public class ConfigTableEditor implements TableCellEditor {
-
- protected TableCellEditor delegate;
- protected ConfigTableModel model;
-
- public ConfigTableEditor(ConfigTableModel model) {
- this.model = model;
- }
-
- public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
- delegate = findDelegate(table, model.getKey(row).getType());
- return delegate.getTableCellEditorComponent(table, value, isSelected, row, column);
- }
-
- public Object getCellEditorValue() {
- return !hasDelegate() ? null : delegate.getCellEditorValue();
- }
-
- public boolean isCellEditable(EventObject anEvent) {
- return !hasDelegate() || delegate.isCellEditable(anEvent);
- }
-
- public boolean shouldSelectCell(EventObject anEvent) {
- return hasDelegate() && delegate.shouldSelectCell(anEvent);
- }
-
- public boolean stopCellEditing() {
- return !hasDelegate() || delegate.stopCellEditing();
- }
-
- public void cancelCellEditing() {
- if (hasDelegate()) {
- delegate.cancelCellEditing();
- }
- }
-
- public void addCellEditorListener(CellEditorListener l) {
- if (hasDelegate()) {
- delegate.addCellEditorListener(l);
- }
- }
-
- public void removeCellEditorListener(CellEditorListener l) {
- if (hasDelegate()) {
- delegate.removeCellEditorListener(l);
- }
- }
-
- protected TableCellEditor findDelegate(JTable table, Class<?> type) {
- TableCellEditor delegate = table.getDefaultEditor(type);
- TableCellEditor defaultEditor = table.getDefaultEditor(Object.class);
- if (delegate == defaultEditor) {
- // find not a specialized editor for the type
- if (type.isEnum()) {
- // add a EnumEditor to table
- delegate = new DefaultCellEditor(org.codelutin.util.EnumEditor.newEditor(type));
- table.setDefaultEditor(type, delegate);
- } else if (type == Class.class) {
- delegate = new ClassCellEditor();
- table.setDefaultEditor(type, delegate);
- } //else if (type == File.class){
- // TODO a FileEditor
- // table.setDefaultEditor(type, delegate);
- //}
- else if (type.equals(Locale.class)) {
- delegate = new DefaultCellEditor(org.codelutin.i18n.LocaleEditor.newEditor());
- table.setDefaultEditor(Locale.class, delegate);
- } else {
- delegate = table.getDefaultEditor(String.class);
- }
- }
- if (delegate == null) {
- throw new IllegalStateException("could not find a editor for type +" + type);
- }
- return delegate;
- }
-
- protected boolean hasDelegate() {
- return delegate != null;
- }
-}
Deleted: trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTableModel.java
===================================================================
--- trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTableModel.java 2008-07-21 00:34:57 UTC (rev 874)
+++ trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTableModel.java 2008-07-22 20:06:39 UTC (rev 875)
@@ -1,235 +0,0 @@
-/*
-* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
-* Tony Chemit
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-* ##% */
-package org.codelutin.option.ui;
-
-import static org.codelutin.i18n.I18n._;
-import org.codelutin.option.Config;
-import org.codelutin.option.ConfigPropertyKey;
-import org.codelutin.util.ArrayUtil;
-
-import javax.swing.table.AbstractTableModel;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * Un mod�le g�n�rique pour une configuration g�n�rique
- *
- * @author chemit
- */
-public class ConfigTableModel extends AbstractTableModel {
-
- private static final long serialVersionUID = -1457510439292016551L;
-
- /**
- * Une enum pour d�finir les types de donn�es � ajouter au model
- *
- * @author chemit
- */
- public enum TypeModel {
- all {
- protected boolean accept(ConfigPropertyKey<?> key) {
- return true;
- }},
- nontech {
- protected boolean accept(ConfigPropertyKey<?> key) {
- return !(tech.accept(key) || key.isTransient());
- }},
- tech {
- protected boolean accept(ConfigPropertyKey<?> key) {
- return key.isFinal();
- //return key.isFinal() && key.isTransient() && key.isStatic();
- }};
-
- abstract boolean accept(ConfigPropertyKey<?> key);
- }
-
- // par d�faut on affiche uniquement les propri�t�s non techniques
- private static final TypeModel DEFAULT_TYPE = TypeModel.nontech;
-
- private final String[] columnNames = {_("lutinutil.common.key"), _("lutinutil.common.value")};
-
- private final Class[] columnClass = {String.class, Object.class};
-
- protected ConfigPropertyKey<?>[] keys;
- protected Map<ConfigPropertyKey<?>, Object> props;
- protected TypeModel type;
-
- protected Config config;
-
- public ConfigTableModel(Config config) {
- this(config, null);
- }
-
- public ConfigTableModel(Config config, TypeModel type) {
- this.config = config;
- setType(type);
- }
-
- public TypeModel getType() {
- return type;
- }
-
- public void setType(TypeModel type) {
- this.type = type;
- // rebuild model
- if (props == null) {
- props = new LinkedHashMap<ConfigPropertyKey<?>, Object>();
- } else {
- props.clear();
- }
- if (type == null) {
- type = DEFAULT_TYPE;
- }
- if (type == TypeModel.all) {
- for (ConfigPropertyKey<?> key : config.getUniverse()) {
- if (TypeModel.nontech.accept(key)) {
- props.put(key, key.getCurrentValue());
- }
- }
- for (ConfigPropertyKey<?> key : config.getUniverse()) {
- if (TypeModel.tech.accept(key)) {
- props.put(key, key.getCurrentValue());
- }
- }
- } else {
- for (ConfigPropertyKey<?> key : config.getUniverse()) {
- if (type.accept(key)) {
- props.put(key, key.getCurrentValue());
- }
- }
- }
- keys = ArrayUtil.toArray(props.keySet(), ConfigPropertyKey.class);
- fireTableDataChanged();
- }
-
- public ConfigPropertyKey<?> getKey(int rowIndex) {
- return keys[rowIndex];
- }
-
- public boolean isModified(int rowIndex) {
- ConfigPropertyKey key = getKey(rowIndex);
- return !key.equals(key.getCurrentValue(), props.get(key));
- }
-
- public boolean isValid(int rowIndex) {
- ConfigPropertyKey<?> key = getKey(rowIndex);
- Object value = props.get(key);
- return !key.isMandatory() || value != null && !"".equals(value);
- }
-
- public boolean isModified() {
- for (int i = 0; i < keys.length; i++) {
- if (isModified(i)) {
- return true;
- }
- }
- return false;
- }
-
- public boolean isValid() {
- for (int i = 0; i < keys.length; i++) {
- if (!isValid(i)) {
- return false;
- }
- }
- return true;
- }
-
- @SuppressWarnings({"unchecked"})
- public void transfertModified(Config config) {
- for (int i = 0; i < getRowCount(); i++) {
- if (isModified(i)) {
- ConfigPropertyKey<Object> key = (ConfigPropertyKey<Object>) getKey(i);
- Object value = props.get(key);
- //System.out.println("transfert property {0} value {1}", key.getKey(), value);
- config.addProperty(key, value);
- }
- }
- }
-
- public void reset() {
- for (int i = 0; i < getRowCount(); i++) {
- if (isModified(i)) {
- ConfigPropertyKey key = getKey(i);
- props.put(key, key.getCurrentValue());
- }
- }
- fireTableDataChanged();
- }
-
- public int getRowCount() {
- return keys.length;
- }
-
- public int getColumnCount() {
- return 2;
- }
-
- public Object getValueAt(int row, int column) {
- ConfigPropertyKey key = getKey(row);
- if (column == 0) {
- return key.getKey();
- }
- return props.get(key);
- }
-
- @Override
- public String getColumnName(int columnIndex) {
- return columnNames[columnIndex];
- }
-
- @Override
- public Class<?> getColumnClass(int columnIndex) {
- return columnClass[columnIndex];
- }
-
- @Override
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- return columnIndex == 1 && !keys[rowIndex].isFinal();
- }
-
- @Override
- public void setValueAt(Object aValue, int row, int column) {
- if (column == 0) {
- return;
- }
- ConfigPropertyKey<?> key = getKey(row);
- Object val;
-
- if (aValue==null || key.getType() ==aValue.getClass()) {
- // we have directly the value, no conversion need
- val = aValue;
- } else {
- String valStr = String.valueOf(aValue).trim();
- try {
- val = key.convert(key.getType(), valStr);
- if (val != null && val instanceof Integer) {
- if (new Integer(0).equals(val) && !valStr.equals("0")) {
- val = null;
- }
- }
- } catch (Exception e) {
- val = null;
- }
- }
- props.put(key, val);
- fireTableRowsUpdated(row, row);
- }
-
-}
Deleted: trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTableRenderer.java
===================================================================
--- trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTableRenderer.java 2008-07-21 00:34:57 UTC (rev 874)
+++ trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTableRenderer.java 2008-07-22 20:06:39 UTC (rev 875)
@@ -1,108 +0,0 @@
-/*
-* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
-* Tony Chemit
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-* ##% */
-package org.codelutin.option.ui;
-
-import static org.codelutin.i18n.I18n._;
-import org.codelutin.option.ConfigPropertyKey;
-
-import javax.swing.JComponent;
-import javax.swing.JTable;
-import javax.swing.border.LineBorder;
-import javax.swing.table.DefaultTableCellRenderer;
-import javax.swing.table.TableCellRenderer;
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Font;
-
-/**
- * le renderer pour l'ui de config
- *
- * @author chemit
- */
-public class ConfigTableRenderer extends DefaultTableCellRenderer {
-
- protected static Color col;
- protected static Font font;
- protected static Font font2;
-
- protected ConfigTableModel model;
-
- public ConfigTableRenderer(ConfigTableModel config) {
- this.model = config;
- col = getForeground();
- }
-
- @Override
- public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
- //System.out.println(">>> ConfigColumnRenderer.getTableCellRendererComponent " + row + "/" + column);
- ConfigPropertyKey key = model.getKey(row);
- boolean isModified = model.isModified(row);
- boolean isValid = model.isValid(row);
-
- boolean isFinal = key.isFinal();
- if (font == null) {
- font = table.getFont();
- font2 = getFont().deriveFont(Font.ITALIC | Font.BOLD);
- }
- Component cellRenderer = null;
- // modified lines are selected
- if (column == 0) {
- cellRenderer = getKeyCellRenderer(table, value, isModified, hasFocus, row, column, key, isValid);
- } else if (column == 1) {
- cellRenderer = getValueCellRenderer(table, value, isModified, hasFocus, row, column, key, isValid);
- }
- if (cellRenderer == null) {
- throw new IllegalStateException("no renderer find for column " + column);
- }
- cellRenderer.setEnabled(!isFinal);
- cellRenderer.setFont(isModified ? font2 : font);
- return cellRenderer;
- }
-
- protected Component getKeyCellRenderer(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column, ConfigPropertyKey key, boolean valid) {
- String tooltip = key.getDescription();
- String s = _("lutinutil.config.modified", key.getCurrentValue());
-
- if (isSelected) {
- value = value + " *";
- tooltip += " [" + s + ']';
- }
- if (!valid) {
- String s2 = _("lutinutil.config.unvalid", key.getCurrentValue(), key.getType());
- tooltip += " (" + s2 + ")";
- }
- JComponent result = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
- result.setToolTipText(tooltip);
- result.setForeground(valid ? col : Color.RED);
- return result;
- }
-
- protected Component getValueCellRenderer(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column, ConfigPropertyKey key, boolean valid) {
- TableCellRenderer defaultRenderer = table.getDefaultRenderer(key.getType());
-
- JComponent result;
- result = (JComponent) defaultRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
- if (!valid) {
- result.setBorder(new LineBorder(Color.red));
- } else {
- result.setBorder(null);
- }
- return result;
- }
-}
Deleted: trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigUI.java
===================================================================
--- trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigUI.java 2008-07-21 00:34:57 UTC (rev 874)
+++ trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigUI.java 2008-07-22 20:06:39 UTC (rev 875)
@@ -1,103 +0,0 @@
-/*
-* ##% Copyright (C) 2007, 2008 Code Lutin, Tony Chemit
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-* ##% */
-package org.codelutin.option.ui;
-
-import org.codelutin.option.AbstractContext;
-import org.codelutin.option.Config;
-
-import javax.swing.*;
-import java.awt.*;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * TODO javadoc
- *
- * @author chemit
- */
-public class ConfigUI extends JConfigUI {
-
- protected List<Config> configs;
-
- public List<Config> getConfigs() {
- if (configs == null) {
- configs = new ArrayList<Config>();
- }
- return configs;
- }
-
- public ListCellRenderer getListener() {
- return new DefaultListCellRenderer() {
- @Override
- public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
- if (value instanceof Config) {
- Config config = (Config) value;
- JComponent listCellRendererComponent = (JComponent) super.getListCellRendererComponent(list, config.getCategory(), index, isSelected, cellHasFocus);
- listCellRendererComponent.setToolTipText(config.getCategory());
- return listCellRendererComponent;
- }
- return this;
- }
- };
- }
-
- public void onValueChanged() {
- Object value = list.getSelectedValue();
- if (value instanceof Config) {
- Config config = (Config) value;
- cardLayout.show(preview, config.getCategory());
- }
- }
-
- public ConfigUI init(AbstractContext context, Config... configs) {
- for (Config config : configs) {
- add(context, config);
- }
- if (list.getModel().getSize() > 0) {
- list.setSelectedIndex(0);
- }
- return this;
- }
-
- public boolean add(AbstractContext context, Config config) {
- int index = getConfigs().indexOf(config);
- if (index > -1) {
- return false;
- }
- configs.add(config);
- ConfigTab ui = new ConfigTab();
- ui.getHandler().init(context, config);
- listModel.addElement(config);
- preview.add(ui, config.getCategory());
- return true;
- }
-
- public boolean remove(Config o) {
- if (configs == null) {
- return false;
- }
- int index = configs.indexOf(o);
- if (index == -1) {
- return false;
- }
- listModel.remove(index);
- preview.remove(index);
- configs.remove(index);
- return true;
- }
-}
Deleted: trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigUIHandler.java
===================================================================
--- trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigUIHandler.java 2008-07-21 00:34:57 UTC (rev 874)
+++ trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigUIHandler.java 2008-07-22 20:06:39 UTC (rev 875)
@@ -1,115 +0,0 @@
-/*
-* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
-* Tony Chemit
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-* ##% */
-package org.codelutin.option.ui;
-
-import org.codelutin.option.AbstractContext;
-import org.codelutin.option.Config;
-
-import javax.swing.*;
-import javax.swing.event.TableModelEvent;
-import javax.swing.event.TableModelListener;
-
-/**
- * Le controleur de l'ui de modification de configuration.
- *
- * @author chemit
- */
-public class ConfigUIHandler {
-
- protected ConfigTab ui;
- protected Config config;
- protected ConfigTableModel tableModel;
- protected TableModelListener tableModelListener;
-
- protected AbstractContext context;
-
- public ConfigUIHandler(ConfigTab ui) {
- this.ui = ui;
- }
-
- public void init(AbstractContext context, Config config) {
- this.config = config;
- this.context = context;
- tableModel = new ConfigTableModel(config);
-
- tableModel.addTableModelListener(getTableModelListener());
- JTable table = ui.getMain();
- table.setModel(tableModel);
-
- ConfigTableRenderer renderer = new ConfigTableRenderer(tableModel);
- table.getColumnModel().getColumn(0).setCellRenderer(renderer);
- table.getColumnModel().getColumn(1).setCellRenderer(renderer);
- table.getColumnModel().getColumn(1).setCellEditor(new ConfigTableEditor(getTableModel()));
-
- tableModel.fireTableDataChanged();
- }
-
- public void doSave() {
- if (!isEmpty() && getTableModel().isModified()) {
- getTableModel().transfertModified(getConfig());
- context.saveSafely();
- }
- doReset();
- }
-
- public void doReset() {
- getTableModel().reset();
- }
-
- public void doSelectTechnical(boolean showTechnical) {
- tableModel.setType(showTechnical ? ConfigTableModel.TypeModel.all : ConfigTableModel.TypeModel.nontech);
- }
-
- protected boolean isSaveEnabled() {
- return isResetEnabled() && tableModel.isValid();
- }
-
- protected boolean isResetEnabled() {
- return !isEmpty() && tableModel.isModified();
- }
-
- protected boolean isEmpty() {
- return tableModel == null || config == null || config.getUniverse().isEmpty();
- }
-
- protected Config getConfig() {
- return config;
- }
-
- protected ConfigTableModel getTableModel() {
- return tableModel;
- }
-
- protected TableModelListener getTableModelListener() {
- if (tableModelListener == null) {
- tableModelListener = new TableModelListener() {
- public void tableChanged(TableModelEvent e) {
- ui.getSave().setEnabled(isSaveEnabled());
- ui.getReset().setEnabled(isResetEnabled());
- }
- };
- }
- return tableModelListener;
- }
-
- protected void dispose() {
- getTableModel().reset();
- }
-
-}
\ No newline at end of file
Deleted: trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/LoginUIHandler.java
===================================================================
--- trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/LoginUIHandler.java 2008-07-21 00:34:57 UTC (rev 874)
+++ trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/LoginUIHandler.java 2008-07-22 20:06:39 UTC (rev 875)
@@ -1,28 +0,0 @@
-package org.codelutin.option.ui;
-
-public abstract class LoginUIHandler {
-
- boolean cancel;
-
- JLoginUI ui;
-
- protected abstract boolean connect(String login, char[] password);
-
- protected abstract boolean failedToConnect();
-
- public abstract void doConnect();
-
- public abstract void doCancel();
-
- protected void setUi(JLoginUI ui) {
- this.ui = ui;
- }
-
- public void setCancel(boolean cancel) {
- this.cancel = cancel;
- }
-
- public boolean isCancel() {
- return cancel;
- }
-}
\ No newline at end of file
1
0
21 Jul '08
Author: tchemit
Date: 2008-07-21 00:34:57 +0000 (Mon, 21 Jul 2008)
New Revision: 874
Modified:
trunk/commandline/pom.xml
Log:
utilisation org.codelutin:lutinutil:0.30-SNAPSHOT
Modified: trunk/commandline/pom.xml
===================================================================
--- trunk/commandline/pom.xml 2008-07-20 23:52:25 UTC (rev 873)
+++ trunk/commandline/pom.xml 2008-07-21 00:34:57 UTC (rev 874)
@@ -26,7 +26,7 @@
<dependencies>
<dependency>
- <groupId>lutinlib</groupId>
+ <groupId>org.codelutin</groupId>
<artifactId>lutinutil</artifactId>
</dependency>
</dependencies>
@@ -212,9 +212,9 @@
</dependency>
<dependency>
- <groupId>lutinlib</groupId>
+ <groupId>org.codelutin</groupId>
<artifactId>lutinutil</artifactId>
- <version>0.29</version>
+ <version>0.30-SNAPSHOT</version>
</dependency>
<dependency>
1
0
[Lutinutil-commits] r873 - trunk/lutinutil/src/main/java/org/codelutin/util
by tchemit@users.labs.libre-entreprise.org 20 Jul '08
by tchemit@users.labs.libre-entreprise.org 20 Jul '08
20 Jul '08
Author: tchemit
Date: 2008-07-20 23:52:25 +0000 (Sun, 20 Jul 2008)
New Revision: 873
Added:
trunk/lutinutil/src/main/java/org/codelutin/util/PropertiesDateRemoveFilterStream.java
Log:
get from maven-i18n-plugin
Added: trunk/lutinutil/src/main/java/org/codelutin/util/PropertiesDateRemoveFilterStream.java
===================================================================
--- trunk/lutinutil/src/main/java/org/codelutin/util/PropertiesDateRemoveFilterStream.java (rev 0)
+++ trunk/lutinutil/src/main/java/org/codelutin/util/PropertiesDateRemoveFilterStream.java 2008-07-20 23:52:25 UTC (rev 873)
@@ -0,0 +1,50 @@
+/*
+* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package org.codelutin.util;
+
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+public class PropertiesDateRemoveFilterStream extends FilterOutputStream {
+
+ private boolean firstLineOver;
+ char endChar;
+
+ public PropertiesDateRemoveFilterStream(OutputStream out) {
+ super(out);
+ firstLineOver = false;
+ String lineSeparator = java.security.AccessController
+ .doPrivileged(new sun.security.action.GetPropertyAction(
+ "line.separator"));
+ endChar = lineSeparator.charAt(lineSeparator.length() - 1);
+ }
+
+ @Override
+ public void write(int b) throws IOException {
+ if (!firstLineOver) {
+ char c = (char) b;
+ if (c == endChar) {
+ firstLineOver = true;
+ }
+ } else {
+ out.write(b);
+ }
+ }
+
+}
\ No newline at end of file
1
0
[Lutinutil-commits] r872 - in trunk/commandline/commandline-ui/src/main: resources/i18n uimodel/org/codelutin/option/ui
by tchemit@users.labs.libre-entreprise.org 20 Jul '08
by tchemit@users.labs.libre-entreprise.org 20 Jul '08
20 Jul '08
Author: tchemit
Date: 2008-07-20 19:47:39 +0000 (Sun, 20 Jul 2008)
New Revision: 872
Added:
trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/JLoginUI.jaxx
trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/LoginUIHandler.java
Modified:
trunk/commandline/commandline-ui/src/main/resources/i18n/commandline-ui-en_GB.properties
trunk/commandline/commandline-ui/src/main/resources/i18n/commandline-ui-fr_FR.properties
Log:
introduction UI pour un login basique
Modified: trunk/commandline/commandline-ui/src/main/resources/i18n/commandline-ui-en_GB.properties
===================================================================
--- trunk/commandline/commandline-ui/src/main/resources/i18n/commandline-ui-en_GB.properties 2008-07-20 19:47:11 UTC (rev 871)
+++ trunk/commandline/commandline-ui/src/main/resources/i18n/commandline-ui-en_GB.properties 2008-07-20 19:47:39 UTC (rev 872)
@@ -1,3 +1,5 @@
+lutinutil.common.apply=Ok
+lutinutil.common.cancel=Cancel
lutinutil.common.key=Key
lutinutil.common.quit=Quit
lutinutil.common.reset=Reset
@@ -9,3 +11,7 @@
lutinutil.config.modified=modified
lutinutil.config.title=Configuration modifier dialog
lutinutil.config.unvalid=unvalid
+lutinutil.connexion=Authentication
+lutinutil.login=Login
+lutinutil.password=Password
+lutinutil.remember_password=Remember password ?
Modified: trunk/commandline/commandline-ui/src/main/resources/i18n/commandline-ui-fr_FR.properties
===================================================================
--- trunk/commandline/commandline-ui/src/main/resources/i18n/commandline-ui-fr_FR.properties 2008-07-20 19:47:11 UTC (rev 871)
+++ trunk/commandline/commandline-ui/src/main/resources/i18n/commandline-ui-fr_FR.properties 2008-07-20 19:47:39 UTC (rev 872)
@@ -1,3 +1,5 @@
+lutinutil.common.apply=Ok
+lutinutil.common.cancel=Annuler
lutinutil.common.key=Clef
lutinutil.common.quit=Quitter
lutinutil.common.reset=R\u00E9initialiser
@@ -9,3 +11,7 @@
lutinutil.config.modified=Modifi\u00E9
lutinutil.config.title=Fen\u00EAtre de modification de configuration
lutinutil.config.unvalid=Invalid
+lutinutil.connexion=Authentification
+lutinutil.login=Login
+lutinutil.password=Mot de passe
+lutinutil.remember_password=Se souvenir du mot de passe ?
Added: trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/JLoginUI.jaxx
===================================================================
--- trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/JLoginUI.jaxx (rev 0)
+++ trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/JLoginUI.jaxx 2008-07-20 19:47:39 UTC (rev 872)
@@ -0,0 +1,79 @@
+<JDialog title="lutinutil.connexion" modal='true' locationRelativeTo="{null}" defaultCloseOperation="dispose_on_close">
+ <script>
+ protected LoginUIHandler handler;
+
+ public boolean launch(String login,String password) {
+ if (login != null) {
+ this.getLogin().setText(login);
+ }
+ if (password!=null) {
+ this.getPassword().setText(password);
+ }
+ check();
+ setVisible(true);
+ return !handler.cancel;
+ }
+
+ public JLoginUI(JFrame instance, LoginUIHandler handler) {
+ super(instance);
+ this.handler = handler;
+ this.handler.setUi(this);
+ // block close operation
+ setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
+ JRootPane rootPane = getRootPane();
+ rootPane.setDefaultButton(ok);
+ }
+
+ protected void doConnect() {
+ handler.doConnect();
+ if (handler.isCancel()) {
+ doCancel();
+ }
+ }
+
+ protected void doCancel() {
+ handler.doCancel();
+ dispose();
+ }
+
+ protected void check() {
+ ok.setEnabled(login.getText().trim().length()>0 && password.getPassword().length>0);
+ }
+
+
+ </script>
+ <Table insets='5,5,5,5'>
+ <row>
+ <cell>
+ <JLabel text="lutinutil.login"/>
+ </cell>
+ <cell>
+ <JTextField id="login" onKeyReleased='check()' onActionPerformed='check()'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text="lutinutil.password"/>
+ </cell>
+ <cell>
+ <JPasswordField id="password" onKeyReleased='check()' onActionPerformed='check()'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JCheckBox id="rememberCheckBox"/>
+ </cell>
+ <cell>
+ <JLabel text="lutinutil.remember_password"/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JButton id='ok' text='lutinutil.common.apply' onActionPerformed="doConnect()" enabled='false'/>
+ </cell>
+ <cell>
+ <JButton text='lutinutil.common.cancel' onActionPerformed="doCancel()"/>
+ </cell>
+ </row>
+ </Table>
+</JDialog>
\ No newline at end of file
Added: trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/LoginUIHandler.java
===================================================================
--- trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/LoginUIHandler.java (rev 0)
+++ trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/LoginUIHandler.java 2008-07-20 19:47:39 UTC (rev 872)
@@ -0,0 +1,28 @@
+package org.codelutin.option.ui;
+
+public abstract class LoginUIHandler {
+
+ boolean cancel;
+
+ JLoginUI ui;
+
+ protected abstract boolean connect(String login, char[] password);
+
+ protected abstract boolean failedToConnect();
+
+ public abstract void doConnect();
+
+ public abstract void doCancel();
+
+ protected void setUi(JLoginUI ui) {
+ this.ui = ui;
+ }
+
+ public void setCancel(boolean cancel) {
+ this.cancel = cancel;
+ }
+
+ public boolean isCancel() {
+ return cancel;
+ }
+}
\ No newline at end of file
1
0
[Lutinutil-commits] r871 - in trunk/commandline: . commandline-core commandline-ui maven-plugin
by tchemit@users.labs.libre-entreprise.org 20 Jul '08
by tchemit@users.labs.libre-entreprise.org 20 Jul '08
20 Jul '08
Author: tchemit
Date: 2008-07-20 19:47:11 +0000 (Sun, 20 Jul 2008)
New Revision: 871
Modified:
trunk/commandline/commandline-core/pom.xml
trunk/commandline/commandline-ui/pom.xml
trunk/commandline/maven-plugin/pom.xml
trunk/commandline/pom.xml
Log:
passage en 0.7-SNAPSHOT
Modified: trunk/commandline/commandline-core/pom.xml
===================================================================
--- trunk/commandline/commandline-core/pom.xml 2008-07-10 14:02:23 UTC (rev 870)
+++ trunk/commandline/commandline-core/pom.xml 2008-07-20 19:47:11 UTC (rev 871)
@@ -7,14 +7,14 @@
<parent>
<groupId>org.codelutin.commandline</groupId>
<artifactId>commandline-pom</artifactId>
- <version>0.6</version>
+ <version>0.7-SNAPSHOT</version>
</parent>
<artifactId>commandline-core</artifactId>
<name>core</name>
<packaging>jar</packaging>
- <version>0.6</version>
+ <version>0.7-SNAPSHOT</version>
<description>lutincommandline core library</description>
<build>
Modified: trunk/commandline/commandline-ui/pom.xml
===================================================================
--- trunk/commandline/commandline-ui/pom.xml 2008-07-10 14:02:23 UTC (rev 870)
+++ trunk/commandline/commandline-ui/pom.xml 2008-07-20 19:47:11 UTC (rev 871)
@@ -12,7 +12,7 @@
<parent>
<groupId>org.codelutin.commandline</groupId>
<artifactId>commandline-pom</artifactId>
- <version>0.6</version>
+ <version>0.7-SNAPSHOT</version>
</parent>
<artifactId>commandline-ui</artifactId>
@@ -20,8 +20,8 @@
<dependencies>
<dependency>
- <groupId>org.codelutin.jaxx.provider</groupId>
- <artifactId>swing</artifactId>
+ <groupId>org.codelutin.jaxx</groupId>
+ <artifactId>jaxx-swing</artifactId>
<scope>compile</scope>
</dependency>
@@ -37,7 +37,7 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
<name>ui</name>
- <version>0.6</version>
+ <version>0.7-SNAPSHOT</version>
<description>lutin commandline UI librairy</description>
<inceptionYear>2008</inceptionYear>
@@ -54,7 +54,7 @@
<plugin>
<groupId>org.codelutin.jaxx</groupId>
<artifactId>maven-jaxx-plugin</artifactId>
- <version>0.1</version>
+ <version>0.2-SNAPSHOT</version>
<configuration>
<src>${maven.src.dir}/main/uimodel</src>
<out>${maven.src.dir}/main/java</out>
@@ -64,15 +64,14 @@
<goals>
<goal>generate</goal>
</goals>
-
</execution>
</executions>
<dependencies>
<dependency>
- <groupId>org.codelutin.jaxx.provider</groupId>
- <artifactId>swing</artifactId>
+ <groupId>org.codelutin.jaxx</groupId>
+ <artifactId>jaxx-swing</artifactId>
<scope>compile</scope>
- <version>0.1</version>
+ <version>0.2-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
Modified: trunk/commandline/maven-plugin/pom.xml
===================================================================
--- trunk/commandline/maven-plugin/pom.xml 2008-07-10 14:02:23 UTC (rev 870)
+++ trunk/commandline/maven-plugin/pom.xml 2008-07-20 19:47:11 UTC (rev 871)
@@ -12,7 +12,7 @@
<parent>
<groupId>org.codelutin.commandline</groupId>
<artifactId>commandline-pom</artifactId>
- <version>0.6</version>
+ <version>0.7-SNAPSHOT</version>
</parent>
<artifactId>maven-commandline-plugin</artifactId>
@@ -58,7 +58,7 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <version>0.6</version>
+ <version>0.7-SNAPSHOT</version>
<description>
Plugin maven 2 pour la generation du parser d'options, des
Modified: trunk/commandline/pom.xml
===================================================================
--- trunk/commandline/pom.xml 2008-07-10 14:02:23 UTC (rev 870)
+++ trunk/commandline/pom.xml 2008-07-20 19:47:11 UTC (rev 871)
@@ -35,7 +35,7 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
<name>pom</name>
- <version>0.6</version>
+ <version>0.7-SNAPSHOT</version>
<description>lutincommandline library main pom</description>
<inceptionYear>2008</inceptionYear>
@@ -156,7 +156,7 @@
</labs.lists>
<!-- maven will suffix with /${pom.artifactId} -->
- <maven.scm.developerConnection>scm:svn:svn+ssh://tchemit@${labs.host}/svnroot/lutinutil/trunk
+ <maven.scm.developerConnection>scm:svn:svn+ssh://${username}@${labs.host}/svnroot/lutinutil/trunk
</maven.scm.developerConnection>
<!-- maven will suffix with /${pom.artifactId} -->
@@ -182,7 +182,7 @@
<activeByDefault>false</activeByDefault>
</activation>
<properties>
- <!-- test (par defaut, on ne les execute pas) -->
+ <!-- test (par defaut, on les execute) -->
<maven.test.skip>false</maven.test.skip>
<maven.reports.generate>false</maven.reports.generate>
</properties>
@@ -194,7 +194,7 @@
</activation>
<properties>
<!-- test (par defaut, on ne les execute pas) -->
- <maven.test.skip>false</maven.test.skip>
+ <maven.test.skip>true</maven.test.skip>
<maven.reports.generate>true</maven.reports.generate>
</properties>
</profile>
@@ -218,21 +218,21 @@
</dependency>
<dependency>
- <groupId>org.codelutin.jaxx.provider</groupId>
- <artifactId>swing</artifactId>
- <version>0.1</version>
+ <groupId>org.codelutin.jaxx</groupId>
+ <artifactId>jaxx-swing</artifactId>
+ <version>0.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.codelutin.commandline</groupId>
<artifactId>commandline-core</artifactId>
- <version>0.6</version>
+ <version>0.7-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.codelutin.commandline</groupId>
<artifactId>commandline-ui</artifactId>
- <version>0.6</version>
+ <version>0.7-SNAPSHOT</version>
</dependency>
<dependency>
@@ -272,7 +272,7 @@
<dependency>
<groupId>org.codelutin.jaxx</groupId>
<artifactId>maven-jaxx-plugin</artifactId>
- <version>0.1</version>
+ <version>0.2-SNAPHOT</version>
</dependency>
</dependencies>
</dependencyManagement>
1
0
[Lutinutil-commits] r870 - trunk/lutinutil/src/main/java/org/codelutin/util
by chatellier@users.labs.libre-entreprise.org 10 Jul '08
by chatellier@users.labs.libre-entreprise.org 10 Jul '08
10 Jul '08
Author: chatellier
Date: 2008-07-10 14:02:23 +0000 (Thu, 10 Jul 2008)
New Revision: 870
Modified:
trunk/lutinutil/src/main/java/org/codelutin/util/Resource.java
Log:
Reformat code, add comment, and correct some comments
Modified: trunk/lutinutil/src/main/java/org/codelutin/util/Resource.java
===================================================================
--- trunk/lutinutil/src/main/java/org/codelutin/util/Resource.java 2008-07-10 08:34:12 UTC (rev 869)
+++ trunk/lutinutil/src/main/java/org/codelutin/util/Resource.java 2008-07-10 14:02:23 UTC (rev 870)
@@ -1,33 +1,33 @@
/**##%%
-* Copyright (C) 2002, 2003, 2004 Code Lutin, C�dric Pineau, Benjamin Poussin
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*##%%**/
+ * Copyright (C) 2002, 2003, 2004 Code Lutin, C�dric Pineau, Benjamin Poussin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%%**/
/**
-* Resource.java
-*
-* Created: Sun Apr 14 2002
-*
-* @author POUSSIN Benjamin <bpoussin(a)free.fr>
-* Copyright Code Lutin
-* @version $Revision$
-*
-* Mise a jour: $Date$
-* par : $Author$
-*/
+ * Resource.java
+ *
+ * Created: Sun Apr 14 2002
+ *
+ * @author POUSSIN Benjamin <bpoussin(a)free.fr>
+ * Copyright Code Lutin
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
package org.codelutin.util;
@@ -54,14 +54,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
/**
-* Cette class permet de recherche un fichier en indiquant son nom
-* avec son chemin. Cette librairie ira ensuite chercher ce fichier
-* sur le syst�me de fichier, et s'il n'est pas trouv� dans le
-* classpath. Le fichier peut donc �tre dans un fichier .jar ou .zip.
-*/
-public class Resource { // Resource
+ * Cette class permet de rechercher un fichier en indiquant son nom avec son
+ * chemin. Cette librairie ira ensuite chercher ce fichier sur le syst�me de
+ * fichier, et s'il n'est pas trouv� dans le classpath. Le fichier peut donc
+ * �tre dans un fichier .jar ou .zip.
+ */
+public class Resource { // Resource
/** to use log facility, just put in your code: log.info(\"...\"); */
private static final Log log = LogFactory.getLog(Resource.class);
@@ -71,64 +70,72 @@
}
/**
- * Permet d'ajouter dans le classloader par defaut une nouvelle URL
- * dans lequel il faut rechercher les fichiers.
- * @param url l'url a ajouter
- */
- static public void addDefaultClassLoader(URL url){
- try{
+ * Permet d'ajouter dans le classloader par defaut une nouvelle URL dans
+ * lequel il faut rechercher les fichiers.
+ *
+ * @param url l'url a ajouter
+ */
+ static public void addDefaultClassLoader(URL url) {
+ try {
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
- Method method = URLClassLoader.class.getDeclaredMethod("addURL", new Class[]{URL.class});
+ Method method = URLClassLoader.class.getDeclaredMethod("addURL",
+ new Class[] { URL.class });
method.setAccessible(true);
method.invoke(classLoader, url);
- }catch(Exception eee){
- throw new RuntimeException("Can't add url in default classloader", eee);
+ } catch (Exception eee) {
+ throw new RuntimeException("Can't add url in default classloader",
+ eee);
}
}
/**
- * recherche la ressource nom
- * @param name nom de la ressource
- * @return l'url de la ressource
- * @throws ResourceNotFoundException si la resource n'a pas ete trouvee
- */
+ * Recherche la ressource nom.
+ *
+ * @param name nom de la ressource
+ * @return l'url de la ressource
+ * @throws ResourceNotFoundException si la resource n'a pas ete trouvee
+ */
static public URL getURL(String name) {
URL url = getURLOrNull(name);
- if (url != null){
+ if (url != null) {
return url;
}
- throw new ResourceNotFoundException("La resource " + name +
- " n'a pas �t� trouv�e");
+ throw new ResourceNotFoundException("La resource " + name
+ + " n'a pas �t� trouv�e");
}
/**
- * recherche la ressource nom
- * @param name le nom de la ressource
- * @return l'url de la ressource ou null
- */
+ * Recherche la ressource nom.
+ *
+ * @param name le nom de la ressource
+ * @return l'url de la ressource ou null
+ */
static public URL getURLOrNull(String name) {
// on recherche d'abord sur le filesystem
File file = new File(name);
- if (file.exists()){
- try{
+ if (file.exists()) {
+ try {
return file.toURI().toURL();
- }catch(MalformedURLException eee){
- log.warn("Le fichier '" + file + "' a �t� trouv�, mais il n'a pas pu etre converti en URL");
+ } catch (MalformedURLException eee) {
+ log
+ .warn("Le fichier '"
+ + file
+ + "' a �t� trouv�, mais il n'a pas pu etre converti en URL");
}
}
- //on ne l'a pas trouve on recherche dans le classpath
+ // on ne l'a pas trouve on recherche dans le classpath
// on supprime le / devant le nom de la ressource, sinon elle
// n'est pas trouve (pas de recherche dans les differents
// element du classpath.
- if(name.length() > 1 && name.startsWith("/")){
+ if (name.length() > 1 && name.startsWith("/")) {
name = name.substring(1);
}
URL url = ClassLoader.getSystemClassLoader().getResource(name);
- if (url != null){
+ if (url != null) {
return url;
}
@@ -138,35 +145,50 @@
}
/**
- * Retourne l'icon demande
- * @param name le nom de l'icone
+ * Retourne l'icone demandee.
+ *
+ * @param name le nom de l'icone
* @return Retourne l'icon demande ou null s'il n'est pas trouv�
- */
- static public ImageIcon getIcon(String name){
- try{
+ */
+ static public ImageIcon getIcon(String name) {
+ try {
return new ImageIcon(getURL(name));
- }catch(Exception eee){
+ } catch (Exception eee) {
log.warn("Can't find icon: " + name, eee);
return null;
}
}
-
/**
- * Recherche et retourne l'objet properties de configuration � utiliser.
- * Les diff�rents fichiers trouv� sont chain�. L'ordre de recherche est
- * le classpath, le fichier dans /etc et enfin le chemin sur le filesystem
- * @param filename le nom du fichier � rechercher
- * @return l'objet Properties de configuration
- * @throws java.io.IOException si pb
- */
- static public Properties getConfigProperties(String filename) throws IOException {
+ * Recherche et retourne l'objet properties de configuration � utiliser.
+ *
+ * Les diff�rents fichiers trouv� sont chain�. L'ordre de recherche est le
+ * classpath, le fichier dans /etc et enfin le chemin sur le filesystem.
+ *
+ * @param filename le nom du fichier � rechercher
+ * @return l'objet Properties de configuration
+ * @throws IOException si une erreur est survenue
+ */
+ static public Properties getConfigProperties(String filename)
+ throws IOException {
Properties result;
result = getConfigProperties(filename, null);
return result;
}
- static public Properties getConfigProperties(String filename, Properties parent) throws IOException {
+ /**
+ * Recherche et retourne l'objet properties de configuration � utiliser.
+ *
+ * Les diff�rents fichiers trouv� sont chain�. L'ordre de recherche est le
+ * classpath, le fichier dans /etc et enfin le chemin sur le filesystem.
+ *
+ * @param filename le nom du fichier � rechercher
+ * @param parent les proprietes parent a surcharger
+ * @return l'objet Properties de configuration
+ * @throws IOException si une erreur est survenue
+ */
+ static public Properties getConfigProperties(String filename,
+ Properties parent) throws IOException {
Properties result;
if (parent != null) {
result = new Properties(parent);
@@ -174,28 +196,29 @@
result = new Properties();
}
- URL inClasspath = ClassLoader.getSystemClassLoader().getResource(filename);
+ URL inClasspath = ClassLoader.getSystemClassLoader().getResource(
+ filename);
if (inClasspath == null) {
inClasspath = Resource.class.getResource(filename);
}
if (inClasspath == null) {
inClasspath = getURLOrNull(filename);
}
- if(inClasspath != null){
+ if (inClasspath != null) {
log.info("Chargement du fichier de config: " + inClasspath);
result.load(inClasspath.openStream());
result = new Properties(result);
}
File etcConfig = new File("/etc/" + filename);
- if(etcConfig.exists()){
+ if (etcConfig.exists()) {
log.info("Chargement du fichier de config: " + etcConfig);
result.load(etcConfig.toURI().toURL().openStream());
result = new Properties(result);
}
File config = new File(filename);
- if(config.exists()){
+ if (config.exists()) {
log.info("Chargement du fichier de config: " + config);
result.load(config.toURI().toURL().openStream());
result = new Properties(result);
@@ -205,22 +228,23 @@
}
/**
- * Retourner la liste des fichiers du classLoader. Ces fichiers doivent
- * correspondent au pattern donne
- *
- * @param pattern le nom du fichier a extraire du
- * fichier compress� ou durepertoire doit correspondre
- * au pattern (repertoire + nom compris).
- * @return la liste des urls correspondant au pattern
- */
+ * Retourner la liste des fichiers du classLoader. Ces fichiers doivent
+ * correspondre au pattern donne.
+ *
+ * @param pattern le nom du fichier a extraire du fichier compress� ou
+ * du repertoire doit correspondre au pattern (repertoire + nom
+ * compris).
+ * @return la liste des urls correspondant au pattern
+ */
static public List<URL> getURLs(String pattern) {
return getURLs(pattern, (URLClassLoader) null);
}
- static private URL[] getURLs(URLClassLoader classLoader) {
- Method m;
+ static protected URL[] getURLs(URLClassLoader classLoader) {
+ Method m;
try {
- // Essai de r�cup�ration de la m�thode getAllURLs() de RepositoryClassLoader (JBoss)
+ // Essai de r�cup�ration de la m�thode getAllURLs() de
+ // RepositoryClassLoader (JBoss)
m = classLoader.getClass().getMethod("getAllURLs");
} catch (Exception e) {
m = null;
@@ -239,34 +263,34 @@
}
/**
- * Retourner la liste des fichiers du classLoader. Ces fichiers doivent
- * correspondent au pattern donne
- *
- *@param classLoader le classLoader
- *@param pattern le nom du fichier a extraire du
- * fichier compress� ou durepertoire doit correspondre
- * au pattern (repertoire + nom compris).
- *@return la liste des urls correspondant au pattern
- */
+ * Retourner la liste des fichiers du classLoader. Ces fichiers doivent
+ * correspondre au pattern donne.
+ *
+ * @param classLoader le classLoader
+ * @param pattern le nom du fichier a extraire du fichier compress� ou
+ * du repertoire doit correspondre au pattern (repertoire + nom
+ * compris).
+ * @return la liste des urls correspondant au pattern
+ */
static public List<URL> getURLs(String pattern, URLClassLoader classLoader) {
- if(classLoader == null){
- classLoader = (URLClassLoader)ClassLoader.getSystemClassLoader();
+ if (classLoader == null) {
+ classLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
}
URL[] arrayURL = getURLs(classLoader);
- return getURLs(pattern,arrayURL);
+ return getURLs(pattern, arrayURL);
}
/**
- * Retourner la liste des fichiers du classLoader. Ces fichiers doivent
- * correspondent au pattern donne
- *
- *@param arrayURL les urls ou chercher
- *@param pattern le nom du fichier a extraire du
- * fichier compress� ou durepertoire doit correspondre
- * au pattern (repertoire + nom compris).
- *@return la liste des urls correspondant au pattern
- */
- static public List<URL> getURLs(String pattern, URL... arrayURL ) {
+ * Retourner la liste des fichiers du classLoader. Ces fichiers doivent
+ * correspondre au pattern donne.
+ *
+ * @param arrayURL les urls ou chercher
+ * @param pattern le nom du fichier a extraire du fichier compress� ou
+ * durepertoire doit correspondre au pattern (repertoire + nom
+ * compris).
+ * @return la liste des urls correspondant au pattern
+ */
+ static public List<URL> getURLs(String pattern, URL... arrayURL) {
long t0 = System.nanoTime();
HashList<URL> urlList = new HashList<URL>();
@@ -279,7 +303,7 @@
arrayURL = getClassPathURLsFromJarManifest(jarURL);
} catch (Exception e) {
log.warn(e);
- arrayURL = new URL[]{jarURL};
+ arrayURL = new URL[] { jarURL };
}
}
}
@@ -291,8 +315,9 @@
for (URL urlFile : arrayURL) {
String fileName = urlFile.getFile();
- //TODO deal with encoding in windows, this is very durty, but it works...
- File file= new File(fileName.replaceAll("%20", " "));
+ // TODO deal with encoding in windows, this is very durty, but it
+ // works...
+ File file = new File(fileName.replaceAll("%20", " "));
// cas ou le ichier du classLoader est un fichier jar ou zip
if (file.exists() && (isJar(fileName) || isZip(fileName))) {
if (log.isDebugEnabled()) {
@@ -305,18 +330,22 @@
if (log.isDebugEnabled()) {
log.debug("file to search " + file);
}
- // on traite le cas ou il peut y avoir des repertoire dans ce repertoire
+ // on traite le cas ou il peut y avoir des repertoire dans ce
+ // repertoire
urlList.addAll(Resource.getURLsFromDirectory(file, pattern));
}
}
if (log.isInfoEnabled()) {
- log.info("search URLs pattern: " + pattern + " in " + arrayURL.length+" urls in "+StringUtil.convertTime(System.nanoTime()-t0));
+ log.info("search URLs pattern: " + pattern + " in "
+ + arrayURL.length + " urls in "
+ + StringUtil.convertTime(System.nanoTime() - t0));
}
return urlList;
}
- static public URL[] getClassPathURLsFromJarManifest(URL jarURL) throws IOException, URISyntaxException {
- JarFile jar=null;
+ static public URL[] getClassPathURLsFromJarManifest(URL jarURL)
+ throws IOException, URISyntaxException {
+ JarFile jar = null;
URL[] result;
try {
String jarPath = jarURL.toURI().getPath();
@@ -327,7 +356,8 @@
jar = new JarFile(jarFile);
File container = jarFile.getParentFile();
Manifest mf = jar.getManifest();
- String classPath = mf.getMainAttributes().getValue(Attributes.Name.CLASS_PATH);
+ String classPath = mf.getMainAttributes().getValue(
+ Attributes.Name.CLASS_PATH);
String[] paths = classPath.split(" ");
result = new URL[paths.length + 1];
result[0] = jarURL;
@@ -336,9 +366,9 @@
String s = paths[i];
if (s.startsWith(".") || !s.startsWith("/")) {
// relative url
- path =new File(container,s);
+ path = new File(container, s);
} else {
- path =new File(s);
+ path = new File(s);
}
if (log.isDebugEnabled()) {
log.debug(path);
@@ -347,7 +377,7 @@
}
jar.close();
} finally {
- if (jar!=null) {
+ if (jar != null) {
jar.close();
}
}
@@ -355,8 +385,8 @@
}
static public List<URL> getURLsFromJar(File jarfile, String pattern) {
- try{
- if(log.isTraceEnabled()) {
+ try {
+ if (log.isTraceEnabled()) {
log.trace("search '" + pattern + "' in " + jarfile);
}
@@ -371,44 +401,45 @@
}
String name = entry.getName();
- if(log.isTraceEnabled()) {
+ if (log.isTraceEnabled()) {
log.trace("jarfile: " + jarfile + " name: " + name);
}
if (pattern == null || name.matches(pattern)) {
- // on recupere le fichier correspondant au pattern dans le classloader
+ // on recupere le fichier correspondant au pattern dans le
+ // classloader
URL url = Resource.getURL(name);
- // on ajoute le fichier correspondant au pattern dans la liste
- if(log.isTraceEnabled()) {
+ // on ajoute le fichier correspondant au pattern dans la
+ // liste
+ if (log.isTraceEnabled()) {
log.trace("jarfile: " + jarfile + " url: " + url);
}
result.add(url);
}
}
- if(log.isTraceEnabled()) {
+ if (log.isTraceEnabled()) {
log.trace("found with pattern '" + pattern + "' : " + result);
}
return result;
- }catch(IOException eee){
- throw new ResourceException("Erreur lors de la lecture du fichier compress�", eee);
+ } catch (IOException eee) {
+ throw new ResourceException(
+ "Erreur lors de la lecture du fichier compress�", eee);
}
}
/**
- * Retourner la liste des fichiers correspondant au pattern donne, aucun
- * ordre ne doit sur le fichier ne doit �tre suppos�.
- *
- *@param repository repertoire dans lequel on recherche les fichiers
- *@param pattern le nom du fichier a extraire du
- * fichier du repertoire doit correspondre
- * au pattern (repertoire + nom compris).
- * si le pattern est null, tous les fichiers trouv�
- * sont retourn�.
- *
- *@return la liste des urls correspondant au pattern
- */
+ * Retourne la liste des fichiers correspondant au pattern donne, aucun
+ * ordre ne doit �tre suppos� sur les fichiers.
+ *
+ * @param repository repertoire dans lequel on recherche les fichiers
+ * @param pattern le nom du fichier a extraire du fichier du repertoire doit
+ * correspondre au pattern (repertoire + nom compris). si le
+ * pattern est null, tous les fichiers trouv� sont retourn�.
+ *
+ * @return la liste des urls correspondant au pattern
+ */
static public List<URL> getURLsFromDirectory(File repository, String pattern) {
- try{
- if(log.isTraceEnabled()) {
+ try {
+ if (log.isTraceEnabled()) {
log.trace("search '" + pattern + "' in " + repository);
}
@@ -422,37 +453,44 @@
String name = file.getAbsolutePath();
if (log.isTraceEnabled()) {
- log.trace("directory: " + repository + " name: " + name);
+ log
+ .trace("directory: " + repository + " name: "
+ + name);
}
// cas de recursivite : repertoire dans un repertoire
if (file.exists() && file.isDirectory()) {
- urlList.addAll(Resource.getURLsFromDirectory(file, pattern));
- // si le fichier du repertoire n'est pas un repertoire on verifie s'il correspond au pattern
+ urlList.addAll(Resource.getURLsFromDirectory(file,
+ pattern));
+ // si le fichier du repertoire n'est pas un repertoire
+ // on verifie s'il correspond au pattern
} else if (pattern == null || name.matches(pattern)) {
URL url = file.toURI().toURL();
if (log.isTraceEnabled()) {
- log.trace("directory: " + repository + " url: " + url);
+ log.trace("directory: " + repository + " url: "
+ + url);
}
urlList.add(url);
}
}
}
- if(log.isTraceEnabled()) {
+ if (log.isTraceEnabled()) {
log.trace("found with pattern '" + pattern + "' : " + urlList);
}
return urlList;
- }catch(MalformedURLException eee){
- throw new ResourceException("Le fichier n'a pu �tre converti en URL", eee);
+ } catch (MalformedURLException eee) {
+ throw new ResourceException(
+ "Le fichier n'a pu �tre converti en URL", eee);
}
}
/**
- * Verifie si le fichier est un fichier jar
- * @param name nom du fichier a tester
- * @return vrai si le fichier se termine par .jar faux sinon
- */
- static public boolean isJar(String name){
+ * Verifie si le fichier est un fichier jar.
+ *
+ * @param name nom du fichier a tester
+ * @return vrai si le fichier se termine par .jar faux sinon
+ */
+ static public boolean isJar(String name) {
if (name != null && name.length() > 4) {
String ext = name.substring(name.length() - 4, name.length());
return ".jar".equalsIgnoreCase(ext);
@@ -461,11 +499,12 @@
}
/**
- * Verifie si le fichier est un fichier zip
- * @param name nom du fichier a tester
- * @return vrai si le fichier se termine par .zip faux sinon
- */
- static public boolean isZip(String name){
+ * Verifie si le fichier est un fichier zip
+ *
+ * @param name nom du fichier a tester
+ * @return vrai si le fichier se termine par .zip faux sinon
+ */
+ static public boolean isZip(String name) {
if (name != null && name.length() > 4) {
String ext = name.substring(name.length() - 4, name.length());
return ".zip".equalsIgnoreCase(ext);
@@ -474,49 +513,48 @@
}
/**
- * Verifie si la classe est de type primtif
- * @param clazz nom de la classe a tester
- * @return vrai si le classe est de type primitif faux sinon
- */
- static public boolean isPrimitive(Class clazz){
- return clazz.isPrimitive()
- || clazz == Boolean.class
- || clazz == Byte.class
- || clazz == Character.class
- || clazz == Short.class
- || clazz == Integer.class
- || clazz == Long.class
- || clazz == Float.class
- || clazz == Double.class;
+ * Verifie si la classe est de type primitif.
+ *
+ * @param clazz nom de la classe a tester
+ * @return vrai si le classe est de type primitif faux sinon
+ */
+ static public boolean isPrimitive(Class clazz) {
+ return clazz.isPrimitive() || clazz == Boolean.class
+ || clazz == Byte.class || clazz == Character.class
+ || clazz == Short.class || clazz == Integer.class
+ || clazz == Long.class || clazz == Float.class
+ || clazz == Double.class;
}
/**
- * Retourne la classe du type primitf associ� avec la classe de de l'objet
- * pass� en parametre. Par exemple si la classe pass�e en param�tre est
- * Integer alors le resultat sera la classe de int.
- * @param clazz la classe dont on souhaite le type primitf
- * @return le type primitif associ� a la classe en param�tre, ou null
- * s'il n'y a pas de type primitif associ�.
- */
+ * Retourne la classe du type primitf associ� avec la classe de de l'objet
+ * pass� en parametre. Par exemple si la classe pass�e en param�tre est
+ * Integer alors le resultat sera la classe de int.
+ *
+ * @param clazz la classe dont on souhaite le type primitf
+ * @return le type primitif associ� a la classe en param�tre, ou null s'il
+ * n'y a pas de type primitif associ�.
+ */
static public Class getPrimitiveClass(Class clazz) {
- if (clazz == Boolean.class) return Boolean.TYPE;
- if (clazz == Byte.class) return Byte.TYPE;
- if (clazz == Character.class) return Character.TYPE;
- if (clazz == Short.class) return Short.TYPE;
- if (clazz == Integer.class) return Integer.TYPE;
- if (clazz == Long.class) return Long.TYPE;
- if (clazz == Float.class) return Float.TYPE;
- if (clazz == Double.class) return Double.TYPE;
- if (clazz == Void.class) return Void.TYPE;
+ if (clazz == Boolean.class)
+ return Boolean.TYPE;
+ if (clazz == Byte.class)
+ return Byte.TYPE;
+ if (clazz == Character.class)
+ return Character.TYPE;
+ if (clazz == Short.class)
+ return Short.TYPE;
+ if (clazz == Integer.class)
+ return Integer.TYPE;
+ if (clazz == Long.class)
+ return Long.TYPE;
+ if (clazz == Float.class)
+ return Float.TYPE;
+ if (clazz == Double.class)
+ return Double.TYPE;
+ if (clazz == Void.class)
+ return Void.TYPE;
return null;
}
-// /**
-// * Test
-// */
-// static public void main(String [] args) throws Exception {
-// String r = args.length>0?args[0]:"/org/codelutin/lutinbuilder/LutinBuilder.class";
-// System.out.println(getURL(r));
-// }
-
} // Resource
1
0
10 Jul '08
Author: tchemit
Date: 2008-07-10 08:34:12 +0000 (Thu, 10 Jul 2008)
New Revision: 869
Modified:
trunk/lutinutil/pom.xml
Log:
le groupId est desormais org.codelutin
Modified: trunk/lutinutil/pom.xml
===================================================================
--- trunk/lutinutil/pom.xml 2008-07-10 08:27:14 UTC (rev 868)
+++ trunk/lutinutil/pom.xml 2008-07-10 08:34:12 UTC (rev 869)
@@ -14,7 +14,7 @@
<version>2.3</version>
</parent>
- <!--groupId>lutinlib</groupId-->
+ <groupId>org.codelutin</groupId>
<artifactId>lutinutil</artifactId>
<dependencies>
1
0
10 Jul '08
Author: tchemit
Date: 2008-07-10 08:27:14 +0000 (Thu, 10 Jul 2008)
New Revision: 868
Modified:
trunk/lutinutil/changelog
trunk/lutinutil/pom.xml
Log:
passage en 0.30-SNAPSHOT et maven 2 layout directory
Modified: trunk/lutinutil/changelog
===================================================================
--- trunk/lutinutil/changelog 2008-07-10 08:21:55 UTC (rev 867)
+++ trunk/lutinutil/changelog 2008-07-10 08:27:14 UTC (rev 868)
@@ -1,3 +1,8 @@
+ver-0-30 chemit 20080710
+ * passage en maven 2 layout directory
+ * utilisation de lutinproject 2.3
+ * suppression du code vcs du projet
+
ver-0-26 poussin 2007????
* bug in concat(Object [] ...), better array type now work
* add unaccent in StringUtil
Modified: trunk/lutinutil/pom.xml
===================================================================
--- trunk/lutinutil/pom.xml 2008-07-10 08:21:55 UTC (rev 867)
+++ trunk/lutinutil/pom.xml 2008-07-10 08:27:14 UTC (rev 868)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
@@ -61,7 +61,7 @@
<name>Lutin utilities library</name>
<version>0.30-SNAPSHOT</version>
- <description>Librairie de classe Java utile a tout projet.</description>
+ <description>Library of usefull class to be used in any project.</description>
<inceptionYear>2004</inceptionYear>
<!-- ************************************************************* -->
1
0
[Lutinutil-commits] r867 - trunk/lutinutil/src
by tchemit@users.labs.libre-entreprise.org 10 Jul '08
by tchemit@users.labs.libre-entreprise.org 10 Jul '08
10 Jul '08
Author: tchemit
Date: 2008-07-10 08:21:55 +0000 (Thu, 10 Jul 2008)
New Revision: 867
Removed:
trunk/lutinutil/src/java/
trunk/lutinutil/src/resources/
Log:
passage en 0.30-SNAPSHOT et maven 2 layout directory
1
0