Jaxx-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
March 2010
- 3 participants
- 75 discussions
r1796 - trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer
by tchemit@users.nuiton.org 19 Mar '10
by tchemit@users.nuiton.org 19 Mar '10
19 Mar '10
Author: tchemit
Date: 2010-03-19 18:32:29 +0100 (Fri, 19 Mar 2010)
New Revision: 1796
Log:
reformat code
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/I18nTableCellRenderer.java
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/I18nTableCellRenderer.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/I18nTableCellRenderer.java 2010-03-18 21:42:47 UTC (rev 1795)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/I18nTableCellRenderer.java 2010-03-19 17:32:29 UTC (rev 1796)
@@ -29,10 +29,10 @@
import java.awt.Component;
/**
- * A simple TableCellRenderer using a delegate TableCellRenderer to render everything elese thant the text :
- * the text is I18nalize.
+ * A simple TableCellRenderer using a delegate TableCellRenderer to render
+ * everything elese thant the text : the text is I18nalize.
*
- * @author chemit
+ * @author tchemit <chemit(a)codelutin.com>
*/
public class I18nTableCellRenderer implements TableCellRenderer {
@@ -45,32 +45,51 @@
/** the delegate cell renderer */
protected TableCellRenderer delegate;
- public I18nTableCellRenderer(TableCellRenderer delegate, String... keysAndTips) {
+ public I18nTableCellRenderer(TableCellRenderer delegate,
+ String... keysAndTips) {
this.delegate = delegate;
if (keysAndTips.length == 0) {
- throw new IllegalArgumentException("can not have empty keysAndTips parameters (means no column ?)");
+ throw new IllegalArgumentException(
+ "can not have empty keysAndTips parameters (means no " +
+ "column ?)");
}
if (keysAndTips.length % 2 == 1) {
- throw new IllegalArgumentException("must have some couple (text,tooltTipText), but had a even number of data in keysAndTips parameter");
+ throw new IllegalArgumentException(
+ "must have some couple (text,tooltTipText), but had an" +
+ " even number of data in keysAndTips parameter");
}
int size = keysAndTips.length / 2;
- this.keys = new String[size];
- this.tips = new String[size];
+ keys = new String[size];
+ tips = new String[size];
for (int i = 0; i < size; i++) {
- this.keys[i] = keysAndTips[2 * i];
- this.tips[i] = keysAndTips[2 * i + 1];
+ keys[i] = keysAndTips[2 * i];
+ tips[i] = keysAndTips[2 * i + 1];
}
}
@Override
- public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasfocus, int row, int column) {
+ public Component getTableCellRendererComponent(JTable table,
+ Object value,
+ boolean isSelected,
+ boolean hasfocus,
+ int row,
+ int column) {
if (column > keys.length) {
- throw new IndexOutOfBoundsException("colum can not be greater than " + keys.length);
+ throw new IndexOutOfBoundsException(
+ "colum can not be greater than " + keys.length);
}
TableColumn col = table.getColumn(table.getColumnName(column));
int index = col.getModelIndex();
value = _(keys[index]);
- JComponent rendererComponent = (JComponent) delegate.getTableCellRendererComponent(table, value, isSelected, hasfocus, row, column);
+ JComponent rendererComponent = (JComponent)
+ delegate.getTableCellRendererComponent(
+ table,
+ value,
+ isSelected,
+ hasfocus,
+ row,
+ column
+ );
rendererComponent.setToolTipText(_(tips[index]));
return rendererComponent;
}
1
0
r1795 - in trunk/jaxx-runtime/src: main/java/jaxx/runtime main/java/jaxx/runtime/swing main/java/jaxx/runtime/swing/help main/java/jaxx/runtime/swing/navigation main/java/jaxx/runtime/swing/wizard main/java/jaxx/runtime/validator/field test/java/jaxx/runtime/context test/java/jaxx/runtime/validator test/java/jaxx/runtime/validator/field
by tchemit@users.nuiton.org 18 Mar '10
by tchemit@users.nuiton.org 18 Mar '10
18 Mar '10
Author: tchemit
Date: 2010-03-18 22:42:47 +0100 (Thu, 18 Mar 2010)
New Revision: 1795
Log:
reformat code + improve generics
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpBroker.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUI.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/FieldExpressionWithParamsValidator.java
trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultApplicationContextTest.java
trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/BeanValidatorTest.java
trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/XWorkBeanValidatorTest.java
trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/FieldExpressionBean.java
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -78,7 +78,7 @@
* <p/>
* Note : Replace previous class jaxx.runtime.swing.Utils in previous versions.
*
- * @author tony
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.2
*/
public class SwingUtil extends JAXXUtil {
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -49,7 +49,7 @@
* <li>override the method {@link #acceptEvent(MouseEvent, JXLayer)}</li>
* </ul>
*
- * @author tony
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.2
*/
public class BlockingLayerUI extends AbstractLayerUI<JComponent> {
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -51,7 +51,7 @@
* <li>override the method {@link #acceptEvent(java.awt.event.MouseEvent, org.jdesktop.jxlayer.JXLayer)}</li>
* </ul>
*
- * @author tony
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.3
*/
public class BlockingLayerUI2 extends org.jdesktop.jxlayer.plaf.AbstractLayerUI<JComponent> {
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -35,7 +35,7 @@
* le contenu sera changé automatiquement, ce qui permet une utilisation direct
* dans jaxx sans à avoir à écrire d'écouteur.
*
- * @author tony
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.3
* @see CardLayout2
*/
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpBroker.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpBroker.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpBroker.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -49,7 +49,7 @@
/**
* La classe pour encapsuler l'aide de l'application.
*
- * @author tony
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.4
*/
public class JAXXHelpBroker {
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUI.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUI.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUI.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -28,7 +28,7 @@
*
* @param <B> type of broker.
*
- * @author tony
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.3
* @see JAXXHelpBroker
*/
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -39,7 +39,7 @@
* from a node we can not just listen selection model changed, we must control
* it.
*
- * @author tony
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.7.2
*/
public abstract class NavigationTreeHandler extends DefaultTreeSelectionModel implements TreeSelectionListener{
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -22,67 +22,68 @@
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* Un modèle de wizard.
+ * <p/>
+ * <p/>
+ * <b>Note:</b> le type des étapes doit être uné énumération qui implante {@link
+ * WizardStep}.
*
- *
- * <b>Note:</b> le type des étapes doit être uné énumération qui implante
- * {@link WizardStep}.
- *
+ * @author tchemit <chemit(a)codelutin.com>
* @param <E> le type des étapes.
- *
- * @author tony
+ * @see WizardStep
* @since 1.3
- * @see WizardStep
*/
public class WizardModel<E extends WizardStep> {
public static final String STEPS_PROPERTY_NAME = "steps";
+
public static final String STEP_PROPERTY_NAME = "step";
+
public static final String PREVIOUS_STEP_PROPERTY_NAME = "previousStep";
+
public static final String NEXT_STEP_PROPERTY_NAME = "nextStep";
+
public static final String VALID_STEP_PROPERTY_NAME = "validStep";
- /**
- * le type d'une etape du model (doit etre une enumeration)
- */
+
+ /** le type d'une etape du model (doit etre une enumeration) */
protected final Class<E> stepClass;
- /**
- * Toutes les étapes à passer
- */
+
+ /** Toutes les étapes à passer */
protected List<E> steps;
+
/** les etapes a exclure */
protected List<E> excludeSteps;
- /**
- * L'étape courante
- */
+
+ /** L'étape courante */
protected E step;
- /**
- * drapeau pour valider l'état de l'étape courante
- */
+
+ /** drapeau pour valider l'état de l'étape courante */
protected boolean validStep;
+
/**
- * drapeau lorsque le modele effectue des operations
- * de transformation de modele mais que les écouteurs
- * ne devraient pas tenir compte des modifications
+ * drapeau lorsque le modele effectue des operations de transformation de
+ * modele mais que les écouteurs ne devraient pas tenir compte des
+ * modifications
*/
protected boolean valueAdjusting;
- /**
- * pour propager les changements dans le modèle vers l'ui
- */
+
+ /** pour propager les changements dans le modèle vers l'ui */
protected PropertyChangeSupport pcs;
public WizardModel(Class<E> stepClass, E... steps) {
if (!Enum.class.isAssignableFrom(stepClass)) {
throw new IllegalArgumentException("stepClass must be an" +
- " Enumeration but was " + stepClass.getName());
+ " Enumeration but was " + stepClass.getName());
}
this.stepClass = stepClass;
- this.pcs = new PropertyChangeSupport(this);
- this.steps = new java.util.ArrayList<E>();
+ pcs = new PropertyChangeSupport(this);
+ this.steps = new ArrayList<E>();
if (steps.length > 0) {
setSteps(steps);
}
@@ -119,7 +120,7 @@
}
if (!steps.contains(e)) {
throw new IllegalStateException("step " + e.toString() +
- " is not in universe of steps (" + steps + ')');
+ " is not in universe of steps (" + steps + ')');
}
setStep(e);
}
@@ -169,7 +170,7 @@
return steps.get(index + 1);
}
- public java.util.List<E> getSteps() {
+ public List<E> getSteps() {
return steps;
}
@@ -179,13 +180,13 @@
/**
* Change l'univers des etapes.
- *
+ * <p/>
* Note: on presume ici que l'étape courante est toujours la meme.
*
* @param steps le nouvel univers des etapes
*/
public void setSteps(E... steps) {
- java.util.List<E> oldValue = this.steps;
+ List<E> oldValue = this.steps;
this.steps = Collections.unmodifiableList(Arrays.asList(steps));
firePropertyChange(STEPS_PROPERTY_NAME, oldValue, this.steps);
// la propriete nextStep peut avoir changee
@@ -199,6 +200,7 @@
public void setExcludeSteps(List<E> excludeSteps) {
this.excludeSteps = excludeSteps;
}
+
public boolean validate(E s) {
return step != null;
}
@@ -233,11 +235,11 @@
return;
}
boolean validate = validate(step);
- this.validStep = validate;
+ validStep = validate;
// toujours forcer la propagation
firePropertyChange(VALID_STEP_PROPERTY_NAME, null, validStep);
}
-
+
protected Class<E> getStepClass() {
return stepClass;
}
@@ -250,7 +252,7 @@
firePropertyChange(NEXT_STEP_PROPERTY_NAME, null, getNextStep());
// la propriete previousStep peut avoir changee
firePropertyChange(PREVIOUS_STEP_PROPERTY_NAME, null,
- getPreviousStep());
+ getPreviousStep());
validate();
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -20,16 +20,17 @@
*/
package jaxx.runtime.swing.wizard;
-import javax.swing.SwingWorker;
import jaxx.runtime.JAXXContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import javax.swing.*;
+
/**
- * La classe de base a implanter pour definir l'action d'une operation
- * dans un wizard.
+ * La classe de base a implanter pour definir l'action d'une operation dans un
+ * wizard.
*
- * @author tony
+ * @author tchemit <chemit(a)codelutin.com>
* @param <E> le type d'étapes
* @param <M> le type de modèle
* @since 1.3
@@ -37,15 +38,19 @@
public abstract class WizardOperationAction<E extends WizardOperationStep, M extends WizardOperationModel<E>> extends SwingWorker<WizardOperationState, String> {
/** to use log facility, just put in your code: log.info(\"...\"); */
- private static final Log log = LogFactory.getLog(WizardOperationAction.class);
+ private static final Log log =
+ LogFactory.getLog(WizardOperationAction.class);
+
E operation;
+
WizardOperationState operationState;
+
Exception error;
public WizardOperationAction(E operation) {
- super();
if (!operation.isOperation()) {
- throw new IllegalArgumentException("the step " + operation + " has no operation defined");
+ throw new IllegalArgumentException(
+ "the step " + operation + " has no operation defined");
}
this.operation = operation;
}
@@ -68,7 +73,8 @@
public abstract void start(JAXXContext context);
- public abstract void beforeAction(JAXXContext context, M model) throws Exception;
+ public abstract void beforeAction(JAXXContext context,
+ M model) throws Exception;
public abstract WizardOperationState doAction(M model) throws Exception;
@@ -86,7 +92,8 @@
@Override
public String toString() {
- return super.toString() + " < operation: " + operation + ", state: " + getState() + " >";
+ return super.toString() + " < operation: " + operation + ", state: " +
+ getState() + " >";
}
@Override
@@ -122,7 +129,7 @@
log.error(e.getMessage(), e);
} finally {
// on enregistre le resultat de l'opération
- this.operationState = result;
+ operationState = result;
}
}
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -20,42 +20,45 @@
*/
package jaxx.runtime.swing.wizard;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.Date;
-import javax.swing.SwingWorker.StateValue;
import jaxx.runtime.JAXXContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import javax.swing.SwingWorker.StateValue;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Date;
+
/**
* Thread qui réalise les opérations.
+ * <p/>
+ * Pour exécuter une nouvelle opération, on utilise la méthode {@link
+ * #launchOperation(WizardOperationStep)}.
+ * <p/>
+ * Note: Pour bloquer (ou débloquer) le thread, on utilise la méthode {@link
+ * #setWaiting(boolean)}
*
- * Pour exécuter une nouvelle opération, on utilise la méthode
- * {@link #launchOperation(WizardOperationStep)}.
- *
- * Note: Pour bloquer (ou débloquer) le thread, on utilise la méthode {@link #setWaiting(boolean)}
- *
+ * @author tchemit <chemit(a)codelutin.com>
* @param <E> le type des etapes
* @param <M> le type de modele
* @param <A> le type d'action d'operation
- *
- * @author tony
* @since 1.3
*/
public abstract class WizardOperationActionThread<E extends WizardOperationStep, M extends WizardOperationModel<E>, A extends WizardOperationAction<E, M>> extends Thread implements PropertyChangeListener {
/** to use log facility, just put in your code: log.info(\"...\"); */
private static final Log log = LogFactory.getLog(WizardOperationActionThread.class);
- /**
- * l'état du thread si annulé
- */
+
+ /** l'état du thread si annulé */
private boolean canceled;
+
protected Class<M> modelClass;
+
protected A currentAction;
+
/**
- * un lock pour permettre la suspension et la reprise du thread
- * lors du mode interactif.
+ * un lock pour permettre la suspension et la reprise du thread lors du mode
+ * interactif.
*/
private final Object LOCK = new Object();
@@ -70,11 +73,11 @@
public void cancel() {
log.info("cancel " + this);
- this.canceled = true;
-
+ canceled = true;
+
// on annule le modele
getModel().cancel();
-
+
// on rend la main au thread
setWaiting(false);
}
@@ -179,10 +182,7 @@
}
}
- /**
- * La méthode pour nettoyer le thread, a la fermeture.
- *
- */
+ /** La méthode pour nettoyer le thread, a la fermeture. */
protected void close() {
// par defaut, on ne fait rien
log.trace(this);
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -20,53 +20,47 @@
*/
package jaxx.runtime.swing.wizard;
-import java.util.Arrays;
-import java.util.EnumMap;
-import java.util.EnumSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
import javax.swing.SwingWorker.StateValue;
+import java.util.*;
/**
* Un modèle de wizard avec des opérations.
*
+ * @author tchemit <chemit(a)codelutin.com>
* @param <E> le type des étapes.
- * @author tony
* @since 1.3
*/
public class WizardOperationModel<E extends WizardOperationStep> extends WizardModel<E> {
public static final String OPERATIONS_PROPERTY_NAME = "operations";
+
public static final String OPERATION_STATE_PROPERTY_NAME = "operationState";
+
public static final String MODEL_STATE_PROPERTY_NAME = "modelState";
+
public static final String WAS_STARTED_PROPERTY_NAME = "wasStarted";
- /**
- * La liste des opérations à effectuer
- */
+ /** La liste des opérations à effectuer */
protected Set<E> operations;
- /**
- * Pour conserver les états des opérations
- */
+
+ /** Pour conserver les états des opérations */
protected Map<E, WizardOperationState> operationStates;
- protected Map<E, WizardOperationAction> operationActions;
- /**
- * L'état générale du modèle
- */
+
+ protected Map<E, WizardOperationAction<E, ? extends WizardOperationModel<E>>> operationActions;
+
+ /** L'état générale du modèle */
protected WizardOperationState modelState;
- /**
- * un drapeau pour savoir siune opération a été lancée
- */
+
+ /** un drapeau pour savoir siune opération a été lancée */
protected boolean wasStarted;
@SuppressWarnings("unchecked")
public <T extends Enum<T>> WizardOperationModel(Class<E> stepClass, E... steps) {
super(stepClass, steps);
- Class<T> k = (Class) stepClass;
- this.operationStates = (Map) new EnumMap(k);
- this.operations = (Set<E>) EnumSet.noneOf(k);
- this.operationActions = (Map) new EnumMap(k);
+ Class<T> k = (Class<T>) stepClass;
+ operationStates = new EnumMap(k);
+ operations = (Set<E>) EnumSet.noneOf(k);
+ operationActions = new EnumMap(k);
}
public Set<E> getOperations() {
@@ -95,11 +89,11 @@
return operationStates.get(operation);
}
- public WizardOperationAction getOperationAction(E operation) {
- WizardOperationAction action = operationActions.get(operation);
+ public WizardOperationAction<E, ? extends WizardOperationModel<E>> getOperationAction(E operation) {
+ WizardOperationAction<E, ? extends WizardOperationModel<E>> action = operationActions.get(operation);
if (action == null) {
try {
- action = operation.getActionClass().newInstance();
+ action = (WizardOperationAction<E, ? extends WizardOperationModel<E>>) operation.getActionClass().newInstance();
operationActions.put(operation, action);
} catch (Exception ex) {
throw new RuntimeException(ex);
@@ -115,7 +109,7 @@
public void setOperationState(E operation, WizardOperationState operationState) {
WizardOperationState oldValue = getOperationState(operation);
- this.operationStates.put(operation, operationState);
+ operationStates.put(operation, operationState);
fireIndexedPropertyChange(OPERATION_STATE_PROPERTY_NAME, getSteps().indexOf(operation), oldValue, operationState);
updateModelState(operation, operationState);
validate();
@@ -136,9 +130,9 @@
// uniquement si l'onglet precedent est accessible, valide et son etat est a SUCCESSED
E previousStep = steps.get(i - 1);
result[i] = modelState == WizardOperationState.SUCCESSED ||
- (result[i - 1] &&
- validate(previousStep) &&
- (!previousStep.isOperation() || getOperationState(previousStep) == WizardOperationState.SUCCESSED));
+ result[i - 1] &&
+ validate(previousStep) &&
+ (!previousStep.isOperation() || getOperationState(previousStep) == WizardOperationState.SUCCESSED);
}
}
//System.out.println("accessibles steps -------- " + java.util.Arrays.toString(result));
@@ -165,10 +159,9 @@
}
setModelState(WizardOperationState.CANCELED);
if (getStep() != null && getStep().isOperation()) {
- WizardOperationAction action = getOperationAction(getStep());
+ WizardOperationAction<E, ? extends WizardOperationModel<E>> action = getOperationAction(getStep());
if (action != null) {
if (!action.isCancelled() && !action.isDone() && action.getState() == StateValue.STARTED) {
- System.out.println("cancel action " + action);
// on annule l'action
action.cancel(true);
}
@@ -210,9 +203,9 @@
firePropertyChange(MODEL_STATE_PROPERTY_NAME, null, modelState);
}
- public WizardOperationAction reloadOperation(E operation) {
+ public WizardOperationAction<E, ? extends WizardOperationModel<E>> reloadOperation(E operation) {
operationActions.remove(operation);
- WizardOperationAction newOp = getOperationAction(operation);
+ WizardOperationAction<E, ? extends WizardOperationModel<E>> newOp = getOperationAction(operation);
return newOp;
}
@@ -222,7 +215,7 @@
firePropertyChange(MODEL_STATE_PROPERTY_NAME, oldValue, modelState);
if (!wasStarted) {
if ((oldValue == null || oldValue == WizardOperationState.PENDING) && modelState == WizardOperationState.RUNNING) {
- this.wasStarted = true;
+ wasStarted = true;
firePropertyChange(WAS_STARTED_PROPERTY_NAME, false, true);
}
}
@@ -279,7 +272,7 @@
protected int getOperationIndex(E operation) {
int index = 0;
for (E o : operations) {
- if (operation == o) {
+ if (o.equals(operation)) {
return index;
}
index++;
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -22,31 +22,26 @@
/**
* Pour caractériser l'état d'une opération.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
*/
public enum WizardOperationState {
- /**
- * quand l'opération n'a pas encore été réalisée
- */
+ /** quand l'opération n'a pas encore été réalisée */
PENDING,
- /**
- * quand l'opération est en cours
- */
+
+ /** quand l'opération est en cours */
RUNNING,
- /**
- * quand l'opération est annulé en cours d'exécution
- */
+
+ /** quand l'opération est annulé en cours d'exécution */
CANCELED,
- /**
- * quand une erreur s'est produite pendant l'exécution
- */
+
+ /** quand une erreur s'est produite pendant l'exécution */
FAILED,
- /**
- * quand l'exécution s'est terminée mais requière des corrections
- */
+
+ /** quand l'exécution s'est terminée mais requière des corrections */
NEED_FIX,
- /**
- * quand l'exécution s'est terminée et ne requière pas de correction
- */
+
+ /** quand l'exécution s'est terminée et ne requière pas de correction */
SUCCESSED
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -21,30 +21,25 @@
package jaxx.runtime.swing.wizard;
/**
- *
* Le contrat a implanter pour une etapes dans le modèle de wizard avec
* opérations.
- *
- * @author tony
+ *
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.3
*/
public interface WizardOperationStep extends WizardStep {
- /**
- * @return le label de l'opération
- */
+ /** @return le label de l'opération */
String getOperationLabel();
- /**
- * @return la description de l'opération
- */
+ /** @return la description de l'opération */
String getOperationDescription();
/**
* @return le type de l'action associée à l'étape ou <code>null</code> si
* l'étape n'a pas d'opération associée.
*/
- Class<? extends WizardOperationAction> getActionClass();
+ Class<? extends WizardOperationAction<?, ?>> getActionClass();
/**
* @return <code>true</code> si l'étape a une opération associée,
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -24,8 +24,8 @@
/**
* le contrat d'une étape d'un wizard.
- *
- * @author tony
+ *
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.3
*/
public interface WizardStep extends Serializable {
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -23,9 +23,9 @@
/**
* Le contrat d'une ui d'étape.
*
+ * @author tchemit <chemit(a)codelutin.com>
* @param <E> le type d'étape
* @param <M> le type de modèle
- * @author tony
* @since 1.3
*/
public interface WizardStepUI<E extends WizardStep, M extends WizardModel<E>> {
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -20,71 +20,56 @@
*/
package jaxx.runtime.swing.wizard;
-import javax.swing.JTabbedPane;
+import javax.swing.*;
/**
- *
* Contrat a respecter pour une ui de wizard.
- *
+ *
+ * @author tchemit <chemit(a)codelutin.com>
* @param <E> le type d'etape
* @param <M> le type de model
- *
- * @author tony
* @since 1.3
*/
public interface WizardUI<E extends WizardStep, M extends WizardModel<E>> {
- /**
- * @return le modèle de wizard
- */
+ /** @return le modèle de wizard */
M getModel();
- /**
- *
- * @return l'étape courante
- */
+ /** @return l'étape courante */
E getSelectedStep();
- /**
- *
- * @return l'ui de l'étape courante
- */
+ /** @return l'ui de l'étape courante */
WizardStepUI<E, M> getSelectedStepUI();
/**
- *
* @param step l'étape donnée
* @return l'ui de l'étape donnée
*/
WizardStepUI<E, M> getStepUI(E step);
/**
- *
* @param stepIndex la position de l'étape
* @return l'ui de l'étape donée
*/
WizardStepUI<E, M> getStepUI(int stepIndex);
- /**
- * démarre le wizard
- */
+ /** démarre le wizard */
void start();
/**
* //TODO il faudrait supprimer cette méthode
+ *
* @return le conteneur d'ui d'étapes
*/
JTabbedPane getTabs();
- /**
- * Méthode invoqué lorsque la première opération du modèlé a été démarrée.
- */
+ /** Méthode invoqué lorsque la première opération du modèlé a été démarrée. */
void onWasStarted();
-
+
/**
* Méthode invoquée lorsque l'univers des étapes a été modifié dans le
* modèle.
- *
+ *
* @param steps les nouvelles étapes
*/
void onStepsChanged(E[] steps);
@@ -106,9 +91,9 @@
/**
* Méthode invoqué lorsque l'état d'une opération a changé.
*
- * @param step l'étape dont l'état a changé
+ * @param step l'étape dont l'état a changé
* @param newState le nouvel état pour l'étape donné
*/
- void onOperationStateChanged(E step,WizardOperationState newState) ;
+ void onOperationStateChanged(E step, WizardOperationState newState);
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -20,48 +20,82 @@
*/
package jaxx.runtime.swing.wizard;
-import java.awt.Window;
-import javax.swing.ImageIcon;
import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXObject;
import jaxx.runtime.context.JAXXInitialContext;
-import jaxx.runtime.JAXXObject;
import org.apache.commons.beanutils.ConstructorUtils;
+import javax.swing.*;
+import java.awt.*;
+
/**
- *
* Une classe pour lancer une ui de wizard.
*
+ * @author tchemit <chemit(a)codelutin.com>
* @param <E> le type des etapes
* @param <M> le type de modele
* @param <UI> le type d'ui
- * @author tony
* @since 1.3
*/
public abstract class WizardUILancher<E extends WizardStep, M extends WizardModel<E>, UI extends WizardUI<E, M>> {
protected UI ui;
- public WizardUILancher(JAXXContext context, Class<UI> uiClass, Class<M> modelClass, String title, String tip, ImageIcon icon) {
+ public WizardUILancher(JAXXContext context,
+ Class<UI> uiClass,
+ Class<M> modelClass,
+ String title,
+ String tip,
+ ImageIcon icon) {
this(context, uiClass, modelClass, null, title, tip, icon);
}
- public WizardUILancher(JAXXContext context, Class<UI> uiClass, Class<M> modelClass, M model, String title, String tip, ImageIcon icon) {
+ public WizardUILancher(JAXXContext context,
+ Class<UI> uiClass,
+ Class<M> modelClass,
+ M model,
+ String title,
+ String tip,
+ ImageIcon icon) {
try {
- ui = createUI(context, uiClass, modelClass, model, title, tip, icon);
+ ui = createUI(context,
+ uiClass,
+ modelClass,
+ model,
+ title,
+ tip,
+ icon
+ );
} catch (Exception ex) {
- throw new RuntimeException("could not instanciate launcher for reason " + ex.getMessage(), ex);
+ throw new RuntimeException(
+ "could not instanciate launcher for reason " +
+ ex.getMessage(), ex);
}
}
- public WizardUILancher(JAXXContext context, Window mainUI, Class<UI> uiClass, Class<M> modelClass, M model) {
+ public WizardUILancher(JAXXContext context,
+ Window mainUI,
+ Class<UI> uiClass,
+ Class<M> modelClass,
+ M model) {
try {
- ui = createUI(context, mainUI, uiClass, modelClass, model);
+ ui = createUI(context,
+ mainUI,
+ uiClass,
+ modelClass,
+ model
+ );
} catch (Exception ex) {
- throw new RuntimeException("could not instanciate launcher for reason " + ex.getMessage(), ex);
+ throw new RuntimeException(
+ "could not instanciate launcher for reason " +
+ ex.getMessage(), ex);
}
}
- public WizardUILancher(JAXXContext context, Window mainUI, Class<UI> uiClass, Class<M> modelClass) {
+ public WizardUILancher(JAXXContext context,
+ Window mainUI,
+ Class<UI> uiClass,
+ Class<M> modelClass) {
this(context, mainUI, uiClass, modelClass, null);
}
@@ -102,7 +136,11 @@
}
@SuppressWarnings("unchecked")
- protected UI createUI(JAXXContext context, Window mainUI, Class<UI> uiClass, Class<M> modelClass, M model) throws Exception {
+ protected UI createUI(JAXXContext context,
+ Window mainUI,
+ Class<UI> uiClass,
+ Class<M> modelClass,
+ M model) throws Exception {
JAXXInitialContext uiContext = new JAXXInitialContext();
uiContext.add(mainUI == null ? context : mainUI);
// parent context model
@@ -137,12 +175,22 @@
// instanciate ui
- UI newUI = (UI) ConstructorUtils.invokeConstructor(uiClass, new Object[]{mainUI, uiContext}, new Class[]{Window.class, JAXXContext.class});
+ UI newUI = (UI) ConstructorUtils.invokeConstructor(
+ uiClass,
+ new Object[]{mainUI, uiContext},
+ new Class[]{Window.class, JAXXContext.class}
+ );
return newUI;
}
@SuppressWarnings("unchecked")
- protected UI createUI(JAXXContext context, Class<UI> uiClass, Class<M> modelClass, M model, String title, String tip, ImageIcon icon) throws Exception {
+ protected UI createUI(JAXXContext context,
+ Class<UI> uiClass,
+ Class<M> modelClass,
+ M model,
+ String title,
+ String tip,
+ ImageIcon icon) throws Exception {
JAXXInitialContext uiContext = new JAXXInitialContext();
uiContext.add(context);
// parent context model
@@ -176,7 +224,16 @@
});
// instanciate ui
- UI newUI = (UI) ConstructorUtils.invokeConstructor(uiClass, new Object[]{uiContext, title, tip, icon}, new Class[]{JAXXContext.class, String.class, String.class, ImageIcon.class});
+ UI newUI = (UI) ConstructorUtils.invokeConstructor(
+ uiClass,
+ new Object[]{uiContext, title, tip, icon},
+ new Class[]{
+ JAXXContext.class,
+ String.class,
+ String.class,
+ ImageIcon.class
+ }
+ );
return newUI;
}
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -20,22 +20,23 @@
*/
package jaxx.runtime.swing.wizard;
-import java.awt.Component;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.*;
+import java.awt.*;
import java.beans.IndexedPropertyChangeEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.lang.reflect.Array;
import java.util.List;
-import javax.swing.JTabbedPane;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import static org.nuiton.i18n.I18n._;
/**
* Classe de méthodes utiles sur les wizard.
*
- * @author tony
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.3
*/
public class WizardUtil {
@@ -139,14 +140,14 @@
/**
* Ajoute un listener sur le modele pour gere la politique d'affichage des
* onglets.
+ * <p/>
+ * Dans cette implantation, les onglets sont ouverts jusqu'a l'etape
+ * courante. Lorsque l'on revient en arrière, les onglets d'etapes
+ * superieurs sont fermes.
*
- * Dans cette implantation, les onglets sont ouverts jusqu'a l'etape courante.
- * Lorsque l'on revient en arrière, les onglets d'etapes superieurs sont
- * fermes.
- *
* @param <E> le type d'un etape de l'assistant
* @param <M> le type du modele de l'assistant
- * @param ui l'ui de l'assitant
+ * @param ui l'ui de l'assitant
* @since 1.7.1
*/
public static <E extends WizardStep, M extends WizardModel<E>> void addTabsDisplayUntilStepListener(final WizardUI<E, M> ui) {
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html 2010-03-18 21:42:47 UTC (rev 1795)
@@ -1,9 +1,9 @@
<html>
- <body>
- <h1>JAXX - Wizard framework</h1>
-
- This package contains all the classes of the wizard framework.
+<body>
+<h1>JAXX - Wizard framework</h1>
- TODO
- </body>
-</html>
\ No newline at end of file
+This package contains all the classes of the wizard framework.
+
+TODO
+</body>
+</html>
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/FieldExpressionWithParamsValidator.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/FieldExpressionWithParamsValidator.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/FieldExpressionWithParamsValidator.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -33,7 +33,7 @@
* Extends {@link FieldExpressionValidator} to add some extra parameters available
* in the {@link #getExpression()}
*
- * @author tony
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.3
*/
public class FieldExpressionWithParamsValidator extends FieldExpressionValidator {
Modified: trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultApplicationContextTest.java
===================================================================
--- trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultApplicationContextTest.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultApplicationContextTest.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -31,7 +31,7 @@
/**
*
- * @author tony
+ * @author tchemit <chemit(a)codelutin.com>
*/
public class DefaultApplicationContextTest {
Modified: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/BeanValidatorTest.java
===================================================================
--- trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/BeanValidatorTest.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/BeanValidatorTest.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -30,7 +30,7 @@
/**
*
- * @author tony
+ * @author tchemit <chemit(a)codelutin.com>
*/
public class BeanValidatorTest {
@@ -215,4 +215,4 @@
}
}
}
-}
\ No newline at end of file
+}
Modified: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/XWorkBeanValidatorTest.java
===================================================================
--- trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/XWorkBeanValidatorTest.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/XWorkBeanValidatorTest.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -29,7 +29,7 @@
/**
*
- * @author tony
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.3
*/
public class XWorkBeanValidatorTest {
@@ -173,4 +173,4 @@
// error was not found
Assert.assertFalse(required);
}
-}
\ No newline at end of file
+}
Modified: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/FieldExpressionBean.java
===================================================================
--- trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/FieldExpressionBean.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/FieldExpressionBean.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -25,7 +25,7 @@
/**
*
- * @author tony
+ * @author tchemit <chemit(a)codelutin.com>
*/
public class FieldExpressionBean {
1
0
r1794 - trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard
by tchemit@users.nuiton.org 18 Mar '10
by tchemit@users.nuiton.org 18 Mar '10
18 Mar '10
Author: tchemit
Date: 2010-03-18 22:15:02 +0100 (Thu, 18 Mar 2010)
New Revision: 1794
Log:
notify ui change model validSetp has changed (to relaod Wizard tab accessible)
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java 2010-03-18 19:40:22 UTC (rev 1793)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java 2010-03-18 21:15:02 UTC (rev 1794)
@@ -25,6 +25,7 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.lang.reflect.Array;
+import java.util.List;
import javax.swing.JTabbedPane;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -99,14 +100,26 @@
return;
}
if (WizardModel.STEPS_PROPERTY_NAME.equals(propertyName)) {
- java.util.List<E> steps = (java.util.List<E>) evt.getNewValue();
- ui.onStepsChanged(steps.toArray((E[]) Array.newInstance(ui.getModel().stepClass, steps.size())));
+ List<E> steps = (List<E>) evt.getNewValue();
+ ui.onStepsChanged(
+ steps.toArray((E[]) Array.newInstance(
+ ui.getModel().stepClass, steps.size()))
+ );
return;
}
if (WizardModel.STEP_PROPERTY_NAME.equals(propertyName)) {
ui.onStepChanged((E) evt.getNewValue());
return;
}
+ if (WizardModel.VALID_STEP_PROPERTY_NAME.equals(propertyName)) {
+ Boolean value = (Boolean) evt.getNewValue();
+ if (value == null || !value) {
+ ui.onModelStateChanged(WizardOperationState.NEED_FIX);
+ } else {
+ ui.onModelStateChanged(WizardOperationState.PENDING);
+ }
+ return;
+ }
if (WizardOperationModel.MODEL_STATE_PROPERTY_NAME.equals(propertyName)) {
//TODO should be unicast : only for good stepUI ?
ui.onModelStateChanged((WizardOperationState) evt.getNewValue());
1
0
r1793 - in trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator: . swing
by tchemit@users.nuiton.org 18 Mar '10
by tchemit@users.nuiton.org 18 Mar '10
18 Mar '10
Author: tchemit
Date: 2010-03-18 20:40:22 +0100 (Thu, 18 Mar 2010)
New Revision: 1793
Log:
add filterscopes in SwingValidator
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorDetector.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java 2010-03-18 09:52:42 UTC (rev 1792)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java 2010-03-18 19:40:22 UTC (rev 1793)
@@ -58,6 +58,9 @@
/** to use log facility, just put in your code: log.info(\"...\"); */
static protected final Log log = LogFactory.getLog(BeanValidator.class);
+ protected static final BeanValidatorScope[] FILTER_SCOPES_EMPTY =
+ new BeanValidatorScope[0];
+
/** the type of bean to watch */
protected final Class<B> beanClass;
@@ -91,6 +94,9 @@
/** xworks scope validator * */
protected EnumMap<BeanValidatorScope, XWorkBeanValidator<B>> validators;
+ /** filter scopes (if {@code null}, no filter on scopes) */
+ protected BeanValidatorScope[] filterScopes;
+
/** listener that listens on bean modification */
protected PropertyChangeListener l;
@@ -100,8 +106,21 @@
/** A list of event listeners for this validators */
protected EventListenerList listenerList = new EventListenerList();
- public BeanValidator(Class<B> beanClass, String contextName) {
+ public BeanValidator(Class<B> beanClass,
+ String contextName) {
+ this(beanClass,
+ contextName,
+ BeanValidatorScope.values()
+ );
+ }
+
+ public BeanValidator(Class<B> beanClass,
+ String contextName,
+ BeanValidatorScope... filterScopes) {
this.beanClass = beanClass;
+ if (filterScopes != null && filterScopes.length > 0) {
+ this.filterScopes = filterScopes;
+ }
pcs = new PropertyChangeSupport(this);
conversionErrors = new TreeMap<String, String>();
validators = new EnumMap<BeanValidatorScope, XWorkBeanValidator<B>>(
@@ -277,7 +296,7 @@
}
public void setContextName(String contextName) {
- String oldValidationContextName = this.contextName;
+ String oldContextName = this.contextName;
this.contextName = contextName;
// changing contextName could change fields definition
// so dettach bean, must rebuild the fields
@@ -287,11 +306,27 @@
// rebuild the fields
initFields();
pcs.firePropertyChange(CONTEXT_NAME_PROPERTY,
- oldValidationContextName,
+ oldContextName,
contextName
);
}
+ /**
+ * Sets the filter scopes.
+ *
+ * @param filterScopes the scopes to used
+ */
+ public void setFilterScopes(BeanValidatorScope... filterScopes) {
+ this.filterScopes = filterScopes;
+ // changing contextName could change fields definition
+ // so dettach bean, must rebuild the fields
+ if (bean != null) {
+ setBean(null);
+ }
+ // rebuild the fields
+ initFields();
+ }
+
public void setParentValidator(BeanValidator<?> parentValidator) {
this.parentValidator = parentValidator;
}
@@ -508,7 +543,16 @@
validators.clear();
- for (BeanValidatorScope scope : BeanValidatorScope.values()) {
+ BeanValidatorScope[] scopeUniverse;
+ if (filterScopes == null) {
+ // use all scopes
+ scopeUniverse = BeanValidatorScope.values();
+ } else {
+ // use customized scopes
+ scopeUniverse = filterScopes;
+ }
+
+ for (BeanValidatorScope scope : scopeUniverse) {
String scopeContext =
(contextName == null ? "" : contextName + "-") +
scope.name().toLowerCase();
@@ -532,7 +576,7 @@
for (String fieldName : detectedFieldNames) {
scopes.clear();
// detect scopes for the field
- for (BeanValidatorScope scope : BeanValidatorScope.values()) {
+ for (BeanValidatorScope scope : scopeUniverse) {
if (tmp.containsKey(scope) &&
tmp.get(scope).contains(fieldName)) {
scopes.add(scope);
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorDetector.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorDetector.java 2010-03-18 09:52:42 UTC (rev 1792)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorDetector.java 2010-03-18 19:40:22 UTC (rev 1793)
@@ -20,26 +20,22 @@
*/
package jaxx.runtime.validator;
+import org.apache.commons.beanutils.ConstructorUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import java.io.File;
import java.io.FilenameFilter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeSet;
+import java.lang.reflect.Constructor;
+import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
/**
- * Un detecteur de validateurs pour un liste de classes données et un
- * répertoire où chercher les fichiers de validation.
- *
+ * Un detecteur de validateurs pour un liste de classes données et un répertoire
+ * où chercher les fichiers de validation.
+ *
* @author tchemit <chemit(a)codelutin.com>
- *
* @since 1.6.0
*/
public class BeanValidatorDetector {
@@ -59,7 +55,20 @@
File sourceRoot,
Pattern contextFilter,
Class<?>... types) {
+ SortedSet<BeanValidator<?>> result = detect(validatorClass,
+ sourceRoot,
+ contextFilter,
+ null,
+ types);
+ return result;
+ }
+ public SortedSet<BeanValidator<?>> detect(Class<?> validatorClass,
+ File sourceRoot,
+ Pattern contextFilter,
+ BeanValidatorScope[] scopes,
+ Class<?>... types) {
+
SortedSet<BeanValidator<?>> result =
new TreeSet<BeanValidator<?>>(new BeanValidatorComparator());
@@ -100,7 +109,8 @@
BeanValidator<?> validator = getValidator(
validatorClass,
c,
- context.isEmpty() ? null : context
+ context.isEmpty() ? null : context,
+ scopes
);
if (validator != null) {
// on enregistre le validateur
@@ -113,36 +123,31 @@
}
/**
- * Pour un context et un type d'entité donné, instancie un validateur
- * et test si ce validateur est utilisable (i.e qu'il admet des champs
- * à valider).
- *
+ * Pour un context et un type d'entité donné, instancie un validateur et
+ * test si ce validateur est utilisable (i.e qu'il admet des champs à
+ * valider).
+ * <p/>
* Si aucun champ n'est trouvé dans le validateur, alors on retourne null.
*
- * @param <B> le type du bean
+ * @param <B> le type du bean
* @param validatorClass le type de validateur a instancie
- * @param klass le type du bean
- * @param context le context du validateur
+ * @param klass le type du bean
+ * @param context le context du validateur
+ * @param scopes les scopes a utiliser (si {@code null} alors pas de
+ * filtre sur les scopes)
* @return le validateur initialisé, ou <code>null</code> si aucun scope
* détecté dans le validateur.
*/
protected <B> BeanValidator<B> getValidator(Class<?> validatorClass,
Class<B> klass,
- String context) {
+ String context,
+ BeanValidatorScope... scopes) {
-// BeanValidator<B> valitator = new BeanValidator<B>(klass, context);
BeanValidator<B> valitator;
- try {
- valitator = (BeanValidator<B>) validatorClass.getConstructor(
- Class.class, String.class).newInstance(klass, context);
- } catch (Exception ex) {
- throw new RuntimeException(
- "could not instanciate validator " + validatorClass +
- " for reason " + ex.getMessage(), ex);
- }
+ valitator = createValidator(validatorClass, klass, context, scopes);
- Set<BeanValidatorScope> scopes = valitator.getScopes();
- if (scopes.isEmpty()) {
+ Set<BeanValidatorScope> resultScopes = valitator.getScopes();
+ if (resultScopes.isEmpty()) {
valitator = null;
if (log.isDebugEnabled()) {
log.debug(klass + " : validator skip (no scopes detected)");
@@ -155,6 +160,63 @@
return valitator;
}
+ protected <B> BeanValidator<B> createValidator(
+ Class<?> validatorClass,
+ Class<B> klass,
+ String context,
+ BeanValidatorScope[] scopes) {
+ BeanValidator<B> valitator;
+ Constructor<?> con;
+ try {
+ con = ConstructorUtils.getAccessibleConstructor(
+ validatorClass,
+ new Class<?>[]{
+ Class.class,
+ String.class,
+ BeanValidatorScope[].class
+ }
+ );
+ if (con != null) {
+
+ valitator = (BeanValidator<B>) con.newInstance(
+ klass,
+ context, scopes
+ );
+
+ } else {
+ con = ConstructorUtils.getAccessibleConstructor(
+ validatorClass,
+ new Class<?>[]{
+ Class.class,
+ String.class,
+ BeanValidatorScope[].class
+ }
+ );
+
+ if (con == null) {
+ throw new IllegalStateException(
+ "could not find a constructor with " +
+ "(Class.class, String) or " +
+ "(Class,String BeanValidatorScope[])");
+ }
+
+ valitator = (BeanValidator<B>) con.newInstance(
+ klass,
+ context
+ );
+ if (scopes != null && scopes.length > 0) {
+ valitator.setFilterScopes(scopes);
+ }
+ }
+
+ } catch (Exception ex) {
+ throw new RuntimeException(
+ "could not instanciate validator " + validatorClass +
+ " for reason " + ex.getMessage(), ex);
+ }
+ return valitator;
+ }
+
protected File getClassDir(File sourceRoot, Class<?> clazz) {
String path = clazz.getPackage().getName();
path = path.replaceAll("\\.", File.separator);
@@ -230,7 +292,9 @@
protected static class ValidatorFilenameFilter implements FilenameFilter {
protected static final String SUFFIX = "-validation.xml";
+
protected Class<?> clazz;
+
protected String prefix;
public ValidatorFilenameFilter(Class<?> clazz) {
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java 2010-03-18 09:52:42 UTC (rev 1792)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java 2010-03-18 19:40:22 UTC (rev 1793)
@@ -22,6 +22,7 @@
import jaxx.runtime.validator.BeanValidator;
import jaxx.runtime.validator.BeanValidatorField;
+import jaxx.runtime.validator.BeanValidatorScope;
import jaxx.runtime.validator.swing.ui.AbstractBeanValidatorUI;
import jaxx.runtime.validator.swing.ui.IconValidationUI;
import org.apache.commons.logging.Log;
@@ -140,11 +141,19 @@
/** ui renderer class */
protected Class<? extends AbstractBeanValidatorUI> uiClass;
- public SwingValidator(Class<B> beanClass, String contextName) {
- super(beanClass, contextName);
+
+
+ public SwingValidator(Class<B> beanClass,
+ String contextName,
+ BeanValidatorScope... filterScopes) {
+ super(beanClass, contextName, filterScopes);
fieldRepresentation = new HashMap<String, JComponent>();
}
+ public SwingValidator(Class<B> beanClass, String contextName) {
+ this(beanClass, contextName, FILTER_SCOPES_EMPTY);
+ }
+
/**
* To reload a bean in the validator.
* <p/>
1
0
r1792 - in trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator: . swing swing/ui
by tchemit@users.nuiton.org 18 Mar '10
by tchemit@users.nuiton.org 18 Mar '10
18 Mar '10
Author: tchemit
Date: 2010-03-18 10:52:42 +0100 (Thu, 18 Mar 2010)
New Revision: 1792
Log:
reformat code
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorDetector.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorField.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorScope.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java 2010-03-18 09:16:31 UTC (rev 1791)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java 2010-03-18 09:52:42 UTC (rev 1792)
@@ -20,76 +20,83 @@
*/
package jaxx.runtime.validator;
-import java.beans.EventSetDescriptor;
import org.apache.commons.beanutils.ConversionException;
import org.apache.commons.beanutils.Converter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.util.ConverterUtil;
-import java.beans.Introspector;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.EnumMap;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
+import javax.swing.event.EventListenerList;
+import java.beans.*;
+import java.util.*;
import java.util.Map.Entry;
-import java.util.Set;
-import java.util.TreeMap;
-import javax.swing.event.EventListenerList;
/**
- *
* A customized validator for a given bean.
+ * <p/>
+ * <b>Note:</b> The bean must be listenable on properyChange events (means must
+ * have public addPropertychangeListener and removePropertyChangeListener
+ * methods).
*
- * <b>Note:</b> The bean must be listenable on properyChange events (means
- * must have public addPropertychangeListener and removePropertyChangeListener methods).
- *
+ * @author tchemit <chemit(a)codelutin.com>
* @param <B> type of the bean to validate.
- *
- * @author tchemit <chemit(a)codelutin.com>
*/
public class BeanValidator<B> {
/** la nom de la propriété bean */
static public final String BEAN_PROERTY = "bean";
+
/** la nom de la propriété contextName */
static public final String CONTEXT_NAME_PROPERTY = "contextName";
+
/** la nom de l'état valid */
static public final String VALID_PROERTY = "valid";
+
/** la nom de l'état changed */
static public final String CHANGED_PROERTY = "changed";
+
/** to use log facility, just put in your code: log.info(\"...\"); */
static protected final Log log = LogFactory.getLog(BeanValidator.class);
+
/** the type of bean to watch */
protected final Class<B> beanClass;
+
/** the validation named context (can be null) */
protected String contextName;
+
/** to chain to a prent validator */
protected BeanValidator<?> parentValidator;
- /** state to indicate that validator has changed since the last time bean was setted */
+
+ /**
+ * state to indicate that validator has changed since the last time bean was
+ * setted
+ */
protected boolean changed;
+
/** state of the validator (is true if no errors of error scope is found) */
protected boolean valid = true;
+
/** bean to be watched */
protected B bean;
+
/** to add and remove PropertyChangeListener on watched beans */
protected EventSetDescriptor beanEventDescriptor;
+
/** list of fields watched by this validator */
protected Set<BeanValidatorField<B>> fields;
+
/** map of conversion errors detected by this validator */
protected Map<String, String> conversionErrors;
- /** xworks scope validator **/
+
+ /** xworks scope validator * */
protected EnumMap<BeanValidatorScope, XWorkBeanValidator<B>> validators;
+
/** listener that listens on bean modification */
protected PropertyChangeListener l;
+
/** delegate property change support */
protected PropertyChangeSupport pcs;
+
/** A list of event listeners for this validators */
protected EventListenerList listenerList = new EventListenerList();
@@ -97,7 +104,8 @@
this.beanClass = beanClass;
pcs = new PropertyChangeSupport(this);
conversionErrors = new TreeMap<String, String>();
- validators = new EnumMap<BeanValidatorScope, XWorkBeanValidator<B>>(BeanValidatorScope.class);
+ validators = new EnumMap<BeanValidatorScope, XWorkBeanValidator<B>>(
+ BeanValidatorScope.class);
setContextName(contextName);
@@ -105,6 +113,7 @@
@Override
public void propertyChange(PropertyChangeEvent evt) {
+ // chaque modification lance la validation
doValidate();
}
};
@@ -131,10 +140,11 @@
}
/**
- * Retourne vrai si l'objet bean a ete modifie depuis le dernier
- * {@link #setBean}
+ * Retourne vrai si l'objet bean a ete modifie depuis le dernier {@link
+ * #setBean}
*
- * @return <code>true</code> if bean was modify since last {@link #setBean(Object)} invocation
+ * @return <code>true</code> if bean was modify since last {@link
+ * #setBean(Object)} invocation
*/
public boolean isChanged() {
return changed;
@@ -188,7 +198,8 @@
* Test a the validator contains the field given his name
*
* @param fieldName the name of the searched field
- * @return <code>true</code> if validator contaisn this field, <code>false</code> otherwise
+ * @return <code>true</code> if validator contaisn this field,
+ * <code>false</code> otherwise
*/
public boolean containsField(String fieldName) {
BeanValidatorField<B> field = getField(fieldName);
@@ -198,7 +209,8 @@
public boolean isValid(String fieldName) {
BeanValidatorField<B> field = getField(fieldName);
if (field == null) {
- throw new IllegalArgumentException("could not find a validator field " + fieldName);
+ throw new IllegalArgumentException(
+ "could not find a validator field " + fieldName);
}
return field.isValid();
}
@@ -231,9 +243,11 @@
if (oldBean != null) {
try {
- getBeanEventDescriptor(oldBean).getRemoveListenerMethod().invoke(oldBean, l);
+ EventSetDescriptor descriptor = getBeanEventDescriptor(oldBean);
+ descriptor.getRemoveListenerMethod().invoke(oldBean, l);
} catch (Exception eee) {
- log.info("Can't register as listener for bean " + beanClass + " for reason " + eee.getMessage(), eee);
+ log.info("Can't register as listener for bean " + beanClass +
+ " for reason " + eee.getMessage(), eee);
}
}
this.bean = bean;
@@ -249,9 +263,11 @@
} else {
try {
- getBeanEventDescriptor(bean).getAddListenerMethod().invoke(bean, l);
+ EventSetDescriptor descriptor = getBeanEventDescriptor(bean);
+ descriptor.getAddListenerMethod().invoke(bean, l);
} catch (Exception eee) {
- log.info("Can't register as listener for bean " + beanClass + " for reason " + eee.getMessage(), eee);
+ log.info("Can't register as listener for bean " + beanClass +
+ " for reason " + eee.getMessage(), eee);
}
validate();
}
@@ -270,7 +286,10 @@
}
// rebuild the fields
initFields();
- pcs.firePropertyChange(CONTEXT_NAME_PROPERTY, oldValidationContextName, contextName);
+ pcs.firePropertyChange(CONTEXT_NAME_PROPERTY,
+ oldValidationContextName,
+ contextName
+ );
}
public void setParentValidator(BeanValidator<?> parentValidator) {
@@ -282,7 +301,7 @@
* <p/>
* If an error occurs, then add an error in validator.
*
- * @param <T> the type of conversion
+ * @param <T> the type of conversion
* @param fieldName the name of the bean property
* @param value the value to convert
* @param valueClass the type of converted value
@@ -297,8 +316,8 @@
throw new IllegalArgumentException("valueClass can not be null");
}
- // on ne convertit pas si il y a un bean et que le resultat de la validation
- // pourra etre affiche quelque part
+ // on ne convertit pas si il y a un bean et que le resultat de la
+ // validation pourra etre affiche quelque part
if (!canValidate() || value == null) {
return null;
}
@@ -310,7 +329,8 @@
try {
Converter converter = ConverterUtil.getConverter(valueClass);
if (converter == null) {
- throw new RuntimeException("could not find converter for the type " + valueClass);
+ throw new RuntimeException(
+ "could not find converter for the type " + valueClass);
}
result = (T) converter.convert(valueClass, value);
/* Why this test ? if (result != null && !value.equals(result.toString())) {
@@ -320,7 +340,8 @@
}*/
} catch (ConversionException e) {
// get
- conversionErrors.put(fieldName, "error.convertor." + Introspector.decapitalize(valueClass.getSimpleName()));
+ String s = Introspector.decapitalize(valueClass.getSimpleName());
+ conversionErrors.put(fieldName, "error.convertor." + s);
result = null;
validate();
}
@@ -330,10 +351,10 @@
/**
* Methode pour forcer la revalidation d'un bean en mettant a jour les etats
* internes.
- *
+ * <p/>
* La méthode appelle {@link #validate()} puis met à jour les etats internes
* {@link #valid} et {@link #changed}.
- *
+ *
* @since 1.5
*/
public void doValidate() {
@@ -344,17 +365,16 @@
/**
* il faut eviter le code re-intrant (durant une validation, une autre est
- * demandee). Pour cela on fait la validation dans un thread, et tant
- * que la premiere validation n'est pas fini, on ne repond pas aux
- * solicitations.
+ * demandee). Pour cela on fait la validation dans un thread, et tant que la
+ * premiere validation n'est pas fini, on ne repond pas aux solicitations.
* Cette method est public pour permettre de force une validation par
- * programmation, ce qui est utile par exemple si le bean ne supporte
- * pas les {@link PropertyChangeListener}
- *
- * TODO la methode devra repasser en protected et on utilise la
- * methode {@link #doValidate()} car {@link #validate()} ne modifie pas
- * les etats internes et cela en rend son utilisation delicate (le
- * validateur entre dans un etat incoherent par rapport aux messages envoyés).
+ * programmation, ce qui est utile par exemple si le bean ne supporte pas
+ * les {@link PropertyChangeListener}
+ * <p/>
+ * TODO la methode devra repasser en protected et on utilise la methode
+ * {@link #doValidate()} car {@link #validate()} ne modifie pas les etats
+ * internes et cela en rend son utilisation delicate (le validateur entre
+ * dans un etat incoherent par rapport aux messages envoyés).
*/
public void validate() {
@@ -415,7 +435,8 @@
@Override
public String toString() {
- return super.toString() + "<beanClass:" + beanClass + ", contextName:" + contextName + ">";
+ return super.toString() + "<beanClass:" + beanClass +
+ ", contextName:" + contextName + ">";
}
public void addBeanValidatorListener(BeanValidatorListener listener) {
@@ -434,7 +455,8 @@
pcs.addPropertyChangeListener(listener);
}
- public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ public void addPropertyChangeListener(String propertyName,
+ PropertyChangeListener listener) {
pcs.addPropertyChangeListener(propertyName, listener);
}
@@ -442,20 +464,34 @@
pcs.removePropertyChangeListener(listener);
}
- public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ public void removePropertyChangeListener(String propertyName,
+ PropertyChangeListener listener) {
pcs.removePropertyChangeListener(propertyName, listener);
}
- /** @return <code>true</code> if validation is enabled, <code>false</code> otherwise. */
+ /**
+ * @return <code>true</code> if validation is enabled, <code>false</code>
+ * otherwise.
+ */
protected boolean canValidate() {
return !(bean == null || fields.isEmpty());
}
- protected void fireFieldChanged(BeanValidatorField<B> field, BeanValidatorScope scope, String[] toAdd, String[] toDelete) {
+ protected void fireFieldChanged(BeanValidatorField<B> field,
+ BeanValidatorScope scope,
+ String[] toAdd,
+ String[] toDelete) {
- BeanValidatorEvent evt = new BeanValidatorEvent(this, field, scope, toAdd, toDelete);
+ BeanValidatorEvent evt = new BeanValidatorEvent(
+ this,
+ field,
+ scope,
+ toAdd,
+ toDelete
+ );
- for (BeanValidatorListener listener : listenerList.getListeners(BeanValidatorListener.class)) {
+ for (BeanValidatorListener listener :
+ listenerList.getListeners(BeanValidatorListener.class)) {
listener.onFieldChanged(evt);
}
}
@@ -463,18 +499,26 @@
protected synchronized void initFields() {
Set<String> detectedFieldNames = new HashSet<String>();
- EnumMap<BeanValidatorScope, Set<String>> tmp = new EnumMap<BeanValidatorScope, Set<String>>(BeanValidatorScope.class);
- Set<BeanValidatorField<B>> detectedFields = new HashSet<BeanValidatorField<B>>();
+ EnumMap<BeanValidatorScope, Set<String>> tmp;
+ tmp = new EnumMap<BeanValidatorScope, Set<String>>(
+ BeanValidatorScope.class
+ );
+ Set<BeanValidatorField<B>> detectedFields =
+ new HashSet<BeanValidatorField<B>>();
validators.clear();
for (BeanValidatorScope scope : BeanValidatorScope.values()) {
- String scopeContext = (contextName == null ? "" : contextName + "-") + scope.name().toLowerCase();
+ String scopeContext =
+ (contextName == null ? "" : contextName + "-") +
+ scope.name().toLowerCase();
- XWorkBeanValidator<B> newValidator = new XWorkBeanValidator<B>(beanClass, scopeContext, false);
+ XWorkBeanValidator<B> newValidator =
+ new XWorkBeanValidator<B>(beanClass, scopeContext, false);
Set<String> fieldNames = newValidator.getFieldNames();
if (log.isDebugEnabled()) {
- log.debug("detected validators for scope " + scopeContext + " : " + fieldNames);
+ log.debug("detected validators for scope " + scopeContext +
+ " : " + fieldNames);
}
if (!fieldNames.isEmpty()) {
// fields detected in this validator, keep it
@@ -489,11 +533,13 @@
scopes.clear();
// detect scopes for the field
for (BeanValidatorScope scope : BeanValidatorScope.values()) {
- if (tmp.containsKey(scope) && tmp.get(scope).contains(fieldName)) {
+ if (tmp.containsKey(scope) &&
+ tmp.get(scope).contains(fieldName)) {
scopes.add(scope);
}
}
- BeanValidatorField<B> f = new BeanValidatorField<B>(beanClass, fieldName, scopes);
+ BeanValidatorField<B> f =
+ new BeanValidatorField<B>(beanClass, fieldName, scopes);
detectedFields.add(f);
}
tmp.clear();
@@ -504,8 +550,12 @@
protected EventSetDescriptor getBeanEventDescriptor(B bean) {
if (beanEventDescriptor == null) {
- // check that the bean is listenable, otherwise, can't use the validator on it
- beanEventDescriptor = BeanValidatorUtil.getPropertyChangeListenerDescriptor(bean.getClass());
+ // check that the bean is listenable, otherwise, can't use the
+ // validator on it
+ beanEventDescriptor =
+ BeanValidatorUtil.getPropertyChangeListenerDescriptor(
+ bean.getClass()
+ );
}
return beanEventDescriptor;
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorDetector.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorDetector.java 2010-03-18 09:16:31 UTC (rev 1791)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorDetector.java 2010-03-18 09:52:42 UTC (rev 1792)
@@ -45,16 +45,23 @@
public class BeanValidatorDetector {
/** to use log facility, just put in your code: log.info(\"...\"); */
- private static final Log log = LogFactory.getLog(BeanValidatorDetector.class);
+ private static final Log log =
+ LogFactory.getLog(BeanValidatorDetector.class);
- public SortedSet<BeanValidator<?>> detect(File sourceRoot, Class<?>... types) {
- SortedSet<BeanValidator<?>> result = detect(BeanValidator.class, sourceRoot, null, types);
+ public SortedSet<BeanValidator<?>> detect(File sourceRoot,
+ Class<?>... types) {
+ SortedSet<BeanValidator<?>> result =
+ detect(BeanValidator.class, sourceRoot, null, types);
return result;
}
- public SortedSet<BeanValidator<?>> detect(Class<?> validatorClass, File sourceRoot, Pattern contextFilter, Class<?>... types) {
+ public SortedSet<BeanValidator<?>> detect(Class<?> validatorClass,
+ File sourceRoot,
+ Pattern contextFilter,
+ Class<?>... types) {
- SortedSet<BeanValidator<?>> result = new TreeSet<BeanValidator<?>>(new BeanValidatorComparator());
+ SortedSet<BeanValidator<?>> result =
+ new TreeSet<BeanValidator<?>>(new BeanValidatorComparator());
for (Class<?> c : types) {
File dir = getClassDir(sourceRoot, c);
@@ -72,21 +79,29 @@
String[] realContexts = getContextsWithoutScopes(contexts);
if (log.isDebugEnabled()) {
- log.debug("realContexts : " + Arrays.toString(realContexts));
+ log.debug("realContexts : " +
+ Arrays.toString(realContexts));
}
if (contextFilter != null) {
// filter contexts
- realContexts = getFilterContexts(contextFilter, realContexts);
+ realContexts = getFilterContexts(contextFilter,
+ realContexts
+ );
if (log.isDebugEnabled()) {
- log.debug("filterContexts : " + Arrays.toString(realContexts));
+ log.debug("filterContexts : " +
+ Arrays.toString(realContexts));
}
}
for (String context : realContexts) {
// on cherche le validateur
- BeanValidator<?> validator = getValidator(validatorClass, c, context.isEmpty() ? null : context);
+ BeanValidator<?> validator = getValidator(
+ validatorClass,
+ c,
+ context.isEmpty() ? null : context
+ );
if (validator != null) {
// on enregistre le validateur
result.add(validator);
@@ -111,14 +126,19 @@
* @return le validateur initialisé, ou <code>null</code> si aucun scope
* détecté dans le validateur.
*/
- protected <B> BeanValidator<B> getValidator(Class<?> validatorClass, Class<B> klass, String context) {
+ protected <B> BeanValidator<B> getValidator(Class<?> validatorClass,
+ Class<B> klass,
+ String context) {
// BeanValidator<B> valitator = new BeanValidator<B>(klass, context);
BeanValidator<B> valitator;
try {
- valitator = (BeanValidator<B>) validatorClass.getConstructor(Class.class, String.class).newInstance(klass, context);
+ valitator = (BeanValidator<B>) validatorClass.getConstructor(
+ Class.class, String.class).newInstance(klass, context);
} catch (Exception ex) {
- throw new RuntimeException("could not instanciate validator " + validatorClass + " for reason " + ex.getMessage(), ex);
+ throw new RuntimeException(
+ "could not instanciate validator " + validatorClass +
+ " for reason " + ex.getMessage(), ex);
}
Set<BeanValidatorScope> scopes = valitator.getScopes();
@@ -136,7 +156,8 @@
}
protected File getClassDir(File sourceRoot, Class<?> clazz) {
- String path = clazz.getPackage().getName().replaceAll("\\.", File.separator);
+ String path = clazz.getPackage().getName();
+ path = path.replaceAll("\\.", File.separator);
File dir = new File(sourceRoot, path);
return dir;
}
@@ -152,9 +173,13 @@
if (log.isDebugEnabled()) {
log.debug("file " + file);
}
- String context = file.substring(filter.prefix.length(), file.length() - ValidatorFilenameFilter.SUFFIX.length());
+ String context = file.substring(
+ filter.prefix.length(),
+ file.length() - ValidatorFilenameFilter.SUFFIX.length()
+ );
if (log.isDebugEnabled()) {
- log.debug("detect " + clazz.getSimpleName() + " context [" + context + "]");
+ log.debug("detect " + clazz.getSimpleName() +
+ " context [" + context + "]");
}
result.add(context);
}
@@ -174,9 +199,15 @@
if (log.isDebugEnabled()) {
log.debug("detect context : " + context);
}
- String realContext = context.substring(0, context.length() - scopeName.length());
+ String realContext = context.substring(
+ 0,
+ context.length() - scopeName.length()
+ );
if (realContext.endsWith("-")) {
- realContext = realContext.substring(0, realContext.length() - 1);
+ realContext = realContext.substring(
+ 0,
+ realContext.length() - 1
+ );
}
result.add(realContext);
}
@@ -184,7 +215,8 @@
return result.toArray(new String[result.size()]);
}
- protected String[] getFilterContexts(Pattern contextFilter, String[] realContexts) {
+ protected String[] getFilterContexts(Pattern contextFilter,
+ String[] realContexts) {
List<String> result = new ArrayList<String>();
for (String c : realContexts) {
Matcher m = contextFilter.matcher(c);
@@ -220,8 +252,12 @@
@Override
public int compare(BeanValidator<?> o1, BeanValidator<?> o2) {
- String contextName1 = o1.getBeanClass().getSimpleName() + "-" + (o1.getContextName() == null ? "" : o1.getContextName());
- String contextName2 = o2.getBeanClass().getSimpleName() + "-" + (o2.getContextName() == null ? "" : o2.getContextName());
+ String contextName1 =
+ o1.getBeanClass().getSimpleName() + "-" +
+ (o1.getContextName() == null ? "" : o1.getContextName());
+ String contextName2 =
+ o2.getBeanClass().getSimpleName() + "-" +
+ (o2.getContextName() == null ? "" : o2.getContextName());
return contextName1.compareTo(contextName2);
}
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java 2010-03-18 09:16:31 UTC (rev 1791)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java 2010-03-18 09:52:42 UTC (rev 1792)
@@ -32,14 +32,22 @@
public class BeanValidatorEvent extends EventObject {
private static final long serialVersionUID = 1L;
+
/** the field impacted by the validator */
BeanValidatorField<?> field;
+
/** the scope impacted by the event */
BeanValidatorScope scope;
+
String[] messagestoAdd;
+
String[] messagestoDelete;
- public BeanValidatorEvent(BeanValidator<?> source, BeanValidatorField<?> field, BeanValidatorScope scope, String[] toAdd, String[] toDelete) {
+ public BeanValidatorEvent(BeanValidator<?> source,
+ BeanValidatorField<?> field,
+ BeanValidatorScope scope,
+ String[] toAdd,
+ String[] toDelete) {
super(source);
this.field = field;
this.scope = scope;
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorField.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorField.java 2010-03-18 09:16:31 UTC (rev 1791)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorField.java 2010-03-18 09:52:42 UTC (rev 1792)
@@ -22,43 +22,43 @@
import com.opensymphony.xwork2.validator.FieldValidator;
+import java.util.*;
+
import static org.nuiton.i18n.I18n._;
-import javax.swing.event.EventListenerList;
-import java.util.ArrayList;
-import java.util.EnumMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.StringTokenizer;
-
/**
* Definition of a field to be handled in a {@link BeanValidator}.
* <p/>
- * A such class is only registred in {@link BeanValidator } when the field of the bean
- * was found in validator xml configuration file for a {@link FieldValidator} only.
+ * A such class is only registred in {@link BeanValidator } when the field of
+ * the bean was found in validator xml configuration file for a {@link
+ * FieldValidator} only.
* <p/>
- * This class use properties {@link #beanClass}, {@link #name} to define
- * his naturel order.
+ * This class use properties {@link #beanClass}, {@link #name} to define his
+ * naturel order.
*
* @author tchemit <chemit(a)codelutin.com>
- * @param <B> the type of the bean handled by the validator and this field of validation.
+ * @param <B> the type of the bean handled by the validator and this field of
+ * validation.
* @since 1.3
*/
public class BeanValidatorField<B> {
/** the class of bean */
protected final Class<B> beanClass;
+
/** name of field in bean */
protected final String name;
+
protected EnumMap<BeanValidatorScope, Set<String>> messages;
- /** A list of event listeners for this validators */
- protected EventListenerList listenerList = new EventListenerList();
- public BeanValidatorField(Class<B> beanClass, String name, List<BeanValidatorScope> scopes) {
+ public BeanValidatorField(Class<B> beanClass,
+ String name,
+ List<BeanValidatorScope> scopes) {
this.beanClass = beanClass;
this.name = name;
- messages = new EnumMap<BeanValidatorScope, Set<String>>(BeanValidatorScope.class);
+ messages = new EnumMap<BeanValidatorScope, Set<String>>(
+ BeanValidatorScope.class
+ );
for (BeanValidatorScope scope : scopes) {
messages.put(scope, new HashSet<String>());
}
@@ -73,8 +73,8 @@
}
/**
- * @return <code>true</code> if this field is valid (says is in error
- * scope and has errors), <code>false</code> otherwise.
+ * @return <code>true</code> if this field is valid (says is in error scope
+ * and has errors), <code>false</code> otherwise.
*/
public boolean isValid() {
return !hasErrors();
@@ -129,7 +129,9 @@
return messages.get(scope);
}
- public void updateMessages(BeanValidator<B> validator, BeanValidatorScope scope, List<String> messages) {
+ public void updateMessages(BeanValidator<B> validator,
+ BeanValidatorScope scope,
+ List<String> messages) {
if (scope == null) {
@@ -143,7 +145,8 @@
}
if (!this.messages.containsKey(scope)) {
- throw new IllegalArgumentException("the scope " + scope + " was not registred for " + this);
+ throw new IllegalArgumentException(
+ "the scope " + scope + " was not registred for " + this);
}
if (messages == null || messages.isEmpty()) {
@@ -235,14 +238,16 @@
sb.append("<").append(super.toString());
sb.append(" beanClass:").append(beanClass);
sb.append(", name:").append(name);
- sb.append(", scopes:").append(messages == null ? "[]" : messages.keySet());
+ sb.append(", scopes:");
+ sb.append(messages == null ? "[]" : messages.keySet());
sb.append(", scope:").append(getScope());
//sb.append(", errors:").append(errors);
sb.append('>');
return sb.toString();
}
- protected void clearMessages(BeanValidatorScope scope, BeanValidator<B> validator) {
+ protected void clearMessages(BeanValidatorScope scope,
+ BeanValidator<B> validator) {
// remove all messages
Set<String> toDelete = getMessages(scope);
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java 2010-03-18 09:16:31 UTC (rev 1791)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java 2010-03-18 09:52:42 UTC (rev 1792)
@@ -23,31 +23,29 @@
/**
* The object to box a validation message.
*
- * @param <E> type of message (use for override {@link #compareTo(Object)} method.
- *
* @author tchemit <chemit(a)codelutin.com>
+ * @param <E> type of message (use for override {@link #compareTo(Object)}
+ * method.
* @since 1.3
*/
public class BeanValidatorMessage<E extends BeanValidatorMessage<?>> implements Comparable<E> {
- /**
- * the validator that produce the message
- */
+ /** the validator that produce the message */
protected BeanValidator<?> validator;
- /**
- * the field that produce the message
- */
+
+ /** the field that produce the message */
protected BeanValidatorField<?> field;
- /**
- * the label of the message (to be displayed somewhere)
- */
+
+ /** the label of the message (to be displayed somewhere) */
protected String message;
- /**
- * the scope of the message
- */
+
+ /** the scope of the message */
protected BeanValidatorScope scope;
- public BeanValidatorMessage(BeanValidator<?> validator, BeanValidatorField<?> field, String message, BeanValidatorScope scope) {
+ public BeanValidatorMessage(BeanValidator<?> validator,
+ BeanValidatorField<?> field,
+ String message,
+ BeanValidatorScope scope) {
this.field = field;
this.validator = validator;
this.message = message;
@@ -86,6 +84,30 @@
}
@Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ BeanValidatorMessage<?> that = (BeanValidatorMessage<?>) o;
+
+ return field.equals(that.field) &&
+ message.equals(that.message) &&
+ scope == that.scope;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = field.hashCode();
+ result = 31 * result + message.hashCode();
+ result = 31 * result + scope.hashCode();
+ return result;
+ }
+
+ @Override
public String toString() {
return scope + " - " + field.getI18nError(message);
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorScope.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorScope.java 2010-03-18 09:16:31 UTC (rev 1791)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorScope.java 2010-03-18 09:52:42 UTC (rev 1792)
@@ -35,25 +35,26 @@
/**
* the error scope level.
- *
- * When a message of a such scope is found on a validator, then the validator
- * is invalid and modified.
+ * <p/>
+ * When a message of a such scope is found on a validator, then the
+ * validator is invalid and modified.
*/
ERROR(n_("validator.scope.error.label")),
/**
* the warning scope level.
- *
- * When a message of a such scope is found on a validator, then the validator
- * is still valid but modified.
+ * <p/>
+ * When a message of a such scope is found on a validator, then the
+ * validator is still valid but modified.
*/
WARNING(n_("validator.scope.warning.label")),
/**
* the information scope level.
- *
+ * <p/>
* When a message of a sucg scope is found on a validator, then the
* validator is still valid and not modified.
*/
INFO(n_("validator.scope.info.label"));
+
private final String label;
BeanValidatorScope(String label) {
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java 2010-03-18 09:16:31 UTC (rev 1791)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java 2010-03-18 09:52:42 UTC (rev 1792)
@@ -20,20 +20,17 @@
*/
package jaxx.runtime.validator;
-import jaxx.runtime.*;
import com.opensymphony.xwork2.config.Configuration;
import com.opensymphony.xwork2.config.ConfigurationManager;
+import com.opensymphony.xwork2.inject.Container;
import com.opensymphony.xwork2.util.ValueStack;
import com.opensymphony.xwork2.util.ValueStackFactory;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.JAXXValidator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import java.beans.BeanInfo;
-import java.beans.EventSetDescriptor;
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.InvocationTargetException;
+import java.beans.*;
import java.util.ArrayList;
import java.util.List;
@@ -46,9 +43,10 @@
/** to use log facility, just put in your code: log.info(\"...\"); */
static private final Log log = LogFactory.getLog(BeanValidatorUtil.class);
+
/**
- * a shared value stack to allow external operations on it (for example
- * add some datas in stack to be usedby validators
+ * a shared value stack to allow external operations on it (for example add
+ * some datas in stack to be usedby validators
*/
static private ValueStack sharedValueStack;
@@ -59,7 +57,10 @@
ConfigurationManager confManager = new ConfigurationManager();
Configuration conf = confManager.getConfiguration();
- sharedValueStack = conf.getContainer().getInstance(ValueStackFactory.class).createValueStack();
+ Container container = conf.getContainer();
+ ValueStackFactory stackFactory = container.getInstance(
+ ValueStackFactory.class);
+ sharedValueStack = stackFactory.createValueStack();
if (log.isDebugEnabled()) {
log.debug("init shared value stack " + sharedValueStack);
}
@@ -81,7 +82,9 @@
* @param excludeIds the list of validator id to exclude
*/
@SuppressWarnings({"unchecked"})
- public static void setValidatorBean(JAXXObject ui, Object bean, String... excludeIds) {
+ public static void setValidatorBean(JAXXObject ui,
+ Object bean,
+ String... excludeIds) {
if (!JAXXValidator.class.isAssignableFrom(ui.getClass())) {
return;
}
@@ -94,8 +97,10 @@
}
}
for (String validatorId : validatorIds) {
- BeanValidator beanValidator = jaxxValidator.getValidator(validatorId);
- if (bean == null || beanValidator.getBeanClass().isAssignableFrom(bean.getClass())) {
+ BeanValidator beanValidator =
+ jaxxValidator.getValidator(validatorId);
+ if (bean == null || beanValidator.getBeanClass().isAssignableFrom(
+ bean.getClass())) {
// touch validator, only if fits the bean type (or bean is null)
beanValidator.setBean(bean);
}
@@ -103,7 +108,8 @@
}
/**
- * Convinient method to set the changed property to all validators of an JAXXObject.
+ * Convinient method to set the changed property to all validators of an
+ * JAXXObject.
* <p/>
* It is possible to exclude some validator to be treated.
*
@@ -112,7 +118,9 @@
* @param excludeIds the list of validator id to exclude
*/
@SuppressWarnings({"unchecked"})
- public static void setValidatorChanged(JAXXObject ui, boolean newValue, String... excludeIds) {
+ public static void setValidatorChanged(JAXXObject ui,
+ boolean newValue,
+ String... excludeIds) {
if (!JAXXValidator.class.isAssignableFrom(ui.getClass())) {
return;
}
@@ -125,42 +133,52 @@
}
}
for (String validatorId : validatorIds) {
- BeanValidator<?> beanValidator = jaxxValidator.getValidator(validatorId);
+ BeanValidator<?> beanValidator =
+ jaxxValidator.getValidator(validatorId);
beanValidator.setChanged(newValue);
}
}
/**
- * Convert a value to a given type and then if was succesffull try to set it in the bean manage by the validator.
+ * Convert a value to a given type and then if was succesffull try to set it
+ * in the bean manage by the validator.
*
* @param validator validator to be involved
* @param fieldName the name of the bean property
* @param value the actual value to convert
* @param valueClass the type of the conversion
*/
- public static void convert(BeanValidator<?> validator, String fieldName, String value, Class<?> valueClass) {
+ public static void convert(BeanValidator<?> validator,
+ String fieldName,
+ String value,
+ Class<?> valueClass) {
Object result = validator.convert(fieldName, value, valueClass);
if (result != null) {
try {
- BeanInfo info = Introspector.getBeanInfo(validator.getBean().getClass());
+ BeanInfo info =
+ Introspector.getBeanInfo(validator.getBean().getClass());
- for (PropertyDescriptor descriptor : info.getPropertyDescriptors()) {
- if (fieldName.equals(descriptor.getName()) && descriptor.getWriteMethod() != null) {
+ for (PropertyDescriptor descriptor :
+ info.getPropertyDescriptors()) {
+ if (fieldName.equals(descriptor.getName()) &&
+ descriptor.getWriteMethod() != null) {
- descriptor.getWriteMethod().invoke(validator.getBean(), result);
+ descriptor.getWriteMethod().invoke(
+ validator.getBean(),
+ result
+ );
break;
}
}
- } catch (IntrospectionException e) {
- log.error("could not obtain beanInfo for " + valueClass.getClass() + ", reason : " + e.getMessage(), e);
- } catch (InvocationTargetException e) {
- log.error("could not obtain beanInfo for " + valueClass.getClass() + ", reason : " + e.getMessage(), e);
- } catch (IllegalAccessException e) {
- log.error("could not obtain beanInfo for " + valueClass.getClass() + ", reason : " + e.getMessage(), e);
+ } catch (Exception e) {
+ log.error("could not obtain beanInfo for " +
+ valueClass.getClass() + ", reason : " +
+ e.getMessage(), e);
}
} else {
- //fixme : conversion failed, we should be able to notify ui that values has changed ?
+ //fixme : conversion failed, we should be able to notify ui
+ // that values has changed ?
// otherwise, bean value has not changed,...
}
}
@@ -176,20 +194,28 @@
if (event.getAddListenerMethod() == null) {
// no property event listener, so can not use the validator
- throw new IllegalStateException("no addPropertyChangeListener method found for " + beanClass);
+ throw new IllegalStateException(
+ "no addPropertyChangeListener method found " +
+ "for " + beanClass);
}
if (event.getRemoveListenerMethod() == null) {
// no property event listener, so can not use the validator
- throw new IllegalStateException("no removePropertyChangeListener method found for " + beanClass);
+ throw new IllegalStateException(
+ "no removePropertyChangeListener method found" +
+ " for " + beanClass);
}
return event;
}
}
// no property event listener, so can not use the validator
- throw new IllegalStateException("no PropertyChangeListener access method found for " + beanClass);
+ throw new IllegalStateException(
+ "no PropertyChangeListener access method found for " +
+ beanClass);
} catch (IntrospectionException ex) {
- throw new IllegalStateException("could not acquire PropertyChangeListener bean info for " + beanClass + " for reason " + ex.getMessage(), ex);
+ throw new IllegalStateException(
+ "could not acquire PropertyChangeListener bean info for " +
+ beanClass + " for reason " + ex.getMessage(), ex);
}
}
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java 2010-03-18 09:16:31 UTC (rev 1791)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java 2010-03-18 09:52:42 UTC (rev 1792)
@@ -24,72 +24,85 @@
import com.opensymphony.xwork2.ValidationAwareSupport;
import com.opensymphony.xwork2.config.Configuration;
import com.opensymphony.xwork2.config.ConfigurationManager;
+import com.opensymphony.xwork2.inject.Container;
import com.opensymphony.xwork2.util.ValueStack;
import com.opensymphony.xwork2.util.ValueStackFactory;
-import com.opensymphony.xwork2.validator.ActionValidatorManager;
-import com.opensymphony.xwork2.validator.DelegatingValidatorContext;
-import com.opensymphony.xwork2.validator.FieldValidator;
-import com.opensymphony.xwork2.validator.ValidationException;
-import com.opensymphony.xwork2.validator.Validator;
-
-import java.util.ArrayList;
-import java.util.Collection;
+import com.opensymphony.xwork2.validator.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
/**
- *
* A customized validator for a given bean.
+ * <p/>
+ * Use the method {@link #validate(Object)} to obtain the messages detected by
+ * the validator for the given bean.
*
- * Use the method {@link #validate(Object)} to obtain the messages
- * detected by the validator for the given bean.
- *
+ * @author tchemit <chemit(a)codelutin.com>
* @param <B> type of the bean to validate.
- *
- * @author tchemit <chemit(a)codelutin.com>
* @since 1.3
*/
public class XWorkBeanValidator<B> {
/** to use log facility, just put in your code: log.info(\"...\"); */
private static final Log log = LogFactory.getLog(XWorkBeanValidator.class);
- protected final static Map<String, List<String>> EMPTY_RESULT = Collections.unmodifiableMap(new HashMap<String, List<String>>());
+
+ protected final static Map<String, List<String>> EMPTY_RESULT =
+ Collections.unmodifiableMap(new HashMap<String, List<String>>());
+
/** the type of bean to validate */
protected final Class<B> beanClass;
+
/** the validation named context (can be null) */
protected String contextName;
+
/** the list of field names detected for this validator */
protected Set<String> fieldNames;
+
/** a flag to include or not the default context validators */
protected boolean includeDefaultContext;
+
// --
// XWorks fields
// --
+
protected ValidationAwareSupport validationSupport;
+
protected DelegatingValidatorContext validationContext;
+
protected ActionValidatorManager validator;
+
protected ActionContext context;
public XWorkBeanValidator(Class<B> beanClass, String contextName) {
- this(beanClass, contextName, true, BeanValidatorUtil.getSharedValueStack());
+ this(beanClass,
+ contextName,
+ true,
+ BeanValidatorUtil.getSharedValueStack()
+ );
}
- public XWorkBeanValidator(Class<B> beanClass, String contextName, ValueStack vs) {
+ public XWorkBeanValidator(Class<B> beanClass,
+ String contextName,
+ ValueStack vs) {
this(beanClass, contextName, true, vs);
}
- public XWorkBeanValidator(Class<B> beanClass, String contextName, boolean includeDefaultContext) {
- this(beanClass, contextName, includeDefaultContext, BeanValidatorUtil.getSharedValueStack());
+ public XWorkBeanValidator(Class<B> beanClass,
+ String contextName,
+ boolean includeDefaultContext) {
+ this(beanClass,
+ contextName,
+ includeDefaultContext,
+ BeanValidatorUtil.getSharedValueStack()
+ );
}
- public XWorkBeanValidator(Class<B> beanClass, String contextName, boolean includeDefaultContext, ValueStack vs) {
+ public XWorkBeanValidator(Class<B> beanClass,
+ String contextName,
+ boolean includeDefaultContext,
+ ValueStack vs) {
this.beanClass = beanClass;
this.includeDefaultContext = includeDefaultContext;
@@ -100,7 +113,10 @@
// create a standalone value stack
ConfigurationManager confManager = new ConfigurationManager();
Configuration conf = confManager.getConfiguration();
- vs = conf.getContainer().getInstance(ValueStackFactory.class).createValueStack();
+ Container container = conf.getContainer();
+ ValueStackFactory stackFactory =
+ container.getInstance(ValueStackFactory.class);
+ vs = stackFactory.createValueStack();
if (log.isDebugEnabled()) {
log.info("create a standalone value stack " + vs);
}
@@ -114,7 +130,10 @@
ActionContext.setContext(context);
// init validator
- validator = context.getContainer().getInstance(ActionValidatorManager.class, "no-annotations");
+ Container container = context.getContainer();
+ validator = container.getInstance(ActionValidatorManager.class,
+ "no-annotations"
+ );
// init context
setContextName(contextName);
@@ -144,7 +163,8 @@
* Test a the validator contains the field given his name
*
* @param fieldName the name of the searched field
- * @return <code>true</code> if validator contaisn this field, <code>false</code> otherwise
+ * @return <code>true</code> if validator contaisn this field,
+ * <code>false</code> otherwise
*/
public boolean containsField(String fieldName) {
return fieldNames.contains(fieldName);
@@ -169,14 +189,14 @@
* Valide le bean donné et retourne les messages produits.
*
* @param bean le bean a valider (il doit etre non null)
- *
* @return le dictionnaire des messages produits par la validation indexées
* par le nom du champs du bean impacté.
*/
public Map<String, List<String>> validate(B bean) {
if (bean == null) {
- throw new NullPointerException("bean can not be null in method validate");
+ throw new NullPointerException(
+ "bean can not be null in method validate");
}
Map<String, List<String>> result = EMPTY_RESULT;
@@ -186,7 +206,8 @@
try {
- //TC - 20081024 : since context is in a ThreadLocal variable, we must do the check
+ //TC - 20081024 : since context is in a ThreadLocal variable,
+ // we must do the check
if (ActionContext.getContext() == null) {
ActionContext.setContext(context);
}
@@ -194,20 +215,25 @@
validator.validate(bean, contextName, validationContext);
if (log.isTraceEnabled()) {
- log.trace("Action errors: " + validationContext.getActionErrors());
- log.trace("Action messages: " + validationContext.getActionMessages());
- log.trace("Field errors: " + validationContext.getFieldErrors());
+ log.trace("Action errors: " +
+ validationContext.getActionErrors());
+ log.trace("Action messages: " +
+ validationContext.getActionMessages());
+ log.trace("Field errors: " +
+ validationContext.getFieldErrors());
}
if (log.isDebugEnabled()) {
- log.debug(this + " : " + validationContext.getFieldErrors());
+ log.debug(this + " : " +
+ validationContext.getFieldErrors());
}
if (validationContext.hasFieldErrors()) {
- Map<?,?> messages = validationContext.getFieldErrors();
+ Map<?, ?> messages = validationContext.getFieldErrors();
result = new HashMap<String, List<String>>(messages.size());
for (Object fieldName : messages.keySet()) {
- Collection<?> c = (Collection<?>) messages.get(fieldName);
+ Collection<?> c =
+ (Collection<?>) messages.get(fieldName);
List<String> mm = new ArrayList<String>(c.size());
for (Object message : c) {
mm.add(message + "");
@@ -217,7 +243,8 @@
}
} catch (ValidationException eee) {
- log.warn("Error during validation on " + beanClass + " for reason : " + eee.getMessage(), eee);
+ log.warn("Error during validation on " + beanClass +
+ " for reason : " + eee.getMessage(), eee);
} finally {
// on nettoye toujours le validateur apres operation
@@ -230,12 +257,11 @@
@Override
public String toString() {
- return super.toString() + "<beanClass:" + beanClass + ", contextName:" + contextName + ">";
+ return super.toString() + "<beanClass:" + beanClass +
+ ", contextName:" + contextName + ">";
}
- /**
- * update the property {@link #fieldNames}, says search in XWorks
- */
+ /** update the property {@link #fieldNames}, says search in XWorks */
protected synchronized void initFields() {
if (fieldNames != null) {
@@ -263,7 +289,10 @@
continue;
}
FieldValidator fieldValidator = (FieldValidator) v;
- log.debug("context " + contextName + " - field " + fieldValidator.getFieldName());
+ if (log.isDebugEnabled()) {
+ log.debug("context " + contextName + " - field " +
+ fieldValidator.getFieldName());
+ }
String fName = fieldValidator.getFieldName();
detectedFieldNames.add(fName);
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java 2010-03-18 09:16:31 UTC (rev 1791)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java 2010-03-18 09:52:42 UTC (rev 1792)
@@ -20,31 +20,30 @@
*/
package jaxx.runtime.validator.swing;
+import jaxx.runtime.validator.BeanValidator;
+import jaxx.runtime.validator.BeanValidatorField;
import jaxx.runtime.validator.swing.ui.AbstractBeanValidatorUI;
import jaxx.runtime.validator.swing.ui.IconValidationUI;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.jxlayer.JXLayer;
-import javax.swing.JComponent;
-import javax.swing.SwingUtilities;
-import java.awt.Container;
+import javax.swing.*;
+import java.awt.*;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
-import jaxx.runtime.validator.BeanValidator;
-import jaxx.runtime.validator.BeanValidatorField;
/**
* La surcharge de {@link BeanValidator} pour les ui swing
* <p/>
* /**
* <p/>
- * Permet d'ajouter facilement le support de la validation des champs d'un
- * bean et de le relier a une interface graphique.
- * Utilise xwork pour la validation et JXLayer pour la visualisation.
+ * Permet d'ajouter facilement le support de la validation des champs d'un bean
+ * et de le relier a une interface graphique. Utilise xwork pour la validation
+ * et JXLayer pour la visualisation.
* <p/>
* <p/>
* Le mieux pour son integration dans Jaxx est de faire de la generation pour
@@ -54,30 +53,32 @@
* myValidor.getBean().get<field>();
* </pre>
* <p/>
- * et ceci pour chaque field ajoute a la map fieldRepresentation. De cette
- * facon meme si le champs field est en texte on a une verification de son
- * existance a la compilation.
+ * et ceci pour chaque field ajoute a la map fieldRepresentation. De cette facon
+ * meme si le champs field est en texte on a une verification de son existance a
+ * la compilation.
* <p/>
* <p/>
* La representation en tag pourrait etre
* <pre>
- * <validator id="myValidator" beanClass="{Personne.class}" errorList="$list">
+ * <validator id="myValidator" beanClass="{Personne.class}"
+ * errorList="$list">
* <field name="name" component="$name"/>
* <field name="firstName" component="$firstName"/>
* <field name="birthDate" component="$birthDate"/>
* </validator>
- * <validator beanClass="{Personne.class}" autoField="true" errorList="$list">
+ * <validator beanClass="{Personne.class}" autoField="true"
+ * errorList="$list">
* <fieldRepresentation name="name" component="$lastName"/>
* </validator>
* </pre>
* <p/>
* dans le premier exemple on fait un mapping explicite des champs, mais on voit
- * que le nom du composant graphique est le meme que celui du champs. Pour eviter
- * de longue saisie, il est possible d'utiliser le flag <b>autoField</b>
- * qui pour chaque champs du ayant une methode get du bean recherche un composant
- * avec cet Id. Il est aussi possible de surcharge un champs explicitement
- * comme ici name, dans le cas ou le composant qui porterait ce nom serait
- * utilise pour autre chose.
+ * que le nom du composant graphique est le meme que celui du champs. Pour
+ * eviter de longue saisie, il est possible d'utiliser le flag <b>autoField</b>
+ * qui pour chaque champs du ayant une methode get du bean recherche un
+ * composant avec cet Id. Il est aussi possible de surcharge un champs
+ * explicitement comme ici name, dans le cas ou le composant qui porterait ce
+ * nom serait utilise pour autre chose.
* <p/>
* <p/>
* Il faut un handler particulier pour ce composant car les attributs
@@ -97,34 +98,45 @@
* for (Method m : beanClass.getMethod()) {
* if (m.getName().startsWith("get")) {
* String fieldName = m.getName().substring(3).toLowerCase();
- * $myValidator.setFieldRepresentation(fieldName, $objectMap.get(fieldName));
+ * $myValidator.setFieldRepresentation(fieldName,
+ * $objectMap.get(fieldName));
* }
* }
* // pour chaque tag fieldRepresentation
* myValidator.setFieldRepresentation("name", $lastName);
- * // si beanClass est specifie et n'est pas Object, on force l'acces au champs
+ * // si beanClass est specifie et n'est pas Object, on force l'acces au
+ * champs
* // pour validation a la compilation
* $myValidator.getBean().getName();
* $objectMap.put("myValidator", $myValidator);
* }
* </pre>
*
- * @param <B> le type de bean a valider
* @author poussin <poussin(a)codelutin.com>
* @author tchemit <chemit(a)codelutin.com>
- * @version 1.0
+ * @version 1.0
+ * @param <B> le type de bean a valider
*/
public class SwingValidator<B> extends BeanValidator<B> {
/** to use log facility, just put in your code: log.info(\"...\"); */
static private final Log log = LogFactory.getLog(SwingValidator.class);
- static private final Class<? extends AbstractBeanValidatorUI> DEFAULT_UI_CLASS = IconValidationUI.class;
- /** permet de faire le lien en un champs du bean et l'objet qui permet de l'editer */
+
+ static private final Class<? extends AbstractBeanValidatorUI>
+ DEFAULT_UI_CLASS = IconValidationUI.class;
+
+ /**
+ * permet de faire le lien en un champs du bean et l'objet qui permet de
+ * l'editer
+ */
protected Map<String, JComponent> fieldRepresentation;
+
/** Object servant a contenir la liste des erreurs */
protected SwingValidatorMessageListModel errorListModel;
+
/** Object servant a contenir la liste des erreurs */
protected SwingValidatorMessageTableModel errorTableModel;
+
/** ui renderer class */
protected Class<? extends AbstractBeanValidatorUI> uiClass;
@@ -135,10 +147,9 @@
/**
* To reload a bean in the validator.
- *
- * This method is used to reload ui, since some editors
- * could not exist when validator is init, so some messages
- * should not be attached to an editor.
+ * <p/>
+ * This method is used to reload ui, since some editors could not exist when
+ * validator is init, so some messages should not be attached to an editor.
*/
public void reloadBean() {
B b = getBean();
@@ -156,7 +167,8 @@
return uiClass;
}
- public void setErrorListModel(SwingValidatorMessageListModel errorListModel) {
+ public void setErrorListModel(
+ SwingValidatorMessageListModel errorListModel) {
this.errorListModel = errorListModel;
if (errorListModel != null) {
// register the validator in the model list
@@ -164,7 +176,8 @@
}
}
- public void setErrorTableModel(SwingValidatorMessageTableModel errorTableModel) {
+ public void setErrorTableModel(
+ SwingValidatorMessageTableModel errorTableModel) {
this.errorTableModel = errorTableModel;
if (errorTableModel != null) {
// register the validator in the model table
@@ -206,8 +219,8 @@
}
/**
- * Permet d'indiquer le composant graphique responsable de l'affichage
- * d'un attribut du bean
+ * Permet d'indiquer le composant graphique responsable de l'affichage d'un
+ * attribut du bean
*
* @param fieldname the field name in the bean
* @param c the editor component for the field
@@ -216,13 +229,15 @@
BeanValidatorField<B> field = getField(fieldname);
if (field == null) {
// no field registred in the validator
- log.warn("the field '" + fieldname + "' is not defined in validator (no rules on it)");
+ log.warn("the field '" + fieldname +
+ "' is not defined in validator (no rules on it)");
return;
}
fieldRepresentation.put(fieldname, c);
}
- public void setFieldRepresentation(Map<String, JComponent> fieldRepresentation) {
+ public void setFieldRepresentation(
+ Map<String, JComponent> fieldRepresentation) {
for (Map.Entry<String, JComponent> e : fieldRepresentation.entrySet()) {
setFieldRepresentation(e.getKey(), e.getValue());
}
@@ -247,9 +262,15 @@
// use the default one
uiClass = DEFAULT_UI_CLASS;
}
- for (Entry<String, JComponent> entry : fieldRepresentation.entrySet()) {
+ for (Entry<String, JComponent> entry :
+ fieldRepresentation.entrySet()) {
try {
- setMessageRepresentation(entry.getKey(), null, entry.getValue(), uiClass);
+ setMessageRepresentation(
+ entry.getKey(),
+ null,
+ entry.getValue(),
+ uiClass
+ );
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -258,8 +279,15 @@
});
}
- protected void setMessageRepresentation(String fieldname, JComponent old, JComponent c, Class<? extends AbstractBeanValidatorUI> uiClass)
- throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException {
+ protected void setMessageRepresentation(
+ String fieldname,
+ JComponent old,
+ JComponent c,
+ Class<? extends AbstractBeanValidatorUI> uiClass)
+ throws InvocationTargetException,
+ IllegalAccessException,
+ InstantiationException,
+ NoSuchMethodException {
if (old == c) {
// same component, nothing to do
return;
@@ -267,7 +295,8 @@
BeanValidatorField<B> field = getField(fieldname);
if (field == null) {
- // this case should not appear since fieldName has already been check in method addFieldRepresentation
+ // this case should not appear since fieldName has already been
+ // check in method addFieldRepresentation
return;
}
if (old != null) {
@@ -287,7 +316,8 @@
// ajout du jxlayer sous ce composant
Container container = c.getParent();
if (container instanceof JXLayer<?>) {
- Constructor<? extends AbstractBeanValidatorUI> cons = uiClass.getConstructor(BeanValidatorField.class);
+ Constructor<? extends AbstractBeanValidatorUI> cons =
+ uiClass.getConstructor(BeanValidatorField.class);
AbstractBeanValidatorUI ui = cons.newInstance(field);
ui.setEnabled(true);
JXLayer<JComponent> jx = (JXLayer<JComponent>) container;
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java 2010-03-18 09:16:31 UTC (rev 1791)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java 2010-03-18 09:52:42 UTC (rev 1792)
@@ -20,33 +20,41 @@
*/
package jaxx.runtime.validator.swing;
-import javax.swing.JComponent;
import jaxx.runtime.validator.BeanValidatorField;
import jaxx.runtime.validator.BeanValidatorMessage;
import jaxx.runtime.validator.BeanValidatorScope;
+import javax.swing.*;
+
/**
* The object to box a validation message within an u.
*
* @author tchemit <chemit(a)codelutin.com>
+ * @see BeanValidatorMessage
* @since 1.3
- * @see BeanValidatorMessage
*/
public class SwingValidatorMessage extends BeanValidatorMessage<SwingValidatorMessage> {
- /**
- * the optional field's editor
- */
+ /** the optional field's editor */
protected JComponent editor;
+
protected String fieldName;
- public SwingValidatorMessage(SwingValidator<?> validator, BeanValidatorField<?> field, String message, BeanValidatorScope scope, JComponent editor) {
+ public SwingValidatorMessage(SwingValidator<?> validator,
+ BeanValidatorField<?> field,
+ String message,
+ BeanValidatorScope scope,
+ JComponent editor) {
super(validator, field, message, scope);
fieldName = field.getName();
this.editor = editor;
}
- public SwingValidatorMessage(SwingValidator<?> validator, String fieldName, String message, BeanValidatorScope scope, JComponent editor) {
+ public SwingValidatorMessage(SwingValidator<?> validator,
+ String fieldName,
+ String message,
+ BeanValidatorScope scope,
+ JComponent editor) {
super(validator, null, message, scope);
this.fieldName = fieldName;
this.editor = editor;
@@ -76,8 +84,33 @@
}
@Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ SwingValidatorMessage that = (SwingValidatorMessage) o;
+
+ return fieldName.equals(that.fieldName) &&
+ message.equals(that.message) &&
+ scope == that.scope;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = fieldName.hashCode();
+ result = 31 * result + message.hashCode();
+ result = 31 * result + scope.hashCode();
+ return result;
+ }
+
+ @Override
public String toString() {
- String s = scope + " - " + (field == null ? message : field.getI18nError(message));
+ String s = scope + " - " +
+ (field == null ? message : field.getI18nError(message));
if (editor == null) {
return s;
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java 2010-03-18 09:16:31 UTC (rev 1791)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java 2010-03-18 09:52:42 UTC (rev 1792)
@@ -21,19 +21,18 @@
package jaxx.runtime.validator.swing;
import jaxx.runtime.validator.BeanValidatorEvent;
-
-import javax.swing.AbstractListModel;
-import javax.swing.JComponent;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
import jaxx.runtime.validator.BeanValidatorField;
import jaxx.runtime.validator.BeanValidatorListener;
import jaxx.runtime.validator.BeanValidatorScope;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import javax.swing.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
/**
* The model of the list of validation's messages
*
@@ -44,10 +43,13 @@
implements BeanValidatorListener {
private static final long serialVersionUID = 1L;
+
/** to use log facility, just put in your code: log.info(\"...\"); */
private static Log log = LogFactory.getLog(SwingValidatorMessageListModel.class);
+
/** list of registred validators */
protected transient List<SwingValidator<?>> validators;
+
/** list of messages actual displayed */
protected List<SwingValidatorMessage> data;
@@ -62,7 +64,9 @@
public void registerValidator(SwingValidator<?> validator) {
if (validators.contains(validator)) {
- throw new IllegalArgumentException("the validator " + validator + " is already registred in " + this);
+ throw new IllegalArgumentException(
+ "the validator " + validator + " is already registred in "
+ + this);
}
validators.add(validator);
validator.addBeanValidatorListener(this);
@@ -119,16 +123,28 @@
protected void ensureRowIndex(int index) throws ArrayIndexOutOfBoundsException {
if (index < -1 || index >= getSize()) {
- throw new ArrayIndexOutOfBoundsException("the rowIndex was " + index + ", but should be int [0," + (getSize() - 1) + "]");
+ throw new ArrayIndexOutOfBoundsException(
+ "the rowIndex was " + index + ", but should be int [0," +
+ (getSize() - 1) + "]");
}
}
- protected void addMessages(SwingValidator<?> validator, BeanValidatorField<?> field, BeanValidatorScope scope, boolean sort, String... messages) {
+ protected void addMessages(SwingValidator<?> validator,
+ BeanValidatorField<?> field,
+ BeanValidatorScope scope,
+ boolean sort,
+ String... messages) {
JComponent editor = validator.getFieldRepresentation(field.getName());
// add new errors
for (String error : messages) {
- SwingValidatorMessage row = new SwingValidatorMessage(validator, field, error, scope, editor);
+ SwingValidatorMessage row = new SwingValidatorMessage(
+ validator,
+ field,
+ error,
+ scope,
+ editor
+ );
data.add(row);
if (!sort) {
fireIntervalAdded(this, data.size() - 1, data.size() - 1);
@@ -145,16 +161,24 @@
}
}
- protected void removeMessages(SwingValidator<?> validator, BeanValidatorField<?> field, BeanValidatorScope scope, boolean notify, String... messages) {
+ protected void removeMessages(SwingValidator<?> validator,
+ BeanValidatorField<?> field,
+ BeanValidatorScope scope,
+ boolean notify,
+ String... messages) {
- List<String> messagesToDel = new ArrayList<String>(Arrays.asList(messages));
+ List<String> messagesToDel =
+ new ArrayList<String>(Arrays.asList(messages));
// do it in reverse mode (only one pass in that way since index
// will stay coherent while removing them)
for (int i = getSize() - 1; i > -1; i--) {
SwingValidatorMessage error = data.get(i);
- if (error.getValidator() == validator && error.getScope() == scope && error.getField() == field && messagesToDel.contains(error.getMessage())) {
+ if (error.getValidator() == validator &&
+ error.getScope() == scope &&
+ error.getField() == field &&
+ messagesToDel.contains(error.getMessage())) {
// remove the message
data.remove(i);
if (notify) {
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java 2010-03-18 09:16:31 UTC (rev 1791)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java 2010-03-18 09:52:42 UTC (rev 1792)
@@ -23,22 +23,24 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import javax.swing.JComponent;
-import javax.swing.JList;
+import javax.swing.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
/**
- * A mouse listener to put on a {@link JList} with a {@link SwingValidatorMessageListModel} as a model.
+ * A mouse listener to put on a {@link JList} with a {@link
+ * SwingValidatorMessageListModel} as a model.
* <p/>
- * When a double click occurs, find the selected error in model and then focus to the associated component of error.
+ * When a double click occurs, find the selected error in model and then focus
+ * to the associated component of error.
*
* @author tchemit <chemit(a)codelutin.com>
*/
public class SwingValidatorMessageListMouseListener extends MouseAdapter {
/** to use log facility, just put in your code: log.info(\"...\"); */
- static private Log log = LogFactory.getLog(SwingValidatorMessageListMouseListener.class);
+ static private Log log =
+ LogFactory.getLog(SwingValidatorMessageListMouseListener.class);
@Override
public void mouseClicked(MouseEvent e) {
@@ -60,17 +62,21 @@
protected SwingValidatorMessage getSelectedMessage(MouseEvent e) {
JList list = (JList) e.getSource();
if (!(list.getModel() instanceof SwingValidatorMessageListModel)) {
- log.warn("model must be a " + SwingValidatorMessageListModel.class + ", but was " + list.getModel());
+ log.warn("model must be a " +
+ SwingValidatorMessageListModel.class + ", but was " +
+ list.getModel());
return null;
}
- SwingValidatorMessageListModel model = (SwingValidatorMessageListModel) list.getModel();
+ SwingValidatorMessageListModel model =
+ (SwingValidatorMessageListModel) list.getModel();
int index = list.getSelectionModel().getMinSelectionIndex();
if (index == -1) {
// nothing is selected
return null;
}
- SwingValidatorMessage entry = (SwingValidatorMessage) model.getElementAt(index);
+ SwingValidatorMessage entry =
+ (SwingValidatorMessage) model.getElementAt(index);
if (log.isDebugEnabled()) {
log.debug("selected index: " + index + " : error: " + entry);
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java 2010-03-18 09:16:31 UTC (rev 1791)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java 2010-03-18 09:52:42 UTC (rev 1792)
@@ -20,26 +20,27 @@
*/
package jaxx.runtime.validator.swing;
-import javax.swing.ImageIcon;
-import javax.swing.JLabel;
-import javax.swing.JList;
-import java.awt.Component;
-import javax.swing.DefaultListCellRenderer;
import jaxx.runtime.validator.BeanValidatorScope;
+
+import javax.swing.*;
+import java.awt.*;
+
import static org.nuiton.i18n.I18n._;
/**
- * A simple render of a table of validator's messages, says a table that use
- * a {@link SwingValidatorMessageTableModel} model.
+ * A simple render of a table of validator's messages, says a table that use a
+ * {@link SwingValidatorMessageTableModel} model.
*
* @author tchemit <chemit(a)codelutin.com>
+ * @see SwingValidatorMessageTableModel
* @since 1.3
- * @see SwingValidatorMessageTableModel
*/
public class SwingValidatorMessageListRenderer extends DefaultListCellRenderer {
private static final long serialVersionUID = 1L;
+
protected String format = "%1$-20s - %2$s";
+
protected String formatTip = "%1$-20s - %2$-20s : %3$s";
public SwingValidatorMessageListRenderer() {
@@ -58,9 +59,20 @@
}
@Override
- public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
+ public Component getListCellRendererComponent(JList list,
+ Object value,
+ int index,
+ boolean isSelected,
+ boolean cellHasFocus) {
- JLabel rendererComponent = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+ JLabel rendererComponent = (JLabel)
+ super.getListCellRendererComponent(
+ list,
+ value,
+ index,
+ isSelected,
+ cellHasFocus
+ );
SwingValidatorMessage model = (SwingValidatorMessage) value;
@@ -68,7 +80,11 @@
ImageIcon icon = SwingValidatorUtil.getIcon(model.getScope());
// field name
- String fieldName = getFieldName(list, model.getField().getName(), index);
+ String fieldName = getFieldName(
+ list,
+ model.getField().getName(),
+ index
+ );
// message
String message = getMessage(model);
@@ -101,8 +117,10 @@
}
public String getFieldName(JList list, String value, int row) {
- SwingValidatorMessageListModel tableModel = (SwingValidatorMessageListModel) list.getModel();
- SwingValidatorMessage model = (SwingValidatorMessage) tableModel.getElementAt(row);
+ SwingValidatorMessageListModel tableModel =
+ (SwingValidatorMessageListModel) list.getModel();
+ SwingValidatorMessage model =
+ (SwingValidatorMessage) tableModel.getElementAt(row);
String fieldName = SwingValidatorUtil.getFieldName(model, value);
return fieldName;
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java 2010-03-18 09:16:31 UTC (rev 1791)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java 2010-03-18 09:52:42 UTC (rev 1792)
@@ -21,18 +21,18 @@
package jaxx.runtime.validator.swing;
import jaxx.runtime.validator.BeanValidatorEvent;
+import jaxx.runtime.validator.BeanValidatorField;
+import jaxx.runtime.validator.BeanValidatorListener;
+import jaxx.runtime.validator.BeanValidatorScope;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
-import javax.swing.JComponent;
+import javax.swing.*;
import javax.swing.table.AbstractTableModel;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import jaxx.runtime.validator.BeanValidatorField;
-import jaxx.runtime.validator.BeanValidatorListener;
-import jaxx.runtime.validator.BeanValidatorScope;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
/**
* The model of the table of errors.
@@ -47,23 +47,24 @@
implements BeanValidatorListener {
private static final long serialVersionUID = 1L;
- /**
- * to use log facility, just put in your code: log.info(\"...\");
- */
- private static Log log = LogFactory.getLog(SwingValidatorMessageTableMouseListener.class);
- public static final String[] columnNames = {"validator.scope", "validator.field", "validator.message"};
- public static final Class<?>[] columnClasses = {BeanValidatorScope.class, String.class, String.class};
- /**
- * list of registred validators
- */
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ private static Log log =
+ LogFactory.getLog(SwingValidatorMessageTableMouseListener.class);
+
+ public static final String[] columnNames =
+ {"validator.scope", "validator.field", "validator.message"};
+
+ public static final Class<?>[] columnClasses =
+ {BeanValidatorScope.class, String.class, String.class};
+
+ /** list of registred validators */
protected transient List<SwingValidator<?>> validators;
- /**
- * list of messages actual displayed
- */
+
+ /** list of messages actual displayed */
protected List<SwingValidatorMessage> data;
public SwingValidatorMessageTableModel() {
- super();
validators = new ArrayList<SwingValidator<?>>();
data = new ArrayList<SwingValidatorMessage>();
}
@@ -78,21 +79,32 @@
*/
public void registerValidator(SwingValidator<?> validator) {
if (validators.contains(validator)) {
- throw new IllegalArgumentException("the validator " + validator + " is already registred in " + this);
+ throw new IllegalArgumentException(
+ "the validator " + validator + " is already registred in "
+ + this);
}
validators.add(validator);
validator.addBeanValidatorListener(this);
}
- public void addMessages(SwingValidator<?> validator, String fieldName, BeanValidatorScope scope, String... messages) {
+ public void addMessages(SwingValidator<?> validator,
+ String fieldName,
+ BeanValidatorScope scope,
+ String... messages) {
addMessages(validator, fieldName, scope, true, messages);
}
- public void addMessages(JComponent editor, String fieldName, BeanValidatorScope scope, String... messages) {
+ public void addMessages(JComponent editor,
+ String fieldName,
+ BeanValidatorScope scope,
+ String... messages) {
addMessages(editor, fieldName, scope, true, messages);
}
- public void addMessages(SwingValidator<?> validator, BeanValidatorField<?> field, BeanValidatorScope scope, String... messages) {
+ public void addMessages(SwingValidator<?> validator,
+ BeanValidatorField<?> field,
+ BeanValidatorScope scope,
+ String... messages) {
addMessages(validator, field, scope, true, messages);
}
@@ -103,7 +115,8 @@
for (int i = getRowCount() - 1; i > -1; i--) {
SwingValidatorMessage error = data.get(i);
- if (error.getEditor() == editor && (scope == null || error.getScope() == scope)) {
+ if (error.getEditor() == editor &&
+ (scope == null || error.getScope() == scope)) {
// remove the message
data.remove(i);
fireTableRowsDeleted(i, i);
@@ -111,15 +124,23 @@
}
}
- public void removeMessages(SwingValidator<?> validator, String fieldName, BeanValidatorScope scope, String... messages) {
+ public void removeMessages(SwingValidator<?> validator,
+ String fieldName,
+ BeanValidatorScope scope,
+ String... messages) {
removeMessages(validator, fieldName, scope, true, messages);
}
- public void removeMessages(JComponent editor, String fieldName, BeanValidatorScope scope) {
+ public void removeMessages(JComponent editor,
+ String fieldName,
+ BeanValidatorScope scope) {
removeMessages(editor, fieldName, scope, true);
}
- public void removeMessages(SwingValidator<?> validator, BeanValidatorField<?> field, BeanValidatorScope scope, String... messages) {
+ public void removeMessages(SwingValidator<?> validator,
+ BeanValidatorField<?> field,
+ BeanValidatorScope scope,
+ String... messages) {
removeMessages(validator, field, scope, true, messages);
}
@@ -223,24 +244,43 @@
return null;
}
- protected void ensureRowIndex(int rowIndex) throws ArrayIndexOutOfBoundsException {
+ protected void ensureRowIndex(int rowIndex)
+ throws ArrayIndexOutOfBoundsException {
if (rowIndex < -1 || rowIndex >= getRowCount()) {
- throw new ArrayIndexOutOfBoundsException("the rowIndex was " + rowIndex + ", but should be int [0," + (getRowCount() - 1) + "]");
+ throw new ArrayIndexOutOfBoundsException(
+ "the rowIndex was " + rowIndex + ", but should be int [0,"
+ + (getRowCount() - 1) + "]");
}
}
- protected void ensureColumnIndex(int index) throws ArrayIndexOutOfBoundsException {
+ protected void ensureColumnIndex(int index)
+ throws ArrayIndexOutOfBoundsException {
if (index < -1 || index >= getColumnCount()) {
- throw new ArrayIndexOutOfBoundsException("the columnIndex was " + index + ", but should be int [0," + (getColumnCount() - 1) + "]");
+ throw new ArrayIndexOutOfBoundsException(
+ "the columnIndex was " + index + ", but should be int [0,"
+ + (getColumnCount() - 1) + "]");
}
}
- protected void addMessages(SwingValidator<?> validator, BeanValidatorField<?> field, BeanValidatorScope scope, boolean sort, String... messages) {
+ protected void addMessages(SwingValidator<?> validator,
+ BeanValidatorField<?> field,
+ BeanValidatorScope scope,
+ boolean sort,
+ String... messages) {
- JComponent editor = validator == null ? null : validator.getFieldRepresentation(field.getName());
+ JComponent editor = validator == null ?
+ null :
+ validator.getFieldRepresentation(field.getName());
// add new errors
for (String error : messages) {
- SwingValidatorMessage row = new SwingValidatorMessage(validator, field, error, scope, editor);
+ SwingValidatorMessage row =
+ new SwingValidatorMessage(
+ validator,
+ field,
+ error,
+ scope,
+ editor
+ );
data.add(row);
if (!sort) {
fireTableRowsInserted(data.size() - 1, data.size() - 1);
@@ -257,12 +297,25 @@
}
}
- protected void addMessages(SwingValidator<?> validator, String fieldName, BeanValidatorScope scope, boolean sort, String... messages) {
+ protected void addMessages(SwingValidator<?> validator,
+ String fieldName,
+ BeanValidatorScope scope,
+ boolean sort,
+ String... messages) {
- JComponent editor = validator == null ? null : validator.getFieldRepresentation(fieldName);
+ JComponent editor = validator == null ?
+ null :
+ validator.getFieldRepresentation(fieldName);
// add new errors
for (String error : messages) {
- SwingValidatorMessage row = new SwingValidatorMessage(validator, fieldName, error, scope, editor);
+ SwingValidatorMessage row =
+ new SwingValidatorMessage(
+ validator,
+ fieldName,
+ error,
+ scope,
+ editor
+ );
data.add(row);
if (!sort) {
fireTableRowsInserted(data.size() - 1, data.size() - 1);
@@ -279,11 +332,22 @@
}
}
- protected void addMessages(JComponent editor, String fieldName, BeanValidatorScope scope, boolean sort, String... messages) {
+ protected void addMessages(JComponent editor,
+ String fieldName,
+ BeanValidatorScope scope,
+ boolean sort,
+ String... messages) {
// add new errors
for (String error : messages) {
- SwingValidatorMessage row = new SwingValidatorMessage(null, fieldName, error, scope, editor);
+ SwingValidatorMessage row =
+ new SwingValidatorMessage(
+ null,
+ fieldName,
+ error,
+ scope,
+ editor
+ );
data.add(row);
if (!sort) {
fireTableRowsInserted(data.size() - 1, data.size() - 1);
@@ -300,16 +364,24 @@
}
}
- protected void removeMessages(SwingValidator<?> validator, BeanValidatorField<?> field, BeanValidatorScope scope, boolean notify, String... messages) {
+ protected void removeMessages(SwingValidator<?> validator,
+ BeanValidatorField<?> field,
+ BeanValidatorScope scope,
+ boolean notify,
+ String... messages) {
- List<String> messagesToDel = new ArrayList<String>(Arrays.asList(messages));
+ List<String> messagesToDel =
+ new ArrayList<String>(Arrays.asList(messages));
// do it in reverse mode (only one pass in that way since index
// will stay coherent while removing them)
for (int i = getRowCount() - 1; i > -1; i--) {
SwingValidatorMessage error = data.get(i);
- if (error.getValidator() == validator && error.getScope() == scope && error.getFieldName().equals(field.getName()) && messagesToDel.contains(error.getMessage())) {
+ if (error.getValidator() == validator &&
+ error.getScope() == scope &&
+ error.getFieldName().equals(field.getName()) &&
+ messagesToDel.contains(error.getMessage())) {
// remove the message
data.remove(i);
if (notify) {
@@ -319,16 +391,24 @@
}
}
- protected void removeMessages(SwingValidator<?> validator, String fieldName, BeanValidatorScope scope, boolean notify, String... messages) {
+ protected void removeMessages(SwingValidator<?> validator,
+ String fieldName,
+ BeanValidatorScope scope,
+ boolean notify,
+ String... messages) {
- List<String> messagesToDel = new ArrayList<String>(Arrays.asList(messages));
+ List<String> messagesToDel =
+ new ArrayList<String>(Arrays.asList(messages));
// do it in reverse mode (only one pass in that way since index
// will stay coherent while removing them)
for (int i = getRowCount() - 1; i > -1; i--) {
SwingValidatorMessage error = data.get(i);
- if (error.getValidator() == validator && error.getScope() == scope && error.getFieldName().equals(fieldName) && messagesToDel.contains(error.getMessage())) {
+ if (error.getValidator() == validator &&
+ error.getScope() == scope &&
+ error.getFieldName().equals(fieldName) &&
+ messagesToDel.contains(error.getMessage())) {
// remove the message
data.remove(i);
if (notify) {
@@ -338,14 +418,19 @@
}
}
- protected void removeMessages(JComponent editor, String fieldName, BeanValidatorScope scope, boolean notify) {
+ protected void removeMessages(JComponent editor,
+ String fieldName,
+ BeanValidatorScope scope,
+ boolean notify) {
// do it in reverse mode (only one pass in that way since index
// will stay coherent while removing them)
for (int i = getRowCount() - 1; i > -1; i--) {
SwingValidatorMessage error = data.get(i);
- if (error.getEditor() == editor && (scope == null || error.getScope() == scope) && error.getFieldName().equals(fieldName)) {
+ if (error.getEditor() == editor &&
+ (scope == null || error.getScope() == scope) &&
+ error.getFieldName().equals(fieldName)) {
// remove the message
data.remove(i);
if (notify) {
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java 2010-03-18 09:16:31 UTC (rev 1791)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java 2010-03-18 09:52:42 UTC (rev 1792)
@@ -23,25 +23,26 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import javax.swing.JComponent;
-import javax.swing.JList;
-import javax.swing.JTable;
+import javax.swing.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
/**
- * A mouse listener to put on a {@link JList} with a {@link SwingValidatorMessageTableModel} as a model.
+ * A mouse listener to put on a {@link JList} with a {@link
+ * SwingValidatorMessageTableModel} as a model.
* <p/>
- * When a double click occurs, find the selected error in model and then focus to the associated component of error.
+ * When a double click occurs, find the selected error in model and then focus
+ * to the associated component of error.
*
* @author tchemit <chemit(a)codelutin.com>
*/
public class SwingValidatorMessageTableMouseListener extends MouseAdapter {
/** to use log facility, just put in your code: log.info(\"...\"); */
- private static Log log = LogFactory.getLog(SwingValidatorMessageTableMouseListener.class);
+ private static Log log =
+ LogFactory.getLog(SwingValidatorMessageTableMouseListener.class);
public static final String HIGHLIGHT_ERROR_PROPERTY = "highlightError";
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java 2010-03-18 09:16:31 UTC (rev 1791)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java 2010-03-18 09:52:42 UTC (rev 1792)
@@ -41,8 +41,21 @@
private static final long serialVersionUID = 1L;
@Override
- public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
- JLabel rendererComponent = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ public Component getTableCellRendererComponent(JTable table,
+ Object value,
+ boolean isSelected,
+ boolean hasFocus,
+ int row,
+ int column) {
+ JLabel rendererComponent = (JLabel)
+ super.getTableCellRendererComponent(
+ table,
+ value,
+ isSelected,
+ hasFocus,
+ row,
+ column
+ );
ImageIcon icon = null;
String text = null;
@@ -88,14 +101,16 @@
}
public String getMessage(JTable table, String value, int row) {
- SwingValidatorMessageTableModel tableModel = (SwingValidatorMessageTableModel) table.getModel();
+ SwingValidatorMessageTableModel tableModel =
+ (SwingValidatorMessageTableModel) table.getModel();
SwingValidatorMessage model = tableModel.getRow(row);
String text = SwingValidatorUtil.getMessage(model);
return text;
}
public String getFieldName(JTable table, String value, int row) {
- SwingValidatorMessageTableModel tableModel = (SwingValidatorMessageTableModel) table.getModel();
+ SwingValidatorMessageTableModel tableModel =
+ (SwingValidatorMessageTableModel) table.getModel();
SwingValidatorMessage model = tableModel.getRow(row);
String fieldName = SwingValidatorUtil.getFieldName(model, value);
return fieldName;
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java 2010-03-18 09:16:31 UTC (rev 1791)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java 2010-03-18 09:52:42 UTC (rev 1792)
@@ -20,19 +20,16 @@
*/
package jaxx.runtime.validator.swing;
-import jaxx.runtime.*;
-import jaxx.runtime.validator.*;
+import jaxx.runtime.SwingUtil;
+import jaxx.runtime.validator.BeanValidatorScope;
+import jaxx.runtime.validator.BeanValidatorUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import javax.swing.JList;
-import javax.swing.JTable;
+import javax.swing.*;
import java.awt.event.MouseListener;
import java.util.Arrays;
-import javax.swing.ImageIcon;
-import javax.swing.JComponent;
-import javax.swing.RowSorter;
-import javax.swing.SortOrder;
+
import static org.nuiton.i18n.I18n.n_;
/**
@@ -43,8 +40,11 @@
public class SwingValidatorUtil extends BeanValidatorUtil {
static ImageIcon errorIcon;
+
static ImageIcon warningIcon;
+
static ImageIcon infoIcon;
+
/** to use log facility, just put in your code: log.info(\"...\"); */
static private final Log log = LogFactory.getLog(SwingValidatorUtil.class);
@@ -75,14 +75,17 @@
/**
* Prepare the ui where to display the validators messages.
- *
+ *
* @param errorTable the table where to display validators messages
- * @param render renderer to use
+ * @param render renderer to use
*/
- public static void installUI(JTable errorTable, SwingValidatorMessageTableRenderer render) {
+ public static void installUI(JTable errorTable,
+ SwingValidatorMessageTableRenderer render) {
errorTable.setDefaultRenderer(Object.class, render);
- errorTable.getRowSorter().setSortKeys(Arrays.asList(new RowSorter.SortKey(0, SortOrder.ASCENDING)));
- SwingUtil.setI18nTableHeaderRenderer(errorTable,
+ errorTable.getRowSorter().setSortKeys(
+ Arrays.asList(new RowSorter.SortKey(0, SortOrder.ASCENDING)));
+ SwingUtil.setI18nTableHeaderRenderer(
+ errorTable,
n_("validator.scope.header"),
n_("validator.scope.header.tip"),
n_("validator.field.header"),
@@ -96,7 +99,7 @@
/**
* Register for a given validator list ui a validator mouse listener.
- *
+ * <p/>
* Note: there is only one listener registred for a given list model, so
* invoking this method tiwce or more will have no effect.
*
@@ -105,7 +108,8 @@
* @see SwingValidatorMessageListMouseListener
*/
public static SwingValidatorMessageListMouseListener registerErrorListMouseListener(JList list) {
- SwingValidatorMessageListMouseListener listener = getErrorListMouseListener(list);
+ SwingValidatorMessageListMouseListener listener =
+ getErrorListMouseListener(list);
if (listener != null) {
return listener;
@@ -120,7 +124,7 @@
/**
* Register for a given validator table ui a validator mouse listener
- *
+ * <p/>
* Note: there is onlt one listener registred for a givne table model, so
* invokin this method twice or more will have no effect.
*
@@ -129,7 +133,8 @@
* @see SwingValidatorMessageTableMouseListener
*/
public static SwingValidatorMessageTableMouseListener registerErrorTableMouseListener(JTable table) {
- SwingValidatorMessageTableMouseListener listener = getErrorTableMouseListener(table);
+ SwingValidatorMessageTableMouseListener listener =
+ getErrorTableMouseListener(table);
if (listener != null) {
return listener;
@@ -144,7 +149,8 @@
/**
* @param list the validator list ui
- * @return the validator list mouse listener, or <code>null</code> if not found
+ * @return the validator list mouse listener, or <code>null</code> if not
+ * found
* @see SwingValidatorMessageListMouseListener
*/
public static SwingValidatorMessageListMouseListener getErrorListMouseListener(JList list) {
@@ -160,7 +166,8 @@
/**
* @param table the validator table ui
- * @return the validator table mouse listener, or <code>null</code> if not found
+ * @return the validator table mouse listener, or <code>null</code> if not
+ * found
* @see SwingValidatorMessageTableMouseListener
*/
public static SwingValidatorMessageTableMouseListener getErrorTableMouseListener(JTable table) {
@@ -187,11 +194,11 @@
JComponent editor = model.getEditor();
if (editor != null) {
text = (String) editor.getClientProperty("validatorLabel");
- /*if (l != null) {
- text = I18n._(l);
- } else {
- // TODO should try the text
- }*/
+ /*if (l != null) {
+ text = I18n._(l);
+ } else {
+ // TODO should try the text
+ }*/
}
if (text == null) {
text = value;
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java 2010-03-18 09:16:31 UTC (rev 1791)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java 2010-03-18 09:52:42 UTC (rev 1792)
@@ -27,7 +27,7 @@
import org.apache.commons.logging.LogFactory;
import org.jdesktop.jxlayer.plaf.AbstractLayerUI;
-import javax.swing.JComponent;
+import javax.swing.*;
/**
* Abstract renderer
@@ -38,6 +38,7 @@
/** to use log facility, just put in your code: log.info(\"...\"); */
private static final Log log = LogFactory.getLog(AbstractBeanValidatorUI.class);
+
/** the field to render */
protected BeanValidatorField<?> field;
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java 2010-03-18 09:16:31 UTC (rev 1791)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java 2010-03-18 09:52:42 UTC (rev 1792)
@@ -20,29 +20,29 @@
*/
package jaxx.runtime.validator.swing.ui;
+import jaxx.runtime.validator.BeanValidatorField;
+import jaxx.runtime.validator.BeanValidatorScope;
import org.jdesktop.jxlayer.JXLayer;
-import javax.swing.BorderFactory;
-import javax.swing.JComponent;
-import java.awt.Color;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
+import javax.swing.*;
+import java.awt.*;
import java.awt.image.BufferedImage;
-import jaxx.runtime.validator.BeanValidatorField;
-import jaxx.runtime.validator.BeanValidatorScope;
/**
- * An implementation of {@link AbstractBeanValidatorUI} which paints a
- * icon on top right corner.
+ * An implementation of {@link AbstractBeanValidatorUI} which paints a icon on
+ * top right corner.
*
* @author tchemit <chemit(a)codelutin.com>
*/
public class IconValidationUI extends AbstractBeanValidatorUI {
// The icon to be shown at the layer's corner
+
protected static BufferedImage errorIcon;
+
protected static BufferedImage warningIcon;
+
protected static BufferedImage infoIcon;
public IconValidationUI(BeanValidatorField<?> field) {
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java 2010-03-18 09:16:31 UTC (rev 1791)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java 2010-03-18 09:52:42 UTC (rev 1792)
@@ -21,28 +21,27 @@
package jaxx.runtime.validator.swing.ui;
import jaxx.runtime.SwingUtil;
+import jaxx.runtime.validator.BeanValidatorField;
+import jaxx.runtime.validator.BeanValidatorScope;
import org.jdesktop.jxlayer.JXLayer;
-import javax.swing.BorderFactory;
-import javax.swing.ImageIcon;
-import javax.swing.JComponent;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
+import javax.swing.*;
+import java.awt.*;
import java.awt.image.BufferedImage;
-import jaxx.runtime.validator.BeanValidatorField;
-import jaxx.runtime.validator.BeanValidatorScope;
/**
- * An implementation of {@link AbstractBeanValidatorUI} which paints a
- * icon on top right corner.
+ * An implementation of {@link AbstractBeanValidatorUI} which paints a icon on
+ * top right corner.
*
* @author tchemit <chemit(a)codelutin.com>
*/
public class ImageValidationUI extends AbstractBeanValidatorUI {
protected static BufferedImage errorIcon;
+
protected static BufferedImage warningIcon;
+
protected static BufferedImage infoIcon;
public ImageValidationUI(BeanValidatorField<?> field) {
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java 2010-03-18 09:16:31 UTC (rev 1791)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java 2010-03-18 09:52:42 UTC (rev 1792)
@@ -20,16 +20,12 @@
*/
package jaxx.runtime.validator.swing.ui;
+import jaxx.runtime.validator.BeanValidatorField;
import jaxx.runtime.validator.BeanValidatorScope;
import org.jdesktop.jxlayer.JXLayer;
-import javax.swing.JComponent;
-import java.awt.AlphaComposite;
-import java.awt.Color;
-import java.awt.Graphics2D;
-import java.awt.Insets;
-import java.awt.Rectangle;
-import jaxx.runtime.validator.BeanValidatorField;
+import javax.swing.*;
+import java.awt.*;
/**
* An implementation of {@link AbstractBeanValidatorUI} which paints a
@@ -41,7 +37,9 @@
public class TranslucentValidationUI extends AbstractBeanValidatorUI {
protected Color errorHightlight;
+
protected Color warningHightlight;
+
protected Color infoHightlight;
public TranslucentValidationUI(BeanValidatorField<?> field) {
@@ -64,8 +62,8 @@
// To prevent painting on view's border
Insets insets = view.getInsets();
g2.clip(new Rectangle(insets.left, insets.top,
- view.getWidth() - insets.left - insets.right,
- view.getHeight() - insets.top - insets.bottom));
+ view.getWidth() - insets.left - insets.right,
+ view.getHeight() - insets.top - insets.bottom));
BeanValidatorScope scope = field.getScope();
@@ -84,7 +82,7 @@
break;
}
}
-
+
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .2f));
g2.fillRect(0, 0, l.getWidth(), l.getHeight());
}
1
0
r1791 - in trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator: . swing swing/ui
by tchemit@users.nuiton.org 18 Mar '10
by tchemit@users.nuiton.org 18 Mar '10
18 Mar '10
Author: tchemit
Date: 2010-03-18 10:16:31 +0100 (Thu, 18 Mar 2010)
New Revision: 1791
Log:
reformat code
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorDetector.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorField.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorScope.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java 2010-03-15 22:30:47 UTC (rev 1790)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java 2010-03-18 09:16:31 UTC (rev 1791)
@@ -32,7 +32,10 @@
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.EnumMap;
+import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -49,7 +52,7 @@
*
* @param <B> type of the bean to validate.
*
- * @author chemit
+ * @author tchemit <chemit(a)codelutin.com>
*/
public class BeanValidator<B> {
@@ -70,11 +73,11 @@
/** to chain to a prent validator */
protected BeanValidator<?> parentValidator;
/** state to indicate that validator has changed since the last time bean was setted */
- protected boolean changed = false;
+ protected boolean changed;
/** state of the validator (is true if no errors of error scope is found) */
protected boolean valid = true;
/** bean to be watched */
- protected B bean = null;
+ protected B bean;
/** to add and remove PropertyChangeListener on watched beans */
protected EventSetDescriptor beanEventDescriptor;
/** list of fields watched by this validator */
@@ -92,9 +95,9 @@
public BeanValidator(Class<B> beanClass, String contextName) {
this.beanClass = beanClass;
- this.pcs = new PropertyChangeSupport(this);
- this.conversionErrors = new TreeMap<String, String>();
- this.validators = new EnumMap<BeanValidatorScope, XWorkBeanValidator<B>>(BeanValidatorScope.class);
+ pcs = new PropertyChangeSupport(this);
+ conversionErrors = new TreeMap<String, String>();
+ validators = new EnumMap<BeanValidatorScope, XWorkBeanValidator<B>>(BeanValidatorScope.class);
setContextName(contextName);
@@ -124,7 +127,7 @@
}
public Set<BeanValidatorScope> getScopes() {
- return new java.util.HashSet<BeanValidatorScope>(validators.keySet());
+ return new HashSet<BeanValidatorScope>(validators.keySet());
}
/**
@@ -378,9 +381,9 @@
errors.clear();
errors.add(conversionError);
} else {
- errors = java.util.Collections.singletonList(conversionError);
+ errors = Collections.singletonList(conversionError);
if (newMessages == XWorkBeanValidator.EMPTY_RESULT) {
- newMessages = new java.util.HashMap<String, List<String>>();
+ newMessages = new HashMap<String, List<String>>();
}
// add the concrete conversion error
newMessages.put(entry.getKey(), errors);
@@ -459,9 +462,9 @@
protected synchronized void initFields() {
- Set<String> detectedFieldNames = new java.util.HashSet<String>();
+ Set<String> detectedFieldNames = new HashSet<String>();
EnumMap<BeanValidatorScope, Set<String>> tmp = new EnumMap<BeanValidatorScope, Set<String>>(BeanValidatorScope.class);
- Set<BeanValidatorField<B>> detectedFields = new java.util.HashSet<BeanValidatorField<B>>();
+ Set<BeanValidatorField<B>> detectedFields = new HashSet<BeanValidatorField<B>>();
validators.clear();
@@ -496,13 +499,13 @@
tmp.clear();
detectedFieldNames.clear();
- this.fields = java.util.Collections.unmodifiableSet(detectedFields);
+ fields = Collections.unmodifiableSet(detectedFields);
}
protected EventSetDescriptor getBeanEventDescriptor(B bean) {
if (beanEventDescriptor == null) {
// check that the bean is listenable, otherwise, can't use the validator on it
- this.beanEventDescriptor = BeanValidatorUtil.getPropertyChangeListenerDescriptor(bean.getClass());
+ beanEventDescriptor = BeanValidatorUtil.getPropertyChangeListenerDescriptor(bean.getClass());
}
return beanEventDescriptor;
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorDetector.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorDetector.java 2010-03-15 22:30:47 UTC (rev 1790)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorDetector.java 2010-03-18 09:16:31 UTC (rev 1791)
@@ -38,7 +38,7 @@
* Un detecteur de validateurs pour un liste de classes données et un
* répertoire où chercher les fichiers de validation.
*
- * @author chemit
+ * @author tchemit <chemit(a)codelutin.com>
*
* @since 1.6.0
*/
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java 2010-03-15 22:30:47 UTC (rev 1790)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java 2010-03-18 09:16:31 UTC (rev 1791)
@@ -20,14 +20,16 @@
*/
package jaxx.runtime.validator;
+import java.util.EventObject;
+
/**
* The definition of an event on {@link BeanValidatorListener}
* to be fired by a {@link BeanValidator}.
*
- * @author chemit
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.3
*/
-public class BeanValidatorEvent extends java.util.EventObject {
+public class BeanValidatorEvent extends EventObject {
private static final long serialVersionUID = 1L;
/** the field impacted by the validator */
@@ -41,8 +43,8 @@
super(source);
this.field = field;
this.scope = scope;
- this.messagestoAdd = toAdd;
- this.messagestoDelete = toDelete;
+ messagestoAdd = toAdd;
+ messagestoDelete = toDelete;
}
@Override
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorField.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorField.java 2010-03-15 22:30:47 UTC (rev 1790)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorField.java 2010-03-18 09:16:31 UTC (rev 1791)
@@ -20,6 +20,8 @@
*/
package jaxx.runtime.validator;
+import com.opensymphony.xwork2.validator.FieldValidator;
+
import static org.nuiton.i18n.I18n._;
import javax.swing.event.EventListenerList;
@@ -34,12 +36,12 @@
* Definition of a field to be handled in a {@link BeanValidator}.
* <p/>
* A such class is only registred in {@link BeanValidator } when the field of the bean
- * was found in validator xml configuration file for a {@link com.opensymphony.xwork2.validator.FieldValidator} only.
+ * was found in validator xml configuration file for a {@link FieldValidator} only.
* <p/>
* This class use properties {@link #beanClass}, {@link #name} to define
* his naturel order.
*
- * @author chemit
+ * @author tchemit <chemit(a)codelutin.com>
* @param <B> the type of the bean handled by the validator and this field of validation.
* @since 1.3
*/
@@ -159,7 +161,7 @@
Set<String> currentMessages = getMessages(scope);
// detect messages to delete
- Set<String> toDelete = new java.util.HashSet<String>(currentMessages);
+ Set<String> toDelete = new HashSet<String>(currentMessages);
toDelete.removeAll(messages);
if (!toDelete.isEmpty()) {
@@ -169,7 +171,7 @@
}
// detect messages to add
- Set<String> toAdd = new java.util.HashSet<String>(messages);
+ Set<String> toAdd = new HashSet<String>(messages);
toAdd.removeAll(currentMessages);
if (!toAdd.isEmpty()) {
@@ -193,7 +195,7 @@
public String getI18nError(String error) {
String text;
- if (error.indexOf("##") == -1) {
+ if (!error.contains("##")) {
text = _(error);
} else {
StringTokenizer stk = new StringTokenizer(error, "##");
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java 2010-03-15 22:30:47 UTC (rev 1790)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java 2010-03-18 09:16:31 UTC (rev 1791)
@@ -20,13 +20,15 @@
*/
package jaxx.runtime.validator;
+import java.util.EventListener;
+
/**
* The listener contract to be used on {@link BeanValidator}
*
- * @author chemit
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.3
*/
-public interface BeanValidatorListener extends java.util.EventListener {
+public interface BeanValidatorListener extends EventListener {
/**
* Invoked when a validator detects some changes on a field.
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java 2010-03-15 22:30:47 UTC (rev 1790)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java 2010-03-18 09:16:31 UTC (rev 1791)
@@ -25,7 +25,7 @@
*
* @param <E> type of message (use for override {@link #compareTo(Object)} method.
*
- * @author chemit
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.3
*/
public class BeanValidatorMessage<E extends BeanValidatorMessage<?>> implements Comparable<E> {
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorScope.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorScope.java 2010-03-15 22:30:47 UTC (rev 1790)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorScope.java 2010-03-18 09:16:31 UTC (rev 1791)
@@ -29,7 +29,7 @@
* <p/>
* Always begin with error, then if no error found, try warning, then info...
*
- * @author chemit
+ * @author tchemit <chemit(a)codelutin.com>
*/
public enum BeanValidatorScope {
@@ -56,7 +56,7 @@
INFO(n_("validator.scope.info.label"));
private final String label;
- private BeanValidatorScope(String label) {
+ BeanValidatorScope(String label) {
this.label = label;
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java 2010-03-15 22:30:47 UTC (rev 1790)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java 2010-03-18 09:16:31 UTC (rev 1791)
@@ -40,7 +40,7 @@
/**
* The helper class for validation module.
*
- * @author chemit
+ * @author tchemit <chemit(a)codelutin.com>
*/
public class BeanValidatorUtil {
@@ -125,7 +125,7 @@
}
}
for (String validatorId : validatorIds) {
- BeanValidator beanValidator = jaxxValidator.getValidator(validatorId);
+ BeanValidator<?> beanValidator = jaxxValidator.getValidator(validatorId);
beanValidator.setChanged(newValue);
}
}
@@ -165,7 +165,7 @@
}
}
- public static EventSetDescriptor getPropertyChangeListenerDescriptor(Class beanClass) {
+ public static EventSetDescriptor getPropertyChangeListenerDescriptor(Class<?> beanClass) {
try {
// check that the bean is listenable, otherwise, can't use
// the validator on it
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java 2010-03-15 22:30:47 UTC (rev 1790)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java 2010-03-18 09:16:31 UTC (rev 1791)
@@ -31,12 +31,15 @@
import com.opensymphony.xwork2.validator.FieldValidator;
import com.opensymphony.xwork2.validator.ValidationException;
import com.opensymphony.xwork2.validator.Validator;
+
+import java.util.ArrayList;
import java.util.Collection;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -45,12 +48,12 @@
*
* A customized validator for a given bean.
*
- * Use the method {@link #validate(java.lang.Object)} to obtain the messages
+ * Use the method {@link #validate(Object)} to obtain the messages
* detected by the validator for the given bean.
*
* @param <B> type of the bean to validate.
*
- * @author chemit
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.3
*/
public class XWorkBeanValidator<B> {
@@ -71,7 +74,7 @@
// --
protected ValidationAwareSupport validationSupport;
protected DelegatingValidatorContext validationContext;
- protected transient ActionValidatorManager validator;
+ protected ActionValidatorManager validator;
protected ActionContext context;
public XWorkBeanValidator(Class<B> beanClass, String contextName) {
@@ -205,7 +208,7 @@
result = new HashMap<String, List<String>>(messages.size());
for (Object fieldName : messages.keySet()) {
Collection<?> c = (Collection<?>) messages.get(fieldName);
- List<String> mm = new java.util.ArrayList<String>(c.size());
+ List<String> mm = new ArrayList<String>(c.size());
for (Object message : c) {
mm.add(message + "");
}
@@ -239,7 +242,7 @@
fieldNames = null;
}
- Set<String> detectedFieldNames = new java.util.HashSet<String>();
+ Set<String> detectedFieldNames = new HashSet<String>();
int skip = 0;
if (contextName != null && !includeDefaultContext) {
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java 2010-03-15 22:30:47 UTC (rev 1790)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java 2010-03-18 09:16:31 UTC (rev 1791)
@@ -38,7 +38,7 @@
import jaxx.runtime.validator.BeanValidatorField;
/**
- * La surcharge de {@link jaxx.runtime.validator.BeanValidator} pour les ui swing
+ * La surcharge de {@link BeanValidator} pour les ui swing
* <p/>
* /**
* <p/>
@@ -110,8 +110,8 @@
* </pre>
*
* @param <B> le type de bean a valider
- * @author poussin
- * @author chemit
+ * @author poussin <poussin(a)codelutin.com>
+ * @author tchemit <chemit(a)codelutin.com>
* @version 1.0
*/
public class SwingValidator<B> extends BeanValidator<B> {
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java 2010-03-15 22:30:47 UTC (rev 1790)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java 2010-03-18 09:16:31 UTC (rev 1791)
@@ -28,7 +28,7 @@
/**
* The object to box a validation message within an u.
*
- * @author chemit
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.3
* @see BeanValidatorMessage
*/
@@ -42,7 +42,7 @@
public SwingValidatorMessage(SwingValidator<?> validator, BeanValidatorField<?> field, String message, BeanValidatorScope scope, JComponent editor) {
super(validator, field, message, scope);
- this.fieldName = field.getName();
+ fieldName = field.getName();
this.editor = editor;
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java 2010-03-15 22:30:47 UTC (rev 1790)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java 2010-03-18 09:16:31 UTC (rev 1791)
@@ -22,10 +22,14 @@
import jaxx.runtime.validator.BeanValidatorEvent;
+import javax.swing.AbstractListModel;
import javax.swing.JComponent;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import jaxx.runtime.validator.BeanValidatorField;
+import jaxx.runtime.validator.BeanValidatorListener;
import jaxx.runtime.validator.BeanValidatorScope;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -33,11 +37,11 @@
/**
* The model of the list of validation's messages
*
- * @author chemit
+ * @author tchemit <chemit(a)codelutin.com>
*/
public class SwingValidatorMessageListModel
- extends javax.swing.AbstractListModel
- implements jaxx.runtime.validator.BeanValidatorListener {
+ extends AbstractListModel
+ implements BeanValidatorListener {
private static final long serialVersionUID = 1L;
/** to use log facility, just put in your code: log.info(\"...\"); */
@@ -49,7 +53,7 @@
public SwingValidatorMessageListModel() {
validators = new ArrayList<SwingValidator<?>>();
- data = new java.util.ArrayList<SwingValidatorMessage>();
+ data = new ArrayList<SwingValidatorMessage>();
}
public boolean isEmpty() {
@@ -134,7 +138,7 @@
if (sort) {
// resort datas
- java.util.Collections.sort(data);
+ Collections.sort(data);
// notify
fireContentsChanged(this, 0, getSize() - 1);
@@ -143,7 +147,7 @@
protected void removeMessages(SwingValidator<?> validator, BeanValidatorField<?> field, BeanValidatorScope scope, boolean notify, String... messages) {
- List<String> messagesToDel = new java.util.ArrayList<String>(java.util.Arrays.asList(messages));
+ List<String> messagesToDel = new ArrayList<String>(Arrays.asList(messages));
// do it in reverse mode (only one pass in that way since index
// will stay coherent while removing them)
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java 2010-03-15 22:30:47 UTC (rev 1790)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java 2010-03-18 09:16:31 UTC (rev 1791)
@@ -29,11 +29,11 @@
import java.awt.event.MouseEvent;
/**
- * A mouse listener to put on a {@link javax.swing.JList} with a {@link SwingValidatorMessageListModel} as a model.
+ * A mouse listener to put on a {@link JList} with a {@link SwingValidatorMessageListModel} as a model.
* <p/>
* When a double click occurs, find the selected error in model and then focus to the associated component of error.
*
- * @author chemit
+ * @author tchemit <chemit(a)codelutin.com>
*/
public class SwingValidatorMessageListMouseListener extends MouseAdapter {
@@ -77,4 +77,4 @@
return entry;
}
-}
\ No newline at end of file
+}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java 2010-03-15 22:30:47 UTC (rev 1790)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java 2010-03-18 09:16:31 UTC (rev 1791)
@@ -32,7 +32,7 @@
* A simple render of a table of validator's messages, says a table that use
* a {@link SwingValidatorMessageTableModel} model.
*
- * @author chemit
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.3
* @see SwingValidatorMessageTableModel
*/
@@ -106,4 +106,4 @@
String fieldName = SwingValidatorUtil.getFieldName(model, value);
return fieldName;
}
-}
\ No newline at end of file
+}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java 2010-03-15 22:30:47 UTC (rev 1790)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java 2010-03-18 09:16:31 UTC (rev 1791)
@@ -23,9 +23,13 @@
import jaxx.runtime.validator.BeanValidatorEvent;
import javax.swing.JComponent;
+import javax.swing.table.AbstractTableModel;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import jaxx.runtime.validator.BeanValidatorField;
+import jaxx.runtime.validator.BeanValidatorListener;
import jaxx.runtime.validator.BeanValidatorScope;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -35,12 +39,12 @@
* <p/>
* The model listens validators messages and update his internal model from it.
*
- * @author chemit
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.3
*/
public class SwingValidatorMessageTableModel
- extends javax.swing.table.AbstractTableModel
- implements jaxx.runtime.validator.BeanValidatorListener {
+ extends AbstractTableModel
+ implements BeanValidatorListener {
private static final long serialVersionUID = 1L;
/**
@@ -61,7 +65,7 @@
public SwingValidatorMessageTableModel() {
super();
validators = new ArrayList<SwingValidator<?>>();
- data = new java.util.ArrayList<SwingValidatorMessage>();
+ data = new ArrayList<SwingValidatorMessage>();
}
/**
@@ -246,7 +250,7 @@
if (sort) {
// resort datas
- java.util.Collections.sort(data);
+ Collections.sort(data);
// notify
fireTableDataChanged();
@@ -268,7 +272,7 @@
if (sort) {
// resort datas
- java.util.Collections.sort(data);
+ Collections.sort(data);
// notify
fireTableDataChanged();
@@ -289,7 +293,7 @@
if (sort) {
// resort datas
- java.util.Collections.sort(data);
+ Collections.sort(data);
// notify
fireTableDataChanged();
@@ -298,7 +302,7 @@
protected void removeMessages(SwingValidator<?> validator, BeanValidatorField<?> field, BeanValidatorScope scope, boolean notify, String... messages) {
- List<String> messagesToDel = new java.util.ArrayList<String>(java.util.Arrays.asList(messages));
+ List<String> messagesToDel = new ArrayList<String>(Arrays.asList(messages));
// do it in reverse mode (only one pass in that way since index
// will stay coherent while removing them)
@@ -317,7 +321,7 @@
protected void removeMessages(SwingValidator<?> validator, String fieldName, BeanValidatorScope scope, boolean notify, String... messages) {
- List<String> messagesToDel = new java.util.ArrayList<String>(java.util.Arrays.asList(messages));
+ List<String> messagesToDel = new ArrayList<String>(Arrays.asList(messages));
// do it in reverse mode (only one pass in that way since index
// will stay coherent while removing them)
@@ -350,4 +354,4 @@
}
}
}
-}
\ No newline at end of file
+}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java 2010-03-15 22:30:47 UTC (rev 1790)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java 2010-03-18 09:16:31 UTC (rev 1791)
@@ -24,6 +24,7 @@
import org.apache.commons.logging.LogFactory;
import javax.swing.JComponent;
+import javax.swing.JList;
import javax.swing.JTable;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
@@ -31,11 +32,11 @@
import java.beans.PropertyChangeSupport;
/**
- * A mouse listener to put on a {@link javax.swing.JList} with a {@link SwingValidatorMessageTableModel} as a model.
+ * A mouse listener to put on a {@link JList} with a {@link SwingValidatorMessageTableModel} as a model.
* <p/>
* When a double click occurs, find the selected error in model and then focus to the associated component of error.
*
- * @author chemit
+ * @author tchemit <chemit(a)codelutin.com>
*/
public class SwingValidatorMessageTableMouseListener extends MouseAdapter {
@@ -111,4 +112,4 @@
pcs.removePropertyChangeListener(propertyName, listener);
}
-}
\ No newline at end of file
+}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java 2010-03-15 22:30:47 UTC (rev 1790)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java 2010-03-18 09:16:31 UTC (rev 1791)
@@ -32,7 +32,7 @@
* A simple render of a table of validator's messages, says a table that use
* a {@link SwingValidatorMessageTableModel} model.
*
- * @author chemit
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.3
* @see SwingValidatorMessageTableModel
*/
@@ -100,4 +100,4 @@
String fieldName = SwingValidatorUtil.getFieldName(model, value);
return fieldName;
}
-}
\ No newline at end of file
+}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java 2010-03-15 22:30:47 UTC (rev 1790)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java 2010-03-18 09:16:31 UTC (rev 1791)
@@ -28,6 +28,7 @@
import javax.swing.JList;
import javax.swing.JTable;
import java.awt.event.MouseListener;
+import java.util.Arrays;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.RowSorter;
@@ -37,7 +38,7 @@
/**
* The helper class for validation module.
*
- * @author chemit
+ * @author tchemit <chemit(a)codelutin.com>
*/
public class SwingValidatorUtil extends BeanValidatorUtil {
@@ -80,7 +81,7 @@
*/
public static void installUI(JTable errorTable, SwingValidatorMessageTableRenderer render) {
errorTable.setDefaultRenderer(Object.class, render);
- errorTable.getRowSorter().setSortKeys(java.util.Arrays.asList(new RowSorter.SortKey(0, SortOrder.ASCENDING)));
+ errorTable.getRowSorter().setSortKeys(Arrays.asList(new RowSorter.SortKey(0, SortOrder.ASCENDING)));
SwingUtil.setI18nTableHeaderRenderer(errorTable,
n_("validator.scope.header"),
n_("validator.scope.header.tip"),
@@ -213,4 +214,4 @@
}
return icon;
}
-}
\ No newline at end of file
+}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java 2010-03-15 22:30:47 UTC (rev 1790)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java 2010-03-18 09:16:31 UTC (rev 1791)
@@ -27,12 +27,14 @@
import org.apache.commons.logging.LogFactory;
import org.jdesktop.jxlayer.plaf.AbstractLayerUI;
+import javax.swing.JComponent;
+
/**
* Abstract renderer
*
- * @author chemit
+ * @author tchemit <chemit(a)codelutin.com>
*/
-public abstract class AbstractBeanValidatorUI extends AbstractLayerUI<javax.swing.JComponent> implements BeanValidatorListener {
+public abstract class AbstractBeanValidatorUI extends AbstractLayerUI<JComponent> implements BeanValidatorListener {
/** to use log facility, just put in your code: log.info(\"...\"); */
private static final Log log = LogFactory.getLog(AbstractBeanValidatorUI.class);
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java 2010-03-15 22:30:47 UTC (rev 1790)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java 2010-03-18 09:16:31 UTC (rev 1791)
@@ -31,7 +31,13 @@
import jaxx.runtime.validator.BeanValidatorField;
import jaxx.runtime.validator.BeanValidatorScope;
-/** @author chemit */
+
+/**
+ * An implementation of {@link AbstractBeanValidatorUI} which paints a
+ * icon on top right corner.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ */
public class IconValidationUI extends AbstractBeanValidatorUI {
// The icon to be shown at the layer's corner
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java 2010-03-15 22:30:47 UTC (rev 1790)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java 2010-03-18 09:16:31 UTC (rev 1791)
@@ -32,7 +32,13 @@
import jaxx.runtime.validator.BeanValidatorField;
import jaxx.runtime.validator.BeanValidatorScope;
-/** @author chemit */
+
+/**
+ * An implementation of {@link AbstractBeanValidatorUI} which paints a
+ * icon on top right corner.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ */
public class ImageValidationUI extends AbstractBeanValidatorUI {
protected static BufferedImage errorIcon;
@@ -96,4 +102,4 @@
}
}
}
-}
\ No newline at end of file
+}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java 2010-03-15 22:30:47 UTC (rev 1790)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java 2010-03-18 09:16:31 UTC (rev 1791)
@@ -31,7 +31,13 @@
import java.awt.Rectangle;
import jaxx.runtime.validator.BeanValidatorField;
-/** @author chemit */
+/**
+ * An implementation of {@link AbstractBeanValidatorUI} which paints a
+ * translucent backgroud color (green for ok, red for error, yellow for
+ * warning).
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ */
public class TranslucentValidationUI extends AbstractBeanValidatorUI {
protected Color errorHightlight;
1
0
r1790 - trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation
by tchemit@users.nuiton.org 15 Mar '10
by tchemit@users.nuiton.org 15 Mar '10
15 Mar '10
Author: tchemit
Date: 2010-03-15 23:30:47 +0100 (Mon, 15 Mar 2010)
New Revision: 1790
Log:
clean code
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationMultiTreeHandler.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationOneClicSelectionHandler.java
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationMultiTreeHandler.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationMultiTreeHandler.java 2010-03-15 20:20:02 UTC (rev 1789)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationMultiTreeHandler.java 2010-03-15 22:30:47 UTC (rev 1790)
@@ -25,15 +25,11 @@
import jaxx.runtime.JAXXObject;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jdesktop.swingx.JXTreeTable;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.tree.TreePath;
-import javax.swing.tree.TreeSelectionModel;
import java.awt.Component;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
/**
@@ -52,14 +48,17 @@
/**
* Logger
*/
- static private final Log log = LogFactory.getLog(NavigationMultiTreeHandler.class);
+ static private final Log log =
+ LogFactory.getLog(NavigationMultiTreeHandler.class);
- public NavigationMultiTreeHandler(String contextPrefix, JAXXObject context, Strategy strategy) {
+ public NavigationMultiTreeHandler(String contextPrefix,
+ JAXXObject context,
+ Strategy strategy) {
super(contextPrefix, context, strategy);
// Enable multi selection
- super.setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
+ setSelectionMode(DISCONTIGUOUS_TREE_SELECTION);
}
@Override
@@ -73,7 +72,8 @@
return;
}
for(TreePath path : paths){
- NavigationTreeNode node = (NavigationTreeNode) path.getLastPathComponent();
+ NavigationTreeNode node =
+ (NavigationTreeNode) path.getLastPathComponent();
nodes.add(node);
if (log.isDebugEnabled()){
log.debug("Adding path : " + path);
@@ -90,7 +90,9 @@
* @param nodes les node de l'ui a ouvrir
* @throws Exception if any
*/
- protected abstract void openUI(Component newUI, List<NavigationTreeNode> nodes) throws Exception;
+ protected abstract void openUI(Component newUI,
+ List<NavigationTreeNode> nodes)
+ throws Exception;
/**
* Instancie une nouvelle ui associé à des noeuds de l'arbre de navigation
@@ -99,7 +101,8 @@
* @return la nouvelle ui associée au noeud
* @throws Exception if any
*/
- protected abstract Component createUI(List<NavigationTreeNode> nodes) throws Exception;
+ protected abstract Component createUI(List<NavigationTreeNode> nodes)
+ throws Exception;
/**
* @param nodes les noeuds associés à l'ui à retrouver
@@ -121,7 +124,8 @@
if (log.isTraceEnabled()) {
log.trace(path);
}
- // now, we are free to open the ui associated with the selected node in navigation
+ // now, we are free to open the ui associated with the selected
+ // node in navigation
// get the bean associated with the node
beans.add(getNavigationTreeModel().getBean(path));
@@ -134,12 +138,13 @@
NavigationTreeContextHelper helper = getContextHelper();
// remove previous selected bean
- //TODO-TC-20091004 should have an automatic clean context method while
+ //TODO-TC-20091004 should have an automatic clean context method
+ //TODO-TC-20091004 while
helper.setSelectedBean(ctxt, null);
- if (beans != null) {
- helper.setSelectedBeans(ctxt, beans);
- }
+// if (beans != null) {
+ helper.setSelectedBeans(ctxt, beans);
+// }
if (newUI == null) {
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationOneClicSelectionHandler.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationOneClicSelectionHandler.java 2010-03-15 20:20:02 UTC (rev 1789)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationOneClicSelectionHandler.java 2010-03-15 22:30:47 UTC (rev 1790)
@@ -52,10 +52,13 @@
/**
* Logger
*/
- static private final Log log = LogFactory.getLog(NavigationOneClicSelectionHandler.class);
+ static private final Log log =
+ LogFactory.getLog(NavigationOneClicSelectionHandler.class);
- public NavigationOneClicSelectionHandler(String contextPrefix, JAXXObject context, NavigationTreeHandler.Strategy strategy) {
+ public NavigationOneClicSelectionHandler(String contextPrefix,
+ JAXXObject context,
+ Strategy strategy) {
super(contextPrefix, context, strategy);
}
1
0
r1789 - in trunk/jaxx-runtime/src: main/java/jaxx/runtime main/java/jaxx/runtime/context main/java/jaxx/runtime/swing/navigation main/resources/i18n test/java/jaxx/runtime/context
by tchemit@users.nuiton.org 15 Mar '10
by tchemit@users.nuiton.org 15 Mar '10
15 Mar '10
Author: tchemit
Date: 2010-03-15 21:20:02 +0100 (Mon, 15 Mar 2010)
New Revision: 1789
Log:
clean code + little improvments
Added:
trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/DataContextEntryIteratorTest.java
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXUtil.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java
trunk/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-en_GB.properties
trunk/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-fr_FR.properties
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXUtil.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXUtil.java 2010-03-15 14:19:31 UTC (rev 1788)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXUtil.java 2010-03-15 20:20:02 UTC (rev 1789)
@@ -132,7 +132,20 @@
return contextEntryDef;
}
+ public static <K, V> JAXXContextEntryDef<Map> newMapContextEntryDef(
+ String name) {
+ Class<Map> mapClass = Map.class;
+ JAXXContextEntryDef<Map> contextEntryDef =
+ new JAXXContextEntryDef<Map>(name, mapClass);
+ return contextEntryDef;
+ }
+
@SuppressWarnings({"unchecked"})
+ protected static Class<Map> castMap() {
+ return Map.class;
+ }
+
+ @SuppressWarnings({"unchecked"})
protected static <O> Class<List<O>> castList() {
return (Class<List<O>>) Collections.emptyList().getClass();
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java 2010-03-15 14:19:31 UTC (rev 1788)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java 2010-03-15 20:20:02 UTC (rev 1789)
@@ -34,6 +34,7 @@
import java.beans.PropertyDescriptor;
import java.io.IOException;
import java.io.InputStream;
+import java.net.URI;
import java.util.List;
import javax.swing.*;
import javax.swing.event.*;
@@ -70,6 +71,8 @@
import org.jdesktop.jxlayer.JXLayer;
import org.jdesktop.swingx.JXTreeTable;
+import static org.nuiton.i18n.I18n._;
+
/**
* The runtime swing util class with some nice stuff.
* <p/>
@@ -869,6 +872,34 @@
}
}
+ public static void openLink(String url) {
+
+ try {
+ if (!Desktop.isDesktopSupported()) {
+ throw new IllegalStateException(
+ _("swing.error.desktop.not.supported"));
+ }
+
+
+ Desktop desktop = Desktop.getDesktop();
+
+ if (!desktop.isSupported(Desktop.Action.BROWSE)) {
+
+ throw new IllegalStateException(
+ _("swing.error.desktop.browse.not.supported"));
+ }
+
+ URI uri = new URI(url);
+ desktop.browse(uri);
+ }
+ catch (Exception e) {
+
+ if (log.isErrorEnabled()) {
+ log.error("Error while opening link", e);
+ }
+ }
+ }
+
/**
* Expand all childs of a tree.
*
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java 2010-03-15 14:19:31 UTC (rev 1788)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java 2010-03-15 20:20:02 UTC (rev 1789)
@@ -35,54 +35,42 @@
* Un contexte de données qui permet l'utilisation des bindings sur les
* entrées du contexte.
*
- * TODO javadoc
- *
- * @author tony
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.3
*/
public abstract class DataContext {
/** to use log facility, just put in your code: log.info(\"...\"); */
static private Log log = LogFactory.getLog(DataContext.class);
+
+ public static final DataContextEntry<?>[] EMPTY_DATA_CONTEXT_ENTRY_ARRAY =
+ new DataContextEntry<?>[0];
+
/** le context qui contient les données */
protected final DefaultJAXXContext delegate;
+
/** la definition de l'entree actuallement selectionnee */
protected DataContextEntry<?> currentEntry;
+
/** to manage properties modifications */
protected final PropertyChangeSupport pcs;
+
protected DataContextEntry<?>[] entries;
+
protected final String[] DEFAULT_JAXX_PCS;
public abstract String getContextPath(Object... e);
- public DataContext(String[] DEFAULT_JAXX_PCS, DataContextEntry<?>[] entries) {
+ public DataContext(String[] DEFAULT_JAXX_PCS,
+ DataContextEntry<?>[] entries) {
this.DEFAULT_JAXX_PCS = DEFAULT_JAXX_PCS;
this.entries = entries;
delegate = new DefaultJAXXContext() {
-// @Override
-// protected void setUi(JAXXObject ui) {
-// throw new IllegalStateException("can not use this method for this type of context");
-// }
-//
-// @Override
-// public <O extends Container> O getParentContainer(Class<O> clazz) {
-// throw new IllegalStateException("can not use this method for this type of context");
-// }
-//
-// @Override
-// public <O extends Container> O getParentContainer(Object top, Class<O> clazz) {
-// throw new IllegalStateException("can not use this method for this type of context");
-// }
-//
-// @Override
-// protected JAXXObject getUi() {
-// throw new IllegalStateException("can not use this method for this type of context");
-// }
-
@Override
protected void setParentContext(JAXXContext parentContext) {
- throw new IllegalStateException("can not use this method for this type of context");
+ throw new IllegalStateException(
+ "can not use this method for this type of context");
}
@Override
@@ -123,7 +111,8 @@
};
}
- public Iterable<? extends DataContextEntry<?>> iterateToLevel(final int level) {
+ public Iterable<? extends DataContextEntry<?>> iterateToLevel(
+ final int level) {
return new Iterable<DataContextEntry<?>>() {
@Override
@@ -172,21 +161,59 @@
return result;
}
- public void setContextValue(DataContextEntry<?> entry, Object value, String key) {
+ public void setContextValue(DataContextEntry<?> entry,
+ Object value,
+ String key) {
String contextKey = getKey(entry, key);
delegate.setContextValue(value, contextKey);
}
- public void removeContextValue(DataContextEntry<?> entry, Object value, String key) {
+ /**
+ *
+ * @param entry
+ * @param value
+ * @param key
+ * @deprecated since 2.0.1, use instead {@link #removeContextValue(DataContextEntry, String)}
+ */
+ public void removeContextValue(DataContextEntry<?> entry,
+ Object value,
+ String key) {
+ removeContextValue(entry,key);
+// String contextKey = getKey(entry, key);
+// delegate.removeContextValue(entry.getKlass(), contextKey);
+// delegate.removeContextValue(value.getClass(), contextKey);
+ }
+
+ /**
+ *
+ * @param entry
+ * @param klass
+ * @param key
+ */
+ public void removeContextValue(DataContextEntry<?> entry,
+ Class<?> klass,
+ String key) {
String contextKey = getKey(entry, key);
- delegate.removeContextValue(value.getClass(), contextKey);
+ delegate.removeContextValue(klass,key);
+// String contextKey = getKey(entry, key);
+// delegate.removeContextValue(entry.getKlass(), contextKey);
+// delegate.removeContextValue(value.getClass(), contextKey);
}
+ public void removeContextValue(DataContextEntry<?> entry,
+ String key) {
+ String contextKey = getKey(entry, key);
+ delegate.removeContextValue(entry.getKlass(), contextKey);
+ }
+
@SuppressWarnings("unchecked")
- public void updateSelectedData(String path, Object data, UpdateDataContext updator) {
+ public void updateSelectedData(String path,
+ Object data,
+ UpdateDataContext updator) {
if (log.isDebugEnabled()) {
- log.debug("----------------------------------------------------------------");
+ log.debug("-----------------------------------------------------" +
+ "-----------");
}
if (currentEntry != null) {
@@ -209,7 +236,8 @@
if (currentEntry != null) {
- for (DataContextEntry<?> s : iterateToLevel(currentEntry.getLevel())) {
+ for (DataContextEntry<?> s :
+ iterateToLevel(currentEntry.getLevel())) {
if (log.isDebugEnabled()) {
log.debug("add entry " + s);
@@ -223,7 +251,8 @@
pcs.addPropertyChangeListener(listener);
}
- public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ public void addPropertyChangeListener(String propertyName,
+ PropertyChangeListener listener) {
pcs.addPropertyChangeListener(propertyName, listener);
}
@@ -231,7 +260,8 @@
pcs.removePropertyChangeListener(listener);
}
- public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ public void removePropertyChangeListener(String propertyName,
+ PropertyChangeListener listener) {
pcs.removePropertyChangeListener(propertyName, listener);
}
@@ -239,7 +269,8 @@
return pcs.hasListeners(propertyName);
}
- public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
+ public synchronized PropertyChangeListener[] getPropertyChangeListeners(
+ String propertyName) {
return pcs.getPropertyChangeListeners(propertyName);
}
@@ -248,7 +279,9 @@
}
public void removeJaxxPropertyChangeListener() {
- PropertyChangeListener[] toRemove = JAXXUtil.findJaxxPropertyChangeListener(DEFAULT_JAXX_PCS, getPropertyChangeListeners());
+ PropertyChangeListener[] toRemove =
+ JAXXUtil.findJaxxPropertyChangeListener(
+ DEFAULT_JAXX_PCS, getPropertyChangeListeners());
if (toRemove == null || toRemove.length == 0) {
return;
}
@@ -264,7 +297,9 @@
}
}
- protected void firePropertyChange(String name, Object oldValue, Object newValue) {
+ protected void firePropertyChange(String name,
+ Object oldValue,
+ Object newValue) {
pcs.firePropertyChange(name, oldValue, newValue);
}
@@ -299,9 +334,9 @@
public DataContextEntry(Class<E> klass, DataContextEntry<?> previous) {
this.previous = previous;
- this.level = previous.level + 1;
+ level = previous.level + 1;
this.klass = klass;
- this.parents = new DataContextEntry<?>[level];
+ parents = new DataContextEntry<?>[level];
int i = level;
while (i > 0) {
parents[--i] = previous;
@@ -310,10 +345,10 @@
}
public DataContextEntry(Class<E> klass) {
- this.level = 0;
+ level = 0;
this.klass = klass;
- this.previous = null;
- this.parents = new DataContextEntry<?>[0];
+ previous = null;
+ parents = EMPTY_DATA_CONTEXT_ENTRY_ARRAY;
}
public Class<E> getKlass() {
@@ -355,7 +390,7 @@
}
}
- public static interface UpdateDataContext<D extends DataContext> {
+ public interface UpdateDataContext<D extends DataContext> {
void onRemovingData(D context, DataContextEntry<D> entry);
@@ -373,15 +408,19 @@
this(datas, false, -1);
}
- public DataContextEntryIterator(DataContextEntry<?>[] datas, int level) {
+ public DataContextEntryIterator(DataContextEntry<?>[] datas,
+ int level) {
this(datas, false, level);
}
- public DataContextEntryIterator(DataContextEntry<?>[] datas, boolean reverse) {
+ public DataContextEntryIterator(DataContextEntry<?>[] datas,
+ boolean reverse) {
this(datas, reverse, -1);
}
- DataContextEntryIterator(DataContextEntry<?>[] datas, boolean reverse, int level) {
+ DataContextEntryIterator(DataContextEntry<?>[] datas,
+ boolean reverse,
+ int level) {
this.datas = datas;
this.reverse = reverse;
if (reverse) {
@@ -397,7 +436,8 @@
if (reverse) {
return index > 0;
} else {
- return index + 1 < datas.length && (level == -1 || datas[index + 1].getLevel() <= level);
+ return index + 1 < datas.length &&
+ (level == -1 || datas[index + 1].getLevel() <= level);
}
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java 2010-03-15 14:19:31 UTC (rev 1788)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java 2010-03-15 20:20:02 UTC (rev 1789)
@@ -26,54 +26,46 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
/**
- * The default {@link JAXXContext} to be used in a {@link JAXXObject} by delegation.
+ * The default {@link JAXXContext} to be used in a {@link JAXXObject} by
+ * delegation.
* <p/>
- * The values are store in a {@link Map} but we can not use directly the values as key.
+ * The values are store in a {@link Map} but we can not use directly the values
+ * as key.
* <p/>
- * Because, it does not work if we add for the same object multi entries (named and unamed)...
+ * Because, it does not work if we add for the same object multi entries (named
+ * and unamed)...
* <p/>
- * We prefer use as entry the {@link JAXXContextEntryDef} associated with the value.
+ * We prefer use as entry the {@link JAXXContextEntryDef} associated with the
+ * value.
*
* @author chemit
*/
public class DefaultJAXXContext implements JAXXContext {
- /**
- * entry of the parent context
- */
- protected static final JAXXContextEntryDef<JAXXContext> PARENT_CONTEXT_ENTRY = JAXXUtil.newContextEntryDef(JAXXContext.class);
- /**
- * Logger
- */
+ /** entry of the parent context */
+ protected static final JAXXContextEntryDef<JAXXContext>
+ PARENT_CONTEXT_ENTRY = JAXXUtil.newContextEntryDef(JAXXContext.class);
+
+ /** Logger */
static private final Log log = LogFactory.getLog(DefaultJAXXContext.class);
-// /**
-// * l'ui auquel est rattache le context
- // */
-// protected JAXXObject ui;
- /**
- * le context parent
- */
+
+ /** le context parent */
protected JAXXContext parentContext;
- /**
- * les données contenues dans le context
- */
+
+ /** les données contenues dans le context */
protected final Map<JAXXContextEntryDef<?>, Object> data;
public DefaultJAXXContext() {
data = new HashMap<JAXXContextEntryDef<?>, Object>();
}
-// public DefaultJAXXContext(JAXXObject ui) {
-// this();
-// this.ui = ui;
-// }
-
@Override
public <T> void setContextValue(T o) {
setContextValue(o, null);
@@ -90,7 +82,8 @@
Object oldValue = remove0(o.getClass(), name);
if (oldValue != null) {
if (log.isDebugEnabled()) {
- log.debug("remove value " + oldValue.getClass() + " for " + entry);
+ log.debug("remove value " + oldValue.getClass() + " for " +
+ entry);
}
}
// then can put safely
@@ -105,7 +98,9 @@
@SuppressWarnings({"unchecked"})
@Override
public <T> T getContextValue(Class<T> clazz, String name) {
- if (parentContext != null && parentContext.getClass() == clazz || PARENT_CONTEXT_ENTRY.accept(clazz, name)) {
+ if (parentContext != null &&
+ parentContext.getClass().equals(clazz) ||
+ PARENT_CONTEXT_ENTRY.accept(clazz, name)) {
return (T) getParentContext();
}
for (Entry<JAXXContextEntryDef<?>, Object> entry : data.entrySet()) {
@@ -115,8 +110,9 @@
}
// no value found in this context, will try in the parent context
- if (JAXXContext.class == clazz) {
- // no seek in the parent context, since we are already looking for it
+ if (JAXXContext.class.equals(clazz)) {
+ // no seek in the parent context, since we are already looking
+ // for it
return null;
}
@@ -139,30 +135,6 @@
remove0(klazz, name);
}
-// @Override
-// public <O extends Container> O getParentContainer(Class<O> clazz) {
-// return this.getParentContainer(ui, clazz);
-// }
-//
-// @SuppressWarnings({"unchecked"})
-// @Override
-// public <O extends Container> O getParentContainer(Object top, Class<O> clazz) {
-// if (ui == null) {
-// throw new IllegalStateException("no ui attached to this context");
-// }
-// if (top == null) {
-// throw new IllegalArgumentException("top parameter can not be null");
-// }
-// if (!Container.class.isAssignableFrom(top.getClass())) {
-// throw new IllegalArgumentException("top parameter " + top + " is not a " + Container.class);
-// }
-// Container parent = ((Container) top).getParent();
-// if (parent != null && !clazz.isAssignableFrom(parent.getClass())) {
-// parent = getParentContainer(parent, clazz);
-// }
-// return (O) parent;
-// }
-
/**
* Obtain all the keys of data for a given type.
*
@@ -171,9 +143,9 @@
* @since 1.3
*/
public String[] getKeys(Class<?> klass) {
- List<String> keys = new java.util.ArrayList<String>();
+ List<String> keys = new ArrayList<String>();
for (JAXXContextEntryDef<?> key : data.keySet()) {
- if (key.getKlass() == klass) {
+ if (key.getKlass().equals(klass)) {
keys.add(key.getName());
}
}
@@ -185,14 +157,6 @@
data.clear();
}
-// protected JAXXObject getUi() {
-// return ui;
-// }
-//
-// protected void setUi(JAXXObject ui) {
-// this.ui = ui;
-// }
-
protected JAXXContextEntryDef<?> getKey(String name, Class<?> klass) {
return JAXXUtil.newContextEntryDef(name, klass);
}
@@ -215,7 +179,7 @@
return (T) data.remove(entry);
}
- if (JAXXContext.class == klazz) {
+ if (JAXXContext.class.equals(klazz)) {
return null;
}
// try in parentContext
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java 2010-03-15 14:19:31 UTC (rev 1788)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java 2010-03-15 20:20:02 UTC (rev 1789)
@@ -20,20 +20,21 @@
*/
package jaxx.runtime.context;
+import java.io.Serializable;
import java.util.List;
-import java.util.Map;
import jaxx.runtime.JAXXContext;
/**
* To qualify an entry in a {@link JAXXContext}.
* <p/>
- * Use the factory methods <code>newContextEntryDef</code> and <code>newListContextEntryDef</code< to obtain new instances.
+ * Use the factory methods <code>newContextEntryDef</code> and
+ * <code>newListContextEntryDef</code< to obtain new instances.
*
* @param <O> type of the entry associated to the definition
* @author chemit
*/
-public class JAXXContextEntryDef<O> implements java.io.Serializable {
+public class JAXXContextEntryDef<O> implements Serializable {
/** name of the entry, can be nuill for a unamed entry. */
protected String name;
@@ -43,27 +44,6 @@
private static final long serialVersionUID = 1L;
-// public static <O> JAXXContextEntryDef<O> newContextEntryDef(Class<O> klass) {
-// return newContextEntryDef(null, klass);
-// }
-//
-// public static <O> JAXXContextEntryDef<O> newContextEntryDef(String name, Class<O> klass) {
-// return new JAXXContextEntryDef<O>(name, klass);
-// }
-//
-// public static <O> JAXXContextEntryDef<List<O>> newListContextEntryDef() {
-// return newListContextEntryDef(null);
-// }
-//
-// @SuppressWarnings({"unchecked"})
-// public static <O> JAXXContextEntryDef<List<O>> newListContextEntryDef(String name) {
-// Class<List<O>> castList = JAXXContextEntryDef.<O>castList();
-// JAXXContextEntryDef<List<O>> contextEntryDef = new JAXXContextEntryDef<List<O>>(name,castList);
-// contextEntryDef.klass = castList;
-// return contextEntryDef;
-// }
-
-
public String getName() {
return name;
}
@@ -104,11 +84,6 @@
}
this.klass = klass;
}
-//
-// @SuppressWarnings({"unchecked"})
-// protected static <O> Class<List<O>> castList() {
-// return (Class<List<O>>) Collections.emptyList().getClass();
-// }
@Override
public boolean equals(Object o) {
@@ -119,28 +94,32 @@
return false;
}
JAXXContextEntryDef<?> that = (JAXXContextEntryDef<?>) o;
- return klass.equals(that.klass) && !(name != null ? !name.equals(that.name) : that.name != null);
+ return klass.equals(that.klass) &&
+ !(name != null ? !name.equals(that.name) : that.name != null);
}
@Override
public int hashCode() {
- int result = (name != null ? name.hashCode() : 0);
+ int result = name != null ? name.hashCode() : 0;
return 31 * result + klass.hashCode();
}
public boolean accept(Class<?> klass, String name) {
if (klass == Object.class && this.klass != Object.class) {
// try on name only
- return (this.name != null && name != null && this.name.equals(name));
+ return this.name != null && name != null && this.name.equals(name);
}
return klass.isAssignableFrom(this.klass) && (this.name == null && name == null
|| (this.name != null && name != null && this.name.equals(name)));
}
public boolean accept2(Class<?> klass, String name) {
- return !(klass == Object.class && this.klass != Object.class) &&
- this.klass.isAssignableFrom(klass) && (this.name == null &&
- name == null || (this.name != null && name != null && this.name.equals(name)));
+ return !(Object.class.equals(klass) &&
+ !Object.class.equals(this.klass)) &&
+ this.klass.isAssignableFrom(klass) &&
+ (this.name == null && name == null ||
+ (this.name != null && name != null && this.name.equals(name))
+ );
}
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java 2010-03-15 14:19:31 UTC (rev 1788)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java 2010-03-15 20:20:02 UTC (rev 1789)
@@ -98,7 +98,7 @@
protected NavigationTreeContextHelper contextHelper;
protected NavigationTreeHandler(String contextPrefix, JAXXObject context, Strategy strategy) {
- this.contextHelper = new NavigationTreeContextHelper(contextPrefix);
+ contextHelper = new NavigationTreeContextHelper(contextPrefix);
this.context = context;
this.strategy = strategy;
addTreeSelectionListener(this);
@@ -210,6 +210,8 @@
@Override
public void setSelectionPaths(TreePath[] paths) {
+ //FIXME-TC20100315 this can not work...
+ // can't test like this paths as Array...
if (paths.equals(getSelectionPaths())) {
// stay on same node, can skip
if (log.isDebugEnabled()) {
Modified: trunk/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-en_GB.properties
===================================================================
--- trunk/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-en_GB.properties 2010-03-15 14:19:31 UTC (rev 1788)
+++ trunk/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-en_GB.properties 2010-03-15 20:20:02 UTC (rev 1789)
@@ -1,3 +1,5 @@
+swing.error.desktop.browse.not.supported=Action 'Go to' not available
+swing.error.desktop.not.supported=Desktop not accessible
validator.field.header=Field
validator.field.header.tip=The field involved
validator.field.tip=Property '%1$s'
Modified: trunk/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-fr_FR.properties
===================================================================
--- trunk/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-fr_FR.properties 2010-03-15 14:19:31 UTC (rev 1788)
+++ trunk/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-fr_FR.properties 2010-03-15 20:20:02 UTC (rev 1789)
@@ -1,3 +1,5 @@
+swing.error.desktop.browse.not.supported=Action 'aller \u00E0' non disponible
+swing.error.desktop.not.supported=Desktop non accessible
validator.field.header=Champ
validator.field.header.tip=Le champ surquel intervient le message
validator.field.tip=Propri\u00E9t\u00E9 '%1$s'
Added: trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/DataContextEntryIteratorTest.java
===================================================================
--- trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/DataContextEntryIteratorTest.java (rev 0)
+++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/DataContextEntryIteratorTest.java 2010-03-15 20:20:02 UTC (rev 1789)
@@ -0,0 +1,284 @@
+/**
+ * *##%
+ * ObServe :: Services
+ * Copyright (C) 2008 - 2010 IRD, Codelutin
+ *
+ * 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.runtime.context;
+
+import jaxx.runtime.context.DataContext.DataContextEntry;
+import jaxx.runtime.context.DataContext.DataContextEntryIterator;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.util.regex.Pattern;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * Tests {@link DataContext}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0.1
+ */
+public class DataContextEntryIteratorTest {
+
+ static DataContextEntry<?>[] entries;
+
+ static class DataContextEntry2 extends DataContextEntry<Object> {
+
+ public DataContextEntry2() {
+ super(Object.class);
+ }
+
+ public DataContextEntry2(DataContextEntry<?> previous) {
+ super(Object.class, previous);
+ }
+
+ @Override
+ public Pattern getPattern() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public String getContextPath(Object... args) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean acceptType(Class<?> type) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ entries = new DataContextEntry<?>[3];
+ entries[0] = new DataContextEntry2();
+ entries[1] = new DataContextEntry2(entries[0]);
+ entries[2] = new DataContextEntry2(entries[1]);
+ }
+
+ DataContextEntryIterator instance;
+
+ @Test
+ public void testEmptyIterator() {
+
+ instance = new DataContextEntryIterator(
+ DataContext.EMPTY_DATA_CONTEXT_ENTRY_ARRAY);
+
+ boolean result = instance.hasNext();
+ assertEquals(false, result);
+ }
+
+ @Test
+ public void testEmptyReverseIterator() {
+
+ instance = new DataContextEntryIterator(
+ DataContext.EMPTY_DATA_CONTEXT_ENTRY_ARRAY, true);
+
+ boolean result = instance.hasNext();
+ assertEquals(false, result);
+ }
+
+ @Test
+ public void testEmptyLevelIterator() {
+
+ instance = new DataContextEntryIterator(
+ DataContext.EMPTY_DATA_CONTEXT_ENTRY_ARRAY, 0);
+
+ boolean result = instance.hasNext();
+ assertEquals(false, result);
+
+ instance = new DataContextEntryIterator(
+ new DataContextEntry<?>[]{entries[1]}, 0);
+
+ result = instance.hasNext();
+ assertEquals(false, result);
+ }
+
+ @Test
+ public void testSingletonIterator() {
+
+ instance = new DataContextEntryIterator(
+ new DataContextEntry<?>[]{entries[0]});
+
+ boolean result = instance.hasNext();
+ assertEquals(true, result);
+ DataContextEntry<?> data = instance.next();
+ assertNotNull(data);
+ assertEquals(entries[0], data);
+ assertEquals(0, data.getLevel());
+
+ result = instance.hasNext();
+ assertEquals(false, result);
+ }
+
+ @Test
+ public void testSingletonReverseIterator() {
+
+ instance = new DataContextEntryIterator(
+ new DataContextEntry<?>[]{entries[0]}, true);
+
+ boolean result = instance.hasNext();
+ assertEquals(true, result);
+ DataContextEntry<?> data = instance.next();
+ assertNotNull(data);
+ assertEquals(entries[0], data);
+ assertEquals(0, data.getLevel());
+
+ result = instance.hasNext();
+ assertEquals(false, result);
+ }
+
+ @Test
+ public void testSingletonLevelIterator() {
+
+ instance = new DataContextEntryIterator(
+ new DataContextEntry<?>[]{entries[0]}, 0);
+
+ boolean result = instance.hasNext();
+ assertEquals(true, result);
+ DataContextEntry<?> data = instance.next();
+ assertNotNull(data);
+ assertEquals(entries[0], data);
+ assertEquals(0, data.getLevel());
+
+ result = instance.hasNext();
+ assertEquals(false, result);
+
+ instance = new DataContextEntryIterator(
+ new DataContextEntry<?>[]{entries[0]}, 1);
+
+ result = instance.hasNext();
+ assertEquals(true, result);
+ data = instance.next();
+ assertNotNull(data);
+ assertEquals(entries[0], data);
+ assertEquals(0, data.getLevel());
+
+ result = instance.hasNext();
+ assertEquals(false, result);
+
+ instance = new DataContextEntryIterator(entries, 0);
+
+ result = instance.hasNext();
+ assertEquals(true, result);
+ data = instance.next();
+ assertNotNull(data);
+ assertEquals(entries[0], data);
+ assertEquals(0, data.getLevel());
+
+ result = instance.hasNext();
+ assertEquals(false, result);
+
+ }
+
+ @Test
+ public void testIterator() {
+
+ instance = new DataContextEntryIterator(entries);
+
+ boolean result = instance.hasNext();
+ assertEquals(true, result);
+ DataContextEntry<?> data = instance.next();
+ assertNotNull(data);
+ assertEquals(entries[0], data);
+ assertEquals(0, data.getLevel());
+
+ result = instance.hasNext();
+ assertEquals(true, result);
+ data = instance.next();
+ assertNotNull(data);
+ assertEquals(entries[1], data);
+ assertEquals(1, data.getLevel());
+
+ result = instance.hasNext();
+ assertEquals(true, result);
+ data = instance.next();
+ assertNotNull(data);
+ assertEquals(entries[2], data);
+ assertEquals(2, data.getLevel());
+
+ result = instance.hasNext();
+ assertEquals(false, result);
+
+
+ }
+
+ @Test
+ public void testReverseIterator() {
+
+ instance = new DataContextEntryIterator(entries, true);
+
+ boolean result = instance.hasNext();
+ assertEquals(true, result);
+ Object data = instance.next();
+ assertNotNull(data);
+ assertEquals(entries[2], data);
+
+ result = instance.hasNext();
+ assertEquals(true, result);
+ data = instance.next();
+ assertNotNull(data);
+ assertEquals(entries[1], data);
+
+ result = instance.hasNext();
+ assertEquals(true, result);
+ data = instance.next();
+ assertNotNull(data);
+ assertEquals(entries[0], data);
+
+ result = instance.hasNext();
+ assertEquals(false, result);
+
+
+ }
+
+ @Test
+ public void testLevelIterator() {
+
+ instance = new DataContextEntryIterator(entries, 2);
+
+ boolean result = instance.hasNext();
+ assertEquals(true, result);
+ DataContextEntry<?> data = instance.next();
+ assertNotNull(data);
+ assertEquals(entries[0], data);
+ assertEquals(0, data.getLevel());
+
+ result = instance.hasNext();
+ assertEquals(true, result);
+ data = instance.next();
+ assertNotNull(data);
+ assertEquals(entries[1], data);
+ assertEquals(1, data.getLevel());
+
+ result = instance.hasNext();
+ assertEquals(true, result);
+ data = instance.next();
+ assertNotNull(data);
+ assertEquals(entries[2], data);
+ assertEquals(2, data.getLevel());
+
+ result = instance.hasNext();
+ assertEquals(false, result);
+
+
+ }
+}
Property changes on: trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/DataContextEntryIteratorTest.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
1
0
r1788 - in trunk: jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation src/site/rst
by sletellier@users.nuiton.org 15 Mar '10
by sletellier@users.nuiton.org 15 Mar '10
15 Mar '10
Author: sletellier
Date: 2010-03-15 15:19:31 +0100 (Mon, 15 Mar 2010)
New Revision: 1788
Log:
- Adding simple clic selection handler
- Adding docs
- Set SelectionMode to discontiguous for multi selection
Added:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationOneClicSelectionHandler.java
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationMultiTreeHandler.java
trunk/src/site/rst/NavigationModel.rst
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationMultiTreeHandler.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationMultiTreeHandler.java 2010-03-15 12:17:04 UTC (rev 1787)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationMultiTreeHandler.java 2010-03-15 14:19:31 UTC (rev 1788)
@@ -43,6 +43,8 @@
* from nodes we can not just listen selection model changed, we must control
* it.
*
+ * This one is used to enable multi selection
+ *
* @author sletellier
* @since 2.0.1
*/
@@ -55,6 +57,9 @@
public NavigationMultiTreeHandler(String contextPrefix, JAXXObject context, Strategy strategy) {
super(contextPrefix, context, strategy);
+
+ // Enable multi selection
+ super.setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
}
@Override
@@ -168,7 +173,7 @@
}
}
- public List<String> getPaths(List<NavigationTreeNode> nodes){
+ protected List<String> getPaths(List<NavigationTreeNode> nodes){
List<String> result = new ArrayList<String>();
for (NavigationTreeNode node : nodes){
result.add(node.getFullPath());
Added: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationOneClicSelectionHandler.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationOneClicSelectionHandler.java (rev 0)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationOneClicSelectionHandler.java 2010-03-15 14:19:31 UTC (rev 1788)
@@ -0,0 +1,72 @@
+/*
+ * *##%
+ * JAXX Runtime
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+
+package jaxx.runtime.swing.navigation;
+
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXObject;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.swingx.JXTreeTable;
+
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.tree.TreePath;
+import javax.swing.tree.TreeSelectionModel;
+import java.awt.Component;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * The handler of a navigation tree.
+ *
+ * This is also the selection model to use, since we must check before moving
+ * from nodes we can not just listen selection model changed, we must control
+ * it.
+ *
+ * This one is used to enable one clic multi selection
+ *
+ * @author sletellier
+ * @since 2.0.1
+ */
+public abstract class NavigationOneClicSelectionHandler extends NavigationMultiTreeHandler {
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(NavigationOneClicSelectionHandler.class);
+
+
+ public NavigationOneClicSelectionHandler(String contextPrefix, JAXXObject context, NavigationTreeHandler.Strategy strategy) {
+ super(contextPrefix, context, strategy);
+ }
+
+ @Override
+ public void setSelectionPath(TreePath path) {
+ TreePath[] treePaths = getSelectionPaths();
+ if (treePaths == null || !Arrays.asList(treePaths).contains(path)){
+ addSelectionPath(path);
+ } else {
+ removeSelectionPath(path);
+ }
+ }
+
+}
Modified: trunk/src/site/rst/NavigationModel.rst
===================================================================
--- trunk/src/site/rst/NavigationModel.rst 2010-03-15 12:17:04 UTC (rev 1787)
+++ trunk/src/site/rst/NavigationModel.rst 2010-03-15 14:19:31 UTC (rev 1788)
@@ -19,7 +19,7 @@
jaxx.runtime.swing.navigation.NavigationModel
=============================================
-Contract représentant le model de l'arbre de navigation.
+Contrat representant le model de l'arbre de navigation.
Les noeuds présents dans se modèle sont aussi typés en
*jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode*.
@@ -104,6 +104,12 @@
Extension de *jaxx.runtime.swing.navigation.NavigationTreeHandler* pour
ajouter la possibilité d'utiliser la multisélection.
+jaxx.runtime.swing.navigation.NavigationOneClicSelectionHandler
+---------------------------------------------------------------
+
+Extension de *jaxx.runtime.swing.navigation.NavigationMultiTreeHandler* pour
+activer le simple clic lors de la multi-selection.
+
Définition d'un noeud
=====================
1
0
r1787 - trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator
by tchemit@users.nuiton.org 15 Mar '10
by tchemit@users.nuiton.org 15 Mar '10
15 Mar '10
Author: tchemit
Date: 2010-03-15 13:17:04 +0100 (Mon, 15 Mar 2010)
New Revision: 1787
Log:
fix javadoc
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/Decorator.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorProvider.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/JXPathDecorator.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/MultiJXPathDecorator.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/PropertyDecorator.java
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/Decorator.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/Decorator.java 2010-03-15 12:12:51 UTC (rev 1786)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/Decorator.java 2010-03-15 12:17:04 UTC (rev 1787)
@@ -23,10 +23,10 @@
import java.io.Serializable;
/**
- * A simple contract to define a String decorator on any java objet.
+ * A simple contract to define a String decorator on any java object.
*
* @param <O> the type of data to decorate
- * @author chemit
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.7.2 (was previously {@code jaxx.runtime.Decorator})
*/
public abstract class Decorator<O> implements Serializable {
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorProvider.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorProvider.java 2010-03-15 12:12:51 UTC (rev 1786)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorProvider.java 2010-03-15 12:17:04 UTC (rev 1787)
@@ -9,13 +9,13 @@
/**
* A decorator provider.
* <p/>
- * Implements the method {@link #loadDecorators()} to fill the decorators availables.
+ * Implements the method {@link #loadDecorators()} to fill the decorators
+ * availables.
* <p/>
* Then can obtain decorator via the methods {@code getDecorator(...)}
* <p/>
- * User: chemit
- * Date: 28 oct. 2009
- * Time: 19:40:48
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.7
*/
public abstract class DecoratorProvider {
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java 2010-03-15 12:12:51 UTC (rev 1786)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java 2010-03-15 12:17:04 UTC (rev 1787)
@@ -40,7 +40,7 @@
* {@link #sort(JXPathDecorator, List, int)}.
* <p/>
*
- * @author tony
+ * @author tchemit <chemit(a)codelutiln.com>
* @since 1.7.2 (was previously {@code jaxx.runtime.DecoratorUtils})
*/
public class DecoratorUtils {
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/JXPathDecorator.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/JXPathDecorator.java 2010-03-15 12:12:51 UTC (rev 1786)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/JXPathDecorator.java 2010-03-15 12:17:04 UTC (rev 1787)
@@ -46,7 +46,7 @@
* assert "expr = %1$s" == d.toString(d);
* </pre>
*
- * @author chemit
+ * @author tchemit <chemit(a)codelutin.com>
* @param <O> type of data to decorate
* @see Decorator
* @since 1.7.2 (was previously {@code jaxx.runtime.JXPathDecorator})
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/MultiJXPathDecorator.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/MultiJXPathDecorator.java 2010-03-15 12:12:51 UTC (rev 1786)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/MultiJXPathDecorator.java 2010-03-15 12:17:04 UTC (rev 1787)
@@ -28,7 +28,7 @@
/**
* TODO
*
- * @author chemit
+ * @author tchemit <chemit(a)codelutin.com>
* @param <O> type of data to decorate
* @see Decorator
* @since 1.7.2 (was previously {@code jaxx.runtime.MultiJXPathDecorator})
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/PropertyDecorator.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/PropertyDecorator.java 2010-03-15 12:12:51 UTC (rev 1786)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/decorator/PropertyDecorator.java 2010-03-15 12:17:04 UTC (rev 1787)
@@ -38,7 +38,7 @@
* Decorator<Object> d = DecoratorUtils.newPropertyDecorator(PropertyDecorator.class,"expressions");
* </pre>
*
- * @author chemit
+ * @author tchemit <chemit(a)codelutin.com>
* @param <O> type of data to decorate
* @see Decorator
* @since 1.7.2 (was previously {@code jaxx.runtime.PropertyDecorator})
1
0