Buix-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
May 2009
- 4 participants
- 61 discussions
r1385 - in jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing: . widget
by sletellier@users.labs.libre-entreprise.org 06 May '09
by sletellier@users.labs.libre-entreprise.org 06 May '09
06 May '09
Author: sletellier
Date: 2009-05-05 00:02:46 +0000 (Tue, 05 May 2009)
New Revision: 1385
Added:
jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/widget/
jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/widget/ErrorDialogUI.jaxx
Log:
Adding ErrorDialog widget
Added: jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/widget/ErrorDialogUI.jaxx
===================================================================
--- jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/widget/ErrorDialogUI.jaxx (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/widget/ErrorDialogUI.jaxx 2009-05-05 00:02:46 UTC (rev 1385)
@@ -0,0 +1,66 @@
+<JDialog title='observe.title.error.dialog' modal='true'>
+ <script><![CDATA[
+protected static ErrorDialogUI instance;
+public static void init(Frame frame) {
+ disposeUI();
+ instance = new ErrorDialogUI(frame);
+ instance.setModalityType(ModalityType.TOOLKIT_MODAL);
+}
+public static void showError(Exception e) {
+ if (instance == null) {
+ instance = new ErrorDialogUI();
+ }
+ instance.getErrorMessage().setText(e.getMessage());
+ StringWriter w = new StringWriter();
+ e.printStackTrace(new PrintWriter(w));
+ instance.getErrorStack().setText(w.toString());
+ instance.getErrorStack().setCaretPosition(0);
+ instance.pack();
+ jaxx.runtime.SwingUtil.center(instance.getContextValue(JFrame.class,"parent"), instance);
+ instance.setVisible(true);
+}
+public static void disposeUI() {
+ instance=null;
+}
+
+public ErrorDialogUI(Frame frame) {
+ super(frame);
+ if (frame!=null) {
+ setContextValue(frame);
+ setContextValue(frame,"parent");
+ }
+
+}
+
+JRootPane rootPane = getRootPane();
+rootPane.setDefaultButton(close);
+rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close");
+rootPane.getActionMap().put("close", close.getAction());
+ ]]></script>
+ <Table>
+ <row fill='both'>
+ <cell>
+ <JPanel>
+ <JLabel text='observe.message.error.dialog'/>
+ </JPanel>
+ </cell>
+ </row>
+ <row fill='both'>
+ <cell>
+ <JLabel id='errorMessage'/>
+ </cell>
+ </row>
+ <row fill='both' weightx='1' weighty='1'>
+ <cell>
+ <JScrollPane width='600' height='200'>
+ <JTextArea id='errorStack' editable='false' font-size='9'/>
+ </JScrollPane>
+ </cell>
+ </row>
+ <row fill='horizontal'>
+ <cell>
+ <JButton id='close' text='observe.action.close' onActionPerformed='dispose()'/>
+ </cell>
+ </row>
+ </Table>
+</JDialog>
2
1
r1386 - in jaxx/trunk: . jaxx-runtime-api jaxx-runtime-swing jaxx-runtime-swing/src/main/java/jaxx/runtime jaxx-runtime-swing/src/main/java/jaxx/runtime/swing jaxx-runtime-swing/src/main/resources/icons jaxx-runtime-swing-widget jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor jaxx-runtime-swing-widget/src/main/resources/i18n jaxx-runtime-validator jaxx-runtime-validator/src/main/java/jaxx/runtime/validator
by tchemit@users.labs.libre-entreprise.org 06 May '09
by tchemit@users.labs.libre-entreprise.org 06 May '09
06 May '09
Author: tchemit
Date: 2009-05-06 05:44:44 +0000 (Wed, 06 May 2009)
New Revision: 1386
Added:
jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx
jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java
jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/ErrorDialogUI.jaxx
jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/TimeEditor.css
jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/TimeEditor.jaxx
jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/TimeEditorHandler.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BooleanCellRenderer.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/EmptyNumberTableCellRenderer.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/EnumTableCellRenderer.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/MyDefaultCellEditor.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/OneClicListSelectionModel.java
jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-delete.png
Modified:
jaxx/trunk/changelog.txt
jaxx/trunk/jaxx-runtime-api/changelog.txt
jaxx/trunk/jaxx-runtime-api/pom.xml
jaxx/trunk/jaxx-runtime-swing-widget/pom.xml
jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties
jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties
jaxx/trunk/jaxx-runtime-swing/changelog.txt
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java
jaxx/trunk/jaxx-runtime-validator/changelog.txt
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator.java
jaxx/trunk/pom.xml
Log:
add some stuff from ObServe + more (see in changelogs...)
TODO : make an example for new editors
Modified: jaxx/trunk/changelog.txt
===================================================================
--- jaxx/trunk/changelog.txt 2009-05-05 00:02:46 UTC (rev 1385)
+++ jaxx/trunk/changelog.txt 2009-05-06 05:44:44 UTC (rev 1386)
@@ -1,4 +1,5 @@
1.5
+ * 20090506 [chemit] - super-pom has no dependencies, use lutinutil 1.0.5
* 20090404 [chemit] - introduce module jaxx-runtime-swing-widget for swing widgets designed with jaxx.
1.4
Modified: jaxx/trunk/jaxx-runtime-api/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-runtime-api/changelog.txt 2009-05-05 00:02:46 UTC (rev 1385)
+++ jaxx/trunk/jaxx-runtime-api/changelog.txt 2009-05-06 05:44:44 UTC (rev 1386)
@@ -1,3 +1,6 @@
+1.5
+ * 20090506 [chemit] - super-pom has no dependencies
+
1.3 chemit 20090409
* 20090404 [chemit] - introduce DataContext class
* 20090331 [chemit] - introduce DecoratorUtils class
Modified: jaxx/trunk/jaxx-runtime-api/pom.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-api/pom.xml 2009-05-05 00:02:46 UTC (rev 1385)
+++ jaxx/trunk/jaxx-runtime-api/pom.xml 2009-05-06 05:44:44 UTC (rev 1386)
@@ -19,6 +19,11 @@
<dependencies>
<dependency>
+ <groupId>org.codelutin</groupId>
+ <artifactId>lutinutil</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
Modified: jaxx/trunk/jaxx-runtime-swing/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/changelog.txt 2009-05-05 00:02:46 UTC (rev 1385)
+++ jaxx/trunk/jaxx-runtime-swing/changelog.txt 2009-05-06 05:44:44 UTC (rev 1386)
@@ -1,3 +1,6 @@
+1.5
+ * 20090506 [chemit] - add some usefull renderer and other stuffs
+
1.3 chemit 20090409
* 20090404 [chemit] - introduce dimension factory in SwingUtil for min and max dimensions
* 20090327 [chemit] - add javax help mecanism
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java 2009-05-05 00:02:46 UTC (rev 1385)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java 2009-05-06 05:44:44 UTC (rev 1386)
@@ -32,15 +32,22 @@
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.Properties;
+import javax.swing.DefaultListCellRenderer;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
+import javax.swing.JList;
import javax.swing.JRootPane;
import javax.swing.JTabbedPane;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
+import javax.swing.table.DefaultTableCellRenderer;
+import jaxx.runtime.swing.BooleanCellRenderer;
+import jaxx.runtime.swing.DecoratorTableCellRenderer;
+import jaxx.runtime.swing.EmptyNumberTableCellRenderer;
+import jaxx.runtime.swing.EnumTableCellRenderer;
import jaxx.runtime.swing.I18nTableCellRenderer;
import jaxx.runtime.swing.Item;
import jaxx.runtime.swing.JAXXComboBox;
@@ -197,12 +204,12 @@
* @param component the component to box
* @return the {@link org.jdesktop.jxlayer.JXLayer} boxing the component
*/
- public static JXLayer boxComponentWithJxLayer(JComponent component) {
- JXLayer layer = getLayer(component);
+ public static JXLayer<?> boxComponentWithJxLayer(JComponent component) {
+ JXLayer<?> layer = getLayer(component);
if (layer != null) {
return layer;
}
- layer = new org.jdesktop.jxlayer.JXLayer();
+ layer = new org.jdesktop.jxlayer.JXLayer<JComponent>();
layer.add(component);
return layer;
}
@@ -234,7 +241,7 @@
public static boolean isLayered(JComponent comp) {
Container parent = comp.getParent();
- return parent != null && parent instanceof JXLayer;
+ return parent != null && parent instanceof JXLayer<?>;
}
/**
@@ -250,7 +257,7 @@
* @param container le container ou rechercher les composants d'edition
* @return le dictionnaire des composants recherches.
*/
- public static Map<String, JComponent> lookingForEditor(Class clazz, Container container) {
+ public static Map<String, JComponent> lookingForEditor(Class<?> clazz, Container container) {
Map<String, JComponent> result = new HashMap<String, JComponent>();
try {
// looking for all component with name set
@@ -552,8 +559,8 @@
if (rect == null || rect.width == 0 || rect.height == 0) {
rect = comp.getBounds();
}
- if (comp instanceof JXLayer) {
- JXLayer layer = (JXLayer) comp;
+ if (comp instanceof JXLayer<?>) {
+ JXLayer<?> layer = (JXLayer<?>) comp;
comp = layer.getView();
}
if (comp instanceof Container) {
@@ -575,8 +582,8 @@
if (rect == null || rect.width == 0 || rect.height == 0) {
rect = comp.getBounds();
}
- if (comp instanceof JXLayer) {
- JXLayer layer = (JXLayer) comp;
+ if (comp instanceof JXLayer<?>) {
+ JXLayer<?> layer = (JXLayer<?>) comp;
comp = layer.getView();
}
if (comp instanceof Container) {
@@ -592,4 +599,56 @@
return cont;
}
}
+
+ /**
+ * Génère un renderer de liste graphique basée sur un décorateur donné.
+ *
+ * @param <O> le type des données gérées par le décorateur
+ * @param decorator le décorateur à encapsuler
+ * @return le nouveau renderer
+ * @see Decorator
+ */
+ public static <O> DefaultListCellRenderer newDecoratedListCellRenderer(final Decorator<O> decorator) {
+ return new DefaultListCellRenderer() {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
+ String decorated;
+ if (value instanceof String) {
+ decorated = (String) value;
+ } else {
+ decorated = decorator.toString(value);
+ }
+ JComponent component = (JComponent) super.getListCellRendererComponent(list, decorated, index, isSelected, cellHasFocus);
+ return component;
+ }
+ };
+ }
+
+ public static TableCellRenderer newDeleteCellRenderer(DefaultTableCellRenderer renderer) {
+ Icon icon = UIManager.getIcon("Table.removeIcon");
+ if (icon == null) {
+ // try with default icon
+ icon = createActionIcon("delete");
+ }
+ return new BooleanCellRenderer(renderer, icon);
+ }
+
+ public static TableCellRenderer newBooleanTableCellRenderer(DefaultTableCellRenderer renderer) {
+ return new BooleanCellRenderer(renderer);
+ }
+
+ public static DecoratorTableCellRenderer newDecorateTableCellRenderer(TableCellRenderer renderer, Decorator<?> decorator) {
+ return new DecoratorTableCellRenderer(renderer, decorator);
+ }
+
+ public static EmptyNumberTableCellRenderer newEmptyNumberTableCellRenderer(TableCellRenderer renderer) {
+ return new EmptyNumberTableCellRenderer(renderer);
+ }
+
+ public static <E extends Enum<E>> EnumTableCellRenderer<E> newEnumTableCellRenderer(TableCellRenderer renderer,Class<E> enumClass) {
+ return new EnumTableCellRenderer<E>(renderer,enumClass);
+ }
}
Added: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BooleanCellRenderer.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BooleanCellRenderer.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BooleanCellRenderer.java 2009-05-06 05:44:44 UTC (rev 1386)
@@ -0,0 +1,61 @@
+package jaxx.runtime.swing;
+
+import javax.swing.Icon;
+import javax.swing.JCheckBox;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTable;
+import javax.swing.table.TableCellRenderer;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+
+/** @author chemit
+ * @since 1.5
+ */
+public class BooleanCellRenderer extends JPanel implements TableCellRenderer {
+
+ private static final long serialVersionUID = 1L;
+ protected TableCellRenderer defaultDelegate;
+ protected JCheckBox checkBox;
+
+ public BooleanCellRenderer(TableCellRenderer delegate) {
+ //super(new BorderLayout());
+ this.checkBox = new JCheckBox();
+ add(checkBox, BorderLayout.CENTER);
+ checkBox.setHorizontalAlignment(JLabel.CENTER);
+ checkBox.setBorderPainted(true);
+ this.defaultDelegate = delegate;
+ }
+
+ public BooleanCellRenderer(TableCellRenderer delegate, Icon icon) {
+ //super(new BorderLayout());
+ this.checkBox = new JCheckBox(icon);
+ add(checkBox, BorderLayout.NORTH);
+ checkBox.setHorizontalAlignment(JLabel.CENTER);
+ checkBox.setVerticalTextPosition(JLabel.TOP);
+ checkBox.setBorderPainted(true);
+ this.defaultDelegate = delegate;
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+ ((JComponent) defaultDelegate).setBackground(null);
+ JComponent render = (JComponent) defaultDelegate.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ if (isSelected) {
+ setForeground(table.getSelectionForeground());
+ setBackground(table.getSelectionBackground());
+ } else {
+ setForeground(render.getForeground());
+ setBackground(render.getBackground());
+ //fixme make this works... and remove the test
+ if (row % 2 == 1) {
+ setBackground(Color.WHITE);
+ }
+ }
+ checkBox.setSelected((value != null && (Boolean) value));
+ setBorder(render.getBorder());
+ return this;
+ }
+}
Added: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/EmptyNumberTableCellRenderer.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/EmptyNumberTableCellRenderer.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/EmptyNumberTableCellRenderer.java 2009-05-06 05:44:44 UTC (rev 1386)
@@ -0,0 +1,37 @@
+package jaxx.runtime.swing;
+
+import javax.swing.JTable;
+import javax.swing.table.TableCellRenderer;
+import java.awt.Component;
+import javax.swing.table.DefaultTableCellRenderer;
+
+/**
+ * A {@link TableCellRenderer} which does not display numbers when they are
+ * equals to 0.
+ *
+ * @author chemit
+ * @since 1.5
+ */
+public class EmptyNumberTableCellRenderer implements TableCellRenderer {
+
+ protected final Integer ZERO = 0;
+ protected final Float ZEROF = 0F;
+ protected final Double ZEROD = 0D;
+ private TableCellRenderer delegate;
+
+ public EmptyNumberTableCellRenderer() {
+ this(new DefaultTableCellRenderer());
+ }
+
+ public EmptyNumberTableCellRenderer(TableCellRenderer delegate) {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+ if (value == null || ZERO.equals(value) || ZEROF.equals(value) || ZEROD.equals(value)) {
+ value = null;
+ }
+ return delegate.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ }
+}
Added: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/EnumTableCellRenderer.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/EnumTableCellRenderer.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/EnumTableCellRenderer.java 2009-05-06 05:44:44 UTC (rev 1386)
@@ -0,0 +1,47 @@
+package jaxx.runtime.swing;
+
+import javax.swing.JTable;
+import javax.swing.table.TableCellRenderer;
+import java.awt.Component;
+import java.util.EnumSet;
+
+/**
+ *
+ *
+ * A {@link TableCellRenderer} which displays enum values from their ordinal value.
+ *
+ * @param <E> le type de l'énumération.
+ *
+ * @author chemit
+ * @since 1.5
+ */
+public class EnumTableCellRenderer<E extends Enum<E>> implements TableCellRenderer {
+
+ private TableCellRenderer delegate;
+ private EnumSet<E> enumValues;
+
+ public EnumTableCellRenderer(TableCellRenderer delegate, Class<E> enumClass) {
+ this.delegate = delegate;
+ this.enumValues = EnumSet.allOf(enumClass);
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+
+ if (value != null) {
+ //FIXME : should be also able to read it by name ?
+ Integer ordinal = Integer.valueOf(value + "");
+ if (ordinal == -1) {
+ value = null;
+ } else {
+ for (E enumValue : enumValues) {
+ if (ordinal == enumValue.ordinal()) {
+ value = enumValue;
+ break;
+ }
+ }
+ }
+ }
+ return delegate.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ }
+}
\ No newline at end of file
Added: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/MyDefaultCellEditor.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/MyDefaultCellEditor.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/MyDefaultCellEditor.java 2009-05-06 05:44:44 UTC (rev 1386)
@@ -0,0 +1,104 @@
+package jaxx.runtime.swing;
+
+import org.codelutin.util.EnumEditor;
+
+import javax.swing.DefaultCellEditor;
+import javax.swing.Icon;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JTable;
+import javax.swing.JTextField;
+import javax.swing.table.TableCellEditor;
+import java.awt.Component;
+
+/**
+ * @author chemit
+ * @since 1.5
+ */
+public class MyDefaultCellEditor extends DefaultCellEditor {
+
+ private static final long serialVersionUID = 1L;
+
+ public static TableCellEditor newTextEditor() {
+ return new MyDefaultCellEditor(new JTextField());
+ }
+
+ public static TableCellEditor newBooleanEditor() {
+ return new MyDefaultCellEditor(new JCheckBox());
+ }
+
+ public static TableCellEditor newListEditor() {
+ return newListEditor(new JComboBox());
+ }
+
+ public static TableCellEditor newListEditor(JComboBox editor) {
+ return new MyDefaultCellEditor(editor);
+ }
+
+ public static TableCellEditor newEnumEditor(EnumEditor editor) {
+ return new MyDefaultCellEditor(editor) {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Object getCellEditorValue() {
+ Object value = super.getCellEditorValue();
+ if (value != null) {
+ value = ((Enum) value).ordinal();
+ } else {
+ value = -1;
+ }
+ return value;
+ }
+ };
+ }
+
+ public static TableCellEditor newBooleanEditor(Icon icon) {
+ return new MyDefaultCellEditor(new JCheckBox(icon));
+ }
+
+ public static TableCellEditor newBooleanEditor(Icon icon, boolean requireSelect) {
+ TableCellEditor cellEditor = newBooleanEditor(icon);
+ ((MyDefaultCellEditor) cellEditor).setRequireSelect(requireSelect);
+ return cellEditor;
+ }
+
+ public static TableCellEditor newBooleanEditor(boolean requireSelect) {
+ TableCellEditor cellEditor = newBooleanEditor();
+ ((MyDefaultCellEditor) cellEditor).setRequireSelect(requireSelect);
+ return cellEditor;
+ }
+ protected boolean requireSelect = true;
+
+ @Override
+ public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
+ if (!isSelected && requireSelect) {
+ // force to have select the cell before editing, a way to not modify edition for nothing...
+ return null;
+ }
+ return super.getTableCellEditorComponent(table, value, isSelected, row, column);
+ }
+
+ public boolean isRequireSelect() {
+ return requireSelect;
+ }
+
+ public void setRequireSelect(boolean requireSelect) {
+ this.requireSelect = requireSelect;
+ }
+
+ protected MyDefaultCellEditor(JTextField textField) {
+ super(textField);
+ setClickCountToStart(1);
+ }
+
+ protected MyDefaultCellEditor(JCheckBox checkBox) {
+ super(checkBox);
+ setClickCountToStart(1);
+ }
+
+ protected MyDefaultCellEditor(JComboBox comboBox) {
+ super(comboBox);
+ setClickCountToStart(1);
+ }
+}
Added: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/OneClicListSelectionModel.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/OneClicListSelectionModel.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/OneClicListSelectionModel.java 2009-05-06 05:44:44 UTC (rev 1386)
@@ -0,0 +1,181 @@
+package jaxx.runtime.swing;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.ListModel;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionListener;
+import java.util.Arrays;
+
+/**
+ * @author chemit
+ * @since 1.5
+ */
+public class OneClicListSelectionModel implements ListSelectionModel {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory.getLog(OneClicListSelectionModel.class);
+ protected ListSelectionModel delegate;
+ protected final ListModel model;
+ private boolean[] _states;
+
+ public OneClicListSelectionModel(ListSelectionModel delegate, ListModel model) {
+ this.delegate = delegate;
+ this.model = model;
+ delegate.clearSelection();
+ }
+
+ protected boolean[] getStates(int selectedIndex) {
+ int max = model.getSize();
+ if (_states == null || _states.length != max) {
+ _states = new boolean[max];
+ } else {
+ Arrays.fill(_states, false);
+ }
+ for (int i = 0; i < max; i++) {
+ _states[i] = i != selectedIndex && delegate.isSelectedIndex(i);
+ }
+ return _states;
+ }
+
+ @Override
+ public void setSelectionInterval(int index0, int index1) {
+ if (index0 != index1) {
+ // not a single selection (come from a click)
+ // use default behaviour
+ delegate.setSelectionInterval(index0, index1);
+ return;
+ }
+ delegate.setValueIsAdjusting(true);
+
+ try {
+ int max = model.getSize();
+
+ if (log.isDebugEnabled()) {
+ log.debug("single [index:" + index0 + "] [selected:" + isSelectedIndex(index0) + "] [size:" + max + "] [anchor:" + delegate.getAnchorSelectionIndex() + "] [lead:" + delegate.getLeadSelectionIndex() + "]");
+ }
+
+ if (!isSelectedIndex(index0)) {
+ // select it
+ delegate.addSelectionInterval(index0, index1);
+ return;
+ }
+ if (max == index0) {
+ // last selected index, so can directly remove it
+ delegate.removeIndexInterval(index0, index0);
+ return;
+ }
+
+ // must recompute the selection removing only the index0 item
+ boolean[] state = getStates(index0);
+
+ if (log.isDebugEnabled()) {
+ log.debug("state : " + Arrays.toString(state));
+ }
+ delegate.clearSelection();
+ for (int i = 0; i < max; i++) {
+ if (state[i]) {
+ delegate.addSelectionInterval(i, i);
+ }
+ }
+ } finally {
+ delegate.setValueIsAdjusting(false);
+ }
+ }
+
+ @Override
+ public void addSelectionInterval(int index0, int index1) {
+ delegate.addSelectionInterval(index0, index1);
+ }
+
+ @Override
+ public void removeSelectionInterval(int index0, int index1) {
+ delegate.removeSelectionInterval(index0, index1);
+ }
+
+ @Override
+ public int getMinSelectionIndex() {
+ return delegate.getMinSelectionIndex();
+ }
+
+ @Override
+ public int getMaxSelectionIndex() {
+ return delegate.getMaxSelectionIndex();
+ }
+
+ @Override
+ public boolean isSelectedIndex(int index) {
+ return delegate.isSelectedIndex(index);
+ }
+
+ @Override
+ public int getAnchorSelectionIndex() {
+ return delegate.getAnchorSelectionIndex();
+ }
+
+ @Override
+ public void setAnchorSelectionIndex(int index) {
+ delegate.setAnchorSelectionIndex(index);
+ }
+
+ @Override
+ public int getLeadSelectionIndex() {
+ return delegate.getLeadSelectionIndex();
+ }
+
+ @Override
+ public void setLeadSelectionIndex(int index) {
+ delegate.setLeadSelectionIndex(index);
+ }
+
+ @Override
+ public void clearSelection() {
+ delegate.clearSelection();
+ }
+
+ @Override
+ public boolean isSelectionEmpty() {
+ return delegate.isSelectionEmpty();
+ }
+
+ @Override
+ public void insertIndexInterval(int index, int length, boolean before) {
+ delegate.insertIndexInterval(index, length, before);
+ }
+
+ @Override
+ public void removeIndexInterval(int index0, int index1) {
+ delegate.removeIndexInterval(index0, index1);
+ }
+
+ @Override
+ public void setValueIsAdjusting(boolean valueIsAdjusting) {
+ delegate.setValueIsAdjusting(valueIsAdjusting);
+ }
+
+ @Override
+ public boolean getValueIsAdjusting() {
+ return delegate.getValueIsAdjusting();
+ }
+
+ @Override
+ public void setSelectionMode(int selectionMode) {
+ delegate.setSelectionMode(selectionMode);
+ }
+
+ @Override
+ public int getSelectionMode() {
+ return delegate.getSelectionMode();
+ }
+
+ @Override
+ public void addListSelectionListener(ListSelectionListener x) {
+ delegate.addListSelectionListener(x);
+ }
+
+ @Override
+ public void removeListSelectionListener(ListSelectionListener x) {
+ delegate.removeListSelectionListener(x);
+ }
+}
Added: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-delete.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-delete.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: jaxx/trunk/jaxx-runtime-swing-widget/pom.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-swing-widget/pom.xml 2009-05-05 00:02:46 UTC (rev 1385)
+++ jaxx/trunk/jaxx-runtime-swing-widget/pom.xml 2009-05-06 05:44:44 UTC (rev 1386)
@@ -1,3 +1,4 @@
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -25,6 +26,16 @@
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.swinglabs</groupId>
+ <artifactId>swingx</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.swinglabs</groupId>
+ <artifactId>swing-worker</artifactId>
+ </dependency>
+
</dependencies>
<!-- ************************************************************* -->
@@ -93,7 +104,7 @@
</goals>
</execution>
</executions>
- </plugin>
+ </plugin>
</plugins>
</build>
Added: jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx
===================================================================
--- jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx 2009-05-06 05:44:44 UTC (rev 1386)
@@ -0,0 +1,110 @@
+<Table fill='both' insets='0'
+ onFocusGained='combobox.requestFocus()'
+ onFocusLost='hidePopup()'>
+
+<!--fill='both' insets='0'-->
+ <!-- auto complete property -->
+ <Boolean id='autoComplete' javaBean='false'/>
+
+ <!-- show reset property -->
+ <Boolean id='showReset' javaBean='false'/>
+
+ <!-- show decorator property -->
+ <Boolean id='showDecorator' javaBean='true'/>
+
+ <Boolean id='editable' javaBean='true'/>
+
+ <!-- bean property linked state -->
+ <String id='property' javaBean='""'/>
+
+ <!-- bean property -->
+ <Object id='bean' javaBean='null'/>
+
+ <!-- selectedItem property -->
+ <Object id='selectedItem' javaBean='null'/>
+
+ <!-- sort index property -->
+ <Integer id='index' javaBean='0'/>
+
+ <!-- datas of the combo-box -->
+ <java.util.List id='data' javaBean='null'/>
+
+ <!-- model of sorted property -->
+ <ButtonGroup id='indexes' useToolTipText='true'
+ onStateChanged='setIndex((Integer)indexes.getSelectedValue())'/>
+
+ <!-- ui handler -->
+ <EntityComboBoxHandler id='handler' constructorParams='this'/>
+
+ <String id='selectedToolTipText' javaBean='null'/>
+
+ <String id='notSelectedToolTipText' javaBean='null'/>
+
+ <String id='popupTitleText' javaBean='null'/>
+
+ <String id='i18nPrefix' javaBean='"observe.common."'/>
+
+ <!-- popup to change sorted property-->
+ <JPopupMenu id='popup'
+ border='{new TitledBorder(_("entitycombobox.popup.title"))}'
+ onPopupMenuWillBecomeInvisible='getChangeDecorator().setSelected(false)'
+ onPopupMenuCanceled='getChangeDecorator().setSelected(false)'>
+ <JLabel id='popupLabel'/>
+ <JSeparator/>
+ </JPopupMenu>
+
+ <script><![CDATA[
+import static org.codelutin.i18n.I18n.n_;
+
+public static final String DEFAULT_POPUP_LABEL = n_("entitycombobox.popup.label");
+
+public static final String DEFAULT_SELECTED_TOOLTIP = n_("entitycombobox.sort.on");
+
+public static final String DEFAULT_NOT_SELECTED_TOOLTIP = n_("entitycombobox.sort.off");
+
+public <O> void init(jaxx.runtime.JXPathDecorator<O> decorator, java.util.List<O> data) {
+ handler.init(decorator, data);
+}
+
+protected void hidePopup() {
+ if (popup.isVisible()) {
+ popup.setVisible(false);
+ }
+}
+]]>
+ </script>
+ <row>
+ <cell anchor='west'>
+ <!-- le boutton pour reinitialiser la valeur sélectionnée -->
+ <JToolBar floatable='false' borderPainted='false' visible='{isShowReset()}'>
+ <JButton actionIcon='combobox-reset'
+ toolTipText='entitycombobox.action.reset.tip'
+ focusable='false'
+ focusPainted='false'
+ enabled='{isEnabled()}'
+ onActionPerformed='setSelectedItem(null)'/>
+ </JToolBar>
+
+ </cell>
+ <cell weightx='1'>
+ <!-- la liste déroulante -->
+ <JComboBox id='combobox'
+ selectedItem='{getSelectedItem()}'
+ enabled='{isEnabled()}'
+ editable='{isEditable()}'
+ onFocusGained='hidePopup()'
+ onItemStateChanged='setSelectedItem(combobox.getSelectedItem())'/>
+ </cell>
+ <cell anchor='east' fill='both' insets='0'>
+ <!-- le boutton pour changer le tri -->
+ <JToolBar floatable='false' borderPainted='false' visible='{isShowDecorator()}'>
+ <JToggleButton id='changeDecorator'
+ actionIcon='combobox-sort'
+ toolTipText='entitycombobox.action.sort.tip'
+ focusable='false'
+ focusPainted='false'
+ onActionPerformed='getHandler().togglePopup()'/>
+ </JToolBar>
+ </cell>
+ </row>
+</Table>
Added: jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java 2009-05-06 05:44:44 UTC (rev 1386)
@@ -0,0 +1,454 @@
+package jaxx.runtime.swing;
+
+import java.awt.Component;
+import jaxx.runtime.JXPathDecorator;
+import jaxx.runtime.MultiJXPathDecorator;
+import jaxx.runtime.Util;
+import jaxx.runtime.SwingUtil;
+import org.apache.commons.beanutils.PropertyUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import static org.codelutin.i18n.I18n._;
+import static org.codelutin.i18n.I18n.n_;
+import org.jdesktop.swingx.autocomplete.ObjectToStringConverter;
+
+import javax.swing.JPopupMenu;
+import javax.swing.JRadioButtonMenuItem;
+import javax.swing.JToggleButton;
+import javax.swing.SwingUtilities;
+import javax.swing.text.Document;
+import javax.swing.text.JTextComponent;
+import java.awt.Dimension;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.beans.Introspector;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
+import java.util.List;
+import javax.swing.JComboBox;
+import jaxx.runtime.Decorator;
+import org.jdesktop.swingx.autocomplete.AutoCompletePropertyChangeListener;
+
+/**
+ * Le handler d'un {@link EntityComboBox}.
+ * <p/>
+ * Note: ce handler n'est pas staeless et n'est donc pas partageable entre plusieurs ui.
+ *
+ * @param <O> le type des objet contenus dans le modèle du composant.
+ *
+ * @author chemit
+ * @see EntityComboBox
+ */
+public class EntityComboBoxHandler<O> implements PropertyChangeListener {
+
+ public static final Log log = LogFactory.getLog(EntityComboBoxHandler.class);
+ public static final String SELECTED_ITEM_PROPERTY = "selectedItem";
+ public static final String INDEX_PROPERTY = "index";
+ public static final String AUTO_COMPLETE_PROPERTY = "autoComplete";
+ public static final String DATA_PROPERTY = "data";
+ /** ui if the handler */
+ protected EntityComboBox ui;
+ /** the mutator method on the property of boxed bean in the ui */
+ protected Method mutator;
+ /** the original document of the combbo box editor (keep it to make possible undecorate) */
+ protected Document originalDocument;
+ /** the convertor used to auto-complete */
+ protected ObjectToStringConverter convertor;
+ /** the decorator of data */
+ protected MultiJXPathDecorator<O> decorator;
+ protected boolean init;
+
+ public EntityComboBoxHandler(EntityComboBox ui) {
+ this.ui = ui;
+ }
+ protected final FocusListener EDITOR_TEXT_COMP0NENT_FOCUSLISTENER = new FocusListener() {
+
+ @Override
+ public void focusGained(FocusEvent e) {
+ if (log.isDebugEnabled()) {
+ log.debug("close popup from " + e);
+ }
+ ui.getPopup().setVisible(false);
+ }
+
+ @Override
+ public void focusLost(FocusEvent e) {
+ }
+ };
+
+ /**
+ * Initialise le handler de l'ui
+ *
+ * @param decorator le decorateur a utiliser
+ * @param data la liste des données a gérer
+ */
+ public void init(JXPathDecorator<O> decorator, List<O> data) {
+
+ if (init) {
+ throw new IllegalStateException("can not init the handler twice");
+ }
+ init = true;
+ if (decorator == null) {
+ throw new NullPointerException("can not have a null decorator as parameter");
+ }
+
+ JAXXButtonGroup indexes = ui.getIndexes();
+
+ MultiJXPathDecorator<O> d;
+ if (decorator instanceof MultiJXPathDecorator<?>) {
+ // should clone decorator ?
+ d = (MultiJXPathDecorator<O>) decorator;
+ } else {
+ d = MultiJXPathDecorator.newDecorator(decorator.getInternalClass(), decorator.getInitialExpression(), " - ");
+ }
+ this.decorator = d;
+
+ // init combobox renderer base on given decorator
+ ui.getCombobox().setRenderer(Util.newDecoratedListCellRenderer(d));
+
+ this.convertor = newDecoratedObjectToStringConverter(d);
+
+ // keep a trace of original document (to make possible reverse autom-complete)
+ JTextComponent editorComponent = (JTextComponent) ui.getCombobox().getEditor().getEditorComponent();
+ this.originalDocument = editorComponent.getDocument();
+
+ // build popup
+ preparePopup(d);
+
+ ui.autoComplete = true;
+
+ ui.addPropertyChangeListener(this);
+
+ // set datas
+ ui.setData(data);
+
+ // select sort button
+ indexes.setSelectedButton(ui.getIndex());
+ }
+
+ /** Toggle the popup visible state. */
+ public void togglePopup() {
+ boolean newValue = !ui.getPopup().isVisible();
+
+ if (log.isTraceEnabled()) {
+ log.trace(newValue);
+ }
+
+ if (!newValue) {
+ if (ui.getPopup() != null) {
+ ui.getPopup().setVisible(false);
+ }
+ return;
+ }
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ ui.getPopup().pack();
+ Dimension dim = ui.getPopup().getPreferredSize();
+ JToggleButton invoker = ui.getChangeDecorator();
+ ui.getPopup().show(invoker, (int) (invoker.getPreferredSize().getWidth() - dim.getWidth()), invoker.getHeight());
+ }
+ });
+ }
+
+ /**
+ * Modifie l'état autoComplete de l'ui.
+ *
+ * @param oldValue l'ancienne valeur
+ * @param newValue la nouvelle valeur
+ */
+ protected void setAutoComplete(Boolean oldValue, Boolean newValue) {
+ oldValue = oldValue != null && oldValue;
+ newValue = newValue != null && newValue;
+ if (oldValue == newValue) {
+ return;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("autocomplete state : <" + oldValue + " to " + newValue + ">");
+ }
+ if (!newValue) {
+ JTextComponent editorComponent = (JTextComponent) ui.getCombobox().getEditor().getEditorComponent();
+ editorComponent.removeFocusListener(EDITOR_TEXT_COMP0NENT_FOCUSLISTENER);
+ undecorate(ui.getCombobox(), originalDocument);
+ } else {
+ decorate(ui.getCombobox(), convertor);
+ JTextComponent editorComponent = (JTextComponent) ui.getCombobox().getEditor().getEditorComponent();
+ editorComponent.addFocusListener(EDITOR_TEXT_COMP0NENT_FOCUSLISTENER);
+ }
+ }
+
+ /**
+ * Modifie l'index du décorateur
+ *
+ * @param oldValue l'ancienne valeur
+ * @param newValue la nouvelle valeur
+ */
+ @SuppressWarnings({"unchecked"})
+ protected void setIndex(Integer oldValue, Integer newValue) {
+ if (newValue.equals(oldValue)) {
+ return;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("check state : <" + oldValue + " to " + newValue + ">");
+ }
+
+ // change decorator context
+ decorator.setContextIndex(newValue);
+
+ // keep selected item
+ Object previousSelectedItem = ui.getSelectedItem();
+ Boolean wasAutoComplete = ui.isAutoComplete();
+
+ if (wasAutoComplete) {
+ ui.setAutoComplete(false);
+ }
+
+ // remove autocomplete
+ if (previousSelectedItem != null) {
+ ui.getCombobox().setSelectedItem(null);
+ ui.selectedItem = null;
+ }
+
+
+ try {
+ // Sort data with the decorator jxpath tokens.
+ JXPathDecorator.sort(decorator, ui.getData(), newValue);
+ } catch (Exception e) {
+ log.warn(e.getMessage(), e);
+ //System.out.println("newValue :: "+decorator+" : "+newValue);
+ //System.out.println("datas :: "+ui.getData());
+ }
+
+ // reload the model
+ SwingUtil.fillComboBox(ui.getCombobox(), ui.getData(), null);
+
+ if (wasAutoComplete) {
+ ui.setAutoComplete(true);
+ }
+
+ if (previousSelectedItem != null) {
+ ui.setSelectedItem(previousSelectedItem);
+ }
+
+ ui.getCombobox().requestFocus();
+ }
+
+ /**
+ * Modifie la valeur sélectionnée dans la liste déroulante.
+ *
+ * @param oldValue l'ancienne valeur
+ * @param newValue la nouvelle valeur
+ */
+ protected void setSelectedItem(Object oldValue, Object newValue) {
+ if (ui.getBean() == null) {
+ return;
+ }
+
+ if (newValue == null) {
+ if (ui.getCombobox().getSelectedItem() == null) {
+ return;
+ }
+ ui.getCombobox().setSelectedItem(null);
+
+ if (ui.isAutoComplete()) {
+ ui.setAutoComplete(false);
+ ui.setAutoComplete(true);
+ }
+
+ if (oldValue == null) {
+ return;
+ }
+ }
+ if (log.isDebugEnabled()) {
+ log.debug(ui.getProperty() + " on " + ui.getBean().getClass() + " :: " + oldValue + " to " + newValue);
+ }
+
+ try {
+ Method mut = getMutator();
+ if (mut != null) {
+ mut.invoke(ui.getBean(), newValue);
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /** @return le document de l'éditeur avant complétion. */
+ public Document getOriginalDocument() {
+ return originalDocument;
+ }
+
+ public MultiJXPathDecorator<O> getDecorator() {
+ return decorator;
+ }
+
+ /**
+ * Creation de l'ui pour modifier le décorateur.
+ *
+ * @param decorator le decorateur a utiliser
+ */
+ protected void preparePopup(MultiJXPathDecorator<?> decorator) {
+ String selectedTip = ui.getSelectedToolTipText();
+ if (selectedTip == null) {
+ // use default selected tip text
+ selectedTip = EntityComboBox.DEFAULT_SELECTED_TOOLTIP;
+ }
+ String notSelectedTip = ui.getNotSelectedToolTipText();
+ if (notSelectedTip == null) {
+ // use default selected tip text
+ notSelectedTip = EntityComboBox.DEFAULT_NOT_SELECTED_TOOLTIP;
+ }
+ JPopupMenu popup = ui.getPopup();
+
+ //Container container = ui.getIndexesContainer();
+ for (int i = 0, max = decorator.getNbContext(); i < max; i++) {
+ String property = ui.getI18nPrefix() + decorator.getProperty(i);
+// String property = "observe.common." + decorator.getProperty(i);
+ String propertyI18n = _(property);
+ JRadioButtonMenuItem button = new JRadioButtonMenuItem(propertyI18n);
+ button.putClientProperty(JAXXButtonGroup.BUTTON8GROUP_CLIENT_PROPERTY, ui.getIndexes());
+ button.putClientProperty(JAXXButtonGroup.VALUE_CLIENT_PROPERTY, i);
+ popup.add(button);
+ if (selectedTip != null) {
+ button.putClientProperty(JAXXButtonGroup.SELECTED_TIP_CLIENT_PROPERTY, _(selectedTip, propertyI18n));
+ }
+ if (notSelectedTip != null) {
+ button.putClientProperty(JAXXButtonGroup.NOT_SELECTED_TIP_CLIENT_PROPERTY, _(notSelectedTip, propertyI18n));
+ }
+ button.setSelected(false);
+ ui.getIndexes().add(button);
+ }
+ String title = ui.getPopupTitleText();
+ if (title == null) {
+ // use default popup title
+ title = EntityComboBox.DEFAULT_POPUP_LABEL;
+
+ Class<?> internalClass = decorator.getInternalClass();
+ String beanI18nKey;
+ if (internalClass == null) {
+ beanI18nKey = n_("entitycombobox.unknown.type");
+ } else {
+ beanI18nKey = ui.getI18nPrefix() + Introspector.decapitalize(internalClass.getSimpleName());
+ //beanI18nKey = "observe.common." + Introspector.decapitalize(internalClass.getSimpleName());
+ }
+ String beanI18n = _(beanI18nKey);
+ title = _(title, beanI18n);
+ } else {
+ title = _(title);
+ }
+ ui.getPopupLabel().setText(title);
+ ui.getPopup().setLabel(title);
+ ui.getPopup().invalidate();
+ }
+
+ public Class<?> getTargetClass() {
+ Method m = getMutator();
+ return m == null ? null : m.getParameterTypes()[0];
+ }
+
+ /** @return le mutateur a utiliser pour modifier le bean associé. */
+ protected Method getMutator() {
+ if (mutator == null) {
+ Object bean = ui.getBean();
+ if (bean == null) {
+ throw new NullPointerException("could not find bean in " + ui);
+ }
+ String property = ui.getProperty();
+ if (property == null) {
+ throw new NullPointerException("could not find property in " + ui);
+ }
+
+ try {
+ PropertyDescriptor descriptor = PropertyUtils.getPropertyDescriptor(bean, property);
+ if (descriptor != null) {
+ mutator = descriptor.getWriteMethod();
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ return mutator;
+ }
+
+ /**
+ * Encapsule un {@link Decorator} dans un {@link ObjectToStringConverter}.
+ *
+ * @param decorator le decorateur a encapsuler.
+ * @return le converter encapsule dans un {@link ObjectToStringConverter}
+ */
+ public static ObjectToStringConverter newDecoratedObjectToStringConverter(final Decorator<?> decorator) {
+
+ return new ObjectToStringConverter() {
+
+ @Override
+ public String getPreferredStringForItem(Object item) {
+ return item instanceof String ? (String) item : (item == null ? "" : decorator.toString(item));
+ }
+ };
+ }
+
+ /**
+ * Ajout l'auto-complétion sur une liste déroulante, en utilisant le
+ * converteur donné pour afficher les données.
+ *
+ * @param combo la combo à décorer
+ * @param convertor le converter utilisé pour afficher les données.
+ */
+ public static void decorate(JComboBox combo, ObjectToStringConverter convertor) {
+
+ org.jdesktop.swingx.autocomplete.AutoCompleteDecorator.decorate(combo, convertor);
+ }
+
+ /**
+ * Désactive l'aut-complétion sur une liste déroulante, en y repositionnant
+ * le modèle du document d'édition d'avant auto-complétion.
+ *
+ * @param combo la liste déroulante à décorer
+ * @param originalDocument le document original de l'édtieur de la
+ * liste déroulante.
+ */
+ public static void undecorate(JComboBox combo, Document originalDocument) {
+
+ // has not to be editable
+ combo.setEditable(false);
+
+ // configure the text component=editor component
+ Component c = combo.getEditor().getEditorComponent();
+ JTextComponent editorComponent = (JTextComponent) c;
+ editorComponent.setDocument(originalDocument);
+ editorComponent.setText(null);
+ //remove old property change listener
+ for (PropertyChangeListener l : c.getPropertyChangeListeners("editor")) {
+ if (l instanceof AutoCompletePropertyChangeListener) {
+ c.removePropertyChangeListener("editor", l);
+ }
+ }
+ }
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ String propertyName = evt.getPropertyName();
+
+ if (SELECTED_ITEM_PROPERTY.equals(propertyName)) {
+ setSelectedItem(evt.getOldValue(), evt.getNewValue());
+ return;
+ }
+
+ if (INDEX_PROPERTY.equals(propertyName)) {
+ setIndex((Integer) evt.getOldValue(), (Integer) evt.getNewValue());
+ return;
+ }
+ if (AUTO_COMPLETE_PROPERTY.equals(propertyName)) {
+ setAutoComplete((Boolean) evt.getOldValue(), (Boolean) evt.getNewValue());
+ return;
+ }
+ if (DATA_PROPERTY.equals(propertyName)) {
+ // list has changed, force reload of index
+ setIndex(-1, ui.getIndex());
+ }
+
+ }
+}
Added: jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/ErrorDialogUI.jaxx
===================================================================
--- jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/ErrorDialogUI.jaxx (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/ErrorDialogUI.jaxx 2009-05-06 05:44:44 UTC (rev 1386)
@@ -0,0 +1,66 @@
+<JDialog title='errorUI.title' modal='true'>
+ <script><![CDATA[
+protected static ErrorDialogUI instance;
+public static void init(Frame frame) {
+ disposeUI();
+ instance = new ErrorDialogUI(frame);
+ instance.setModalityType(ModalityType.TOOLKIT_MODAL);
+}
+public static void showError(Exception e) {
+ if (instance == null) {
+ instance = new ErrorDialogUI();
+ }
+ instance.getErrorMessage().setText(e.getMessage());
+ StringWriter w = new StringWriter();
+ e.printStackTrace(new PrintWriter(w));
+ instance.getErrorStack().setText(w.toString());
+ instance.getErrorStack().setCaretPosition(0);
+ instance.pack();
+ jaxx.runtime.SwingUtil.center(instance.getContextValue(JFrame.class,"parent"), instance);
+ instance.setVisible(true);
+}
+public static void disposeUI() {
+ instance=null;
+}
+
+public ErrorDialogUI(Frame frame) {
+ super(frame);
+ if (frame!=null) {
+ setContextValue(frame);
+ setContextValue(frame,"parent");
+ }
+
+}
+
+JRootPane rootPane = getRootPane();
+rootPane.setDefaultButton(close);
+rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close");
+rootPane.getActionMap().put("close", close.getAction());
+ ]]></script>
+ <Table>
+ <row fill='both'>
+ <cell>
+ <JPanel>
+ <JLabel text='errorUI.message'/>
+ </JPanel>
+ </cell>
+ </row>
+ <row fill='both'>
+ <cell>
+ <JLabel id='errorMessage'/>
+ </cell>
+ </row>
+ <row fill='both' weightx='1' weighty='1'>
+ <cell>
+ <JScrollPane width='600' height='200'>
+ <JTextArea id='errorStack' editable='false' font-size='9'/>
+ </JScrollPane>
+ </cell>
+ </row>
+ <row fill='horizontal'>
+ <cell>
+ <JButton id='close' text='errorUI.action.close' onActionPerformed='dispose()'/>
+ </cell>
+ </row>
+ </Table>
+</JDialog>
Added: jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/TimeEditor.css
===================================================================
--- jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/TimeEditor.css (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/TimeEditor.css 2009-05-06 05:44:44 UTC (rev 1386)
@@ -0,0 +1,31 @@
+#title{
+ text:{getLabel()};
+ horizontalAlignment:center;
+}
+
+#hour{
+ value:{getTimeModel()/60};
+ enabled:{isEnabled()};
+ model:{new SpinnerNumberModel(0,0,23,1)};
+}
+
+#labelH {
+ text:"H";
+ horizontalAlignment:center;
+}
+#minute{
+ value:{getTimeModel()%60};
+ enabled:{isEnabled()};
+ model:{new SpinnerNumberModel(0,0,59,1)};
+}
+
+#slider{
+ font-size: 11;
+ paintTicks:true;
+ paintLabels:true;
+ majorTickSpacing:60;
+ minorTickSpacing:30;
+ value:{getTimeModel()};
+ enabled:{isEnabled()};
+ model:{new DefaultBoundedRangeModel(0,1,0,60*24)};
+}
Added: jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/TimeEditor.jaxx
===================================================================
--- jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/TimeEditor.jaxx (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/TimeEditor.jaxx 2009-05-06 05:44:44 UTC (rev 1386)
@@ -0,0 +1,56 @@
+
+<JPanel layout='{new BorderLayout()}'>
+
+ <style source='TimeEditor.css'/>
+
+ <!-- bean property -->
+ <String id='property' javaBean='""'/>
+
+ <!-- title -->
+ <String id='label' javaBean='""'/>
+
+ <!-- bean -->
+ <Object id='bean' javaBean='null'/>
+
+ <!-- time model -->
+ <Integer id="timeModel" javaBean='0'/>
+
+ <!-- the real date -->
+ <java.util.Date id="date" javaBean='null'/>
+
+ <!-- ui handler -->
+ <TimeEditorHandler id='handler' constructorParams='this'/>
+
+ <script><![CDATA[
+public void init() {
+ handler.init();
+}
+]]>
+ </script>
+
+ <Table constraints='BorderLayout.NORTH' fill='horizontal' insets='0'>
+ <row>
+ <cell>
+ <JLabel id='title'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel/>
+ </cell>
+ <cell>
+ <JSpinner id='hour'
+ onStateChanged='setTimeModel((Integer)hour.getValue()* 60 + timeModel % 60)'/>
+ </cell>
+ <cell>
+ <JLabel id='labelH'/>
+ </cell>
+ <cell>
+ <JSpinner id='minute'
+ onStateChanged='setTimeModel((timeModel / 60) * 60 + (Integer) minute.getValue())'/>
+ </cell>
+ </row>
+ </Table>
+
+ <JSlider id='slider' constraints='BorderLayout.SOUTH'
+ onStateChanged='if (!slider.getValueIsAdjusting()) setTimeModel(slider.getValue());'/>
+
+</JPanel>
Added: jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/TimeEditorHandler.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/TimeEditorHandler.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/TimeEditorHandler.java 2009-05-06 05:44:44 UTC (rev 1386)
@@ -0,0 +1,204 @@
+package jaxx.runtime.swing.editor;
+
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import org.apache.commons.beanutils.PropertyUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.JLabel;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.Map;
+import javax.swing.JSlider;
+import javax.swing.plaf.basic.BasicSliderUI;
+
+/** @author chemit */
+public class TimeEditorHandler {
+
+ public static final Log log = LogFactory.getLog(TimeEditorHandler.class);
+ public static final String BEAN_PROPERTY = "bean";
+ public static final String PROPERTY_PROPERTY = "property";
+ public static final String DATE_PROPERTY = "date";
+ public static final String TIME_MODEL_PROPERTY = "timeModel";
+ /** editor ui */
+ protected TimeEditor editor;
+ /** the mutator method on the property of boxed bean in the editor */
+ protected Method mutator;
+ protected Calendar calendar;
+
+ public TimeEditorHandler(TimeEditor ui) {
+ this.editor = ui;
+ this.calendar = Calendar.getInstance();
+ }
+
+ public void init() {
+
+ if (editor.getBean() == null) {
+ throw new NullPointerException("can not have a null bean in ui " + editor);
+ }
+
+ // create slider labels
+ Map<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>();
+ for (int i = 0; i < 25; i += 2) {
+ labelTable.put(i * 60, new JLabel(i + ""));
+ }
+ JSlider slider = editor.getSlider();
+ slider.setLabelTable((Dictionary<?,?>) labelTable);
+
+ MouseAdapter m = new MouseAdapter() {
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ // set the value
+ int value = getSliderValue(e);
+ JSlider slider = (JSlider) e.getComponent();
+ slider.setValueIsAdjusting(true);
+ slider.setValue(value);
+ slider.setValueIsAdjusting(false);
+ showToolTip(e);
+ e.consume();
+ }
+
+ @Override
+ public void mouseDragged(MouseEvent e) {
+ showToolTip(e);
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent e) {
+ showToolTip(e);
+ }
+
+ @Override
+ public void mouseMoved(MouseEvent e) {
+ showToolTip(e);
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent e) {
+ showToolTip(e);
+ }
+
+ int getSliderValue(MouseEvent e) {
+ JSlider slider = (JSlider) e.getSource();
+ int value = -1;
+ if (slider.getUI() instanceof BasicSliderUI) {
+ BasicSliderUI ui = (BasicSliderUI) slider.getUI();
+ value = slider.getOrientation() == JSlider.HORIZONTAL
+ ? ui.valueForXPosition(e.getX())
+ : ui.valueForYPosition(e.getY());
+ }
+ return value;
+ }
+
+ void showToolTip(MouseEvent e) {
+
+ int value = getSliderValue(e);
+ if (value == -1) {
+ return;
+ }
+ int h = value / 60;
+ int m = value % 60;
+
+ String text = "";
+ if (h < 10) {
+ text = "0";
+ }
+ text += h + " : ";
+ if (m < 10) {
+ text += "0";
+ }
+ text += m;
+
+ JSlider slider = (JSlider) e.getSource();
+ slider.setToolTipText(text);
+
+ }
+ };
+ slider.addMouseListener(m);
+ slider.addMouseMotionListener(m);
+
+ // listen when date changes (should come from outside)
+ editor.addPropertyChangeListener(DATE_PROPERTY, new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ Date date = (Date) evt.getNewValue();
+
+ if (date == null) {
+ return;
+ }
+ calendar.setTime(date);
+ int hours = calendar.get(Calendar.HOUR_OF_DAY);
+ int minutes = calendar.get(Calendar.MINUTE);
+ if (log.isDebugEnabled()) {
+ log.debug("date changed : new value " + hours + ":" + minutes);
+ }
+ getEditor().setTimeModel((hours * 60) + minutes);
+ }
+ });
+
+ // listen when time model changes (should come from editor)
+ editor.addPropertyChangeListener(TIME_MODEL_PROPERTY, new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ Integer time = (Integer) evt.getNewValue();
+ int hours = time / 60;
+ int minutes = time % 60;
+ calendar.set(Calendar.HOUR_OF_DAY, hours);
+ calendar.set(Calendar.MINUTE, minutes);
+ setDate(null, calendar.getTime());
+ }
+ });
+ }
+
+ public TimeEditor getEditor() {
+ return editor;
+ }
+
+ protected void setDate(Date oldValue, Date newValue) {
+ if (editor.getBean() == null) {
+ return;
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug(editor.getProperty() + " on " + editor.getBean().getClass() + " :: " + oldValue + " to " + newValue);
+ }
+
+ try {
+ getMutator().invoke(editor.getBean(), newValue);
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ protected Method getMutator() {
+ if (mutator == null) {
+ Object bean = editor.getBean();
+ if (bean == null) {
+ throw new NullPointerException("could not find bean in " + editor);
+ }
+ String property = editor.getProperty();
+ if (property == null) {
+ throw new NullPointerException("could not find property in " + editor);
+ }
+
+ try {
+ PropertyDescriptor descriptor = PropertyUtils.getPropertyDescriptor(bean, property);
+ mutator = descriptor.getWriteMethod();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ return mutator;
+ }
+}
\ No newline at end of file
Modified: jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties
===================================================================
--- jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties 2009-05-05 00:02:46 UTC (rev 1385)
+++ jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties 2009-05-06 05:44:44 UTC (rev 1386)
@@ -10,8 +10,21 @@
8=
9=
H=
+entitycombobox.action.reset.tip=
+entitycombobox.action.sort.tip=
+entitycombobox.popup.label=
+entitycombobox.popup.title=
+entitycombobox.sort.off=
+entitycombobox.sort.on=
+entitycombobox.unknown.type=
+errorUI.action.close=
+errorUI.message=
+errorUI.title=
numbereditor.action.reset.tip=Reset
numbereditor.action.show.tip=Show numeric panel
numbereditor.clearAll=C
numbereditor.clearOne=CE
numbereditor.toggleSign=+/-
+observe.action.close=
+observe.message.error.dialog=
+observe.title.error.dialog=
Modified: jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties
===================================================================
--- jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties 2009-05-05 00:02:46 UTC (rev 1385)
+++ jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties 2009-05-06 05:44:44 UTC (rev 1386)
@@ -10,6 +10,16 @@
8=
9=
H=
+entitycombobox.action.reset.tip=R\u00E9initialiser la valeur de la liste d\u00E9roulante
+entitycombobox.action.sort.tip=Modifier le tri de la liste d\u00E9roulante
+entitycombobox.popup.label=Objet '%1$s'
+entitycombobox.popup.title=Modifier le tri
+entitycombobox.sort.off=Cliquer pour activer le tri sur la propri\u00E9t\u00E9 '%1$s'
+entitycombobox.sort.on=Le tri est effectu\u00E9 sur la propri\u00E9t\u00E9 '%1$s'
+entitycombobox.unknown.type=Objet de type inconnu
+errorUI.action.close=Fermer
+errorUI.message=Une erreur est survenue \!
+errorUI.title=Erreur...
numbereditor.action.reset.tip=R\u00E9initialiser
numbereditor.action.show.tip=Afficher le pav\u00E9 num\u00E9rique
numbereditor.clearAll=C
Modified: jaxx/trunk/jaxx-runtime-validator/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/changelog.txt 2009-05-05 00:02:46 UTC (rev 1385)
+++ jaxx/trunk/jaxx-runtime-validator/changelog.txt 2009-05-06 05:44:44 UTC (rev 1386)
@@ -1,4 +1,5 @@
1.5
+ * 20090506 [chemit] - on chained validation, do not changed parentValidator changed state
* 20090503 [chemit] - add a new property collectionFieldName on CollectionFieldExpression validator to be able to validate a collection but not for a collection field
- add doRevalidate on BeanValidator to validate and update internal states (validate method does not update internal state and should be used in outside...)
Modified: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator.java 2009-05-05 00:02:46 UTC (rev 1385)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator.java 2009-05-06 05:44:44 UTC (rev 1386)
@@ -380,7 +380,13 @@
if (parentValidator != null) {
// chained validation
- parentValidator.l.propertyChange(null);
+ // the parent validator should not be changed from this validation
+ boolean wasModified = parentValidator.isChanged();
+ parentValidator.doValidate();
+ if (!wasModified) {
+ // push back old state
+ parentValidator.setChanged(false);
+ }
}
}
Modified: jaxx/trunk/pom.xml
===================================================================
--- jaxx/trunk/pom.xml 2009-05-05 00:02:46 UTC (rev 1385)
+++ jaxx/trunk/pom.xml 2009-05-06 05:44:44 UTC (rev 1386)
@@ -34,12 +34,12 @@
<module>jaxx-example</module>
</modules>
- <dependencies>
+ <!--dependencies>
<dependency>
<groupId>org.codelutin</groupId>
<artifactId>lutinutil</artifactId>
</dependency>
- </dependencies>
+ </dependencies-->
<dependencyManagement>
<dependencies>
@@ -121,6 +121,18 @@
<version>3.0.1</version>
</dependency>
+ <dependency>
+ <groupId>org.swinglabs</groupId>
+ <artifactId>swingx</artifactId>
+ <version>${swingx.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.swinglabs</groupId>
+ <artifactId>swing-worker</artifactId>
+ <version>1.1</version>
+ </dependency>
+
</dependencies>
</dependencyManagement>
@@ -147,10 +159,11 @@
<labs.project>buix</labs.project>
<!-- libs version -->
- <lutinutil.version>1.0.3</lutinutil.version>
+ <lutinutil.version>1.0.5</lutinutil.version>
<jaxx.version>${project.version}</jaxx.version>
<i18n.version>0.11</i18n.version>
<lutinpluginutil.version>0.4</lutinpluginutil.version>
+ <swingx.version>0.9.6</swingx.version>
<maven.version>2.0.10</maven.version>
</properties>
1
0
r1384 - in jaxx/trunk: jaxx-example/src/main/java/jaxx/demo jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor
by sletellier@users.labs.libre-entreprise.org 04 May '09
by sletellier@users.labs.libre-entreprise.org 04 May '09
04 May '09
Author: sletellier
Date: 2009-05-04 23:55:44 +0000 (Mon, 04 May 2009)
New Revision: 1384
Modified:
jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/NumberEditorDemo.jaxx
jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java
Log:
Determine si la propriete concernee est un float
Modified: jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/NumberEditorDemo.jaxx
===================================================================
--- jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/NumberEditorDemo.jaxx 2009-05-04 23:09:13 UTC (rev 1383)
+++ jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/NumberEditorDemo.jaxx 2009-05-04 23:55:44 UTC (rev 1384)
@@ -95,8 +95,7 @@
model='{demoModel.getPositifFloat()}'
autoPopup='false'
showPopupButton='true'
- showReset='true'
- useFloat='true'/>
+ showReset='true'/>
</cell>
<cell>
<NumberEditor id='positifFloatEditor2'
@@ -106,8 +105,7 @@
model='{demoModel.getPositifFloat()}'
autoPopup='true'
showPopupButton='true'
- showReset='true'
- useFloat='true'/>
+ showReset='true'/>
</cell>
</row>
<row>
@@ -123,8 +121,7 @@
autoPopup='false'
showPopupButton='true'
showReset='true'
- useSign='true'
- useFloat='true'/>
+ useSign='true'/>
</cell>
<cell>
<NumberEditor id='normalFloatEditor2'
@@ -135,32 +132,9 @@
autoPopup='true'
showPopupButton='true'
showReset='true'
- useSign='true'
- useFloat='true'/>
+ useSign='true'/>
</cell>
</row>
- <row>
- <cell>
-
- </cell>
- <cell>
-
- </cell>
- <cell>
-
- </cell>
- </row>
- <row>
- <cell>
-
- </cell>
- <cell>
-
- </cell>
- <cell>
-
- </cell>
- </row>
</Table>
</DemoPanel>
Modified: jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java 2009-05-04 23:09:13 UTC (rev 1383)
+++ jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java 2009-05-04 23:55:44 UTC (rev 1384)
@@ -33,13 +33,15 @@
public static final String MODEL_PROPERTY = "model";
public static final String AUTO_POPUP_PROPERTY = "autoPopup";
public static final String POPUP_VISIBLE_PROPERTY = "popupVisible";
- public static final String USE_FLOAT_PROPERTY = "useFloat";
+// public static final String USE_FLOAT_PROPERTY = "useFloat";
public static final String USE_SIGN_PROPERTY = "useSign";
public static final String VALIDATE_PROPERTY = "validate";
/** editor ui */
protected NumberEditor editor;
/** the mutator method on the property of boxed bean in the editor */
protected Method mutator;
+ /** the getter method on the property */
+ protected Method getter;
/** a flag to known if mutator accept null value */
protected Boolean acceptNull;
@@ -72,6 +74,11 @@
}
});
editor.getTextField().addMouseListener(new PopupListener());
+
+ // Determine si c'est un float
+ Class type = getGetter().getReturnType();
+ editor.setUseFloat(!type.equals(Integer.class) && !type.equals(int.class));
+
/*if (editor.getResetButton().getIcon() == null) {
editor.getResetButton().setIcon(SwingUtil.createActionIcon("numbereditor-reset"));
}
@@ -141,8 +148,8 @@
} else if (s.endsWith(".")) {
s += "0";
endWithDot = true;
- } else if (s.length() == 1 && s.startsWith("-")) {
- s += "0";
+ } else if (editor.isUseSign() && s.length() == 1 && s.startsWith("-")) {
+ s = "0";
isLess = true;
}
@@ -186,10 +193,12 @@
if (log.isDebugEnabled()) {
log.debug("can apply new model value : " + newValue);
}
- if (!isLess){
- // on peut mettre a jour le model
- editor.setModel(newValue);
+ if (isLess){
+ editor.setModelText("-");
+ return;
}
+ // on peut mettre a jour le model
+ editor.setModel(newValue);
if (endWithDot) {
editor.setModelText(s.substring(0, s.length() - 1));
field.setCaretPosition(oldPosition);
@@ -208,7 +217,12 @@
oldPosition--;
}
field.setText(text);
- field.setCaretPosition(oldPosition);
+ try {
+ field.setCaretPosition(oldPosition);
+ }
+ catch(IllegalArgumentException ex){
+ log.debug("CaretPosition is invalid for position : " + oldPosition, ex);
+ }
}
/**
@@ -383,6 +397,27 @@
return mutator;
}
+ protected Method getGetter() {
+ if (getter == null) {
+ Object bean = editor.getBean();
+ if (bean == null) {
+ throw new NullPointerException("could not find bean in " + editor);
+ }
+ String property = editor.getProperty();
+ if (property == null) {
+ throw new NullPointerException("could not find property in " + editor);
+ }
+
+ try {
+ PropertyDescriptor descriptor = PropertyUtils.getPropertyDescriptor(bean, property);
+ getter = descriptor.getReadMethod();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ return getter;
+ }
+
public Boolean getAcceptNull() {
if (acceptNull == null) {
Method m = getMutator();
1
0
r1382 - in jaxx/trunk: jaxx-example jaxx-example/src/main/java/jaxx/demo jaxx-example/src/main/resources jaxx-example/src/main/resources/i18n jaxx-runtime-swing-widget jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor jaxx-runtime-swing-widget/src/main/resources jaxx-runtime-swing-widget/src/main/resources/i18n jaxx-runtime-swing-widget/src/main/resources/icons
by tchemit@users.labs.libre-entreprise.org 04 May '09
by tchemit@users.labs.libre-entreprise.org 04 May '09
04 May '09
Author: tchemit
Date: 2009-05-04 19:39:58 +0000 (Mon, 04 May 2009)
New Revision: 1382
Added:
jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/NumberEditorDemo.jaxx
jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/NumberEditorDemoModel.java
jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/
jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditor.jaxx
jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java
jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditorPopup.css
jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/icons/
jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/icons/action-numbereditor-calculator.png
jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/icons/action-numbereditor-reset.png
jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/icons/action-numbereditor-validate.png
Modified:
jaxx/trunk/jaxx-example/pom.xml
jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/JAXXDemo.jaxx
jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-en_GB.properties
jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-fr_FR.properties
jaxx/trunk/jaxx-example/src/main/resources/log4j.properties
jaxx/trunk/jaxx-runtime-swing-widget/pom.xml
jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties
jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties
Log:
add NumberEditor + do example
Modified: jaxx/trunk/jaxx-example/pom.xml
===================================================================
--- jaxx/trunk/jaxx-example/pom.xml 2009-05-04 16:50:00 UTC (rev 1381)
+++ jaxx/trunk/jaxx-example/pom.xml 2009-05-04 19:39:58 UTC (rev 1382)
@@ -1,3 +1,4 @@
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -54,6 +55,9 @@
<maven.jar.main.class>jaxx.demo.JAXXDemo</maven.jar.main.class>
+ <jaxx.addProjectClassPath>true</jaxx.addProjectClassPath>
+ <jaxx.addSourcesToClassPath>true</jaxx.addSourcesToClassPath>
+
<!-- jnlp -->
<keystorepath>${codelutin.keystorepath}</keystorepath>
<keystorealias>CodeLutin</keystorealias>
Modified: jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/JAXXDemo.jaxx
===================================================================
--- jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/JAXXDemo.jaxx 2009-05-04 16:50:00 UTC (rev 1381)
+++ jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/JAXXDemo.jaxx 2009-05-04 19:39:58 UTC (rev 1382)
@@ -1,9 +1,13 @@
<Application title="JAXX Demo" width='1024' height='800' defaultCloseOperation='exit_on_close'>
<script><![CDATA[
-org.codelutin.i18n.I18n.init();
+static {
+org.codelutin.i18n.I18n.init("fr", "FR");
+}
void $afterCompleteSetup() {
+
+
try { jaxx.runtime.SwingUtil.initNimbusLoookAndFeel(); } catch (Exception e) { log.error(e.getMessage(), e); }
SwingUtilities.invokeLater(new Runnable() {
@Override
@@ -81,6 +85,9 @@
</item>
<item value='{dataBindingDemo}'/>
<item value='{boxedDecoratorDemo}'/>
+ <item value='Editors'>
+ <item value='{numberEditorDemo}'/>
+ </item>
</item>
</JTree>
</JScrollPane>
@@ -113,6 +120,7 @@
<CounterDemo id='counterDemo' constraints='counterDemo.getLabel()'/>
<CalculatorDemo id='calculatorDemo' constraints='calculatorDemo.getLabel()'/>
<BoxedDecoratorDemo id='boxedDecoratorDemo' constraints='boxedDecoratorDemo.getLabel()'/>
+ <NumberEditorDemo id='numberEditorDemo' constraints='numberEditorDemo.getLabel()'/>
</JPanel>
</JSplitPane>
</Application>
\ No newline at end of file
Added: jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/NumberEditorDemo.jaxx
===================================================================
--- jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/NumberEditorDemo.jaxx (rev 0)
+++ jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/NumberEditorDemo.jaxx 2009-05-04 19:39:58 UTC (rev 1382)
@@ -0,0 +1,166 @@
+
+<DemoPanel>
+ <script><![CDATA[
+import jaxx.runtime.swing.editor.NumberEditor;
+
+void $afterCompleteSetup() {
+ positifIntegerEditor.init();
+ positifIntegerEditor2.init();
+ normalIntegerEditor.init();
+ normalIntegerEditor2.init();
+ positifFloatEditor.init();
+ positifFloatEditor2.init();
+ normalFloatEditor.init();
+ normalFloatEditor2.init();
+}
+]]>
+ </script>
+
+ <!-- model -->
+ <NumberEditorDemoModel id='demoModel'/>
+
+ <Table id='demoPanel' insets='0' fill='both'>
+ <row>
+ <cell weightx='0.5'>
+ <JLabel horizontalAlignment='center' text='numbereditor.type'/>
+ </cell>
+ <cell weightx='0.25'>
+ <JLabel horizontalAlignment='center' text='numbereditor.without.auto.popup'/>
+ </cell>
+ <cell weightx='0.25'>
+ <JLabel horizontalAlignment='center' text='numbereditor.with.auto.popup'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='{_("numbereditor.positive.int", demoModel.getPositifInteger())}'/>
+ </cell>
+ <cell>
+ <NumberEditor id='positifIntegerEditor'
+ property='positifInteger'
+ constructorParams='this'
+ bean='{demoModel}'
+ model='{demoModel.getPositifInteger()}'
+ autoPopup='false'
+ showPopupButton='true'
+ showReset='true'/>
+ </cell>
+ <cell>
+ <NumberEditor id='positifIntegerEditor2'
+ property='positifInteger'
+ constructorParams='this'
+ bean='{demoModel}'
+ model='{demoModel.getPositifInteger()}'
+ autoPopup='true'
+ showPopupButton='true'
+ showReset='true'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='{_("numbereditor.normal.int", demoModel.getNormalInteger())}'/>
+ </cell>
+ <cell>
+ <NumberEditor id='normalIntegerEditor'
+ property='normalInteger'
+ constructorParams='this'
+ bean='{demoModel}'
+ model='{demoModel.getNormalInteger()}'
+ autoPopup='false'
+ showPopupButton='true'
+ showReset='true'
+ useSign='true'/>
+ </cell>
+ <cell>
+ <NumberEditor id='normalIntegerEditor2'
+ property='normalInteger'
+ constructorParams='this'
+ bean='{demoModel}'
+ model='{demoModel.getNormalInteger()}'
+ autoPopup='true'
+ showPopupButton='true'
+ showReset='true'
+ useSign='true'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='{_("numbereditor.positive.float", demoModel.getPositifFloat())}'/>
+ </cell>
+ <cell>
+ <NumberEditor id='positifFloatEditor'
+ property='positifFloat'
+ constructorParams='this'
+ bean='{demoModel}'
+ model='{demoModel.getPositifFloat()}'
+ autoPopup='false'
+ showPopupButton='true'
+ showReset='true'
+ useFloat='true'/>
+ </cell>
+ <cell>
+ <NumberEditor id='positifFloatEditor2'
+ property='positifFloat'
+ constructorParams='this'
+ bean='{demoModel}'
+ model='{demoModel.getPositifFloat()}'
+ autoPopup='true'
+ showPopupButton='true'
+ showReset='true'
+ useFloat='true'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='{_("numbereditor.normal.float", demoModel.getNormalFloat())}'/>
+ </cell>
+ <cell>
+ <NumberEditor id='normalFloatEditor'
+ property='normalFloat'
+ constructorParams='this'
+ bean='{demoModel}'
+ model='{demoModel.getNormalFloat()}'
+ autoPopup='false'
+ showPopupButton='true'
+ showReset='true'
+ useSign='true'
+ useFloat='true'/>
+ </cell>
+ <cell>
+ <NumberEditor id='normalFloatEditor2'
+ property='normalFloat'
+ constructorParams='this'
+ bean='{demoModel}'
+ model='{demoModel.getNormalFloat()}'
+ autoPopup='true'
+ showPopupButton='true'
+ showReset='true'
+ useSign='true'
+ useFloat='true'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+
+ </cell>
+ <cell>
+
+ </cell>
+ <cell>
+
+ </cell>
+ </row>
+ <row>
+ <cell>
+
+ </cell>
+ <cell>
+
+ </cell>
+ <cell>
+
+ </cell>
+ </row>
+ </Table>
+
+</DemoPanel>
Added: jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/NumberEditorDemoModel.java
===================================================================
--- jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/NumberEditorDemoModel.java (rev 0)
+++ jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/NumberEditorDemoModel.java 2009-05-04 19:39:58 UTC (rev 1382)
@@ -0,0 +1,78 @@
+package jaxx.demo;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+
+/**
+ *
+ * @author chemit
+ * @since 1.5
+ */
+public class NumberEditorDemoModel {
+
+ protected PropertyChangeSupport p;
+ protected int positifInteger;
+ protected int normalInteger;
+ protected float positifFloat;
+ protected float normalFloat;
+
+ public NumberEditorDemoModel() {
+ p = new PropertyChangeSupport(this);
+ }
+
+ public float getNormalFloat() {
+ return normalFloat;
+ }
+
+ public int getNormalInteger() {
+ return normalInteger;
+ }
+
+ public float getPositifFloat() {
+ return positifFloat;
+ }
+
+ public int getPositifInteger() {
+ return positifInteger;
+ }
+
+ public void setNormalFloat(float normalFloat) {
+ float old = this.normalFloat;
+ this.normalFloat = normalFloat;
+ p.firePropertyChange("normalFloat", old, normalFloat);
+ }
+
+ public void setNormalInteger(int normalInteger) {
+ int old = this.normalInteger;
+ this.normalInteger = normalInteger;
+ p.firePropertyChange("normalInteger", old, normalInteger);
+ }
+
+ public void setPositifFloat(float positifFloat) {
+ float old = this.positifFloat;
+ this.positifFloat = positifFloat;
+ p.firePropertyChange("positifFloat", old, positifFloat);
+ }
+
+ public void setPositifInteger(int positifInteger) {
+ int old = this.positifInteger;
+ this.positifInteger = positifInteger;
+ p.firePropertyChange("positifInteger", old, positifInteger);
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ p.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ p.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ p.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ p.removePropertyChangeListener(propertyName, listener);
+ }
+}
Modified: jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-en_GB.properties
===================================================================
--- jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-en_GB.properties 2009-05-04 16:50:00 UTC (rev 1381)
+++ jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-en_GB.properties 2009-05-04 19:39:58 UTC (rev 1382)
@@ -106,6 +106,18 @@
form2.text=Form2 \: text
form2.text2=Form2 \: text2
no\ layer=
+numbereditor.normal.float=
+numbereditor.normal.float.value=
+numbereditor.normal.int=
+numbereditor.normal.int.value=
+numbereditor.positive.float=
+numbereditor.positive.float.value=
+numbereditor.positive.int=
+numbereditor.positive.int.value=
+numbereditor.positive.integer=Simple positive integer editor
+numbereditor.type=
+numbereditor.with.auto.popup=
+numbereditor.without.auto.popup=
valid=
validator.field=Champ
validator.field.header.tip=
Modified: jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-fr_FR.properties
===================================================================
--- jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-fr_FR.properties 2009-05-04 16:50:00 UTC (rev 1381)
+++ jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-fr_FR.properties 2009-05-04 19:39:58 UTC (rev 1382)
@@ -106,6 +106,13 @@
form2.text=Form2 \: text
form2.text2=Form2 \: text2
no\ layer=
+numbereditor.normal.float=D\u00E9cimal primitif \: [%1$s]
+numbereditor.normal.int=Entier primitif \: [%1$s]
+numbereditor.positive.float=D\u00E9cimal primitif positif \: [%1$s]
+numbereditor.positive.int=Entier primitif positif \: [%1$s]
+numbereditor.type=Type d'\u00E9diteur
+numbereditor.with.auto.popup=Avec popup auto
+numbereditor.without.auto.popup=Sans popup auto
valid=
validator.field=
validator.field.header.tip=
Modified: jaxx/trunk/jaxx-example/src/main/resources/log4j.properties
===================================================================
--- jaxx/trunk/jaxx-example/src/main/resources/log4j.properties 2009-05-04 16:50:00 UTC (rev 1381)
+++ jaxx/trunk/jaxx-example/src/main/resources/log4j.properties 2009-05-04 19:39:58 UTC (rev 1382)
@@ -5,5 +5,6 @@
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
-log4j.logger.examples=DEBUG
+log4j.logger.demo=DEBUG
log4j.logger.jaxx=INFO
+log4j.logger.org.codelutin=INFO
Modified: jaxx/trunk/jaxx-runtime-swing-widget/pom.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-swing-widget/pom.xml 2009-05-04 16:50:00 UTC (rev 1381)
+++ jaxx/trunk/jaxx-runtime-swing-widget/pom.xml 2009-05-04 19:39:58 UTC (rev 1382)
@@ -32,7 +32,7 @@
<!-- ************************************************************* -->
<name>${project.artifactId}</name>
- <description>Jaxx Examples</description>
+ <description>Jaxx runtime swing widgets</description>
<!-- ************************************************************* -->
<!-- *** Build Settings ****************************************** -->
@@ -57,25 +57,6 @@
</resource>
</resources>
- <pluginManagement>
- <plugins>
-
- <plugin>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
- <manifest>
- <addClasspath>true</addClasspath>
- <classpathPrefix>./lib/</classpathPrefix>
- </manifest>
- </archive>
- </configuration>
- </plugin>
-
- </plugins>
-
- </pluginManagement>
-
<plugins>
<plugin>
@@ -112,15 +93,8 @@
</goals>
</execution>
</executions>
- </plugin>
+ </plugin>
- <plugin>
- <artifactId>maven-dependency-plugin</artifactId>
- <configuration>
- <outputDirectory>${project.build.directory}/lib</outputDirectory>
- </configuration>
- </plugin>
-
</plugins>
</build>
Added: jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditor.jaxx
===================================================================
--- jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditor.jaxx (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditor.jaxx 2009-05-04 19:39:58 UTC (rev 1382)
@@ -0,0 +1,152 @@
+
+<JPanel layout='{new BorderLayout()}'
+ onFocusGained='textField.requestFocus()'
+ onFocusLost='setPopupVisible(false);popup.setVisible(false);'
+ onMouseExited='setPopupVisible(false);popup.setVisible(false);'>
+
+ <!-- onFocusGained='if (autoPopup) setPopupVisible(true); textField.requestFocus();'-->
+
+ <!-- bean property associated with the editing value -->
+ <String id='property' javaBean='""'/>
+
+ <!-- bean property -->
+ <Object id='bean' javaBean='null'/>
+
+ <!-- editor model -->
+ <Number id="model" javaBean='null'/>
+
+ <!-- useFloat property -->
+ <Boolean id='useFloat' javaBean='false'/>
+
+ <!-- useSign property -->
+ <Boolean id='useSign' javaBean='false'/>
+
+ <!-- autoPopup property -->
+ <Boolean id='autoPopup' javaBean='false'/>
+
+ <!-- showPopupButton property -->
+ <Boolean id='showPopupButton' javaBean='true'/>
+
+ <!-- show reset property -->
+ <Boolean id='showReset' javaBean='false'/>
+
+ <!-- internal editor model as text -->
+ <String id="modelText" javaBean='""'/>
+
+ <!-- internal state -->
+ <Boolean id='popupVisible' javaBean='false'/>
+
+ <!-- ui handler -->
+ <NumberEditorHandler id='handler' constructorParams='this'/>
+
+ <!-- popup digital number editor -->
+ <JPopupMenu id='popup'
+ onPopupMenuWillBecomeVisible='button.setSelected(true)'
+ onPopupMenuWillBecomeInvisible='button.setSelected(false)'
+ onPopupMenuCanceled='button.setSelected(false)'>
+ <style source='NumberEditorPopup.css'/>
+ <JPanel layout='{new GridLayout(4,4)}'
+ border='{BorderFactory.createEmptyBorder(4, 4, 4, 4)}'
+ background='{Color.WHITE}'>
+ <JButton text='7' onActionPerformed='addChar(event)' styleClass='digit'/>
+ <JButton text='8' onActionPerformed='addChar(event)' styleClass='digit'/>
+ <JButton text='9' onActionPerformed='addChar(event)' styleClass='digit'/>
+ <JButton text='numbereditor.clearAll' onActionPerformed='setModel(null)' styleClass='clear'
+ enabled='{!getModelText().isEmpty()}'/>
+
+
+ <JButton text='4' onActionPerformed='addChar(event)' styleClass='digit'/>
+ <JButton text='5' onActionPerformed='addChar(event)' styleClass='digit'/>
+ <JButton text='6' onActionPerformed='addChar(event)' styleClass='digit'/>
+ <JButton text='numbereditor.clearOne' onActionPerformed='getHandler().removeChar()' styleClass='clear'
+ enabled='{!(getModelText().isEmpty() || textField.getCaretPosition() ==0 )}'/>
+
+ <JButton text='1' onActionPerformed='addChar(event)' styleClass='digit'/>
+ <JButton text='2' onActionPerformed='addChar(event)' styleClass='digit'/>
+ <JButton text='3' onActionPerformed='addChar(event)' styleClass='digit'/>
+
+ <JButton enabled="false"/>
+
+ <JButton text='0' onActionPerformed='addChar(event)' styleClass='digit'
+ enabled='{!getEditor().getModelText().equals("0")}'/>
+
+ <JButton id='toggleSign' text='numbereditor.toggleSign' styleClass='operator'
+ onActionPerformed='getHandler().toggleSign()'
+ enabled='{isUseSign() && !getEditor().getModelText().isEmpty()}'/>
+
+ <JButton id='dot' text='.' styleClass='operator'
+ onActionPerformed='addChar(event)'
+ enabled='{isUseFloat() && getEditor().getModelText().indexOf(".") == -1 }'/>
+
+ <JButton actionIcon='numbereditor-validate' onActionPerformed="getHandler().validate()"/>
+ </JPanel>
+ </JPopupMenu>
+ <script><![CDATA[
+public void init() {
+ handler.init();
+}
+
+public NumberEditor getEditor() {
+ return this;
+}
+
+public void addChar(ActionEvent event) {
+ getHandler().addChar(((JButton)event.getSource()).getText());
+}
+
+void showPopup() {
+ if ( popupVisible || autoPopup ) {
+ if (!popupVisible) {
+ setPopupVisible(true);
+ } else if (!getPopup().isVisible()) {
+ getHandler().setPopupVisible(true);
+ }
+ }
+}
+
+]]>
+ </script>
+
+ <JToolBar floatable='false'
+ borderPainted='false'
+ visible='{isShowReset()}'
+ constraints='BorderLayout.WEST'>
+ <JButton id='resetButton'
+ actionIcon='numbereditor-reset'
+ toolTipText='numbereditor.action.reset.tip'
+ focusable='false'
+ focusPainted='false'
+ enabled='{isEnabled()}'
+ onActionPerformed='setModel(null)'/>
+ </JToolBar>
+
+ <JTextField id='textField'
+ constraints='BorderLayout.CENTER'
+ text='{getModelText()}'
+ enabled='{isEnabled()}'
+ onKeyReleased='getHandler().setModel(textField.getText())'
+ onFocusGained='showPopup()'/>
+
+ <!--JFormattedTextField id='textField' constraints='BorderLayout.CENTER'
+ text='{getModelText()}'
+ enabled='{isEnabled()}'
+ onKeyReleased='getHandler().setModel(textField.getText())'
+ focusLostBehavior='0'
+ onFocusGained='showPopup()'/-->
+
+ <JToolBar constraints='BorderLayout.EAST'
+ floatable='false'
+ opaque='false'
+ borderPainted='false'
+ visible='{isShowPopupButton()}'
+ maximumSize='{new Dimension(24,24)}'>
+ <JToggleButton id='button'
+ focusable='false'
+ focusPainted='false'
+ actionIcon='numbereditor-calculator'
+ toolTipText='numbereditor.action.show.tip'
+ enabled='{isEnabled()}'
+ onActionPerformed='getHandler().setPopupVisible(!popup.isVisible())'/>
+ </JToolBar>
+
+</JPanel>
\ No newline at end of file
Added: jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java 2009-05-04 19:39:58 UTC (rev 1382)
@@ -0,0 +1,394 @@
+package jaxx.runtime.swing.editor;
+
+import java.awt.Dimension;
+import javax.swing.JTextField;
+import org.apache.commons.beanutils.PropertyUtils;
+import org.apache.commons.lang.math.NumberUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.SwingUtilities;
+import javax.swing.text.BadLocationException;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
+import javax.swing.JToggleButton;
+
+/**
+ * Le handler de l'éditeur graphique de nombres.
+ * <p/>
+ * Note: Ce handler n'est pas staless, et chaque ui possède le sien.
+ *
+ * @author chemit
+ * @see NumberEditor
+ */
+public class NumberEditorHandler {
+
+ public static final Log log = LogFactory.getLog(NumberEditorHandler.class);
+ public static final String BEAN_PROPERTY = "bean";
+ public static final String PROPERTY_PROPERTY = "property";
+ public static final String MODEL_PROPERTY = "model";
+ public static final String AUTO_POPUP_PROPERTY = "autoPopup";
+ public static final String POPUP_VISIBLE_PROPERTY = "popupVisible";
+ public static final String USE_FLOAT_PROPERTY = "useFloat";
+ public static final String USE_SIGN_PROPERTY = "useSign";
+ public static final String VALIDATE_PROPERTY = "validate";
+ /** editor ui */
+ protected NumberEditor editor;
+ /** the mutator method on the property of boxed bean in the editor */
+ protected Method mutator;
+ /** a flag to known if mutator accept null value */
+ protected Boolean acceptNull;
+
+ public NumberEditorHandler(NumberEditor ui) {
+ this.editor = ui;
+ }
+
+ /** initialise l'ui et les listeners d'évènements. */
+ public void init() {
+
+ if (editor.getBean() == null) {
+ throw new NullPointerException("can not have a null bean in ui " + editor);
+ }
+
+ editor.addPropertyChangeListener(MODEL_PROPERTY, new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (log.isDebugEnabled()) {
+ log.debug("set new model " + evt.getNewValue() + " for " + editor.getProperty());
+ }
+ setModel((Number) evt.getOldValue(), (Number) evt.getNewValue());
+ }
+ });
+ editor.addPropertyChangeListener(POPUP_VISIBLE_PROPERTY, new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ setPopupVisible((Boolean) evt.getNewValue());
+ }
+ });
+ editor.getTextField().addMouseListener(new PopupListener());
+ /*if (editor.getResetButton().getIcon() == null) {
+ editor.getResetButton().setIcon(SwingUtil.createActionIcon("numbereditor-reset"));
+ }
+ if (editor.getButton().getIcon() == null) {
+ editor.getButton().setIcon(SwingUtil.createActionIcon("numbereditor-calculator"));
+ }*/
+ }
+
+ /**
+ * Affiche ou cache la popup.
+ *
+ * @param newValue la nouvelle valeur de visibilité de la popup.
+ */
+ public void setPopupVisible(Boolean newValue) {
+
+ if (log.isTraceEnabled()) {
+ log.trace(newValue);
+ }
+
+ if (newValue == null || !newValue) {
+ editor.getPopup().setVisible(false);
+ return;
+ }
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ JToggleButton invoker = editor.getButton();
+ Dimension dim = editor.getPopup().getPreferredSize();
+ editor.getPopup().show(invoker, (int) (invoker.getPreferredSize().getWidth() - dim.getWidth()), invoker.getHeight());
+ editor.getTextField().requestFocus();
+ }
+ });
+ }
+
+ /**
+ * Modifie le modèle de la donnée à éditer à partir d'un evenement clavier
+ *
+ * TODO utiliser une filtre sur les donnes en entrees pour ne pas a avoir
+ * faire les tests ici.
+ *
+ * @param s la nouvelle valeur du modèle
+ */
+ public void setModel(String s) {
+
+ String text = editor.getModelText();
+ if (text.equals(s)) {
+ // le modeèle n'a pas changé, rien a faire sur le modèle
+ if (log.isDebugEnabled()) {
+ log.debug("modelText is the same, skip !");
+ }
+ return;
+ }
+
+ boolean canApply = false;
+
+ boolean endWithDot = false;
+
+ Number newValue = null;
+
+ if (s.trim().isEmpty()) {
+ // le champ est vide donc c'est la valeur null a reaffecter
+ s = null;
+ canApply = true;
+ } else if (s.endsWith(".")) {
+ s += "0";
+ endWithDot = true;
+ }
+
+ if (s != null && NumberUtils.isNumber(s)) {
+
+ // on a un nombre valide
+
+ try {
+ Float f = Float.parseFloat(s);
+ if (!editor.isUseSign() && (s.startsWith("-"))) {
+ if (log.isDebugEnabled()) {
+ log.debug("will skip since can not allow sign on this editor but was " + f);
+ }
+ } else {
+
+ if (!editor.isUseFloat() && s.contains(".")) {
+ if (log.isDebugEnabled()) {
+ log.debug("will skip since can not allow float on this editor but was " + f);
+ }
+ } else {
+ // ok on peut utilise ce modele
+ if (editor.isUseFloat()) {
+ newValue = f;
+ } else {
+ newValue = f.intValue();
+ }
+ canApply = true;
+ }
+ }
+
+ } catch (NumberFormatException e) {
+ // rien a faire
+ log.debug(e);
+ }
+ }
+ JTextField field = editor.getTextField();
+
+ int oldPosition = field.getCaretPosition();
+
+ if (canApply) {
+ if (log.isDebugEnabled()) {
+ log.debug("can apply new model value : " + newValue);
+ }
+ // on peut mettre a jour le model
+ editor.setModel(newValue);
+ if (endWithDot) {
+ editor.setModelText(s.substring(0, s.length() - 1));
+ field.setCaretPosition(oldPosition);
+ }
+ return;
+ }
+
+ // on ne peut pas appliquer, on repositionne l'ancien texte
+ // dans l'éditeur
+
+ if (log.isDebugEnabled()) {
+ log.debug("invalid text " + s + " reput old text " + text);
+ }
+
+ if (oldPosition > 0) {
+ oldPosition--;
+ }
+ field.setText(text);
+ field.setCaretPosition(oldPosition);
+ }
+
+ /**
+ * Ajoute le caractère donné à l'endroit où est le curseur dans la zone de
+ * saisie et met à jour le modèle.
+ *
+ * @param s le caractère à ajouter.
+ */
+ public void addChar(String s) {
+ char c = s.charAt(0);
+ try {
+ editor.getTextField().getDocument().insertString(editor.getTextField().getCaretPosition(), c + "", null);
+ setModel(editor.getTextField().getText());
+ //setModel(editor.getModelText() + c);
+
+ } catch (BadLocationException e) {
+ log.warn(e);
+ }
+ }
+
+ /**
+ * Supprime le caractère juste avant le curseur du modèle (textuel) et
+ * met à jour la zone de saisie.
+ */
+ public void removeChar() {
+ String s = editor.getModelText();
+ int position = editor.getTextField().getCaretPosition();
+ if (position < 1 || s.isEmpty()) {
+ if (log.isDebugEnabled()) {
+ log.debug("cannot remove when caret on first position or text empty");
+ }
+ // on est au debut du doc, donc rien a faire
+ return;
+ }
+ try {
+ editor.getTextField().getDocument().remove(position - 1, 1);
+ } catch (BadLocationException ex) {
+ // ne devrait jamais arrive vu qu'on a fait le controle...
+ log.debug(ex);
+ return;
+ }
+ String newText = editor.getTextField().getText();
+ if (log.isDebugEnabled()) {
+ log.debug("text updated : " + newText);
+ }
+ position--;
+ editor.getTextField().setCaretPosition(position);
+ setModel(newText);
+ }
+
+ /**
+ * Permute le signe dans la zone de saisie et
+ * dans le modèle.
+ */
+ public void toggleSign() {
+ String newValue = editor.getModelText();
+
+ if (newValue.startsWith("-")) {
+ setModel(newValue.substring(1));
+ } else {
+ setModel("-" + newValue);
+ }
+ }
+
+ /** @return l'éditeur au quel est rattaché le handler. */
+ public NumberEditor getEditor() {
+ return editor;
+ }
+
+ protected void setModel(Number oldValue, Number newValue) {
+ if (editor.getBean() == null) {
+ return;
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug(editor.getProperty() + " on " + editor.getBean().getClass() + " :: " + oldValue + " to " + newValue);
+ }
+
+ try {
+ if (newValue == null && !getAcceptNull()) {
+ // valeur nulle sur une propriete primitive
+ // on ne peut pas utiliser la valeur null, mais 0 à la place
+ if (editor.isUseFloat()) {
+ getMutator().invoke(editor.getBean(), 0.0f);
+ } else {
+ getMutator().invoke(editor.getBean(), 0);
+ }
+
+ } else {
+ getMutator().invoke(editor.getBean(), newValue);
+ }
+ String strValue;
+ if (newValue == null) {
+ strValue = "";
+ } else {
+ strValue = newValue + "";
+ if (editor.isUseFloat()) {
+ Float n = Float.parseFloat(strValue);
+ if (((float) n.intValue()) == n) {
+ strValue = n.intValue() + "";
+ }
+ }
+ }
+
+ editor.setModelText(strValue);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ protected void validate() {
+
+ setPopupVisible(false);
+ // fire validate property (to be able to notify listeners)
+ editor.firePropertyChange(VALIDATE_PROPERTY, null, true);
+ }
+
+ protected class PopupListener extends MouseAdapter {
+
+ @Override
+ public void mousePressed(MouseEvent e) {
+ maybeShowPopup(e);
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent e) {
+ maybeShowPopup(e);
+ }
+
+ protected void maybeShowPopup(MouseEvent e) {
+ if (!e.isPopupTrigger()) {
+ return;
+ }
+ if (editor.isAutoPopup()) {
+ if (editor.isPopupVisible()) {
+ if (!editor.getPopup().isVisible()) {
+ setPopupVisible(true);
+ }
+ // popup already visible
+
+ } else {
+ // set popup auto
+ editor.setPopupVisible(true);
+
+ }
+ } else {
+ if (editor.isPopupVisible()) {
+ setPopupVisible(true);
+ }
+ }
+ }
+ }
+
+ protected Method getMutator() {
+ if (mutator == null) {
+ Object bean = editor.getBean();
+ if (bean == null) {
+ throw new NullPointerException("could not find bean in " + editor);
+ }
+ String property = editor.getProperty();
+ if (property == null) {
+ throw new NullPointerException("could not find property in " + editor);
+ }
+
+ try {
+ PropertyDescriptor descriptor = PropertyUtils.getPropertyDescriptor(bean, property);
+ mutator = descriptor.getWriteMethod();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ return mutator;
+ }
+
+ public Boolean getAcceptNull() {
+ if (acceptNull == null) {
+ Method m = getMutator();
+ if (m == null) {
+ // should never happens
+ throw new IllegalStateException("could not find the mutator");
+ }
+ Class<?> returnType = m.getParameterTypes()[0];
+ acceptNull = !returnType.isPrimitive();
+ if (log.isDebugEnabled()) {
+ log.debug(acceptNull + " for mutator " + m.getName() + " type : " + returnType);
+ }
+ }
+ return acceptNull;
+ }
+}
\ No newline at end of file
Added: jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditorPopup.css
===================================================================
--- jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditorPopup.css (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditorPopup.css 2009-05-04 19:39:58 UTC (rev 1382)
@@ -0,0 +1,25 @@
+JButton {
+ font-size: 14;
+ focusPainted: false;
+ focusable: false;
+}
+
+JButton.digit {
+ foreground: blue;
+}
+
+JButton.operator {
+ foreground: #009900;
+}
+
+JButton.clear {
+ foreground: red;
+}
+
+JButton:mouseover {
+ font-weight: bold;
+}
+
+JButton.operator:mouseover {
+ font-weight: normal;
+}
Modified: jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties
===================================================================
--- jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties 2009-05-04 16:50:00 UTC (rev 1381)
+++ jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties 2009-05-04 19:39:58 UTC (rev 1382)
@@ -0,0 +1,17 @@
+.=
+0=
+1=
+2=
+3=
+4=
+5=
+6=
+7=
+8=
+9=
+H=
+numbereditor.action.reset.tip=Reset
+numbereditor.action.show.tip=Show numeric panel
+numbereditor.clearAll=C
+numbereditor.clearOne=CE
+numbereditor.toggleSign=+/-
Modified: jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties
===================================================================
--- jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties 2009-05-04 16:50:00 UTC (rev 1381)
+++ jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties 2009-05-04 19:39:58 UTC (rev 1382)
@@ -0,0 +1,17 @@
+.=
+0=
+1=
+2=
+3=
+4=
+5=
+6=
+7=
+8=
+9=
+H=
+numbereditor.action.reset.tip=R\u00E9initialiser
+numbereditor.action.show.tip=Afficher le pav\u00E9 num\u00E9rique
+numbereditor.clearAll=C
+numbereditor.clearOne=CE
+numbereditor.toggleSign=+/-
Added: jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/icons/action-numbereditor-calculator.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/icons/action-numbereditor-calculator.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/icons/action-numbereditor-reset.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/icons/action-numbereditor-reset.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/icons/action-numbereditor-validate.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/icons/action-numbereditor-validate.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
1
0
r1381 - in jaxx/trunk: . jaxx-runtime-swing-widget/src/main
by tchemit@users.labs.libre-entreprise.org 04 May '09
by tchemit@users.labs.libre-entreprise.org 04 May '09
04 May '09
Author: tchemit
Date: 2009-05-04 16:50:00 +0000 (Mon, 04 May 2009)
New Revision: 1381
Removed:
jaxx/trunk/jaxx-runtime-swing-widget/src/main/jnlp/
Modified:
jaxx/trunk/changelog.txt
jaxx/trunk/pom.xml
Log:
remove jnlp
Modified: jaxx/trunk/changelog.txt
===================================================================
--- jaxx/trunk/changelog.txt 2009-05-04 16:48:43 UTC (rev 1380)
+++ jaxx/trunk/changelog.txt 2009-05-04 16:50:00 UTC (rev 1381)
@@ -1,3 +1,6 @@
+1.5
+ * 20090404 [chemit] - introduce module jaxx-runtime-swing-widget for swing widgets designed with jaxx.
+
1.4
* 20090402 [chemit] - use lutinproject 3.5.3
- use doxia-module-jrst 1.0.0 (instead of maven-jrst-plugin)
Modified: jaxx/trunk/pom.xml
===================================================================
--- jaxx/trunk/pom.xml 2009-05-04 16:48:43 UTC (rev 1380)
+++ jaxx/trunk/pom.xml 2009-05-04 16:50:00 UTC (rev 1381)
@@ -29,6 +29,8 @@
<module>jaxx-swing-action</module>
<module>maven-jaxx-plugin</module>
+ <module>jaxx-runtime-swing-widget</module>
+
<module>jaxx-example</module>
</modules>
1
0
04 May '09
Author: tchemit
Date: 2009-05-04 16:48:43 +0000 (Mon, 04 May 2009)
New Revision: 1380
Modified:
jaxx/trunk/jaxx-runtime-swing-widget/pom.xml
Log:
introduce module jaxx-runtime-swing-widget for swing widgets designed with jaxx.
- generics on JXPathDecorator
Modified: jaxx/trunk/jaxx-runtime-swing-widget/pom.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-swing-widget/pom.xml 2009-05-04 16:43:46 UTC (rev 1379)
+++ jaxx/trunk/jaxx-runtime-swing-widget/pom.xml 2009-05-04 16:48:43 UTC (rev 1380)
@@ -40,19 +40,6 @@
<packaging>jar</packaging>
- <properties>
-
- <maven.jar.main.class>jaxx.demo.JAXXDemo</maven.jar.main.class>
-
- <!-- jnlp -->
- <keystorepath>${codelutin.keystorepath}</keystorepath>
- <keystorealias>CodeLutin</keystorealias>
- <keystorepass>codelutin</keystorepass>
-
- <jnlp.build.directory>${project.build.directory}/jnlp</jnlp.build.directory>
-
- </properties>
-
<build>
<resources>
@@ -147,129 +134,4 @@
<url>${maven.scm.url.child}</url>
</scm>
- <profiles>
- <!-- by default jnlp is only perform on a release stage when using the maven-release-plugin -->
- <profile>
- <id>release-profile</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
-
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <!-- Ajout des libs signe par Sun dans un fichier jnlp separe -->
- <execution>
- <id>JnlpSun</id>
- <phase>verify</phase>
- <configuration>
- <tasks>
- <mkdir dir="${jnlp.build.directory}" />
- <copy file="${project.basedir}/src/main/jnlp/sun.jnlp" verbose="${maven.verbose}" todir="${jnlp.build.directory}" failonerror="false">
- <filterset>
- <filter token="lib" value="javahelp-2.0.02.jar" />
- <filter token="url" value="${project.url}" />
- </filterset>
- </copy>
- <copy file="${project.basedir}/src/main/jnlp/jxlayer.jnlp" verbose="${maven.verbose}" todir="${jnlp.build.directory}" failonerror="false">
- <filterset>
- <filter token="lib" value="jxlayer-3.0.1.jar" />
- <filter token="url" value="${project.url}" />
- </filterset>
- </copy>
- <copy file="${project.build.directory}/lib/javahelp-2.0.02.jar" verbose="${maven.verbose}" todir="${jnlp.build.directory}/lib" failonerror="false" />
- <copy file="${project.build.directory}/lib/jxlayer-3.0.1.jar" verbose="${maven.verbose}" todir="${jnlp.build.directory}/lib" failonerror="false" />
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- <execution>
- <id>JnlpToSite</id>
- <phase>pre-site</phase>
- <configuration>
- <tasks>
- <mkdir dir="targset/site" />
- <copy todir="targset/site" verbose="${maven.verbose}" failonerror="false" overwrite="false">
- <fileset dir="${jnlp.build.directory}">
- <include name="**" />
- </fileset>
- </copy>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo.webstart</groupId>
- <artifactId>webstart-maven-plugin</artifactId>
- <version>1.0-alpha-2-cl_20081018</version>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>jnlp-inline</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <force>false</force>
- <dependencies>
- <excludes>
- <exclude>javax.help:javahelp</exclude>
- <exclude>org.swinglabs:jxlayer</exclude>
- </excludes>
- </dependencies>
- <libPath>lib</libPath>
- <extensions>
- <sun>sun.jnlp</sun>
- <jxlayer>jxlayer.jnlp</jxlayer>
- </extensions>
- <jnlp>
- <outputFile>launch-demo.jnlp</outputFile>
- <mainClass>${maven.jar.main.class}</mainClass>
- <allPermissions>true</allPermissions>
- <offlineAllowed>true</offlineAllowed>
- </jnlp>
-
- <sign>
- <keystore>${keystorepath}</keystore>
- <keypass />
- <storepass>${keystorepass}</storepass>
- <storetype />
- <alias>${keystorealias}</alias>
- <validity />
- <dnameCn />
- <dnameOu />
- <dnameO />
- <dnameL />
- <dnameSt />
- <dnameC />
- <verify>true</verify>
- <keystoreConfig>
- <delete>false</delete>
- <gen>false</gen>
- </keystoreConfig>
- </sign>
-
- <pack200>false</pack200>
- <gzip>true</gzip>
- <verbose>false</verbose>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
</project>
\ No newline at end of file
1
0
r1379 - in jaxx/trunk: jaxx-example jaxx-runtime-api/src/main/java/jaxx/runtime
by tchemit@users.labs.libre-entreprise.org 04 May '09
by tchemit@users.labs.libre-entreprise.org 04 May '09
04 May '09
Author: tchemit
Date: 2009-05-04 16:43:46 +0000 (Mon, 04 May 2009)
New Revision: 1379
Modified:
jaxx/trunk/jaxx-example/changelog.txt
jaxx/trunk/jaxx-example/pom.xml
jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/JXPathDecorator.java
Log:
introduce module jaxx-runtime-swing-widget for swing widgets designed with jaxx.
- generics on JXPathDecorator
Modified: jaxx/trunk/jaxx-example/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-example/changelog.txt 2009-05-04 16:38:07 UTC (rev 1378)
+++ jaxx/trunk/jaxx-example/changelog.txt 2009-05-04 16:43:46 UTC (rev 1379)
@@ -1,3 +1,6 @@
+1.5
+ * 20090404 [chemit] - use module jaxx-runtime-swing-widget
+
1.3 chemit 20090409
* 20090319 [chemit] - refactor Validator : now can deal with scopes, improve design
* 20090313 [chemit] - improve demo
Modified: jaxx/trunk/jaxx-example/pom.xml
===================================================================
--- jaxx/trunk/jaxx-example/pom.xml 2009-05-04 16:38:07 UTC (rev 1378)
+++ jaxx/trunk/jaxx-example/pom.xml 2009-05-04 16:43:46 UTC (rev 1379)
@@ -24,11 +24,11 @@
<artifactId>jaxx-runtime-swing</artifactId>
<version>${project.version}</version>
</dependency>
- <!--dependency>
+ <dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jaxx-runtime-swing-widget</artifactId>
<version>${project.version}</version>
- </dependency-->
+ </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jaxx-runtime-validator-swing</artifactId>
Modified: jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/JXPathDecorator.java
===================================================================
--- jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/JXPathDecorator.java 2009-05-04 16:38:07 UTC (rev 1378)
+++ jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/JXPathDecorator.java 2009-05-04 16:43:46 UTC (rev 1379)
@@ -28,6 +28,7 @@
* assert "expr = %1$s" == d.toString(d);
* </pre>
*
+ * @param <O> type of data
* @author chemit
* @see Decorator
*/
@@ -60,39 +61,43 @@
* Sort a list of data based on the first token property of a given context
* in a given decorator.
*
+ * @param <O> type of data to sort
* @param decorator the decorator to use to sort
* @param datas the list of data to sort
* @param pos the index of context to used in decorator to obtain sorted property.
*/
public static <O> void sort(JXPathDecorator<O> decorator, List<O> datas, int pos) {
- Comparator<O> c = decorator.getComparator(pos);
- boolean cachedComparator = c instanceof JXPathComparator;
+ Comparator<O> c = null;
+ boolean cachedComparator = false;
try {
+ c = decorator.getComparator(pos);
+ cachedComparator = c instanceof JXPathComparator<?>;
+
if (cachedComparator) {
((JXPathComparator<O>) c).init(decorator, datas);
}
Collections.sort(datas, c);
} finally {
if (cachedComparator) {
- ((JXPathComparator) c).clear();
+ ((JXPathComparator<?>) c).clear();
}
}
}
public static class JXPathComparator<O> implements Comparator<O> {
- protected Map<O, Comparable<Comparable>> valueCache;
+ protected Map<O, Comparable<Comparable<?>>> valueCache;
private final String expression;
public JXPathComparator(String expression) {
this.expression = expression;
- this.valueCache = new HashMap<O, Comparable<Comparable>>();
+ this.valueCache = new HashMap<O, Comparable<Comparable<?>>>();
}
@Override
public int compare(O o1, O o2) {
- Comparable<Comparable> c1 = valueCache.get(o1);
- Comparable<Comparable> c2 = valueCache.get(o2);
+ Comparable<Comparable<?>> c1 = valueCache.get(o1);
+ Comparable<Comparable<?>> c2 = valueCache.get(o2);
return c1.compareTo(c2);
}
@@ -104,7 +109,7 @@
clear();
for (O data : datas) {
JXPathContext jxcontext = JXPathContext.newContext(data);
- Comparable<Comparable> key = decorator.getTokenValue(jxcontext, expression);
+ Comparable<Comparable<?>> key = decorator.getTokenValue(jxcontext, expression);
valueCache.put(data, key);
}
}
@@ -175,9 +180,9 @@
}
@SuppressWarnings({"unchecked"})
- protected Comparable<Comparable> getTokenValue(JXPathContext jxcontext, String token) {
+ protected Comparable<Comparable<?>> getTokenValue(JXPathContext jxcontext, String token) {
// assume all values are comparable
- return (Comparable<Comparable>) jxcontext.getValue(token);
+ return (Comparable<Comparable<?>>) jxcontext.getValue(token);
}
public String getProperty(int pos) {
@@ -265,7 +270,7 @@
return new Context<O>(buffer.toString(), lTokens.toArray(new String[lTokens.size()]));
}
- protected static void ensureTokenIndex(JXPathDecorator decorator, int pos) {
+ protected static void ensureTokenIndex(JXPathDecorator<?> decorator, int pos) {
if (pos < -1 || pos > decorator.getNbToken()) {
throw new ArrayIndexOutOfBoundsException("token index " + pos + " is out of bound, can be inside [" + 0 + "," + decorator.nbToken + "]");
}
1
0
r1378 - in jaxx/trunk: . jaxx-runtime-swing-widget jaxx-runtime-swing-widget/src/main/java/jaxx jaxx-runtime-swing-widget/src/main/java/jaxx/runtime jaxx-runtime-swing-widget/src/main/resources jaxx-runtime-swing-widget/src/main/resources/i18n
by tchemit@users.labs.libre-entreprise.org 04 May '09
by tchemit@users.labs.libre-entreprise.org 04 May '09
04 May '09
Author: tchemit
Date: 2009-05-04 16:38:07 +0000 (Mon, 04 May 2009)
New Revision: 1378
Added:
jaxx/trunk/jaxx-runtime-swing-widget/
jaxx/trunk/jaxx-runtime-swing-widget/pom.xml
jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/
jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/
jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties
jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties
Removed:
jaxx/trunk/jaxx-runtime-swing-widget/pom.xml
jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/demo/
jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-example-en_GB.properties
jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-example-fr_FR.properties
jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/icons/
jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/jaxx/
jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/log4j.properties
Modified:
jaxx/trunk/jaxx-runtime-swing-widget/changelog.txt
Log:
introduce module jaxx-runtime-swing-widget for swing widgets designed with jaxx.
Copied: jaxx/trunk/jaxx-runtime-swing-widget (from rev 1345, jaxx/trunk/jaxx-example)
Property changes on: jaxx/trunk/jaxx-runtime-swing-widget
___________________________________________________________________
Name: svn:ignore
+ velocity.log
target
nbactions.xml
Name: svn:mergeinfo
+
Modified: jaxx/trunk/jaxx-runtime-swing-widget/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-example/changelog.txt 2009-04-20 15:55:10 UTC (rev 1345)
+++ jaxx/trunk/jaxx-runtime-swing-widget/changelog.txt 2009-05-04 16:38:07 UTC (rev 1378)
@@ -1,15 +1,2 @@
-1.3 chemit 20090409
- * 20090319 [chemit] - refactor Validator : now can deal with scopes, improve design
- * 20090313 [chemit] - improve demo
-
-1.1 chemit 20090220
- * 20090202 [chemit] - no more scope attribute on validator
- - fix I18NTableCellRenderer (must have tip inside)
- * 20090122 [chemit] - refactor poms (sibling dependencies, pluginsManagment,...)
- - rename i18n bundles according artifactId
-
-1.0 chemit 20090111
- * 20090111 [chemit] - use lutinproject 3.3
- - refactor examples : now onyl one module, with one webstart demo (cost very less time to release)
-0.7 chemit 200812??
- * 20081207 [chemit] use lutinproject 3.1
\ No newline at end of file
+1.5
+ * 20090404 [chemit] - initial version
Deleted: jaxx/trunk/jaxx-runtime-swing-widget/pom.xml
===================================================================
--- jaxx/trunk/jaxx-example/pom.xml 2009-04-20 15:55:10 UTC (rev 1345)
+++ jaxx/trunk/jaxx-runtime-swing-widget/pom.xml 2009-05-04 16:38:07 UTC (rev 1378)
@@ -1,285 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <!-- ************************************************************* -->
- <!-- *** POM Relationships *************************************** -->
- <!-- ************************************************************* -->
-
- <parent>
- <groupId>org.codelutin</groupId>
- <artifactId>jaxx</artifactId>
- <version>1.4-SNAPSHOT</version>
- </parent>
-
- <groupId>org.codelutin.jaxx</groupId>
- <artifactId>jaxx-example</artifactId>
-
- <dependencies>
-
- <!-- sibiling dependencies -->
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>jaxx-runtime-swing</artifactId>
- <version>${project.version}</version>
- </dependency>
- <!--dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>jaxx-runtime-swing-widget</artifactId>
- <version>${project.version}</version>
- </dependency-->
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>jaxx-runtime-validator-swing</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- </dependencies>
-
- <!-- ************************************************************* -->
- <!-- *** Project Information ************************************* -->
- <!-- ************************************************************* -->
-
- <name>${project.artifactId}</name>
- <description>Jaxx Examples</description>
-
- <!-- ************************************************************* -->
- <!-- *** Build Settings ****************************************** -->
- <!-- ************************************************************* -->
-
- <packaging>jar</packaging>
-
- <properties>
-
- <maven.jar.main.class>jaxx.demo.JAXXDemo</maven.jar.main.class>
-
- <!-- jnlp -->
- <keystorepath>${codelutin.keystorepath}</keystorepath>
- <keystorealias>CodeLutin</keystorealias>
- <keystorepass>codelutin</keystorepass>
-
- <jnlp.build.directory>${project.build.directory}/jnlp</jnlp.build.directory>
-
- </properties>
-
- <build>
-
- <resources>
- <resource>
- <directory>src/main/java</directory>
- <includes>
- <include>**/*.jaxx</include>
- </includes>
- </resource>
- <resource>
- <directory>src/main/resources</directory>
- <includes>
- <include>**/*</include>
- </includes>
- </resource>
- </resources>
-
- <pluginManagement>
- <plugins>
-
- <plugin>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
- <manifest>
- <addClasspath>true</addClasspath>
- <classpathPrefix>./lib/</classpathPrefix>
- </manifest>
- </archive>
- </configuration>
- </plugin>
-
- </plugins>
-
- </pluginManagement>
-
- <plugins>
-
- <plugin>
- <groupId>org.codelutin.jaxx</groupId>
- <artifactId>maven-jaxx-plugin</artifactId>
- <version>${project.version}</version>
- <executions>
- <execution>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.codelutin</groupId>
- <artifactId>maven-i18n-plugin</artifactId>
- <configuration>
- <entries>
- <entry>
- <basedir>${maven.gen.dir}/java/</basedir>
- <includes>
- <param>**\/**.java</param>
- </includes>
- </entry>
- </entries>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>parserJava</goal>
- <goal>gen</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <artifactId>maven-dependency-plugin</artifactId>
- <configuration>
- <outputDirectory>${project.build.directory}/lib</outputDirectory>
- </configuration>
- </plugin>
-
- </plugins>
- </build>
-
- <!-- ************************************************************* -->
- <!-- *** Build Environment ************************************** -->
- <!-- ************************************************************* -->
-
- <scm>
- <connection>${maven.scm.connection.child}</connection>
- <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
- <url>${maven.scm.url.child}</url>
- </scm>
-
- <profiles>
- <!-- by default jnlp is only perform on a release stage when using the maven-release-plugin -->
- <profile>
- <id>release-profile</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
-
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <!-- Ajout des libs signe par Sun dans un fichier jnlp separe -->
- <execution>
- <id>JnlpSun</id>
- <phase>verify</phase>
- <configuration>
- <tasks>
- <mkdir dir="${jnlp.build.directory}" />
- <copy file="${project.basedir}/src/main/jnlp/sun.jnlp" verbose="${maven.verbose}" todir="${jnlp.build.directory}" failonerror="false">
- <filterset>
- <filter token="lib" value="javahelp-2.0.02.jar" />
- <filter token="url" value="${project.url}" />
- </filterset>
- </copy>
- <copy file="${project.basedir}/src/main/jnlp/jxlayer.jnlp" verbose="${maven.verbose}" todir="${jnlp.build.directory}" failonerror="false">
- <filterset>
- <filter token="lib" value="jxlayer-3.0.1.jar" />
- <filter token="url" value="${project.url}" />
- </filterset>
- </copy>
- <copy file="${project.build.directory}/lib/javahelp-2.0.02.jar" verbose="${maven.verbose}" todir="${jnlp.build.directory}/lib" failonerror="false" />
- <copy file="${project.build.directory}/lib/jxlayer-3.0.1.jar" verbose="${maven.verbose}" todir="${jnlp.build.directory}/lib" failonerror="false" />
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- <execution>
- <id>JnlpToSite</id>
- <phase>pre-site</phase>
- <configuration>
- <tasks>
- <mkdir dir="${maven.site.gen.dir}/resources" />
- <copy todir="${maven.site.gen.dir}/resources" verbose="${maven.verbose}" failonerror="false" overwrite="false">
- <fileset dir="${jnlp.build.directory}">
- <include name="**" />
- </fileset>
- </copy>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo.webstart</groupId>
- <artifactId>webstart-maven-plugin</artifactId>
- <version>1.0-alpha-2-cl_20081018</version>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>jnlp-inline</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <force>false</force>
- <dependencies>
- <excludes>
- <exclude>javax.help:javahelp</exclude>
- <exclude>org.swinglabs:jxlayer</exclude>
- </excludes>
- </dependencies>
- <libPath>lib</libPath>
- <extensions>
- <sun>sun.jnlp</sun>
- <jxlayer>jxlayer.jnlp</jxlayer>
- </extensions>
- <jnlp>
- <outputFile>launch-demo.jnlp</outputFile>
- <mainClass>${maven.jar.main.class}</mainClass>
- <allPermissions>true</allPermissions>
- <offlineAllowed>true</offlineAllowed>
- </jnlp>
-
- <sign>
- <keystore>${keystorepath}</keystore>
- <keypass />
- <storepass>${keystorepass}</storepass>
- <storetype />
- <alias>${keystorealias}</alias>
- <validity />
- <dnameCn />
- <dnameOu />
- <dnameO />
- <dnameL />
- <dnameSt />
- <dnameC />
- <verify>true</verify>
- <keystoreConfig>
- <delete>false</delete>
- <gen>false</gen>
- </keystoreConfig>
- </sign>
-
- <pack200>false</pack200>
- <gzip>true</gzip>
- <verbose>false</verbose>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
-</project>
\ No newline at end of file
Copied: jaxx/trunk/jaxx-runtime-swing-widget/pom.xml (from rev 1354, jaxx/trunk/jaxx-example/pom.xml)
===================================================================
--- jaxx/trunk/jaxx-runtime-swing-widget/pom.xml (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing-widget/pom.xml 2009-05-04 16:38:07 UTC (rev 1378)
@@ -0,0 +1,275 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>org.codelutin</groupId>
+ <artifactId>jaxx</artifactId>
+ <version>1.5-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.codelutin.jaxx</groupId>
+ <artifactId>jaxx-runtime-swing-widget</artifactId>
+
+ <dependencies>
+
+ <!-- sibiling dependencies -->
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-runtime-swing</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ </dependencies>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>${project.artifactId}</name>
+ <description>Jaxx Examples</description>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>jar</packaging>
+
+ <properties>
+
+ <maven.jar.main.class>jaxx.demo.JAXXDemo</maven.jar.main.class>
+
+ <!-- jnlp -->
+ <keystorepath>${codelutin.keystorepath}</keystorepath>
+ <keystorealias>CodeLutin</keystorealias>
+ <keystorepass>codelutin</keystorepass>
+
+ <jnlp.build.directory>${project.build.directory}/jnlp</jnlp.build.directory>
+
+ </properties>
+
+ <build>
+
+ <resources>
+ <resource>
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*.jaxx</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+
+ <pluginManagement>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ <classpathPrefix>./lib/</classpathPrefix>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ </pluginManagement>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.codelutin.jaxx</groupId>
+ <artifactId>maven-jaxx-plugin</artifactId>
+ <version>${project.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codelutin</groupId>
+ <artifactId>maven-i18n-plugin</artifactId>
+ <configuration>
+ <entries>
+ <entry>
+ <basedir>${maven.gen.dir}/java/</basedir>
+ <includes>
+ <param>**\/**.java</param>
+ </includes>
+ </entry>
+ </entries>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>parserJava</goal>
+ <goal>gen</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <configuration>
+ <outputDirectory>${project.build.directory}/lib</outputDirectory>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Environment ************************************** -->
+ <!-- ************************************************************* -->
+
+ <scm>
+ <connection>${maven.scm.connection.child}</connection>
+ <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
+ <url>${maven.scm.url.child}</url>
+ </scm>
+
+ <profiles>
+ <!-- by default jnlp is only perform on a release stage when using the maven-release-plugin -->
+ <profile>
+ <id>release-profile</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <!-- Ajout des libs signe par Sun dans un fichier jnlp separe -->
+ <execution>
+ <id>JnlpSun</id>
+ <phase>verify</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="${jnlp.build.directory}" />
+ <copy file="${project.basedir}/src/main/jnlp/sun.jnlp" verbose="${maven.verbose}" todir="${jnlp.build.directory}" failonerror="false">
+ <filterset>
+ <filter token="lib" value="javahelp-2.0.02.jar" />
+ <filter token="url" value="${project.url}" />
+ </filterset>
+ </copy>
+ <copy file="${project.basedir}/src/main/jnlp/jxlayer.jnlp" verbose="${maven.verbose}" todir="${jnlp.build.directory}" failonerror="false">
+ <filterset>
+ <filter token="lib" value="jxlayer-3.0.1.jar" />
+ <filter token="url" value="${project.url}" />
+ </filterset>
+ </copy>
+ <copy file="${project.build.directory}/lib/javahelp-2.0.02.jar" verbose="${maven.verbose}" todir="${jnlp.build.directory}/lib" failonerror="false" />
+ <copy file="${project.build.directory}/lib/jxlayer-3.0.1.jar" verbose="${maven.verbose}" todir="${jnlp.build.directory}/lib" failonerror="false" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>JnlpToSite</id>
+ <phase>pre-site</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="targset/site" />
+ <copy todir="targset/site" verbose="${maven.verbose}" failonerror="false" overwrite="false">
+ <fileset dir="${jnlp.build.directory}">
+ <include name="**" />
+ </fileset>
+ </copy>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo.webstart</groupId>
+ <artifactId>webstart-maven-plugin</artifactId>
+ <version>1.0-alpha-2-cl_20081018</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>jnlp-inline</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <force>false</force>
+ <dependencies>
+ <excludes>
+ <exclude>javax.help:javahelp</exclude>
+ <exclude>org.swinglabs:jxlayer</exclude>
+ </excludes>
+ </dependencies>
+ <libPath>lib</libPath>
+ <extensions>
+ <sun>sun.jnlp</sun>
+ <jxlayer>jxlayer.jnlp</jxlayer>
+ </extensions>
+ <jnlp>
+ <outputFile>launch-demo.jnlp</outputFile>
+ <mainClass>${maven.jar.main.class}</mainClass>
+ <allPermissions>true</allPermissions>
+ <offlineAllowed>true</offlineAllowed>
+ </jnlp>
+
+ <sign>
+ <keystore>${keystorepath}</keystore>
+ <keypass />
+ <storepass>${keystorepass}</storepass>
+ <storetype />
+ <alias>${keystorealias}</alias>
+ <validity />
+ <dnameCn />
+ <dnameOu />
+ <dnameO />
+ <dnameL />
+ <dnameSt />
+ <dnameC />
+ <verify>true</verify>
+ <keystoreConfig>
+ <delete>false</delete>
+ <gen>false</gen>
+ </keystoreConfig>
+ </sign>
+
+ <pack200>false</pack200>
+ <gzip>true</gzip>
+ <verbose>false</verbose>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
\ No newline at end of file
Deleted: jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-example-en_GB.properties
===================================================================
--- jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-en_GB.properties 2009-04-20 15:55:10 UTC (rev 1345)
+++ jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-example-en_GB.properties 2009-05-04 16:38:07 UTC (rev 1378)
@@ -1,120 +0,0 @@
--=
-.=
-0=
-1=
-10=
-12=
-14=
-18=
-2=
-24=
-3=
-4=
-5=
-6=
-7=
-8=
-9=
-Age\:=
-Animal=
-Blue=
-Blue\:=
-Bold=
-Button\ label\:=
-C=
-CE=
-Cancel=
-Change\ layer\ state=
-Comments\:=
-Config\ file\ \:=
-Config\ file\:=
-Cyan=
-Dec\ (-)=
-Demo=
-Directory\ file\:=
-Editable=
-Email\ Address\:=
-Email\:=
-Enabled=
-Fancy\ Button=
-First\ Name\:=
-FirstName\:=
-Font\ size=
-Green=
-Green\:=
-Greet=
-Inc\ (+)=
-Italic=
-JAXX\ Demo=
-JMenu\ demo=
-Last\ Name\:=
-LastName\:=
-Message\ Box=
-Mineral=
-Normal\ text\:=
-OK=
-Orange=
-Password\:=
-Purple=
-Ratio\:=
-Red=
-Red\:=
-Reset=
-Show\ Background=
-Show\ password\ dialog=
-Sign\ on=
-Simple\ Button=
-Size\:=
-Source=
-Spacing\:=
-Start=
-Stop=
-Supported\ Swing\ components\:=
-Text2\:=
-Text\:=
-Underline=
-Upper\ case\ text\:=
-Use\ the\ spinner\ to=
-Username\:=
-Vegetable=
-View=
-Welcome\ to\ the\ JAXX\ framework\!=
-Working\ directory\:=
-Yellow=
-Your\ name\:=
-\\u00f7=
-adjust\ the\ spacing=
-between\ these\ lines=
-button\ A=
-button\ B=
-button\ C=
-button\ C\ (full\ block)=
-button\ D\ (full\ block\ 2)=
-button\ with\ layer=
-cancel=
-close=
-close2=
-close3=
-edit=
-edit2=
-edit3=
-emptyNode=< empty node >
-form.ratio=Form \: ratio
-form.text=Form \: text
-form.text2=Form \: text2
-form2.ratio=Form2 \: ratio
-form2.text=Form2 \: text
-form2.text2=Form2 \: text2
-no\ layer=
-valid=
-validator.field=Champ
-validator.field.header.tip=
-validator.field.tip=
-validator.message=Message
-validator.message.header.tip=
-validator.message.tip=
-validator.scope=...
-validator.scope.header.tip=
-validator.scope.tip=
-with\ layer=
-x=
Deleted: jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-example-fr_FR.properties
===================================================================
--- jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-fr_FR.properties 2009-04-20 15:55:10 UTC (rev 1345)
+++ jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-example-fr_FR.properties 2009-05-04 16:38:07 UTC (rev 1378)
@@ -1,117 +0,0 @@
--=
-.=
-0=
-1=
-10=
-12=
-14=
-18=
-2=
-24=
-3=
-4=
-5=
-6=
-7=
-8=
-9=
-Age\:=
-Animal=
-Blue=
-Blue\:=
-Bold=
-Button\ label\:=
-C=
-CE=
-Cancel=
-Change\ layer\ state=
-Comments\:=
-Config\ file\ \:=
-Config\ file\:=
-Cyan=
-Dec\ (-)=
-Demo=
-Directory\ file\:=
-Editable=
-Email\ Address\:=
-Email\:=
-Enabled=
-Fancy\ Button=
-First\ Name\:=
-FirstName\:=
-Font\ size=
-Green=
-Green\:=
-Greet=
-Inc\ (+)=
-Italic=
-JAXX\ Demo=
-JMenu\ demo=
-Last\ Name\:=
-LastName\:=
-Message\ Box=
-Mineral=
-Normal\ text\:=
-OK=
-Orange=
-Password\:=
-Purple=
-Ratio\:=
-Red=
-Red\:=
-Reset=
-Show\ Background=
-Show\ password\ dialog=
-Sign\ on=
-Simple\ Button=
-Size\:=
-Source=
-Spacing\:=
-Start=
-Stop=
-Supported\ Swing\ components\:=
-Text2\:=
-Text\:=
-Underline=
-Upper\ case\ text\:=
-Use\ the\ spinner\ to=
-Username\:=
-Vegetable=
-View=
-Welcome\ to\ the\ JAXX\ framework\!=
-Working\ directory\:=
-Yellow=
-Your\ name\:=
-\\u00f7=
-adjust\ the\ spacing=
-between\ these\ lines=
-button\ A=
-button\ B=
-button\ C=
-button\ C\ (full\ block)=
-button\ D\ (full\ block\ 2)=
-button\ with\ layer=
-cancel=
-close=
-close2=
-close3=
-edit=
-edit2=
-edit3=
-emptyNode=< empty node >
-form.ratio=Form \: ratio
-form.text=Form \: text
-form.text2=Form \: text2
-form2.ratio=Form2 \: ratio
-form2.text=Form2 \: text
-form2.text2=Form2 \: text2
-no\ layer=
-valid=
-validator.field=
-validator.field.header.tip=
-validator.message=
-validator.message.header.tip=
-validator.scope=
-validator.scope.header.tip=
-with\ layer=
-x=
Copied: jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties (from rev 1345, jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-en_GB.properties)
===================================================================
Property changes on: jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties (from rev 1345, jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-fr_FR.properties)
===================================================================
Property changes on: jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted: jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/log4j.properties
===================================================================
--- jaxx/trunk/jaxx-example/src/main/resources/log4j.properties 2009-04-20 15:55:10 UTC (rev 1345)
+++ jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/log4j.properties 2009-05-04 16:38:07 UTC (rev 1378)
@@ -1,9 +0,0 @@
-# Global logging configuration
-log4j.rootLogger=ERROR, stdout
-# Console output...
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
-
-log4j.logger.examples=DEBUG
-log4j.logger.jaxx=INFO
1
0
r1377 - jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/field
by tchemit@users.labs.libre-entreprise.org 04 May '09
by tchemit@users.labs.libre-entreprise.org 04 May '09
04 May '09
Author: tchemit
Date: 2009-05-04 07:13:44 +0000 (Mon, 04 May 2009)
New Revision: 1377
Modified:
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/field/CollectionFieldExpressionValidator.java
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidator.java
Log:
add a UNIQUE_KEY mode in CollectionExpressionFieldValidator
Modified: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/field/CollectionFieldExpressionValidator.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/field/CollectionFieldExpressionValidator.java 2009-05-04 01:01:04 UTC (rev 1376)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/field/CollectionFieldExpressionValidator.java 2009-05-04 07:13:44 UTC (rev 1377)
@@ -5,6 +5,8 @@
import com.opensymphony.xwork2.validator.validators.FieldExpressionValidator;
import java.util.Collection;
+import java.util.Set;
+import org.apache.commons.lang.builder.HashCodeBuilder;
/**
* Un validateur basé sur {@link FieldExpressionValidator} qui valide sur une collection de propriéte.
@@ -22,7 +24,9 @@
/** toutes les valeurs de la collection doivent etre valides */
ALL,
/** aucune valeur de la collection doivent etre valides */
- NONE
+ NONE,
+ /** detection de clef unique */
+ UNIQUE_KEY
}
/** le mode de validation sur la liste */
protected Mode mode;
@@ -58,6 +62,11 @@
* Note : Pour le moment, on autorise uniquement cela en mode ALL.
*/
protected String expressionForLast;
+ /**
+ * la liste des propriétés d'une entrée de la collection qui définit la
+ * clef unique (en mode UNIQUE_KEY).
+ */
+ protected String[] keys;
/** le context de parcours */
protected WalkerContext c;
private boolean useFirst, useLast;
@@ -102,6 +111,18 @@
this.expressionForLast = expressionForLast;
}
+ public String[] getKeys() {
+ return keys;
+ }
+
+ public void setKeys(String[] keys) {
+ if (keys != null && keys.length == 1 && keys[0].indexOf(",") != -1) {
+ this.keys = keys[0].split(",");
+ } else {
+ this.keys = keys;
+ }
+ }
+
@Override
public void validate(Object object) throws ValidationException {
if (mode == null) {
@@ -147,6 +168,12 @@
case NONE:
answer = validateNoneEntry(col);
break;
+ case UNIQUE_KEY:
+ if (keys == null || keys.length == 0) {
+ throw new ValidationException("no unique keys defined");
+ }
+ answer = validateUniqueKey(col);
+ break;
default:
// should never come here...
@@ -242,6 +269,30 @@
return count == 1;
}
+ protected Boolean validateUniqueKey(Collection<?> col) throws ValidationException {
+ boolean answer = true;
+
+ Set<Integer> hashCodes = new java.util.HashSet<Integer>();
+ int index = -1;
+ for (Object entry : col) {
+ index++;
+ // construction du hash de la clef d'unicite
+ Integer hash = getUniqueKeyHashCode(entry);
+ if (!hashCodes.contains(hash)) {
+ hashCodes.add(hash);
+ continue;
+ }
+ // une entree avec ce hash a deja ete trouvee
+ // on est donc en violation sur la clef unique
+ answer = false;
+ if (log.isDebugEnabled()) {
+ log.debug("duplicated uniquekey " + hash + " for entry " + index);
+ }
+ }
+ hashCodes.clear();
+ return answer;
+ }
+
protected boolean validateOneEntry(Object object) throws ValidationException {
Boolean answer = Boolean.FALSE;
@@ -276,6 +327,7 @@
} catch (ValidationException e) {
throw e;
} catch (Exception e) {
+ log.error(e.getMessage(), e);
// let this pass, but it will be logged right below
}
@@ -323,6 +375,26 @@
return (Collection<?>) obj;
}
+ /**
+ * Calcule pour une entrée donné, le hash de la clef unique
+ *
+ * @param o l'entree de la collection dont on va calculer le hash de la clef unique
+ * @return le hashCode calclé de la clef unique sur l'entrée donné
+ * @throws ValidationException if any pb to retreave properties values
+ */
+ protected Integer getUniqueKeyHashCode(Object o) throws ValidationException {
+ // calcul du hash à la volée
+ HashCodeBuilder builder = new HashCodeBuilder();
+ for (String key : this.keys) {
+ Object property = getFieldValue(key, o);
+ if (log.isDebugEnabled()) {
+ log.debug("key " + key + " : " + property);
+ }
+ builder.append(property);
+ }
+ return builder.toHashCode();
+ }
+
@Override
public String getValidatorType() {
return "collectionFieldExpression";
Modified: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidator.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidator.java 2009-05-04 01:01:04 UTC (rev 1376)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidator.java 2009-05-04 07:13:44 UTC (rev 1377)
@@ -18,18 +18,18 @@
*/
public class CollectionUniqueKeyValidator extends FieldExpressionValidator {
- public enum Mode {
-
- /** au moins une entrée de la collection doit etre valide */
- AT_LEAST_ONE,
- /** exactement une entrée dela collection doit être valide */
- EXACTLY_ONE,
- /** toutes les valeurs de la collection doivent etre valides */
- ALL,
- /** aucune valeur de la collection doivent etre valides */
- NONE
- }
/**
+ * pour indiquer la propriété qui contient la liste à valider.
+ *
+ * Si cette prorpiété n'est pas renseignée alors on utilise la
+ * {@link #getFieldName()} pour obtenir la collection.
+ *
+ * Cela permet d'effectuer une validation si une collection mais portant
+ * en fait sur un autre champs
+ * @since 1.5
+ */
+ protected String collectionFieldName;
+ /**
* la liste des propriétés d'une entrée de la collection qui définit la
* clef unique.
*/
@@ -47,16 +47,16 @@
*/
protected String againstIndexExpression;
- public String[] getKeys() {
- return keys;
+ public String getCollectionFieldName() {
+ return collectionFieldName;
}
- public String getAgainstProperty() {
- return againstProperty;
+ public void setCollectionFieldName(String collectionFieldName) {
+ this.collectionFieldName = collectionFieldName;
}
- public String getAgainstIndexExpression() {
- return againstIndexExpression;
+ public String[] getKeys() {
+ return keys;
}
public void setKeys(String[] keys) {
@@ -67,10 +67,18 @@
}
}
+ public String getAgainstProperty() {
+ return againstProperty;
+ }
+
public void setAgainstProperty(String againstProperty) {
this.againstProperty = againstProperty;
}
+ public String getAgainstIndexExpression() {
+ return againstIndexExpression;
+ }
+
public void setAgainstIndexExpression(String againstIndexExpression) {
this.againstIndexExpression = againstIndexExpression;
}
@@ -165,7 +173,11 @@
* @throws ValidationException if any pb to retreave the collection
*/
protected Collection<?> getCollection(Object object) throws ValidationException {
- String fieldName = getFieldName();
+ String fieldName = getCollectionFieldName();
+ if (fieldName == null || fieldName.trim().isEmpty()) {
+ // on travaille directement sur le fieldName
+ fieldName = getFieldName();
+ }
Object obj = null;
1
0
r1376 - in jaxx/trunk/jaxx-runtime-validator: . src/main/java/jaxx/runtime/validator
by tchemit@users.labs.libre-entreprise.org 04 May '09
by tchemit@users.labs.libre-entreprise.org 04 May '09
04 May '09
Author: tchemit
Date: 2009-05-04 01:01:04 +0000 (Mon, 04 May 2009)
New Revision: 1376
Modified:
jaxx/trunk/jaxx-runtime-validator/changelog.txt
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator.java
Log:
add doRevalidate on BeanValidator to validate and update internal states (validate method does not update internal state and should be used in outside...)
Modified: jaxx/trunk/jaxx-runtime-validator/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/changelog.txt 2009-05-03 21:10:18 UTC (rev 1375)
+++ jaxx/trunk/jaxx-runtime-validator/changelog.txt 2009-05-04 01:01:04 UTC (rev 1376)
@@ -1,5 +1,6 @@
1.5
* 20090503 [chemit] - add a new property collectionFieldName on CollectionFieldExpression validator to be able to validate a collection but not for a collection field
+ - add doRevalidate on BeanValidator to validate and update internal states (validate method does not update internal state and should be used in outside...)
1.3 chemit 20090409
* 20090404 [chemit] - can now use a shared instance of ValueStack (in BeanValidatorUtil)
Modified: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator.java 2009-05-03 21:10:18 UTC (rev 1375)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator.java 2009-05-04 01:01:04 UTC (rev 1376)
@@ -83,9 +83,7 @@
@Override
public void propertyChange(PropertyChangeEvent evt) {
- validate();
- setValid(!hasErrors());
- setChanged(true);
+ doValidate();
}
};
}
@@ -308,6 +306,21 @@
}
/**
+ * Methode pour forcer la revalidation d'un bean en mettant a jour les etats
+ * internes.
+ *
+ * La méthode appelle {@link #validate()} puis met à jour les etats internes
+ * {@link #valid} et {@link #changed}.
+ *
+ * @since 1.5
+ */
+ public void doValidate() {
+ validate();
+ setValid(!hasErrors());
+ setChanged(true);
+ }
+
+ /**
* 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
@@ -315,6 +328,11 @@
* 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 preperar utiliser la
+ * methode {@link #doRevalidate()} car {@link #validate()} ne modifie pas
+ * les etats internes et cela en rends son utilisation delicate (le
+ * validateur entre dans un etat incoherent par rapport aux messages envoyés).
*/
public void validate() {
1
0